summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2024-02-14 10:31:27 +0100
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>2024-02-19 11:04:09 +0100
commit2e8d68c02ed17263310e3c49f542c1d9df57ec74 (patch)
tree1876d8f21d336078670c7cb9c5eb615682d80680
parent097779f1577df28fe5d02193ea8192a4b55d766a (diff)
downloadlinux-stable-2e8d68c02ed17263310e3c49f542c1d9df57ec74.tar.gz
linux-stable-2e8d68c02ed17263310e3c49f542c1d9df57ec74.tar.bz2
linux-stable-2e8d68c02ed17263310e3c49f542c1d9df57ec74.zip
pwm: fsl-ftm: Make use of devm_pwmchip_alloc() function
This prepares the pwm-fsl-ftm 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/b3c75dea5b2944402b14944fdf71a5db0e26cbd7.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
-rw-r--r--drivers/pwm/pwm-fsl-ftm.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/pwm/pwm-fsl-ftm.c b/drivers/pwm/pwm-fsl-ftm.c
index b4f8dff60c50..2510c10ca473 100644
--- a/drivers/pwm/pwm-fsl-ftm.c
+++ b/drivers/pwm/pwm-fsl-ftm.c
@@ -40,7 +40,6 @@ struct fsl_pwm_periodcfg {
};
struct fsl_pwm_chip {
- struct pwm_chip chip;
struct mutex lock;
struct regmap *regmap;
@@ -55,7 +54,7 @@ struct fsl_pwm_chip {
static inline struct fsl_pwm_chip *to_fsl_chip(struct pwm_chip *chip)
{
- return container_of(chip, struct fsl_pwm_chip, chip);
+ return pwmchip_get_drvdata(chip);
}
static void ftm_clear_write_protection(struct fsl_pwm_chip *fpc)
@@ -398,15 +397,14 @@ static int fsl_pwm_probe(struct platform_device *pdev)
void __iomem *base;
int ret;
- fpc = devm_kzalloc(&pdev->dev, sizeof(*fpc), GFP_KERNEL);
- if (!fpc)
- return -ENOMEM;
- chip = &fpc->chip;
+ chip = devm_pwmchip_alloc(&pdev->dev, 8, sizeof(*fpc));
+ if (IS_ERR(chip))
+ return PTR_ERR(chip);
+ fpc = to_fsl_chip(chip);
mutex_init(&fpc->lock);
fpc->soc = of_device_get_match_data(&pdev->dev);
- chip->dev = &pdev->dev;
base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base))
@@ -446,9 +444,7 @@ static int fsl_pwm_probe(struct platform_device *pdev)
if (IS_ERR(fpc->ipg_clk))
fpc->ipg_clk = fpc->clk[FSL_PWM_CLK_SYS];
-
chip->ops = &fsl_pwm_ops;
- chip->npwm = 8;
ret = devm_pwmchip_add(&pdev->dev, chip);
if (ret < 0) {