Skip to content

Commit aad4e53

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: imx27: Simplify helper function to enable and disable clocks
pwm_imx27_clk_prepare_enable() took a pointer to a struct pwm_chip just to convert it to a struct pwm_imx27_chip pointer while all callers already have the latter. Ditto for pwm_imx27_clk_disable_unprepare(). Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 15d4dbd commit aad4e53

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

drivers/pwm/pwm-imx27.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ struct pwm_imx27_chip {
9696

9797
#define to_pwm_imx27_chip(chip) container_of(chip, struct pwm_imx27_chip, chip)
9898

99-
static int pwm_imx27_clk_prepare_enable(struct pwm_chip *chip)
99+
static int pwm_imx27_clk_prepare_enable(struct pwm_imx27_chip *imx)
100100
{
101-
struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip);
102101
int ret;
103102

104103
ret = clk_prepare_enable(imx->clk_ipg);
@@ -114,10 +113,8 @@ static int pwm_imx27_clk_prepare_enable(struct pwm_chip *chip)
114113
return 0;
115114
}
116115

117-
static void pwm_imx27_clk_disable_unprepare(struct pwm_chip *chip)
116+
static void pwm_imx27_clk_disable_unprepare(struct pwm_imx27_chip *imx)
118117
{
119-
struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip);
120-
121118
clk_disable_unprepare(imx->clk_per);
122119
clk_disable_unprepare(imx->clk_ipg);
123120
}
@@ -130,7 +127,7 @@ static void pwm_imx27_get_state(struct pwm_chip *chip,
130127
u64 tmp;
131128
int ret;
132129

133-
ret = pwm_imx27_clk_prepare_enable(chip);
130+
ret = pwm_imx27_clk_prepare_enable(imx);
134131
if (ret < 0)
135132
return;
136133

@@ -175,7 +172,7 @@ static void pwm_imx27_get_state(struct pwm_chip *chip,
175172
state->duty_cycle = DIV_ROUND_CLOSEST_ULL(tmp, pwm_clk);
176173

177174
if (!state->enabled)
178-
pwm_imx27_clk_disable_unprepare(chip);
175+
pwm_imx27_clk_disable_unprepare(imx);
179176
}
180177

181178
static void pwm_imx27_sw_reset(struct pwm_chip *chip)
@@ -259,7 +256,7 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm,
259256
if (cstate.enabled) {
260257
pwm_imx27_wait_fifo_slot(chip, pwm);
261258
} else {
262-
ret = pwm_imx27_clk_prepare_enable(chip);
259+
ret = pwm_imx27_clk_prepare_enable(imx);
263260
if (ret)
264261
return ret;
265262

@@ -290,7 +287,7 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm,
290287
writel(cr, imx->mmio_base + MX3_PWMCR);
291288

292289
if (!state->enabled)
293-
pwm_imx27_clk_disable_unprepare(chip);
290+
pwm_imx27_clk_disable_unprepare(imx);
294291

295292
return 0;
296293
}
@@ -361,7 +358,7 @@ static int pwm_imx27_remove(struct platform_device *pdev)
361358

362359
imx = platform_get_drvdata(pdev);
363360

364-
pwm_imx27_clk_disable_unprepare(&imx->chip);
361+
pwm_imx27_clk_disable_unprepare(imx);
365362

366363
return pwmchip_remove(&imx->chip);
367364
}

0 commit comments

Comments
 (0)