Skip to content

Commit

Permalink
pwm: sifive: Fold pwm_sifive_enable() into its only caller
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Uwe Kleine-König authored and Thierry Reding committed Jul 29, 2022
1 parent 20550a6 commit 61180f6
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions drivers/pwm/pwm-sifive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 61180f6

Please sign in to comment.