PM: domains: use dev_err_probe() to simplify error handling
authorAhmad Fatoum <a.fatoum@pengutronix.de>
Wed, 23 Feb 2022 08:03:23 +0000 (09:03 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 1 Mar 2022 14:58:17 +0000 (15:58 +0100)
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>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/domain.c

index c87588c..c0d9ad0 100644 (file)
@@ -2267,12 +2267,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
@@ -2331,9 +2327,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;
                        }
 
@@ -2691,12 +2686,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;