[PATCH v3 5/5] powernv:cpufreq: Implement the driver->get() method
Gautham R Shenoy
ego at linux.vnet.ibm.com
Sat Mar 22 18:53:56 EST 2014
Hi Ben,
On Sat, Mar 22, 2014 at 09:56:30AM +1100, Benjamin Herrenschmidt wrote:
> On Fri, 2014-03-21 at 16:34 +0530, Gautham R Shenoy wrote:
>
> > > >
> > > > +/*
> > > > + * Computes the current frequency on this cpu
> > > > + * and stores the result in *ret_freq.
> > > > + */
> > > > +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
> > :-(
>
> Casting integers into void * is a recipe for disaster... what is that
> supposed to be about ?
Like I mentioned elsewhere on this thread, we're calling
powernv_read_cpu_freq via an smp_call_function(). We use this to
obtain the frequency on the cpu where powernv_read_cpu_freq
executes and return it to the caller of smp_call_function.
> We lose all type checking and get exposed
> to endian issues etc... the day somebody uses a different type on both
> sides.
>
Yes, I understand the problem now. I'll think of a safer way to pass
the return value.
> Also is "freq" a frequency ? In this case an int isn't big enough.
freq is the frequency stored in the cpufreq_table. The value is in
kHz. So, int should be big enough.
> Cheers,
> Ben.
>
>
--
Thanks and Regards
gautham.
More information about the Linuxppc-dev
mailing list