aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pwm/pwm-imx.c25
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 @@
42struct imx_chip { 42struct 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,
139static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) 139static 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
152static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) 153static 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
164static struct pwm_ops imx_pwm_ops = { 163static 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");