diff --git a/drivers/amlogic/pwm/pwm_meson.c b/drivers/amlogic/pwm/pwm_meson.c index bcd477d0634e..76e289380d32 100644 --- a/drivers/amlogic/pwm/pwm_meson.c +++ b/drivers/amlogic/pwm/pwm_meson.c @@ -61,8 +61,6 @@ #include #include - - struct meson_pwm_channel { unsigned int hi; unsigned int lo; @@ -75,8 +73,6 @@ struct meson_pwm_channel { struct clk *clk; }; - - struct meson_pwm *to_meson_pwm(struct pwm_chip *chip) { return container_of(chip, struct meson_pwm, chip); @@ -327,13 +323,12 @@ static int meson_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, { struct meson_pwm_channel *channel = pwm_get_chip_data(pwm); struct meson_pwm *meson = to_meson_pwm(chip); - unsigned long flags; int err = 0; if (!state) return -EINVAL; - spin_lock_irqsave(&meson->lock, flags); + mutex_lock(&meson->lock); if (!state->enabled) { meson_pwm_disable(meson, pwm->hwpwm); @@ -373,7 +368,7 @@ static int meson_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, } unlock: - spin_unlock_irqrestore(&meson->lock, flags); + mutex_unlock(&meson->lock); return err; } @@ -510,7 +505,7 @@ static int meson_pwm_init_channels(struct meson_pwm *meson, channel->mux.shift = mux_reg_shifts[i]; channel->mux.mask = BIT(MISC_CLK_SEL_WIDTH) - 1; channel->mux.flags = 0; - channel->mux.lock = &meson->lock; + channel->mux.lock = &meson->pwm_lock; channel->mux.table = NULL; channel->mux.hw.init = &init; @@ -561,7 +556,8 @@ static int meson_pwm_probe(struct platform_device *pdev) if (IS_ERR(meson->base)) return PTR_ERR(meson->base); - spin_lock_init(&meson->lock); + mutex_init(&meson->lock); + spin_lock_init(&meson->pwm_lock); meson->chip.dev = &pdev->dev; meson->chip.ops = &meson_pwm_ops; meson->chip.base = -1; diff --git a/include/linux/amlogic/pwm_meson.h b/include/linux/amlogic/pwm_meson.h index 415c84e4872b..81428698dd11 100644 --- a/include/linux/amlogic/pwm_meson.h +++ b/include/linux/amlogic/pwm_meson.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -118,8 +119,8 @@ struct meson_pwm { struct meson_pwm_data *data; struct meson_pwm_variant variant; u32 inverter_mask; - spinlock_t lock; - + struct mutex lock; + spinlock_t pwm_lock; unsigned int clk_mask; };