Linux Kernels

pwm: pxa: Remove clk_enabled field from struct pxa_pwm_chip

This change “pwm: pxa: Remove clk_enabled field from struct pxa_pwm_chip” (commit b014a30) in Linux kernel is authored by Axel Lin <axel.lin [at] ingics.com> on Sun Mar 31 23:04:31 2013 +0800.

Description of "pwm: pxa: Remove clk_enabled field from struct pxa_pwm_chip"

The change “pwm: pxa: Remove clk_enabled field from struct pxa_pwm_chip” introduces changes as follows.

pwm: pxa: Remove clk_enabled field from struct pxa_pwm_chip

clk_enable/clk_disable maintain an enable_count, clk_prepare and clk_unprepare
also maintain a prepare_count. These APIs will do prepare/enable when the first
user calling these APIs, and do disable/unprepare when the corresponding counter
reach 0. Thus We don't need to maintain a clk_enabled counter here.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>

Linux kernel releases containing commit b014a30

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "pwm: pxa: Remove clk_enabled field from struct pxa_pwm_chip"

There are 16 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/pwm/pwm-pxa.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
 
diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
index 20370e61de5a..b78988255aee 100644
--- a/drivers/pwm/pwm-pxa.c
+++ b/drivers/pwm/pwm-pxa.c
@@ -48,7 +48,6 @@ struct pxa_pwm_chip {
 	struct device	*dev;
 
 	struct clk	*clk;
-	int		clk_enabled;
 	void __iomem	*mmio_base;
 };
 
@@ -108,24 +107,15 @@ static int pxa_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 static int pxa_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
 	struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip);
-	int rc = 0;
 
-	if (!pc->clk_enabled) {
-		rc = clk_prepare_enable(pc->clk);
-		if (!rc)
-			pc->clk_enabled++;
-	}
-	return rc;
+	return clk_prepare_enable(pc->clk);
 }
 
 static void pxa_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
 	struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip);
 
-	if (pc->clk_enabled) {
-		clk_disable_unprepare(pc->clk);
-		pc->clk_enabled--;
-	}
+	clk_disable_unprepare(pc->clk);
 }
 
 static struct pwm_ops pxa_pwm_ops = {
@@ -152,8 +142,6 @@ static int pwm_probe(struct platform_device *pdev)
 	if (IS_ERR(pwm->clk))
 		return PTR_ERR(pwm->clk);
 
-	pwm->clk_enabled = 0;
-
 	pwm->chip.dev = &pdev->dev;
 	pwm->chip.ops = &pxa_pwm_ops;
 	pwm->chip.base = -1;

The commit for this change in Linux stable tree is b014a30 (patch).

Last modified: 2020/01/11 06:41