Skip to content

Commit 7431853

Browse files
Uwe Kleine-Königclaudiubeznea
authored andcommitted
pwm: Always allocate PWM chip base ID dynamically
Since commit 5e5da1e ("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: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com> [claudiu.beznea@microchip.com: adapt for v5.10] Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
1 parent 8f3b40e commit 7431853

52 files changed

Lines changed: 7 additions & 69 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

drivers/pwm/core.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,13 @@ static struct pwm_device *pwm_to_device(unsigned int pwm)
3737
return radix_tree_lookup(&pwm_tree, pwm);
3838
}
3939

40-
static int alloc_pwms(int pwm, unsigned int count)
40+
static int alloc_pwms(unsigned int count)
4141
{
42-
unsigned int from = 0;
4342
unsigned int start;
4443

45-
if (pwm >= MAX_PWMS)
46-
return -EINVAL;
47-
48-
if (pwm >= 0)
49-
from = pwm;
50-
51-
start = bitmap_find_next_zero_area(allocated_pwms, MAX_PWMS, from,
44+
start = bitmap_find_next_zero_area(allocated_pwms, MAX_PWMS, 0,
5245
count, 0);
5346

54-
if (pwm >= 0 && start != pwm)
55-
return -EEXIST;
56-
5747
if (start + count > MAX_PWMS)
5848
return -ENOSPC;
5949

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

286275
mutex_lock(&pwm_lock);
287276

288-
ret = alloc_pwms(chip->base, chip->npwm);
277+
ret = alloc_pwms(chip->npwm);
289278
if (ret < 0)
290279
goto out;
291280

281+
chip->base = ret;
282+
292283
chip->pwms = kcalloc(chip->npwm, sizeof(*pwm), GFP_KERNEL);
293284
if (!chip->pwms) {
294285
ret = -ENOMEM;
295286
goto out;
296287
}
297288

298-
chip->base = ret;
299-
300289
for (i = 0; i < chip->npwm; i++) {
301290
pwm = &chip->pwms[i];
302291

drivers/pwm/pwm-ab8500.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ static int ab8500_pwm_probe(struct platform_device *pdev)
9898

9999
ab8500->chip.dev = &pdev->dev;
100100
ab8500->chip.ops = &ab8500_pwm_ops;
101-
ab8500->chip.base = -1;
102101
ab8500->chip.npwm = 1;
103102

104103
err = pwmchip_add(&ab8500->chip);

drivers/pwm/pwm-atmel-hlcdc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
265265
chip->hlcdc = hlcdc;
266266
chip->chip.ops = &atmel_hlcdc_pwm_ops;
267267
chip->chip.dev = dev;
268-
chip->chip.base = -1;
269268
chip->chip.npwm = 1;
270269
chip->chip.of_xlate = of_pwm_xlate_with_flags;
271270
chip->chip.of_pwm_n_cells = 3;

drivers/pwm/pwm-atmel-tcb.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,6 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
454454
tcbpwm->chip.ops = &atmel_tcb_pwm_ops;
455455
tcbpwm->chip.of_xlate = of_pwm_xlate_with_flags;
456456
tcbpwm->chip.of_pwm_n_cells = 3;
457-
tcbpwm->chip.base = -1;
458457
tcbpwm->chip.npwm = NPWM;
459458
tcbpwm->channel = channel;
460459
tcbpwm->regmap = regmap;

drivers/pwm/pwm-atmel.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ static int atmel_pwm_probe(struct platform_device *pdev)
429429
atmel_pwm->chip.ops = &atmel_pwm_ops;
430430
atmel_pwm->chip.of_xlate = of_pwm_xlate_with_flags;
431431
atmel_pwm->chip.of_pwm_n_cells = 3;
432-
atmel_pwm->chip.base = -1;
433432
atmel_pwm->chip.npwm = 4;
434433

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

drivers/pwm/pwm-bcm-iproc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ static int iproc_pwmc_probe(struct platform_device *pdev)
210210

211211
ip->chip.dev = &pdev->dev;
212212
ip->chip.ops = &iproc_pwm_ops;
213-
ip->chip.base = -1;
214213
ip->chip.npwm = 4;
215214
ip->chip.of_xlate = of_pwm_xlate_with_flags;
216215
ip->chip.of_pwm_n_cells = 3;

drivers/pwm/pwm-bcm-kona.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ static int kona_pwmc_probe(struct platform_device *pdev)
272272

273273
kp->chip.dev = &pdev->dev;
274274
kp->chip.ops = &kona_pwm_ops;
275-
kp->chip.base = -1;
276275
kp->chip.npwm = 6;
277276
kp->chip.of_xlate = of_pwm_xlate_with_flags;
278277
kp->chip.of_pwm_n_cells = 3;

drivers/pwm/pwm-bcm2835.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
162162

163163
pc->chip.dev = &pdev->dev;
164164
pc->chip.ops = &bcm2835_pwm_ops;
165-
pc->chip.base = -1;
166165
pc->chip.npwm = 2;
167166
pc->chip.of_xlate = of_pwm_xlate_with_flags;
168167
pc->chip.of_pwm_n_cells = 3;

drivers/pwm/pwm-berlin.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ static int berlin_pwm_probe(struct platform_device *pdev)
208208

209209
pwm->chip.dev = &pdev->dev;
210210
pwm->chip.ops = &berlin_pwm_ops;
211-
pwm->chip.base = -1;
212211
pwm->chip.npwm = 4;
213212
pwm->chip.of_xlate = of_pwm_xlate_with_flags;
214213
pwm->chip.of_pwm_n_cells = 3;

drivers/pwm/pwm-brcmstb.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ static int brcmstb_pwm_probe(struct platform_device *pdev)
259259

260260
p->chip.dev = &pdev->dev;
261261
p->chip.ops = &brcmstb_pwm_ops;
262-
p->chip.base = -1;
263262
p->chip.npwm = 2;
264263

265264
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

0 commit comments

Comments
 (0)