diff mbox series

[31/31] OPP: Rearrange dev_pm_opp_set_config() and friends

Message ID d56cbb49707a4b08635496cc3318592a96383710.1653564321.git.viresh.kumar@linaro.org
State New
Headers show
Series OPP: Add new configuration interface: dev_pm_opp_set_config() | expand

Commit Message

Viresh Kumar May 26, 2022, 11:42 a.m. UTC
Rearrange the helpers now to make them look clean.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/opp/core.c | 49 +++++++++++++++-------------------------------
 1 file changed, 16 insertions(+), 33 deletions(-)
diff mbox series

Patch

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index e6c76b90dbf7..a9e39ebfe9da 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -2370,8 +2370,8 @@  static void _opp_detach_genpd(struct opp_table *opp_table)
 struct opp_table *dev_pm_opp_set_config(struct device *dev,
 					struct dev_pm_opp_config *config)
 {
-	struct opp_table *opp_table, *ret;
-	int err;
+	struct opp_table *opp_table;
+	int ret;
 
 	opp_table = _add_opp_table(dev, false);
 	if (IS_ERR(opp_table))
@@ -2379,73 +2379,61 @@  struct opp_table *dev_pm_opp_set_config(struct device *dev,
 
 	/* This should be called before OPPs are initialized */
 	if (WARN_ON(!list_empty(&opp_table->opp_list))) {
-		ret = ERR_PTR(-EBUSY);
+		ret = -EBUSY;
 		goto err;
 	}
 
 	// Configure clock
 	if (config->clk_name) {
-		err = _opp_set_clkname(opp_table, dev, config->clk_name);
-		if (err) {
-			ret = ERR_PTR(err);
+		ret = _opp_set_clkname(opp_table, dev, config->clk_name);
+		if (ret)
 			goto err;
-		}
 	}
 
 	// Configure property names
 	if (config->prop_name) {
-		err = _opp_set_prop_name(opp_table, config->prop_name);
-		if (err) {
-			ret = ERR_PTR(err);
+		ret = _opp_set_prop_name(opp_table, config->prop_name);
+		if (ret)
 			goto err;
-		}
 	}
 
 	// Configure opp helper
 	if (config->set_opp) {
-		err = _opp_register_set_opp_helper(opp_table, dev, config->set_opp);
-		if (err) {
-			ret = ERR_PTR(err);
+		ret = _opp_register_set_opp_helper(opp_table, dev, config->set_opp);
+		if (ret)
 			goto err;
-		}
 	}
 
 	// Configure supported hardware
 	if (config->supported_hw) {
-		err = _opp_set_supported_hw(opp_table, config->supported_hw,
+		ret = _opp_set_supported_hw(opp_table, config->supported_hw,
 					    config->supported_hw_count);
-		if (err) {
-			ret = ERR_PTR(err);
+		if (ret)
 			goto err;
-		}
 	}
 
 	// Configure supplies
 	if (config->regulator_names) {
-		err = _opp_set_regulators(opp_table, dev,
+		ret = _opp_set_regulators(opp_table, dev,
 					  config->regulator_names,
 					  config->regulator_count);
-		if (err) {
-			ret = ERR_PTR(err);
+		if (ret)
 			goto err;
-		}
 	}
 
 	// Attach genpds
 	if (config->genpd_names) {
-		err = _opp_attach_genpd(opp_table, dev, config->genpd_names,
+		ret = _opp_attach_genpd(opp_table, dev, config->genpd_names,
 					config->virt_devs);
-		if (err) {
-			ret = ERR_PTR(err);
+		if (ret)
 			goto err;
-		}
 	}
 
 	return opp_table;
 
 err:
 	dev_pm_opp_clear_config(opp_table);
-	return ret;
+	return ERR_PTR(ret);
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_set_config);
 
@@ -2465,15 +2453,10 @@  EXPORT_SYMBOL_GPL(dev_pm_opp_set_config);
 void dev_pm_opp_clear_config(struct opp_table *opp_table)
 {
 	_opp_detach_genpd(opp_table);
-
 	_opp_put_regulators(opp_table);
-
 	_opp_put_supported_hw(opp_table);
-
 	_opp_unregister_set_opp_helper(opp_table);
-
 	_opp_put_prop_name(opp_table);
-
 	_opp_put_clkname(opp_table);
 
 	dev_pm_opp_put_opp_table(opp_table);