mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] PM: domains: use dev_err_probe() to simplify error handling
@ 2022-02-23  8:03 Sascha Hauer
  2022-02-23  8:08 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2022-02-23  8:03 UTC (permalink / raw)
  To: linux-pm
  Cc: linux-kernel, Rafael J . Wysocki, Kevin Hilman, kernel, Ahmad Fatoum

From: Ahmad Fatoum <a.fatoum@pengutronix.de>

dev_err_probe() can reduce code size, makes the code easier to read
and has the added benefit of recording the defer reason for later
read out. Use it where appropriate.

This also fixes an issue, where an error message in __genpd_dev_pm_attach
was not terminated by a line break.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/base/power/domain.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 5db704f02e712..29428ae91349d 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2248,12 +2248,8 @@ int of_genpd_add_provider_simple(struct device_node *np,
 	/* Parse genpd OPP table */
 	if (genpd->set_performance_state) {
 		ret = dev_pm_opp_of_add_table(&genpd->dev);
-		if (ret) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(&genpd->dev, "Failed to add OPP table: %d\n",
-					ret);
-			return ret;
-		}
+		if (ret)
+			return dev_err_probe(&genpd->dev, ret, "Failed to add OPP table\n");
 
 		/*
 		 * Save table for faster processing while setting performance
@@ -2312,9 +2308,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 		if (genpd->set_performance_state) {
 			ret = dev_pm_opp_of_add_table_indexed(&genpd->dev, i);
 			if (ret) {
-				if (ret != -EPROBE_DEFER)
-					dev_err(&genpd->dev, "Failed to add OPP table for index %d: %d\n",
-						i, ret);
+				dev_err_probe(&genpd->dev, ret,
+					      "Failed to add OPP table for index %d\n", i);
 				goto error;
 			}
 
@@ -2672,12 +2667,8 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
 	ret = genpd_add_device(pd, dev, base_dev);
 	mutex_unlock(&gpd_list_lock);
 
-	if (ret < 0) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "failed to add to PM domain %s: %d",
-				pd->name, ret);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "failed to add to PM domain %s\n", pd->name);
 
 	dev->pm_domain->detach = genpd_dev_pm_detach;
 	dev->pm_domain->sync = genpd_dev_pm_sync;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PM: domains: use dev_err_probe() to simplify error handling
  2022-02-23  8:03 [PATCH] PM: domains: use dev_err_probe() to simplify error handling Sascha Hauer
@ 2022-02-23  8:08 ` Sascha Hauer
  2022-03-01  9:43   ` Ulf Hansson
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2022-02-23  8:08 UTC (permalink / raw)
  To: linux-pm
  Cc: Kevin Hilman, Ahmad Fatoum, linux-kernel, kernel, Rafael J . Wysocki

On Wed, Feb 23, 2022 at 09:03:23AM +0100, Sascha Hauer wrote:
> From: Ahmad Fatoum <a.fatoum@pengutronix.de>
> 
> dev_err_probe() can reduce code size, makes the code easier to read
> and has the added benefit of recording the defer reason for later
> read out. Use it where appropriate.
> 
> This also fixes an issue, where an error message in __genpd_dev_pm_attach
> was not terminated by a line break.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/base/power/domain.c | 21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)

And of course:

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Sascha

> 
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 5db704f02e712..29428ae91349d 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -2248,12 +2248,8 @@ int of_genpd_add_provider_simple(struct device_node *np,
>  	/* Parse genpd OPP table */
>  	if (genpd->set_performance_state) {
>  		ret = dev_pm_opp_of_add_table(&genpd->dev);
> -		if (ret) {
> -			if (ret != -EPROBE_DEFER)
> -				dev_err(&genpd->dev, "Failed to add OPP table: %d\n",
> -					ret);
> -			return ret;
> -		}
> +		if (ret)
> +			return dev_err_probe(&genpd->dev, ret, "Failed to add OPP table\n");
>  
>  		/*
>  		 * Save table for faster processing while setting performance
> @@ -2312,9 +2308,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>  		if (genpd->set_performance_state) {
>  			ret = dev_pm_opp_of_add_table_indexed(&genpd->dev, i);
>  			if (ret) {
> -				if (ret != -EPROBE_DEFER)
> -					dev_err(&genpd->dev, "Failed to add OPP table for index %d: %d\n",
> -						i, ret);
> +				dev_err_probe(&genpd->dev, ret,
> +					      "Failed to add OPP table for index %d\n", i);
>  				goto error;
>  			}
>  
> @@ -2672,12 +2667,8 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
>  	ret = genpd_add_device(pd, dev, base_dev);
>  	mutex_unlock(&gpd_list_lock);
>  
> -	if (ret < 0) {
> -		if (ret != -EPROBE_DEFER)
> -			dev_err(dev, "failed to add to PM domain %s: %d",
> -				pd->name, ret);
> -		return ret;
> -	}
> +	if (ret < 0)
> +		return dev_err_probe(dev, ret, "failed to add to PM domain %s\n", pd->name);
>  
>  	dev->pm_domain->detach = genpd_dev_pm_detach;
>  	dev->pm_domain->sync = genpd_dev_pm_sync;
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PM: domains: use dev_err_probe() to simplify error handling
  2022-02-23  8:08 ` Sascha Hauer
@ 2022-03-01  9:43   ` Ulf Hansson
  2022-03-01 14:59     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2022-03-01  9:43 UTC (permalink / raw)
  To: Sascha Hauer
  Cc: linux-pm, Kevin Hilman, Ahmad Fatoum, linux-kernel, Kernel,
	Rafael J . Wysocki

On Wed, 23 Feb 2022 at 09:09, Sascha Hauer <s.hauer@pengutronix.de> wrote:
>
> On Wed, Feb 23, 2022 at 09:03:23AM +0100, Sascha Hauer wrote:
> > From: Ahmad Fatoum <a.fatoum@pengutronix.de>
> >
> > dev_err_probe() can reduce code size, makes the code easier to read
> > and has the added benefit of recording the defer reason for later
> > read out. Use it where appropriate.
> >
> > This also fixes an issue, where an error message in __genpd_dev_pm_attach
> > was not terminated by a line break.
> >
> > Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> > ---
> >  drivers/base/power/domain.c | 21 ++++++---------------
> >  1 file changed, 6 insertions(+), 15 deletions(-)
>
> And of course:
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Next time, please add me on the to-list, otherwise it's likely that I
will fail to review your patch.

Kind regards
Uffe

>
> Sascha
>
> >
> > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> > index 5db704f02e712..29428ae91349d 100644
> > --- a/drivers/base/power/domain.c
> > +++ b/drivers/base/power/domain.c
> > @@ -2248,12 +2248,8 @@ int of_genpd_add_provider_simple(struct device_node *np,
> >       /* Parse genpd OPP table */
> >       if (genpd->set_performance_state) {
> >               ret = dev_pm_opp_of_add_table(&genpd->dev);
> > -             if (ret) {
> > -                     if (ret != -EPROBE_DEFER)
> > -                             dev_err(&genpd->dev, "Failed to add OPP table: %d\n",
> > -                                     ret);
> > -                     return ret;
> > -             }
> > +             if (ret)
> > +                     return dev_err_probe(&genpd->dev, ret, "Failed to add OPP table\n");
> >
> >               /*
> >                * Save table for faster processing while setting performance
> > @@ -2312,9 +2308,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
> >               if (genpd->set_performance_state) {
> >                       ret = dev_pm_opp_of_add_table_indexed(&genpd->dev, i);
> >                       if (ret) {
> > -                             if (ret != -EPROBE_DEFER)
> > -                                     dev_err(&genpd->dev, "Failed to add OPP table for index %d: %d\n",
> > -                                             i, ret);
> > +                             dev_err_probe(&genpd->dev, ret,
> > +                                           "Failed to add OPP table for index %d\n", i);
> >                               goto error;
> >                       }
> >
> > @@ -2672,12 +2667,8 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
> >       ret = genpd_add_device(pd, dev, base_dev);
> >       mutex_unlock(&gpd_list_lock);
> >
> > -     if (ret < 0) {
> > -             if (ret != -EPROBE_DEFER)
> > -                     dev_err(dev, "failed to add to PM domain %s: %d",
> > -                             pd->name, ret);
> > -             return ret;
> > -     }
> > +     if (ret < 0)
> > +             return dev_err_probe(dev, ret, "failed to add to PM domain %s\n", pd->name);
> >
> >       dev->pm_domain->detach = genpd_dev_pm_detach;
> >       dev->pm_domain->sync = genpd_dev_pm_sync;
> > --
> > 2.30.2
> >
> >
> >
>
> --
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PM: domains: use dev_err_probe() to simplify error handling
  2022-03-01  9:43   ` Ulf Hansson
@ 2022-03-01 14:59     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2022-03-01 14:59 UTC (permalink / raw)
  To: Ulf Hansson, Sascha Hauer
  Cc: Linux PM, Kevin Hilman, Ahmad Fatoum, Linux Kernel Mailing List,
	Sascha Hauer, Rafael J . Wysocki

On Tue, Mar 1, 2022 at 10:44 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Wed, 23 Feb 2022 at 09:09, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> >
> > On Wed, Feb 23, 2022 at 09:03:23AM +0100, Sascha Hauer wrote:
> > > From: Ahmad Fatoum <a.fatoum@pengutronix.de>
> > >
> > > dev_err_probe() can reduce code size, makes the code easier to read
> > > and has the added benefit of recording the defer reason for later
> > > read out. Use it where appropriate.
> > >
> > > This also fixes an issue, where an error message in __genpd_dev_pm_attach
> > > was not terminated by a line break.
> > >
> > > Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> > > ---
> > >  drivers/base/power/domain.c | 21 ++++++---------------
> > >  1 file changed, 6 insertions(+), 15 deletions(-)
> >
> > And of course:
> >
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
>
> Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Applied as 5.18 material, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-01 14:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23  8:03 [PATCH] PM: domains: use dev_err_probe() to simplify error handling Sascha Hauer
2022-02-23  8:08 ` Sascha Hauer
2022-03-01  9:43   ` Ulf Hansson
2022-03-01 14:59     ` 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

all inboxes | Powered by JetHome®