mirror of https://github.com/torvalds/linux.git
pwm: sl28cpld: Make use of devm_pwmchip_alloc() function
This prepares the pwm-sl28cpld 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. Reviewed-by: Michael Walle <mwalle@kernel.org> Link: https://lore.kernel.org/r/ee687086f7fc78264fac723f65ddc96cb7518c03.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This commit is contained in:
parent
554d9acae4
commit
57014f0726
|
|
@ -81,14 +81,13 @@
|
||||||
regmap_write((priv)->regmap, (priv)->offset + (reg), (val))
|
regmap_write((priv)->regmap, (priv)->offset + (reg), (val))
|
||||||
|
|
||||||
struct sl28cpld_pwm {
|
struct sl28cpld_pwm {
|
||||||
struct pwm_chip chip;
|
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
u32 offset;
|
u32 offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct sl28cpld_pwm *sl28cpld_pwm_from_chip(struct pwm_chip *chip)
|
static inline struct sl28cpld_pwm *sl28cpld_pwm_from_chip(struct pwm_chip *chip)
|
||||||
{
|
{
|
||||||
return container_of(chip, struct sl28cpld_pwm, chip);
|
return pwmchip_get_drvdata(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sl28cpld_pwm_get_state(struct pwm_chip *chip,
|
static int sl28cpld_pwm_get_state(struct pwm_chip *chip,
|
||||||
|
|
@ -213,9 +212,10 @@ static int sl28cpld_pwm_probe(struct platform_device *pdev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
|
chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*priv));
|
||||||
if (!priv)
|
if (IS_ERR(chip))
|
||||||
return -ENOMEM;
|
return PTR_ERR(chip);
|
||||||
|
priv = sl28cpld_pwm_from_chip(chip);
|
||||||
|
|
||||||
priv->regmap = dev_get_regmap(pdev->dev.parent, NULL);
|
priv->regmap = dev_get_regmap(pdev->dev.parent, NULL);
|
||||||
if (!priv->regmap) {
|
if (!priv->regmap) {
|
||||||
|
|
@ -231,10 +231,7 @@ static int sl28cpld_pwm_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the pwm_chip structure */
|
/* Initialize the pwm_chip structure */
|
||||||
chip = &priv->chip;
|
|
||||||
chip->dev = &pdev->dev;
|
|
||||||
chip->ops = &sl28cpld_pwm_ops;
|
chip->ops = &sl28cpld_pwm_ops;
|
||||||
chip->npwm = 1;
|
|
||||||
|
|
||||||
ret = devm_pwmchip_add(&pdev->dev, chip);
|
ret = devm_pwmchip_add(&pdev->dev, chip);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue