diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-14 10:30:59 +0100 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-15 12:59:19 +0100 |
commit | 93dcf8e00e16d76a5f0d689ebad13761a1213c33 (patch) | |
tree | 3c2b3b370b04c35c64da849c9a4c83433ce10fd1 /drivers | |
parent | pwm: atmel-hlcdc: Prepare removing pwm_chip from driver data (diff) | |
download | linux-93dcf8e00e16d76a5f0d689ebad13761a1213c33.tar.xz linux-93dcf8e00e16d76a5f0d689ebad13761a1213c33.zip |
pwm: atmel-hlcdc: Make use of devm_pwmchip_alloc() function
This prepares the pwm-atmel-hlcdc 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/4724c6a0f052160ac80ba5a3065c9470778b7457.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pwm/pwm-atmel-hlcdc.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c index 718f1b1cce0b..2afb302be02c 100644 --- a/drivers/pwm/pwm-atmel-hlcdc.c +++ b/drivers/pwm/pwm-atmel-hlcdc.c @@ -28,7 +28,6 @@ struct atmel_hlcdc_pwm_errata { }; struct atmel_hlcdc_pwm { - struct pwm_chip chip; struct atmel_hlcdc *hlcdc; struct clk *cur_clk; const struct atmel_hlcdc_pwm_errata *errata; @@ -36,7 +35,7 @@ struct atmel_hlcdc_pwm { static inline struct atmel_hlcdc_pwm *to_atmel_hlcdc_pwm(struct pwm_chip *chip) { - return container_of(chip, struct atmel_hlcdc_pwm, chip); + return pwmchip_get_drvdata(chip); } static int atmel_hlcdc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, @@ -250,9 +249,10 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev) hlcdc = dev_get_drvdata(dev->parent); - atmel = devm_kzalloc(dev, sizeof(*atmel), GFP_KERNEL); - if (!atmel) - return -ENOMEM; + chip = devm_pwmchip_alloc(dev, 1, sizeof(*atmel)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + atmel = to_atmel_hlcdc_pwm(chip); ret = clk_prepare_enable(hlcdc->periph_clk); if (ret) @@ -263,10 +263,7 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev) atmel->errata = match->data; atmel->hlcdc = hlcdc; - chip = &atmel->chip; chip->ops = &atmel_hlcdc_pwm_ops; - chip->dev = dev; - chip->npwm = 1; ret = pwmchip_add(chip); if (ret) { |