]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pwm: microchip-core: Drop driver local locking
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Tue, 24 Jun 2025 18:15:41 +0000 (20:15 +0200)
committerUwe Kleine-König <ukleinek@kernel.org>
Mon, 7 Jul 2025 06:39:36 +0000 (08:39 +0200)
The pwm core already serializes .apply() and .get_state(), so the driver
local lock is always free and adds no protection.

Drop it.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/6d6ef0376ea0058b040eec3b257e324493a083f1.1750788649.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
drivers/pwm/pwm-microchip-core.c

index 12821b4bbf97560638d848412851b195504aa3ad..4ff32bb4c205307a4e76137aee4bf7b1888d7026 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/ktime.h>
 #include <linux/math.h>
 #include <linux/module.h>
-#include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
@@ -56,7 +55,6 @@
 struct mchp_core_pwm_chip {
        struct clk *clk;
        void __iomem *base;
-       struct mutex lock; /* protects the shared period */
        ktime_t update_timestamp;
        u32 sync_update_mask;
        u16 channel_enabled;
@@ -360,17 +358,10 @@ static int mchp_core_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
                               const struct pwm_state *state)
 {
        struct mchp_core_pwm_chip *mchp_core_pwm = to_mchp_core_pwm(chip);
-       int ret;
-
-       mutex_lock(&mchp_core_pwm->lock);
 
        mchp_core_pwm_wait_for_sync_update(mchp_core_pwm, pwm->hwpwm);
 
-       ret = mchp_core_pwm_apply_locked(chip, pwm, state);
-
-       mutex_unlock(&mchp_core_pwm->lock);
-
-       return ret;
+       return mchp_core_pwm_apply_locked(chip, pwm, state);
 }
 
 static int mchp_core_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
@@ -381,8 +372,6 @@ static int mchp_core_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm
        u16 prescale, period_steps;
        u8 duty_steps, posedge, negedge;
 
-       mutex_lock(&mchp_core_pwm->lock);
-
        mchp_core_pwm_wait_for_sync_update(mchp_core_pwm, pwm->hwpwm);
 
        if (mchp_core_pwm->channel_enabled & (1 << pwm->hwpwm))
@@ -415,8 +404,6 @@ static int mchp_core_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm
        posedge = readb_relaxed(mchp_core_pwm->base + MCHPCOREPWM_POSEDGE(pwm->hwpwm));
        negedge = readb_relaxed(mchp_core_pwm->base + MCHPCOREPWM_NEGEDGE(pwm->hwpwm));
 
-       mutex_unlock(&mchp_core_pwm->lock);
-
        if (negedge == posedge) {
                state->duty_cycle = state->period;
                state->period *= 2;
@@ -469,8 +456,6 @@ static int mchp_core_pwm_probe(struct platform_device *pdev)
                                 &mchp_core_pwm->sync_update_mask))
                mchp_core_pwm->sync_update_mask = 0;
 
-       mutex_init(&mchp_core_pwm->lock);
-
        chip->ops = &mchp_core_pwm_ops;
 
        mchp_core_pwm->channel_enabled = readb_relaxed(mchp_core_pwm->base + MCHPCOREPWM_EN(0));