Skip to content

Commit

Permalink
PM: domains: use dev_err_probe() to simplify error handling
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Sascha Hauer <[email protected]>
Acked-by: Ulf Hansson <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
a3f authored and rafaeljw committed Mar 1, 2022
1 parent e7d90cf commit 9a6582b
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9a6582b

Please sign in to comment.