Re: [PATCH] PM: domains: use dev_err_probe() to simplify error handling

From: Ulf Hansson
Date: Tue Mar 01 2022 - 04:45:03 EST


On Wed, 23 Feb 2022 at 09:09, Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> wrote:
>
> On Wed, Feb 23, 2022 at 09:03:23AM +0100, Sascha Hauer wrote:
> > From: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
> >
> > 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@xxxxxxxxxxxxxx>
> > ---
> > drivers/base/power/domain.c | 21 ++++++---------------
> > 1 file changed, 6 insertions(+), 15 deletions(-)
>
> And of course:
>
> Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>

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

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 |