]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
pwm: sun4i: Drop driver local locking
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Tue, 24 Jun 2025 18:15:43 +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 serializes calls to .apply(), so the driver lock doesn't
add any protection and can safely be dropped.

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

index e60dc7d6b5915fc2493e5fc070f5cf7127fb7499..6c5591ca868b439fc4f5e4f5632986e94b881288 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/pwm.h>
 #include <linux/reset.h>
 #include <linux/slab.h>
-#include <linux/spinlock.h>
 #include <linux/time.h>
 
 #define PWM_CTRL_REG           0x0
@@ -85,7 +84,6 @@ struct sun4i_pwm_chip {
        struct clk *clk;
        struct reset_control *rst;
        void __iomem *base;
-       spinlock_t ctrl_lock;
        const struct sun4i_pwm_data *data;
 };
 
@@ -258,7 +256,6 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
                return ret;
        }
 
-       spin_lock(&sun4ichip->ctrl_lock);
        ctrl = sun4i_pwm_readl(sun4ichip, PWM_CTRL_REG);
 
        if (sun4ichip->data->has_direct_mod_clk_output) {
@@ -266,7 +263,6 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
                        ctrl |= BIT_CH(PWM_BYPASS, pwm->hwpwm);
                        /* We can skip other parameter */
                        sun4i_pwm_writel(sun4ichip, ctrl, PWM_CTRL_REG);
-                       spin_unlock(&sun4ichip->ctrl_lock);
                        return 0;
                }
 
@@ -297,8 +293,6 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
        sun4i_pwm_writel(sun4ichip, ctrl, PWM_CTRL_REG);
 
-       spin_unlock(&sun4ichip->ctrl_lock);
-
        if (state->enabled)
                return 0;
 
@@ -309,12 +303,10 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
        else
                usleep_range(delay_us, delay_us * 2);
 
-       spin_lock(&sun4ichip->ctrl_lock);
        ctrl = sun4i_pwm_readl(sun4ichip, PWM_CTRL_REG);
        ctrl &= ~BIT_CH(PWM_CLK_GATING, pwm->hwpwm);
        ctrl &= ~BIT_CH(PWM_EN, pwm->hwpwm);
        sun4i_pwm_writel(sun4ichip, ctrl, PWM_CTRL_REG);
-       spin_unlock(&sun4ichip->ctrl_lock);
 
        clk_disable_unprepare(sun4ichip->clk);
 
@@ -456,8 +448,6 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
 
        chip->ops = &sun4i_pwm_ops;
 
-       spin_lock_init(&sun4ichip->ctrl_lock);
-
        ret = pwmchip_add(chip);
        if (ret < 0) {
                dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret);