diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-14 10:31:19 +0100 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-19 11:02:57 +0100 |
commit | aaa3cc29a78e0db72762999d7ad1224d1cf3d45c (patch) | |
tree | 2cde5c72bc109f0f224573d90f41c06c3674aef8 /drivers/pwm/pwm-dwc-core.c | |
parent | pwm: cros-ec: Make use of devm_pwmchip_alloc() function (diff) | |
download | linux-aaa3cc29a78e0db72762999d7ad1224d1cf3d45c.tar.xz linux-aaa3cc29a78e0db72762999d7ad1224d1cf3d45c.zip |
pwm: dwc: Prepare removing pwm_chip from driver data
This prepares the driver for further changes that will drop struct
pwm_chip chip from struct dwc_pwm. Use the pwm_chip as driver
data and return value of dwc_pwm_alloc() instead of the dwc_pwm to get
access to the pwm_chip in dwc_pwm_probe() and dwc_pwm_suspend() without
using dwc->chip.
Thanks to Raag Jadav for providing a hunk of this patch that Uwe missed
during creation of this patch.
Link: https://lore.kernel.org/r/008ce5ab84b8e3baa3e81ab6d36dbb0e4be5c319.1707900770.git.u.kleine-koenig@pengutronix.de
Link: https://lore.kernel.org/r/20240219033835.11369-2-raag.jadav@intel.com
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 | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/pwm/pwm-dwc-core.c b/drivers/pwm/pwm-dwc-core.c index ea63dd741f5c..ac7a0b2cb8b9 100644 --- a/drivers/pwm/pwm-dwc-core.c +++ b/drivers/pwm/pwm-dwc-core.c @@ -159,21 +159,23 @@ static const struct pwm_ops dwc_pwm_ops = { .get_state = dwc_pwm_get_state, }; -struct dwc_pwm *dwc_pwm_alloc(struct device *dev) +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 NULL; + return ERR_PTR(-ENOMEM); + chip = &dwc->chip; dwc->clk_ns = 10; - dwc->chip.dev = dev; - dwc->chip.ops = &dwc_pwm_ops; - dwc->chip.npwm = DWC_TIMERS_TOTAL; + chip->dev = dev; + chip->ops = &dwc_pwm_ops; + chip->npwm = DWC_TIMERS_TOTAL; - dev_set_drvdata(dev, dwc); - return dwc; + dev_set_drvdata(dev, chip); + return chip; } EXPORT_SYMBOL_GPL(dwc_pwm_alloc); |