Message ID | 20220223080323.3717853-1-s.hauer@pengutronix.de |
---|---|
State | New |
Headers | show |
Series | PM: domains: use dev_err_probe() to simplify error handling | expand |
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 |
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!
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;