diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-08-28 03:12:01 -0400 |
---|---|---|
committer | Thierry Reding <thierry.reding@avionic-design.de> | 2012-09-12 08:25:04 -0400 |
commit | 140827c148f2f3a95fdcec5310f6cd980139b383 (patch) | |
tree | 513ab07873ffadbc33251f2b7d4ecd785f16b6b9 /drivers/pwm | |
parent | 19e73333236a6115617f8ffb4cc290bdb6f2865a (diff) |
pwm: i.MX: remove unnecessary if in pwm_[en|dis]able
The PWM core makes sure that pwm_enable/disable are called only
once. Still keep the enabled state since we will need it in
pwm_config.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Shawn Guo <shawn.guo@linaro.org>
Reviewed-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Diffstat (limited to 'drivers/pwm')
-rw-r--r-- | drivers/pwm/pwm-imx.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c index 8b7f01e0a100..5d426ffe6a31 100644 --- a/drivers/pwm/pwm-imx.c +++ b/drivers/pwm/pwm-imx.c | |||
@@ -42,7 +42,7 @@ | |||
42 | struct imx_chip { | 42 | struct imx_chip { |
43 | struct clk *clk; | 43 | struct clk *clk; |
44 | 44 | ||
45 | int clk_enabled; | 45 | int enabled; |
46 | void __iomem *mmio_base; | 46 | void __iomem *mmio_base; |
47 | 47 | ||
48 | struct pwm_chip chip; | 48 | struct pwm_chip chip; |
@@ -139,14 +139,15 @@ static int imx_pwm_config(struct pwm_chip *chip, | |||
139 | static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) | 139 | static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) |
140 | { | 140 | { |
141 | struct imx_chip *imx = to_imx_chip(chip); | 141 | struct imx_chip *imx = to_imx_chip(chip); |
142 | int rc = 0; | 142 | int ret; |
143 | 143 | ||
144 | if (!imx->clk_enabled) { | 144 | ret = clk_prepare_enable(imx->clk); |
145 | rc = clk_prepare_enable(imx->clk); | 145 | if (ret) |
146 | if (!rc) | 146 | return ret; |
147 | imx->clk_enabled = 1; | 147 | |
148 | } | 148 | imx->enabled = 1; |
149 | return rc; | 149 | |
150 | return 0; | ||
150 | } | 151 | } |
151 | 152 | ||
152 | static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) | 153 | static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) |
@@ -155,10 +156,8 @@ static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) | |||
155 | 156 | ||
156 | writel(0, imx->mmio_base + MX3_PWMCR); | 157 | writel(0, imx->mmio_base + MX3_PWMCR); |
157 | 158 | ||
158 | if (imx->clk_enabled) { | 159 | clk_disable_unprepare(imx->clk); |
159 | clk_disable_unprepare(imx->clk); | 160 | imx->enabled = 0; |
160 | imx->clk_enabled = 0; | ||
161 | } | ||
162 | } | 161 | } |
163 | 162 | ||
164 | static struct pwm_ops imx_pwm_ops = { | 163 | static struct pwm_ops imx_pwm_ops = { |
@@ -190,8 +189,6 @@ static int __devinit imx_pwm_probe(struct platform_device *pdev) | |||
190 | imx->chip.base = -1; | 189 | imx->chip.base = -1; |
191 | imx->chip.npwm = 1; | 190 | imx->chip.npwm = 1; |
192 | 191 | ||
193 | imx->clk_enabled = 0; | ||
194 | |||
195 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 192 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
196 | if (r == NULL) { | 193 | if (r == NULL) { |
197 | dev_err(&pdev->dev, "no memory resource defined\n"); | 194 | dev_err(&pdev->dev, "no memory resource defined\n"); |