[PATCH v3 5/5] powernv:cpufreq: Implement the driver->get() method
David Laight
David.Laight at ACULAB.COM
Fri Mar 21 23:01:07 EST 2014
From: Viresh Kumar
> On 21 March 2014 16:34, Gautham R Shenoy <ego at linux.vnet.ibm.com> wrote:
> > Heh! Well, that wasn't the reason why this was sent out as a separate
> > patch, but never mind. Though I don't understand why it would be
> > difficult to review the patch though.
>
> Because the initial driver wasn't complete earlier. There were 2-3 patches
> after the first one which are changing what the first patch has added.
> Nothing else :)
>
> >> > +static void powernv_read_cpu_freq(void *ret_freq)
> >> > +{
> >> > + unsigned long pmspr_val;
> >> > + s8 local_pstate_id;
> >> > + int *cur_freq, freq, pstate_id;
> >> > +
> >> > + cur_freq = (int *)ret_freq;
> >>
> >> You don't need cur_freq variable at all..
> >
> > I don't like it either. But the compiler complains without this hack
> > :-(
>
> Why would the compiler warn for doing this?:
>
> *(int *)ret_freq = freq;
Because it is very likely to be wrong.
In general casts of pointers to integer types are dangerous.
In this case why not make the function return the value?
David
More information about the Linuxppc-dev
mailing list