diff mbox series

PM: domains: using dev_err_probe() to simplify error handling

Message ID YWWIw1hAQAYjjrfK@fedora (mailing list archive)
State Changes Requested, archived
Headers show
Series PM: domains: using dev_err_probe() to simplify error handling | expand

Commit Message

Maíra Canal Oct. 12, 2021, 1:08 p.m. UTC
Replacing dev_err() for dev_err_probe() in order to reduce code size and
uniform error handling.

Signed-off-by: Maíra Canal <maira.canal@usp.br>
---
 drivers/base/power/domain.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

Comments

Greg Kroah-Hartman Oct. 12, 2021, 1:27 p.m. UTC | #1
On Tue, Oct 12, 2021 at 10:08:19AM -0300, Maíra Canal wrote:
> Replacing dev_err() for dev_err_probe() in order to reduce code size and
> uniform error handling.
> 
> Signed-off-by: Maíra Canal <maira.canal@usp.br>
> ---
>  drivers/base/power/domain.c | 17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 5db704f02e71..e7701b79494a 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -2249,10 +2249,8 @@ int of_genpd_add_provider_simple(struct device_node *np,
>  	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",
> +			return dev_err_probe(&genpd->dev, ret, "Failed to add OPP table: %d\n",
>  					ret);

But this isn't a probe function of a driver, shouldn't that be the only
place you use dev_err_probe()?

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 5db704f02e71..e7701b79494a 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2249,10 +2249,8 @@  int of_genpd_add_provider_simple(struct device_node *np,
 	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",
+			return dev_err_probe(&genpd->dev, ret, "Failed to add OPP table: %d\n",
 					ret);
-			return ret;
 		}
 
 		/*
@@ -2312,9 +2310,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: %d\n",
+					i, ret);
 				goto error;
 			}
 
@@ -2673,10 +2670,8 @@  static int __genpd_dev_pm_attach(struct device *dev, struct device *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",
+		return dev_err_probe(dev, ret, "failed to add to PM domain %s: %d",
 				pd->name, ret);
-		return ret;
 	}
 
 	dev->pm_domain->detach = genpd_dev_pm_detach;
@@ -2707,8 +2702,8 @@  static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
 	return 1;
 
 err:
-	dev_err(dev, "failed to set required performance state for power-domain %s: %d\n",
-		pd->name, ret);
+	dev_err(dev, "failed to set required performance state for power-domain %s: %d\n", 
+			pd->name, ret);
 	genpd_remove_device(pd, dev);
 	return ret;
 }