summaryrefslogtreecommitdiff
path: root/drivers/pwm/pwm-sifive.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2022-07-21 12:31:24 +0200
committerThierry Reding <thierry.reding@gmail.com>2022-07-29 13:40:45 +0200
commit61180f68ad5b9058008e227d5f289934a963af1f (patch)
tree2dc98a8fb39a9083cf0ecb393b3a421b6d1cc21e /drivers/pwm/pwm-sifive.c
parent20550a61880fc55e68a0d290ad195b74729c0e7b (diff)
pwm: sifive: Fold pwm_sifive_enable() into its only caller
There is only a single caller of pwm_sifive_enable() which only enables or disables the clk. Put this implementation directly into pwm_sifive_apply() which allows further simplification in the next change. There is no change in behaviour. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Tested-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/pwm-sifive.c')
-rw-r--r--drivers/pwm/pwm-sifive.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c
index b7fc33b08d82..91cf90bd4083 100644
--- a/drivers/pwm/pwm-sifive.c
+++ b/drivers/pwm/pwm-sifive.c
@@ -124,24 +124,6 @@ static void pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
state->polarity = PWM_POLARITY_INVERSED;
}
-static int pwm_sifive_enable(struct pwm_chip *chip, bool enable)
-{
- struct pwm_sifive_ddata *ddata = pwm_sifive_chip_to_ddata(chip);
- int ret;
-
- if (enable) {
- ret = clk_enable(ddata->clk);
- if (ret) {
- dev_err(ddata->chip.dev, "Enable clk failed\n");
- return ret;
- }
- } else {
- clk_disable(ddata->clk);
- }
-
- return 0;
-}
-
static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm,
const struct pwm_state *state)
{
@@ -192,8 +174,14 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm,
writel(frac, ddata->regs + PWM_SIFIVE_PWMCMP(pwm->hwpwm));
- if (state->enabled != enabled)
- pwm_sifive_enable(chip, state->enabled);
+ if (state->enabled != enabled) {
+ if (state->enabled) {
+ if (clk_enable(ddata->clk))
+ dev_err(ddata->chip.dev, "Enable clk failed\n");
+ } else {
+ clk_disable(ddata->clk);
+ }
+ }
exit:
clk_disable(ddata->clk);