Skip to contentSkip to conversation

PM / devfreq: exynos: Use Use devm_clk_get_enabled() helpers

PATCH Applied Anand Moon 2 participants 6 messages May 10, 2024 – Jun 29, 2024

Subsystems (3)
lore
Share & tools
lore

Anand Moon

author
#0 lore raw

PATCH v5 1/2 PM / devfreq: exynos: Use Use devm_clk_get_enabled() helpers

The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource.

This simplifies the code and avoids the calls to clk_disable_unprepare().

While at it, use dev_err_probe consistently, and use its return value to return the error code.

---
v5 - No change
V4 - wrap up the error messagee within 80 char
v3 - No change
v2 - No change

---
 drivers/devfreq/exynos-bus.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)
drivers/devfreq/exynos-bus.c +5 -17
index 00118580905a..7d06c476d8e9 100644
@@ -160,7 +160,6 @@ static void exynos_bus_exit(struct device *dev)
 	platform_device_unregister(bus->icc_pdev);
 
 	dev_pm_opp_of_remove_table(dev);
-	clk_disable_unprepare(bus->clk);
 	dev_pm_opp_put_regulators(bus->opp_token);
 }
 
@@ -171,7 +170,6 @@ static void exynos_bus_passive_exit(struct device *dev)
 	platform_device_unregister(bus->icc_pdev);
 
 	dev_pm_opp_of_remove_table(dev);
