* [PATCH] PM / Domains: Convert pm_genpd_init() to return an error code
@ 2016-06-17 10:27 Ulf Hansson
2016-06-17 10:59 ` Geert Uytterhoeven
2016-06-20 18:00 ` Kevin Hilman
0 siblings, 2 replies; 6+ messages in thread
From: Ulf Hansson @ 2016-06-17 10:27 UTC (permalink / raw)
To: Rafael J. Wysocki, Kevin Hilman, Ulf Hansson, linux-pm
Cc: Len Brown, Pavel Machek, Geert Uytterhoeven, Lina Iyer,
Axel Haslam, Marek Szyprowski, Jon Hunter, Andy Gross,
Laurent Pinchart
The are already cases when pm_genpd_init() can fail. Currently we hide the
failures instead of propagating an error code, which is a better method.
Moreover, to prepare for future changes like moving away from using a
fixed array-size of the struct genpd_power_state, to instead dynamically
allocate data for it, the pm_genpd_init() API needs to be able to return
an error code, as allocation can fail.
Current users of the pm_genpd_init() is thus requested to start dealing
with error codes. In the transition phase, users will have to live with
only error messages being printed to log.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/base/power/domain.c | 10 +++++++---
include/linux/pm_domain.h | 9 +++++----
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 9193aac..a1f2aff 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1258,12 +1258,14 @@ EXPORT_SYMBOL_GPL(pm_genpd_remove_subdomain);
* @genpd: PM domain object to initialize.
* @gov: PM domain governor to associate with the domain (may be NULL).
* @is_off: Initial value of the domain's power_is_off field.
+ *
+ * Returns 0 on successful initialization, else a negative error code.
*/
-void pm_genpd_init(struct generic_pm_domain *genpd,
- struct dev_power_governor *gov, bool is_off)
+int pm_genpd_init(struct generic_pm_domain *genpd,
+ struct dev_power_governor *gov, bool is_off)
{
if (IS_ERR_OR_NULL(genpd))
- return;
+ return -EINVAL;
INIT_LIST_HEAD(&genpd->master_links);
INIT_LIST_HEAD(&genpd->slave_links);
@@ -1321,6 +1323,8 @@ void pm_genpd_init(struct generic_pm_domain *genpd,
mutex_lock(&gpd_list_lock);
list_add(&genpd->gpd_list_node, &gpd_list);
mutex_unlock(&gpd_list_lock);
+
+ return 0;
}
EXPORT_SYMBOL_GPL(pm_genpd_init);
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index dd5b044..31fec85 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -127,8 +127,8 @@ extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
struct generic_pm_domain *new_subdomain);
extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
struct generic_pm_domain *target);
-extern void pm_genpd_init(struct generic_pm_domain *genpd,
- struct dev_power_governor *gov, bool is_off);
+extern int pm_genpd_init(struct generic_pm_domain *genpd,
+ struct dev_power_governor *gov, bool is_off);
extern struct dev_power_governor simple_qos_governor;
extern struct dev_power_governor pm_domain_always_on_gov;
@@ -163,9 +163,10 @@ static inline int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
{
return -ENOSYS;
}
-static inline void pm_genpd_init(struct generic_pm_domain *genpd,
- struct dev_power_governor *gov, bool is_off)
+static inline int pm_genpd_init(struct generic_pm_domain *genpd,
+ struct dev_power_governor *gov, bool is_off)
{
+ return -ENOSYS;
}
#endif
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] PM / Domains: Convert pm_genpd_init() to return an error code
2016-06-17 10:27 [PATCH] PM / Domains: Convert pm_genpd_init() to return an error code Ulf Hansson
@ 2016-06-17 10:59 ` Geert Uytterhoeven
2016-06-17 12:07 ` Jon Hunter
2016-06-20 11:17 ` Ulf Hansson
2016-06-20 18:00 ` Kevin Hilman
1 sibling, 2 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2016-06-17 10:59 UTC (permalink / raw)
To: Ulf Hansson
Cc: Rafael J. Wysocki, Kevin Hilman, Linux PM list, Len Brown,
Pavel Machek, Geert Uytterhoeven, Lina Iyer, Axel Haslam,
Marek Szyprowski, Jon Hunter, Andy Gross, Laurent Pinchart
Hi Ulf,
On Fri, Jun 17, 2016 at 12:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> The are already cases when pm_genpd_init() can fail. Currently we hide the
> failures instead of propagating an error code, which is a better method.
>
> Moreover, to prepare for future changes like moving away from using a
> fixed array-size of the struct genpd_power_state, to instead dynamically
> allocate data for it, the pm_genpd_init() API needs to be able to return
> an error code, as allocation can fail.
>
> Current users of the pm_genpd_init() is thus requested to start dealing
> with error codes. In the transition phase, users will have to live with
> only error messages being printed to log.
What can we do in case of error? It's not like anything is going to work
if PM domains are failing...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PM / Domains: Convert pm_genpd_init() to return an error code
2016-06-17 10:59 ` Geert Uytterhoeven
@ 2016-06-17 12:07 ` Jon Hunter
2016-06-20 11:17 ` Ulf Hansson
1 sibling, 0 replies; 6+ messages in thread
From: Jon Hunter @ 2016-06-17 12:07 UTC (permalink / raw)
To: Geert Uytterhoeven, Ulf Hansson
Cc: Rafael J. Wysocki, Kevin Hilman, Linux PM list, Len Brown,
Pavel Machek, Geert Uytterhoeven, Lina Iyer, Axel Haslam,
Marek Szyprowski, Andy Gross, Laurent Pinchart
On 17/06/16 11:59, Geert Uytterhoeven wrote:
> On Fri, Jun 17, 2016 at 12:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> The are already cases when pm_genpd_init() can fail. Currently we hide the
>> failures instead of propagating an error code, which is a better method.
>>
>> Moreover, to prepare for future changes like moving away from using a
>> fixed array-size of the struct genpd_power_state, to instead dynamically
>> allocate data for it, the pm_genpd_init() API needs to be able to return
>> an error code, as allocation can fail.
>>
>> Current users of the pm_genpd_init() is thus requested to start dealing
>> with error codes. In the transition phase, users will have to live with
>> only error messages being printed to log.
>
> What can we do in case of error? It's not like anything is going to work
> if PM domains are failing...
It seems natural that you would WARN and skip any failing PM domains and
just initialise all the ones you can. Hopefully, not all would fail and
you would have some functionality ...
Cheers
Jon
--
nvpublic
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PM / Domains: Convert pm_genpd_init() to return an error code
2016-06-17 10:59 ` Geert Uytterhoeven
2016-06-17 12:07 ` Jon Hunter
@ 2016-06-20 11:17 ` Ulf Hansson
1 sibling, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2016-06-20 11:17 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Rafael J. Wysocki, Kevin Hilman, Linux PM list, Len Brown,
Pavel Machek, Geert Uytterhoeven, Lina Iyer, Axel Haslam,
Marek Szyprowski, Jon Hunter, Andy Gross, Laurent Pinchart
On 17 June 2016 at 12:59, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Hi Ulf,
>
> On Fri, Jun 17, 2016 at 12:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> The are already cases when pm_genpd_init() can fail. Currently we hide the
>> failures instead of propagating an error code, which is a better method.
>>
>> Moreover, to prepare for future changes like moving away from using a
>> fixed array-size of the struct genpd_power_state, to instead dynamically
>> allocate data for it, the pm_genpd_init() API needs to be able to return
>> an error code, as allocation can fail.
>>
>> Current users of the pm_genpd_init() is thus requested to start dealing
>> with error codes. In the transition phase, users will have to live with
>> only error messages being printed to log.
>
> What can we do in case of error? It's not like anything is going to work
> if PM domains are failing...
I guess that would depend on the SoC and what particular PM domain
that would be failing.
Due to that, I would prefer to allow the user to be able to act on
errors - currently they can't.
Kind regards
Uffe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PM / Domains: Convert pm_genpd_init() to return an error code
2016-06-17 10:27 [PATCH] PM / Domains: Convert pm_genpd_init() to return an error code Ulf Hansson
2016-06-17 10:59 ` Geert Uytterhoeven
@ 2016-06-20 18:00 ` Kevin Hilman
2016-07-04 13:06 ` Rafael J. Wysocki
1 sibling, 1 reply; 6+ messages in thread
From: Kevin Hilman @ 2016-06-20 18:00 UTC (permalink / raw)
To: Ulf Hansson
Cc: Rafael J. Wysocki, linux-pm, Len Brown, Pavel Machek,
Geert Uytterhoeven, Lina Iyer, Axel Haslam, Marek Szyprowski,
Jon Hunter, Andy Gross, Laurent Pinchart
Ulf Hansson <ulf.hansson@linaro.org> writes:
> The are already cases when pm_genpd_init() can fail. Currently we hide the
> failures instead of propagating an error code, which is a better method.
>
> Moreover, to prepare for future changes like moving away from using a
> fixed array-size of the struct genpd_power_state, to instead dynamically
> allocate data for it, the pm_genpd_init() API needs to be able to return
> an error code, as allocation can fail.
>
> Current users of the pm_genpd_init() is thus requested to start dealing
> with error codes. In the transition phase, users will have to live with
> only error messages being printed to log.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Kevin Hilman <khilman@baylibre.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PM / Domains: Convert pm_genpd_init() to return an error code
2016-06-20 18:00 ` Kevin Hilman
@ 2016-07-04 13:06 ` Rafael J. Wysocki
0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2016-07-04 13:06 UTC (permalink / raw)
To: Kevin Hilman, Ulf Hansson
Cc: linux-pm, Len Brown, Pavel Machek, Geert Uytterhoeven, Lina Iyer,
Axel Haslam, Marek Szyprowski, Jon Hunter, Andy Gross,
Laurent Pinchart
On Monday, June 20, 2016 11:00:24 AM Kevin Hilman wrote:
> Ulf Hansson <ulf.hansson@linaro.org> writes:
>
> > The are already cases when pm_genpd_init() can fail. Currently we hide the
> > failures instead of propagating an error code, which is a better method.
> >
> > Moreover, to prepare for future changes like moving away from using a
> > fixed array-size of the struct genpd_power_state, to instead dynamically
> > allocate data for it, the pm_genpd_init() API needs to be able to return
> > an error code, as allocation can fail.
> >
> > Current users of the pm_genpd_init() is thus requested to start dealing
> > with error codes. In the transition phase, users will have to live with
> > only error messages being printed to log.
> >
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>
> Acked-by: Kevin Hilman <khilman@baylibre.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-07-04 13:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-17 10:27 [PATCH] PM / Domains: Convert pm_genpd_init() to return an error code Ulf Hansson
2016-06-17 10:59 ` Geert Uytterhoeven
2016-06-17 12:07 ` Jon Hunter
2016-06-20 11:17 ` Ulf Hansson
2016-06-20 18:00 ` Kevin Hilman
2016-07-04 13:06 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).