summaryrefslogtreecommitdiff
path: root/drivers/pwm
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2022-12-02 21:35:11 +0300
committerThierry Reding <thierry.reding@gmail.com>2022-12-06 14:46:06 +0300
commit4034e5944884dca1673e52cc392b07d0d35b6ff0 (patch)
tree44bb994f69bcf77b9231811ecc1a66e65b6fb69d /drivers/pwm
parentc8135b5174145a65c72c4303f2752cc8cecf8d08 (diff)
downloadlinux-4034e5944884dca1673e52cc392b07d0d35b6ff0.tar.xz
pwm: Mark free pwm IDs as used in alloc_pwms()
alloc_pwms() only identified a free range of IDs and this range was marked as used only later by pwmchip_add(). Instead let alloc_pwms() already do the marking (which makes the function actually allocating the range and so justifies the function name). This way access to the allocated_pwms bitfield is limited to two functions only. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20221117211143.3817381-4-u.kleine-koenig@pengutronix.de 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')
-rw-r--r--drivers/pwm/core.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 2338119a09d8..b43b24bd3c9f 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -51,6 +51,8 @@ static int alloc_pwms(unsigned int count)
if (start + count > MAX_PWMS)
return -ENOSPC;
+ bitmap_set(allocated_pwms, start, count);
+
return start;
}
@@ -297,8 +299,6 @@ int pwmchip_add(struct pwm_chip *chip)
radix_tree_insert(&pwm_tree, pwm->pwm, pwm);
}
- bitmap_set(allocated_pwms, chip->base, chip->npwm);
-
INIT_LIST_HEAD(&chip->list);
list_add(&chip->list, &pwm_chips);