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>
if (start + count > MAX_PWMS)
return -ENOSPC;
+ bitmap_set(allocated_pwms, start, count);
+
return start;
}
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);