Commit 5d0237a7 authored by Uwe Kleine-König's avatar Uwe Kleine-König

pwm: jz4740: Make use of devm_pwmchip_alloc() function

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.
Acked-by: default avatarPaul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/14a081c097b4e7c7f346ca6557ece8d16ad5749d.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 4eeb3322
...@@ -25,14 +25,13 @@ struct soc_info { ...@@ -25,14 +25,13 @@ struct soc_info {
}; };
struct jz4740_pwm_chip { struct jz4740_pwm_chip {
struct pwm_chip chip;
struct regmap *map; struct regmap *map;
struct clk *clk[]; struct clk *clk[];
}; };
static inline struct jz4740_pwm_chip *to_jz4740(struct pwm_chip *chip) static inline struct jz4740_pwm_chip *to_jz4740(struct pwm_chip *chip)
{ {
return container_of(chip, struct jz4740_pwm_chip, chip); return pwmchip_get_drvdata(chip);
} }
static bool jz4740_pwm_can_use_chn(struct pwm_chip *chip, unsigned int channel) static bool jz4740_pwm_can_use_chn(struct pwm_chip *chip, unsigned int channel)
...@@ -224,6 +223,7 @@ static const struct pwm_ops jz4740_pwm_ops = { ...@@ -224,6 +223,7 @@ static const struct pwm_ops jz4740_pwm_ops = {
static int jz4740_pwm_probe(struct platform_device *pdev) static int jz4740_pwm_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct pwm_chip *chip;
struct jz4740_pwm_chip *jz; struct jz4740_pwm_chip *jz;
const struct soc_info *info; const struct soc_info *info;
...@@ -231,10 +231,10 @@ static int jz4740_pwm_probe(struct platform_device *pdev) ...@@ -231,10 +231,10 @@ static int jz4740_pwm_probe(struct platform_device *pdev)
if (!info) if (!info)
return -EINVAL; return -EINVAL;
jz = devm_kzalloc(dev, struct_size(jz, clk, info->num_pwms), chip = devm_pwmchip_alloc(dev, info->num_pwms, struct_size(jz, clk, info->num_pwms));
GFP_KERNEL); if (IS_ERR(chip))
if (!jz) return PTR_ERR(chip);
return -ENOMEM; jz = to_jz4740(chip);
jz->map = device_node_to_regmap(dev->parent->of_node); jz->map = device_node_to_regmap(dev->parent->of_node);
if (IS_ERR(jz->map)) { if (IS_ERR(jz->map)) {
...@@ -242,11 +242,9 @@ static int jz4740_pwm_probe(struct platform_device *pdev) ...@@ -242,11 +242,9 @@ static int jz4740_pwm_probe(struct platform_device *pdev)
return PTR_ERR(jz->map); return PTR_ERR(jz->map);
} }
jz->chip.dev = dev; chip->ops = &jz4740_pwm_ops;
jz->chip.ops = &jz4740_pwm_ops;
jz->chip.npwm = info->num_pwms;
return devm_pwmchip_add(dev, &jz->chip); return devm_pwmchip_add(dev, chip);
} }
static const struct soc_info jz4740_soc_info = { static const struct soc_info jz4740_soc_info = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment