[05/10] cpufreq: governor: Drop __gov_queue_work()

Message ID c4dfd8121fd454a04a8d700a5a0f8b7858f7aed3.1434959517.git.viresh.kumar@linaro.org
State New
Headers show

Commit Message

Viresh Kumar June 22, 2015, 8:02 a.m.
__gov_queue_work() isn't required anymore and can be merged with
gov_queue_work(). Do it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq_governor.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

Comments

Viresh Kumar June 26, 2015, 7:32 a.m. | #1
On 26-06-15, 12:33, Preeti U Murthy wrote:
> On 06/22/2015 01:32 PM, Viresh Kumar wrote:
> > __gov_queue_work() isn't required anymore and can be merged with
> > gov_queue_work(). Do it.
> > 
> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> > ---
> >  drivers/cpufreq/cpufreq_governor.c | 17 ++++++-----------
> >  1 file changed, 6 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
> > index 416a8c5665dd..ac288f0efb06 100644
> > --- a/drivers/cpufreq/cpufreq_governor.c
> > +++ b/drivers/cpufreq/cpufreq_governor.c
> > @@ -158,25 +158,20 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu)
> >  }
> >  EXPORT_SYMBOL_GPL(dbs_check_cpu);
> > 
> > -static inline void __gov_queue_work(int cpu, struct dbs_data *dbs_data,
> > -		unsigned int delay)
> > -{
> > -	struct cpu_dbs_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu);
> > -
> > -	mod_delayed_work_on(cpu, system_wq, &cdbs->dwork, delay);
> > -}
> 
> Looking at this patch I feel now that, you can simply make the above
> function non static and call the same from update_sampling_rate() in
> patch[04/10] It already gives scope to pass in the cpu parameter, if not
> the mask. Anyway you want to pass in a single cpu from
> update_sampling_rate(). This will avoid having to change the other call
> sites of gov_queue_work().
> 
> I also see elsewhere in the kernel where a fn() and __fn() are sometimes
> both non-static, with __fn() giving you the additional benefit of
> passing a critical parameter. Eg:
> __hrtimer_start_range_ns() and hrtimer_start_range_ns().

Keeping two functions that way isn't a problem and is beneficial many
a times. But that doesn't fit here.

The above function doesn't have the necessary lock and so was never
used directly. And there is no need to keep two routines now that only
one is sufficient.

Patch

diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 416a8c5665dd..ac288f0efb06 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -158,25 +158,20 @@  void dbs_check_cpu(struct dbs_data *dbs_data, int cpu)
 }
 EXPORT_SYMBOL_GPL(dbs_check_cpu);
 
-static inline void __gov_queue_work(int cpu, struct dbs_data *dbs_data,
-		unsigned int delay)
-{
-	struct cpu_dbs_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu);
-
-	mod_delayed_work_on(cpu, system_wq, &cdbs->dwork, delay);
-}
-
 void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy,
 		    unsigned int delay, const struct cpumask *cpus)
 {
-	int i;
+	struct cpu_dbs_info *cdbs;
+	int cpu;
 
 	mutex_lock(&cpufreq_governor_lock);
 	if (!policy->governor_enabled)
 		goto out_unlock;
 
-	for_each_cpu(i, cpus)
-		__gov_queue_work(i, dbs_data, delay);
+	for_each_cpu(cpu, cpus) {
+		cdbs = dbs_data->cdata->get_cpu_cdbs(cpu);
+		mod_delayed_work_on(cpu, system_wq, &cdbs->dwork, delay);
+	}
 
 out_unlock:
 	mutex_unlock(&cpufreq_governor_lock);