diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2021-09-09 11:48:49 +0200 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2021-11-05 11:51:41 +0100 |
commit | 4ad91a227817ae48f931595d1101fc7100073ce9 (patch) | |
tree | 66c8a2c4961fcd269c3e933e8a2cb11a5ca7f5fa /drivers/pwm/core.c | |
parent | 27d9a4d69433af1827a764fe235866d5d5501fdb (diff) | |
download | linux-stable-4ad91a227817ae48f931595d1101fc7100073ce9.tar.gz linux-stable-4ad91a227817ae48f931595d1101fc7100073ce9.tar.bz2 linux-stable-4ad91a227817ae48f931595d1101fc7100073ce9.zip |
pwm: Make it explicit that pwm_apply_state() might sleep
At least some implementations sleep. So mark pwm_apply_state() with a
might_sleep() to make callers aware. In the worst case this uncovers a
valid atomic user, then we revert this patch and at least gained some more
knowledge and then can work on a concept similar to
gpio_get_value/gpio_get_value_cansleep.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/core.c')
-rw-r--r-- | drivers/pwm/core.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 4527f09a5c50..fb04a439462c 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -532,6 +532,15 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state) struct pwm_chip *chip; int err; + /* + * Some lowlevel driver's implementations of .apply() make use of + * mutexes, also with some drivers only returning when the new + * configuration is active calling pwm_apply_state() from atomic context + * is a bad idea. So make it explicit that calling this function might + * sleep. + */ + might_sleep(); + if (!pwm || !state || !state->period || state->duty_cycle > state->period) return -EINVAL; |