aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2024-02-14 10:30:53 +0100
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>2024-02-15 12:59:19 +0100
commit6357c2cd05e167f885edd784254da59e311197bd (patch)
treef35258d734a29d366dd6b3b9df764c03f619352c /drivers/pwm
parent96af28dc44b9a13c04d6b70a9ad5a8fa0daf1d67 (diff)
downloadlinux-6357c2cd05e167f885edd784254da59e311197bd.tar.gz
pwm: ab8500: Make use of devm_pwmchip_alloc() function
This prepares the pwm-ab8500 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/9c952baafe7e53c482adf23215138724b61e376b.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/pwm-ab8500.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/pwm/pwm-ab8500.c b/drivers/pwm/pwm-ab8500.c
index 9043e5643f44ee..f000adab85b00e 100644
--- a/drivers/pwm/pwm-ab8500.c
+++ b/drivers/pwm/pwm-ab8500.c
@@ -24,13 +24,12 @@
#define AB8500_PWM_CLKRATE 9600000
struct ab8500_pwm_chip {
- struct pwm_chip chip;
unsigned int hwid;
};
static struct ab8500_pwm_chip *ab8500_pwm_from_chip(struct pwm_chip *chip)
{
- return container_of(chip, struct ab8500_pwm_chip, chip);
+ return pwmchip_get_drvdata(chip);
}
static int ab8500_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
@@ -196,14 +195,13 @@ static int ab8500_pwm_probe(struct platform_device *pdev)
* Nothing to be done in probe, this is required to get the
* device which is required for ab8500 read and write
*/
- ab8500 = devm_kzalloc(&pdev->dev, sizeof(*ab8500), GFP_KERNEL);
- if (ab8500 == NULL)
- return -ENOMEM;
+ chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*ab8500));
+ if (IS_ERR(chip))
+ return PTR_ERR(chip);
+
+ ab8500 = ab8500_pwm_from_chip(chip);
- chip = &ab8500->chip;
- chip->dev = &pdev->dev;
chip->ops = &ab8500_pwm_ops;
- chip->npwm = 1;
ab8500->hwid = pdev->id - 1;
err = devm_pwmchip_add(&pdev->dev, chip);