From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sekhar Nori Date: Mon, 25 Mar 2013 09:53:41 +0000 Subject: Re: [PATCH 2/2] cpufreq: drivers: Remove unnecessary assignments of policy-> members Message-Id: <51501BD5.2070807@ti.com> List-Id: References: <2ece6d9fe8dfb6882a1c83a1cb2404bacc40b22d.1364138740.git.viresh.kumar@linaro.org> <07b96c5b68470001197445fb3d28786ad9acdbe0.1364138740.git.viresh.kumar@linaro.org> <51500C81.7040307@ti.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Viresh Kumar Cc: rjw@sisk.pl, arvind.chauhan@arm.com, robin.randhawa@arm.com, Steve.Bannister@arm.com, Liviu.Dudau@arm.com, charles.garcia-tobin@arm.com, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, Sascha Hauer , Paul Mundt , linux-sh@vger.kernel.org, linux-omap@vger.kernel.org On 3/25/2013 2:15 PM, Viresh Kumar wrote: > On 25 March 2013 14:06, Sekhar Nori wrote: >> There is a line in the code a little above the ones you deleted that >> also sets these same variables. I guess you were relying on that line to >> set policy->cur, but that also sets policy->{min, max} which can be >> cleaned up. > > This code is rather confusing or wrong, this was the state of code before > this patch: > > policy->cur = policy->min = policy->max = davinci_getspeed(0); > > if (freq_table) { > result = cpufreq_frequency_table_cpuinfo(policy, freq_table); > if (!result) > cpufreq_frequency_table_get_attr(freq_table, > policy->cpu); > } else { > policy->cpuinfo.min_freq = policy->min; > policy->cpuinfo.max_freq = policy->max; > } > > policy->min = policy->cpuinfo.min_freq; > policy->max = policy->cpuinfo.max_freq; > policy->cur = davinci_getspeed(0); > > > The tricky part is if/else, where if don't return error if > cpufreq_frequency_table_cpuinfo() fails. We want to set ->min[max] > and cpuinfo.min[max] always. And i can see this code not doing that for some > case even with my patch. > > Possible scenarios: > 1. Valid freq_table: My patch + what you suggested is required. > 2. Invalid freq_table: We never set cpuinfo.min[max] with or without my patch > 3. No freq_table: Only my patch is required. > > If i do what you suggested then 2 and 3 would fail... If you want to > return error > in case cpufreq_frequency_table_cpuinfo(), then i can fix it properly. So down in the cpufreq driver probe below, we bail out if freq_table is not provided. So all this checking for freq_table in the code you pasted above is superfluous. If you can clean that part up and add checking for cpufreq_frequency_table_cpuinfo() as you proposed, I will be glad to test it out ;) Thanks, Sekhar