Message ID | 20231121134901.208535-63-u.kleine-koenig@pengutronix.de (mailing list archive) |
---|---|
State | Handled Elsewhere |
Headers | show |
Series | pwm: Fix lifetime issues for pwm_chips | expand |
Hi Uwe, Le mardi 21 novembre 2023 à 14:50 +0100, Uwe Kleine-König a écrit : > This prepares the pwm-jz4740 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. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- > drivers/pwm/pwm-jz4740.c | 18 ++++++++---------- > 1 file changed, 8 insertions(+), 10 deletions(-) > > diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c > index 555c2db3968d..84ad5c3eb599 100644 > --- a/drivers/pwm/pwm-jz4740.c > +++ b/drivers/pwm/pwm-jz4740.c > @@ -25,14 +25,13 @@ struct soc_info { > }; > > struct jz4740_pwm_chip { > - struct pwm_chip chip; Ah, nevermind my previous comment on patch [014/108] then. Acked-by: Paul Cercueil <paul@crapouillou.net> Cheers, -Paul > struct regmap *map; > struct clk *clk[]; > }; > > static inline struct jz4740_pwm_chip *to_jz4740(struct pwm_chip > *chip) > { > - return container_of(chip, struct jz4740_pwm_chip, chip); > + return pwmchip_priv(chip); > } > > static bool jz4740_pwm_can_use_chn(struct pwm_chip *chip, unsigned > int channel) > @@ -222,6 +221,7 @@ static const struct pwm_ops jz4740_pwm_ops = { > static int jz4740_pwm_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > + struct pwm_chip *chip; > struct jz4740_pwm_chip *jz; > const struct soc_info *info; > > @@ -229,10 +229,10 @@ static int jz4740_pwm_probe(struct > platform_device *pdev) > if (!info) > return -EINVAL; > > - jz = devm_kzalloc(dev, struct_size(jz, clk, info->num_pwms), > - GFP_KERNEL); > - if (!jz) > - return -ENOMEM; > + chip = devm_pwmchip_alloc(dev, info->num_pwms, > struct_size(jz, clk, info->num_pwms)); > + if (IS_ERR(chip)) > + return PTR_ERR(chip); > + jz = to_jz4740(chip); > > jz->map = device_node_to_regmap(dev->parent->of_node); > if (IS_ERR(jz->map)) { > @@ -240,11 +240,9 @@ static int jz4740_pwm_probe(struct > platform_device *pdev) > return PTR_ERR(jz->map); > } > > - jz->chip.dev = dev; > - jz->chip.ops = &jz4740_pwm_ops; > - jz->chip.npwm = info->num_pwms; > + chip->ops = &jz4740_pwm_ops; > > - return devm_pwmchip_add(dev, &jz->chip); > + return devm_pwmchip_add(dev, chip); > } > > static const struct soc_info jz4740_soc_info = {
diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c index 555c2db3968d..84ad5c3eb599 100644 --- a/drivers/pwm/pwm-jz4740.c +++ b/drivers/pwm/pwm-jz4740.c @@ -25,14 +25,13 @@ struct soc_info { }; struct jz4740_pwm_chip { - struct pwm_chip chip; struct regmap *map; struct clk *clk[]; }; static inline struct jz4740_pwm_chip *to_jz4740(struct pwm_chip *chip) { - return container_of(chip, struct jz4740_pwm_chip, chip); + return pwmchip_priv(chip); } static bool jz4740_pwm_can_use_chn(struct pwm_chip *chip, unsigned int channel) @@ -222,6 +221,7 @@ static const struct pwm_ops jz4740_pwm_ops = { static int jz4740_pwm_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct pwm_chip *chip; struct jz4740_pwm_chip *jz; const struct soc_info *info; @@ -229,10 +229,10 @@ static int jz4740_pwm_probe(struct platform_device *pdev) if (!info) return -EINVAL; - jz = devm_kzalloc(dev, struct_size(jz, clk, info->num_pwms), - GFP_KERNEL); - if (!jz) - return -ENOMEM; + chip = devm_pwmchip_alloc(dev, info->num_pwms, struct_size(jz, clk, info->num_pwms)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + jz = to_jz4740(chip); jz->map = device_node_to_regmap(dev->parent->of_node); if (IS_ERR(jz->map)) { @@ -240,11 +240,9 @@ static int jz4740_pwm_probe(struct platform_device *pdev) return PTR_ERR(jz->map); } - jz->chip.dev = dev; - jz->chip.ops = &jz4740_pwm_ops; - jz->chip.npwm = info->num_pwms; + chip->ops = &jz4740_pwm_ops; - return devm_pwmchip_add(dev, &jz->chip); + return devm_pwmchip_add(dev, chip); } static const struct soc_info jz4740_soc_info = {
This prepares the pwm-jz4740 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. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/pwm-jz4740.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)