From: "Jan Beulich" Subject: Re: [PATCH v2 6/9] x86/intel_pstate: the main boby of the intel_pstate driver Date: Mon, 01 Jun 2015 10:37:31 +0100 Message-ID: <556C43FB020000780007F9F3@mail.emea.novell.com> References: <1463125852-14155-1-git-send-email-wei.w.wang@intel.com> <55649803020000780007DF1A@mail.emea.novell.com> <286AC319A985734F985F78AFA26841F79764A5@shsmsx102.ccr.corp.intel.com> <5568436D020000780007EDB2@mail.emea.novell.com> <286AC319A985734F985F78AFA26841F7978E36@shsmsx102.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <286AC319A985734F985F78AFA26841F7978E36@shsmsx102.ccr.corp.intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei W Wang Cc: "jinsong.liu@alibaba-inc.com" , "xen-devel@lists.xen.org" , "wei.liu2@citrix.com" , "ian.campbell@citrix.com" , "andrew.cooper3@citrix.com" List-Id: xen-devel@lists.xenproject.org >>> On 01.06.15 at 11:12, wrote: > On 29/05/2015 16:46, Jan Beulich wrote >> >>> On 29.05.15 at 10:19, wrote: >> > On 26/05/2015 21:58, Jan Beulich wrote >> >> >>> On 13.05.16 at 09:50, 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