[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 6/9] x86/intel_pstate: the main boby of the intel_pstate driver
>>> On 01.06.15 at 11:12, <wei.w.wang@xxxxxxxxx> wrote: > On 29/05/2015 16:46, Jan Beulich wrote >> >>> On 29.05.15 at 10:19, <wei.w.wang@xxxxxxxxx> wrote: >> > On 26/05/2015 21:58, Jan Beulich wrote >> >> >>> On 13.05.16 at 09:50, <wei.w.wang@xxxxxxxxx> wrote: >> >> > +static int intel_pstate_verify_policy(struct cpufreq_policy >> >> > +*policy) { >> >> > + cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, >> >> > + policy->cpuinfo.max_freq); >> >> > + >> >> > + if ( policy->policy != CPUFREQ_POLICY_POWERSAVE && >> >> > + policy->policy != CPUFREQ_POLICY_PERFORMANCE && >> >> > + policy->policy != CPUFREQ_POLICY_USERSPACE && >> >> > + policy->policy != CPUFREQ_POLICY_ONDEMAND ) >> >> >> >> switch() >> > >> > How would we use switch() here? >> >> switch ( policy->policy ) >> { >> case CPUFREQ_POLICY_POWERSAVE: >> >> etc. But I thought that to be obvious, so I'm not sure I understand what you >> don't understand. > > I thought there would be a special usage of switch() here, but no. > So, using switch, we will have > switch ( policy->policy ) > { > case CPUFREQ_POLICY_POWERSAVE: > case CPUFREQ_POLICY_PERFORMANCE: > case CPUFREQ_POLICY_USERSPACE: > case CPUFREQ_POLICY_ONDEMAND: > return 0; > case default: > return -EINVAL > } > > Is there a particular reason why we need to change to this style? I think > using if() looks more straightforward, since this is just a condition check. Well, a good compiler will avoid fetching policy->policy anyway at least when optimizing, but I consider it good practice to guide the compiler in the right direction (including non-optimized builds). Jan _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |