Commit f9a8ee8c authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Thierry Reding
Browse files

pwm: Always allocate PWM chip base ID dynamically



Since commit 5e5da1e9 ("pwm: ab8500: Explicitly allocate pwm chip
base dynamically") all drivers use dynamic ID allocation explicitly. New
drivers are supposed to do the same, so remove support for driver
specified base IDs and drop all assignments in the low-level drivers.

Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 5a43c201
Loading
Loading
Loading
Loading
+7 −18
Original line number Diff line number Diff line
@@ -37,23 +37,13 @@ static struct pwm_device *pwm_to_device(unsigned int pwm)
	return radix_tree_lookup(&pwm_tree, pwm);
}

static int alloc_pwms(int pwm, unsigned int count)
static int alloc_pwms(unsigned int count)
{
	unsigned int from = 0;
	unsigned int start;

	if (pwm >= MAX_PWMS)
		return -EINVAL;

	if (pwm >= 0)
		from = pwm;

	start = bitmap_find_next_zero_area(allocated_pwms, MAX_PWMS, from,
	start = bitmap_find_next_zero_area(allocated_pwms, MAX_PWMS, 0,
					   count, 0);

	if (pwm >= 0 && start != pwm)
		return -EEXIST;

	if (start + count > MAX_PWMS)
		return -ENOSPC;

@@ -264,9 +254,8 @@ static bool pwm_ops_check(const struct pwm_chip *chip)
 * @chip: the PWM chip to add
 * @polarity: initial polarity of PWM channels
 *
 * Register a new PWM chip. If chip->base < 0 then a dynamically assigned base
 * will be used. The initial polarity for all channels is specified by the
 * @polarity parameter.
 * Register a new PWM chip. The initial polarity for all channels is specified
 * by the @polarity parameter.
 *
 * Returns: 0 on success or a negative error code on failure.
 */
@@ -285,18 +274,18 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip,

	mutex_lock(&pwm_lock);

	ret = alloc_pwms(chip->base, chip->npwm);
	ret = alloc_pwms(chip->npwm);
	if (ret < 0)
		goto out;

	chip->base = ret;

	chip->pwms = kcalloc(chip->npwm, sizeof(*pwm), GFP_KERNEL);
	if (!chip->pwms) {
		ret = -ENOMEM;
		goto out;
	}

	chip->base = ret;

	for (i = 0; i < chip->npwm; i++) {
		pwm = &chip->pwms[i];

+0 −1
Original line number Diff line number Diff line
@@ -98,7 +98,6 @@ static int ab8500_pwm_probe(struct platform_device *pdev)

	ab8500->chip.dev = &pdev->dev;
	ab8500->chip.ops = &ab8500_pwm_ops;
	ab8500->chip.base = -1;
	ab8500->chip.npwm = 1;

	err = pwmchip_add(&ab8500->chip);
+0 −1
Original line number Diff line number Diff line
@@ -265,7 +265,6 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
	chip->hlcdc = hlcdc;
	chip->chip.ops = &atmel_hlcdc_pwm_ops;
	chip->chip.dev = dev;
	chip->chip.base = -1;
	chip->chip.npwm = 1;
	chip->chip.of_xlate = of_pwm_xlate_with_flags;
	chip->chip.of_pwm_n_cells = 3;
+0 −1
Original line number Diff line number Diff line
@@ -454,7 +454,6 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
	tcbpwm->chip.ops = &atmel_tcb_pwm_ops;
	tcbpwm->chip.of_xlate = of_pwm_xlate_with_flags;
	tcbpwm->chip.of_pwm_n_cells = 3;
	tcbpwm->chip.base = -1;
	tcbpwm->chip.npwm = NPWM;
	tcbpwm->channel = channel;
	tcbpwm->regmap = regmap;
+0 −1
Original line number Diff line number Diff line
@@ -429,7 +429,6 @@ static int atmel_pwm_probe(struct platform_device *pdev)
	atmel_pwm->chip.ops = &atmel_pwm_ops;
	atmel_pwm->chip.of_xlate = of_pwm_xlate_with_flags;
	atmel_pwm->chip.of_pwm_n_cells = 3;
	atmel_pwm->chip.base = -1;
	atmel_pwm->chip.npwm = 4;

	ret = pwmchip_add(&atmel_pwm->chip);
Loading