Commit 140827c1 authored by Sascha Hauer's avatar Sascha Hauer Committed by Thierry Reding

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: default avatarSascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: default avatarShawn Guo <shawn.guo@linaro.org>
Reviewed-by: default avatarBenoît Thébaudeau <benoit.thebaudeau@advansee.com>
Signed-off-by: default avatarThierry Reding <thierry.reding@avionic-design.de>
parent 19e73333
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
struct imx_chip { struct imx_chip {
struct clk *clk; struct clk *clk;
int clk_enabled; int enabled;
void __iomem *mmio_base; void __iomem *mmio_base;
struct pwm_chip chip; struct pwm_chip chip;
...@@ -139,14 +139,15 @@ static int imx_pwm_config(struct pwm_chip *chip, ...@@ -139,14 +139,15 @@ static int imx_pwm_config(struct pwm_chip *chip,
static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
{ {
struct imx_chip *imx = to_imx_chip(chip); struct imx_chip *imx = to_imx_chip(chip);
int rc = 0; int ret;
if (!imx->clk_enabled) { ret = clk_prepare_enable(imx->clk);
rc = clk_prepare_enable(imx->clk); if (ret)
if (!rc) return ret;
imx->clk_enabled = 1;
} imx->enabled = 1;
return rc;
return 0;
} }
static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) 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,10 +156,8 @@ static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
writel(0, imx->mmio_base + MX3_PWMCR); writel(0, imx->mmio_base + MX3_PWMCR);
if (imx->clk_enabled) { clk_disable_unprepare(imx->clk);
clk_disable_unprepare(imx->clk); imx->enabled = 0;
imx->clk_enabled = 0;
}
} }
static struct pwm_ops imx_pwm_ops = { static struct pwm_ops imx_pwm_ops = {
...@@ -190,8 +189,6 @@ static int __devinit imx_pwm_probe(struct platform_device *pdev) ...@@ -190,8 +189,6 @@ static int __devinit imx_pwm_probe(struct platform_device *pdev)
imx->chip.base = -1; imx->chip.base = -1;
imx->chip.npwm = 1; imx->chip.npwm = 1;
imx->clk_enabled = 0;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (r == NULL) { if (r == NULL) {
dev_err(&pdev->dev, "no memory resource defined\n"); dev_err(&pdev->dev, "no memory resource defined\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment