Commit af184748 authored by Uwe Kleine-König's avatar Uwe Kleine-König

pwm: atmel-tcb: Make use of devm_pwmchip_alloc() function

This prepares the pwm-atmel-tcb driver to further changes of the pwm
core outlined in the commit introducing devm_pwmchip_alloc(). There is
no intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/c845e6c9d27c8a4037755b2ae702b0039947a3c1.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent dfab73eb
...@@ -47,7 +47,6 @@ struct atmel_tcb_channel { ...@@ -47,7 +47,6 @@ struct atmel_tcb_channel {
}; };
struct atmel_tcb_pwm_chip { struct atmel_tcb_pwm_chip {
struct pwm_chip chip;
spinlock_t lock; spinlock_t lock;
u8 channel; u8 channel;
u8 width; u8 width;
...@@ -63,7 +62,7 @@ static const u8 atmel_tcb_divisors[] = { 2, 8, 32, 128, 0, }; ...@@ -63,7 +62,7 @@ static const u8 atmel_tcb_divisors[] = { 2, 8, 32, 128, 0, };
static inline struct atmel_tcb_pwm_chip *to_tcb_chip(struct pwm_chip *chip) static inline struct atmel_tcb_pwm_chip *to_tcb_chip(struct pwm_chip *chip)
{ {
return container_of(chip, struct atmel_tcb_pwm_chip, chip); return pwmchip_get_drvdata(chip);
} }
static int atmel_tcb_pwm_request(struct pwm_chip *chip, static int atmel_tcb_pwm_request(struct pwm_chip *chip,
...@@ -397,9 +396,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) ...@@ -397,9 +396,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
int err; int err;
int channel; int channel;
tcbpwm = devm_kzalloc(&pdev->dev, sizeof(*tcbpwm), GFP_KERNEL); chip = devm_pwmchip_alloc(&pdev->dev, NPWM, sizeof(*tcbpwm));
if (tcbpwm == NULL) if (IS_ERR(chip))
return -ENOMEM; return PTR_ERR(chip);
tcbpwm = to_tcb_chip(chip);
err = of_property_read_u32(np, "reg", &channel); err = of_property_read_u32(np, "reg", &channel);
if (err < 0) { if (err < 0) {
...@@ -437,10 +437,7 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) ...@@ -437,10 +437,7 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
} }
} }
chip = &tcbpwm->chip;
chip->dev = &pdev->dev;
chip->ops = &atmel_tcb_pwm_ops; chip->ops = &atmel_tcb_pwm_ops;
chip->npwm = NPWM;
tcbpwm->channel = channel; tcbpwm->channel = channel;
tcbpwm->width = config->counter_width; tcbpwm->width = config->counter_width;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment