diff mbox

[v4,1/7] cpufreq: Store cpufreq policies in a list

Message ID 1371661969-7660-2-git-send-email-l.majewski@samsung.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Lukasz Majewski June 19, 2013, 5:12 p.m. UTC
Policies available in a cpufreq framework are now linked together. They are
accessible via cpufreq_policy_list defined at cpufreq core.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>

Changes for v4:
- New patch
---
 drivers/cpufreq/cpufreq.c |    3 +++
 include/linux/cpufreq.h   |    1 +
 2 files changed, 4 insertions(+)

Comments

Viresh Kumar June 26, 2013, 10:35 a.m. UTC | #1
On 19 June 2013 22:42, Lukasz Majewski <l.majewski@samsung.com> wrote:
> Policies available in a cpufreq framework are now linked together. They are
> accessible via cpufreq_policy_list defined at cpufreq core.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
>
> Changes for v4:
> - New patch

You need to write changelog after ---, so that it doesn't get commited.

> ---
>  drivers/cpufreq/cpufreq.c |    3 +++
>  include/linux/cpufreq.h   |    1 +
>  2 files changed, 4 insertions(+)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 2ce86ed..665e641 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -46,6 +46,7 @@ static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data);
>  static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor);
>  #endif
>  static DEFINE_RWLOCK(cpufreq_driver_lock);
> +static LIST_HEAD(cpufreq_policy_list);
>
>  /*
>   * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure
> @@ -989,6 +990,7 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
>         }
>  #endif
>
> +       list_add(&policy->policy_list, &cpufreq_policy_list);
>         ret = cpufreq_add_dev_interface(cpu, policy, dev);
>         if (ret)
>                 goto err_out_unregister;

what about handling error cases?

> @@ -1992,6 +1994,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)
>         subsys_interface_unregister(&cpufreq_interface);
>         unregister_hotcpu_notifier(&cpufreq_cpu_notifier);
>
> +       list_del(&cpufreq_policy_list);
>         write_lock_irqsave(&cpufreq_driver_lock, flags);
>         cpufreq_driver = NULL;
>         write_unlock_irqrestore(&cpufreq_driver_lock, flags);
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index ab1932c..5348981 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -117,6 +117,7 @@ struct cpufreq_policy {
>
>         struct cpufreq_real_policy      user_policy;
>
> +       struct list_head        policy_list;
>         struct kobject          kobj;
>         struct completion       kobj_unregister;

--
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lukasz Majewski June 26, 2013, 10:54 a.m. UTC | #2
On 26 Jun 2013 16:05:12,Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On 19 June 2013 22:42, Lukasz Majewski <l.majewski@samsung.com> wrote:
> > Policies available in a cpufreq framework are now linked together.
> > They are accessible via cpufreq_policy_list defined at cpufreq core.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
> >
> > Changes for v4:
> > - New patch
> 
> You need to write changelog after ---, so that it doesn't get
> commited.
> 
> > ---

So here <---> I will put change log for v5.


> >  drivers/cpufreq/cpufreq.c |    3 +++
> >  include/linux/cpufreq.h   |    1 +
> >  2 files changed, 4 insertions(+)
> >
> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > index 2ce86ed..665e641 100644
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -46,6 +46,7 @@ static DEFINE_PER_CPU(struct cpufreq_policy *,
> > cpufreq_cpu_data); static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN],
> > cpufreq_cpu_governor); #endif
> >  static DEFINE_RWLOCK(cpufreq_driver_lock);
> > +static LIST_HEAD(cpufreq_policy_list);
> >
> >  /*
> >   * cpu_policy_rwsem is a per CPU reader-writer semaphore designed
> > to cure @@ -989,6 +990,7 @@ static int cpufreq_add_dev(struct
> > device *dev, struct subsys_interface *sif) }
> >  #endif
> >
> > +       list_add(&policy->policy_list, &cpufreq_policy_list);
> >         ret = cpufreq_add_dev_interface(cpu, policy, dev);
> >         if (ret)

I will add list_del(&cpufreq_policy_list);
here.

> >                 goto err_out_unregister;
> 
> what about handling error cases?

Thanks for spotting.

> 
> > @@ -1992,6 +1994,7 @@ int cpufreq_unregister_driver(struct
> > cpufreq_driver *driver)
> > subsys_interface_unregister(&cpufreq_interface);
> > unregister_hotcpu_notifier(&cpufreq_cpu_notifier);
> >
> > +       list_del(&cpufreq_policy_list);
> >         write_lock_irqsave(&cpufreq_driver_lock, flags);
> >         cpufreq_driver = NULL;
> >         write_unlock_irqrestore(&cpufreq_driver_lock, flags);
> > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> > index ab1932c..5348981 100644
> > --- a/include/linux/cpufreq.h
> > +++ b/include/linux/cpufreq.h
> > @@ -117,6 +117,7 @@ struct cpufreq_policy {
> >
> >         struct cpufreq_real_policy      user_policy;
> >
> > +       struct list_head        policy_list;
> >         struct kobject          kobj;
> >         struct completion       kobj_unregister;
> 
> --
> viresh
Viresh Kumar June 26, 2013, 10:56 a.m. UTC | #3
On 26 June 2013 16:24, Lukasz Majewski <l.majewski@samsung.com> wrote:
>> > ---
>
> So here <---> I will put change log for v5.

correct.

>> >         ret = cpufreq_add_dev_interface(cpu, policy, dev);
>> >         if (ret)
>
> I will add list_del(&cpufreq_policy_list);
> here.

May not be sufficient. You must do it once at the end of this routine.
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lukasz Majewski June 26, 2013, 11:04 a.m. UTC | #4
On Wed, 26 Jun 2013 16:26:30 +0530, Viresh Kumar wrote:
> On 26 June 2013 16:24, Lukasz Majewski <l.majewski@samsung.com> wrote:
> >> > ---
> >
> > So here <---> I will put change log for v5.
> 
> correct.

OK.

> 
> >> >         ret = cpufreq_add_dev_interface(cpu, policy, dev);
> >> >         if (ret)
> >
> > I will add list_del(&cpufreq_policy_list);
> > here.
> 
> May not be sufficient. You must do it once at the end of this routine.

Then I will add this code below:

err_out_kobj_put:
	list_del(&cpufreq_policy_list);
	[rest of error path]
Viresh Kumar June 26, 2013, 11:08 a.m. UTC | #5
On 26 June 2013 16:34, Lukasz Majewski <l.majewski@samsung.com> wrote:
> err_out_kobj_put:
>         list_del(&cpufreq_policy_list);
>         [rest of error path]

I couldn't find err_out_kobj_put in existing code :)

BTW, just add to the list only once everything passed.
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lukasz Majewski June 26, 2013, 12:15 p.m. UTC | #6
On Wed, 26 Jun 2013 16:38:15 +0530, Viresh Kumar wrote:

> On 26 June 2013 16:34, Lukasz Majewski <l.majewski@samsung.com> wrote:
> > err_out_kobj_put:
> >         list_del(&cpufreq_policy_list);
> >         [rest of error path]
> 
> I couldn't find err_out_kobj_put in existing code :)
> 
> BTW, just add to the list only once everything passed.

Ok, we can do it like that :-)
diff mbox

Patch

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 2ce86ed..665e641 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -46,6 +46,7 @@  static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data);
 static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor);
 #endif
 static DEFINE_RWLOCK(cpufreq_driver_lock);
+static LIST_HEAD(cpufreq_policy_list);
 
 /*
  * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure
@@ -989,6 +990,7 @@  static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
 	}
 #endif
 
+	list_add(&policy->policy_list, &cpufreq_policy_list);
 	ret = cpufreq_add_dev_interface(cpu, policy, dev);
 	if (ret)
 		goto err_out_unregister;
@@ -1992,6 +1994,7 @@  int cpufreq_unregister_driver(struct cpufreq_driver *driver)
 	subsys_interface_unregister(&cpufreq_interface);
 	unregister_hotcpu_notifier(&cpufreq_cpu_notifier);
 
+	list_del(&cpufreq_policy_list);
 	write_lock_irqsave(&cpufreq_driver_lock, flags);
 	cpufreq_driver = NULL;
 	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index ab1932c..5348981 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -117,6 +117,7 @@  struct cpufreq_policy {
 
 	struct cpufreq_real_policy	user_policy;
 
+	struct list_head        policy_list;
 	struct kobject		kobj;
 	struct completion	kobj_unregister;
 };