Message ID | xc3xx56vvesaen7r2c3q5thmrjva7zcfq5habasejlyn7vnpbj@jxsfprt5gfa4 (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | sparse reports "different lock contexts for basic block" when using guard syntax | expand |
On Mon, 2 Dec 2024 at 01:26, Uwe Kleine-König <u.kleine-koenig@baylibre.com> wrote: > > Trying to understand what sparse wants to tell me, I tried the following > change and the 2nd warning goes away: Sparse really doesn't understand the new guard infrastructure. It gets _parsed_, but that's just about it. So it parses the cleanup function, but never actually generates the logic to _call_ the cleanup function when the variable goes out of scope. Which obviously then means that none of the context updates of the cleanup get done, and so the lock context never gets undone. Sadly, I think sparse is unmaintained these days, Linus
diff --git a/drivers/pwm/pwm-gpio.c b/drivers/pwm/pwm-gpio.c index 9f8884ac7504..d811b1f71c92 100644 --- a/drivers/pwm/pwm-gpio.c +++ b/drivers/pwm/pwm-gpio.c @@ -103,6 +103,7 @@ static int pwm_gpio_apply(struct pwm_chip *chip, struct pwm_device *pwm, { struct pwm_gpio *gpwm = pwmchip_get_drvdata(chip); bool invert = state->polarity == PWM_POLARITY_INVERSED; + unsigned long flags; if (state->duty_cycle && state->duty_cycle < hrtimer_resolution) return -EINVAL; @@ -125,7 +126,7 @@ static int pwm_gpio_apply(struct pwm_chip *chip, struct pwm_device *pwm, return ret; } - guard(spinlock_irqsave)(&gpwm->lock); + spin_lock_irqsave(&gpwm->lock, flags); if (!state->enabled) { pwm_gpio_round(&gpwm->state, state); @@ -148,6 +149,7 @@ static int pwm_gpio_apply(struct pwm_chip *chip, struct pwm_device *pwm, HRTIMER_MODE_REL); } + spin_unlock_irqrestore(&gpwm->lock, flags); return 0; }