-	clk_disable_unprepare(bus->clk);
 }
 
 static int exynos_bus_parent_parse_of(struct device_node *np,
@@ -247,23 +245,16 @@ static int exynos_bus_parse_of(struct device_node *np,
 	int ret;
 
 	/* Get the clock to provide each bus with source clock */
-	bus->clk = devm_clk_get(dev, "bus");
-	if (IS_ERR(bus->clk)) {
-		dev_err(dev, "failed to get bus clock\n");
-		return PTR_ERR(bus->clk);
-	}
-
-	ret = clk_prepare_enable(bus->clk);
-	if (ret < 0) {
-		dev_err(dev, "failed to get enable clock\n");
-		return ret;
-	}
+	bus->clk = devm_clk_get_enabled(dev, "bus");
+	if (IS_ERR(bus->clk))
+		return dev_err_probe(dev, PTR_ERR(bus->clk),
+				"failed to get bus clock\n");
 
 	/* Get the freq and voltage from OPP table to scale the bus freq */
 	ret = dev_pm_opp_of_add_table(dev);
 	if (ret < 0) {
 		dev_err(dev, "failed to get OPP table\n");
-		goto err_clk;
+		return ret;
 	}
 
 	rate = clk_get_rate(bus->clk);
@@ -281,8 +272,6 @@ static int exynos_bus_parse_of(struct device_node *np,
 
 err_opp:
 	dev_pm_opp_of_remove_table(dev);
-err_clk:
-	clk_disable_unprepare(bus->clk);
 
 	return ret;
 }
@@ -453,7 +442,6 @@ static int exynos_bus_probe(struct platform_device *pdev)
 
 err:
 	dev_pm_opp_of_remove_table(dev);
-	clk_disable_unprepare(bus->clk);
 err_reg:
 	dev_pm_opp_put_regulators(bus->opp_token);
 
Signature · 1 line
2.44.0
author
#1 lore raw

PATCH v5 2/2 PM / devfreq: exynos: Use local clk variable instead of exynos_bus member

This commit modifies the exynos bus driver to use a local clk variable for clock handling instead of storing it in the exynos_bus struct member. This helps in simplifying the code and makes it more readable.

---
v5: New patch

---
 drivers/devfreq/exynos-bus.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/devfreq/exynos-bus.c +5 -5
index 7d06c476d8e9..e55ae59a8ae7 100644
@@ -34,7 +34,6 @@ struct exynos_bus {
 	unsigned long curr_freq;
 
 	int opp_token;
-	struct clk *clk;
 	unsigned int ratio;
 };
 
@@ -241,13 +240,14 @@ static int exynos_bus_parse_of(struct device_node *np,
 {
 	struct device *dev = bus->dev;
 	struct dev_pm_opp *opp;
+	struct clk *clk;
 	unsigned long rate;
 	int ret;
 
 	/* Get the clock to provide each bus with source clock */
-	bus->clk = devm_clk_get_enabled(dev, "bus");
-	if (IS_ERR(bus->clk))
-		return dev_err_probe(dev, PTR_ERR(bus->clk),
+	clk = devm_clk_get_enabled(dev, "bus");
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk),
 				"failed to get bus clock\n");
 
 	/* Get the freq and voltage from OPP table to scale the bus freq */
@@ -257,7 +257,7 @@ static int exynos_bus_parse_of(struct device_node *np,
 		return ret;
 	}
 
-	rate = clk_get_rate(bus->clk);
+	rate = clk_get_rate(clk);
 
 	opp = devfreq_recommended_opp(dev, &rate, 0);
 	if (IS_ERR(opp)) {
Signature · 1 line
2.44.0
author
#2 lore raw

Re: [PATCH v5 2/2] PM / devfreq: exynos: Use local clk variable instead of exynos_bus member

Hi Chamwoo,

Quoted 8 lines · Anand Moon

This commit modifies the exynos bus driver to use a local clk variable for clock handling instead of storing it in the exynos_bus struct member. This helps in simplifying the code and makes it more readable.

---

I am letting you know that you missed this patch.

Quoted 45 lines

v5: New patch

---
 drivers/devfreq/exynos-bus.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/devfreq/exynos-bus.c +5 -6
index 7d06c476d8e9..e55ae59a8ae7 100644
@@ -34,7 +34,6 @@ struct exynos_bus {
        unsigned long curr_freq;
 
        int opp_token;
-       struct clk *clk;
        unsigned int ratio;
 };
 
@@ -241,13 +240,14 @@ static int exynos_bus_parse_of(struct device_node *np,
 {
        struct device *dev = bus->dev;
        struct dev_pm_opp *opp;
+       struct clk *clk;
        unsigned long rate;
        int ret;
 
        /* Get the clock to provide each bus with source clock */
-       bus->clk = devm_clk_get_enabled(dev, "bus");
-       if (IS_ERR(bus->clk))
-               return dev_err_probe(dev, PTR_ERR(bus->clk),
+       clk = devm_clk_get_enabled(dev, "bus");
+       if (IS_ERR(clk))
+               return dev_err_probe(dev, PTR_ERR(clk),
                                "failed to get bus clock\n");
 
        /* Get the freq and voltage from OPP table to scale the bus freq */
@@ -257,7 +257,7 @@ static int exynos_bus_parse_of(struct device_node *np,
                return ret;
        }
 
-       rate = clk_get_rate(bus->clk);
+       rate = clk_get_rate(clk);
 
        opp = devfreq_recommended_opp(dev, &rate, 0);
        if (IS_ERR(opp)) {
--
Quoted 2 lines

2.44.0

Thanks & Regards

-Anand

author
#3 lore raw
In reply to Anand Moon

Hi All,

Quoted 6 lines · Anand Moon

The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource.

Quoted 6 lines

This simplifies the code and avoids the calls to clk_disable_unprepare().

While at it, use dev_err_probe consistently, and use its return value to return the error code.

Gentle ping?

Thanks
-Anand

Applied
#4 lore raw

24. 6. 17. 17:24에 Anand Moon 이(가) 쓴 글:

Quoted 14 lines

Hi All,

Quoted 11 lines · Anand Moon

The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource.

This simplifies the code and avoids the calls to clk_disable_unprepare().

While at it, use dev_err_probe consistently, and use its return value to return the error code.

Quoted 7 lines
Quoted 1 line

Gentle ping?

Thanks
-Anand

Applied it. Thanks.
I'm sorry for late reply.

Signature · 3 lines
Best Regards,
Samsung Electronics
Chanwoo Choi
author
#5 lore raw

Hi Chanwoo,

Quoted 18 lines · Chanwoo Choi

24. 6. 17. 17:24에 Anand Moon 이(가) 쓴 글:

Quoted 16 lines

Hi All,

Quoted 12 lines · Anand Moon

The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource.

This simplifies the code and avoids the calls to clk_disable_unprepare().

While at it, use dev_err_probe consistently, and use its return value to return the error code.

Quoted 9 lines
Quoted 5 lines

Gentle ping?

Thanks
-Anand

Applied it. Thanks.
I'm sorry for late reply.

Thanks & Regards
-Anand

Quoted 5 lines

--
Best Regards,
Samsung Electronics
Chanwoo Choi