diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-14 10:31:20 +0100 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-19 11:04:08 +0100 |
commit | 1647e5065b4d67bec47977e650ad8ba3812cd259 (patch) | |
tree | b6e75b0c35abca666cb7a2eff780fc423b6d5599 /drivers/pwm/pwm-dwc-core.c | |
parent | pwm: dwc: Prepare removing pwm_chip from driver data (diff) | |
download | linux-1647e5065b4d67bec47977e650ad8ba3812cd259.tar.xz linux-1647e5065b4d67bec47977e650ad8ba3812cd259.zip |
pwm: dwc: Make use of devm_pwmchip_alloc() function
This prepares the pwm-dwc 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.
Also convert the to_dwc_pwm() helper macro to a static inline to get
some type safety.
Link: https://lore.kernel.org/r/64e64a9a8644600d51b234ad9bcae951b5748998.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Diffstat (limited to 'drivers/pwm/pwm-dwc-core.c')
-rw-r--r-- | drivers/pwm/pwm-dwc-core.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/pwm/pwm-dwc-core.c b/drivers/pwm/pwm-dwc-core.c index ac7a0b2cb8b9..de1d2ac3316c 100644 --- a/drivers/pwm/pwm-dwc-core.c +++ b/drivers/pwm/pwm-dwc-core.c @@ -164,15 +164,13 @@ struct pwm_chip *dwc_pwm_alloc(struct device *dev) struct pwm_chip *chip; struct dwc_pwm *dwc; - dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL); - if (!dwc) - return ERR_PTR(-ENOMEM); - chip = &dwc->chip; + chip = devm_pwmchip_alloc(dev, DWC_TIMERS_TOTAL, sizeof(*dwc)); + if (IS_ERR(chip)) + return chip; + dwc = to_dwc_pwm(chip); dwc->clk_ns = 10; - chip->dev = dev; chip->ops = &dwc_pwm_ops; - chip->npwm = DWC_TIMERS_TOTAL; dev_set_drvdata(dev, chip); return chip; |