summaryrefslogtreecommitdiff
path: root/drivers/pwm/pwm-sprd.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2024-02-14 10:32:37 +0100
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>2024-02-22 14:39:10 +0100
commitf2075c0b1a8f8285b72d2dc800345e854d3a711b (patch)
treeaa4ece711620ddbcd1a8f41c2ace75fa55bc4dfc /drivers/pwm/pwm-sprd.c
parentaac1b805a61ced530b4d427354a205b4bbff69c6 (diff)
pwm: sprd: Make use of devm_pwmchip_alloc() function
This prepares the pwm-sprd 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. Tested-by: Chunyan Zhang <zhang.lyra@gmail.com> Link: https://lore.kernel.org/r/543213f44686ee72d8f88897bf2ca616e837ae44.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-sprd.c')
-rw-r--r--drivers/pwm/pwm-sprd.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/pwm/pwm-sprd.c b/drivers/pwm/pwm-sprd.c
index a38f50c3dc00..4c76ca5e4cdd 100644
--- a/drivers/pwm/pwm-sprd.c
+++ b/drivers/pwm/pwm-sprd.c
@@ -34,13 +34,12 @@ struct sprd_pwm_chn {
struct sprd_pwm_chip {
void __iomem *base;
- struct pwm_chip chip;
struct sprd_pwm_chn chn[SPRD_PWM_CHN_NUM];
};
static inline struct sprd_pwm_chip* sprd_pwm_from_chip(struct pwm_chip *chip)
{
- return container_of(chip, struct sprd_pwm_chip, chip);
+ return pwmchip_get_drvdata(chip);
}
/*
@@ -248,6 +247,7 @@ static int sprd_pwm_clk_init(struct device *dev,
static int sprd_pwm_probe(struct platform_device *pdev)
{
+ struct pwm_chip *chip;
struct sprd_pwm_chip *spc;
struct sprd_pwm_chn chn[SPRD_PWM_CHN_NUM];
int ret, npwm;
@@ -256,9 +256,10 @@ static int sprd_pwm_probe(struct platform_device *pdev)
if (npwm < 0)
return npwm;
- spc = devm_kzalloc(&pdev->dev, sizeof(*spc), GFP_KERNEL);
- if (!spc)
- return -ENOMEM;
+ chip = devm_pwmchip_alloc(&pdev->dev, npwm, sizeof(*spc));
+ if (IS_ERR(chip))
+ return PTR_ERR(chip);
+ spc = sprd_pwm_from_chip(chip);
spc->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(spc->base))
@@ -266,11 +267,9 @@ static int sprd_pwm_probe(struct platform_device *pdev)
memcpy(spc->chn, chn, sizeof(chn));
- spc->chip.dev = &pdev->dev;
- spc->chip.ops = &sprd_pwm_ops;
- spc->chip.npwm = npwm;
+ chip->ops = &sprd_pwm_ops;
- ret = devm_pwmchip_add(&pdev->dev, &spc->chip);
+ ret = devm_pwmchip_add(&pdev->dev, chip);
if (ret)
dev_err(&pdev->dev, "failed to add PWM chip\n");