mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-22 16:06:04 -05:00
pwm: ntxec: Make use of devm_pwmchip_alloc() function
This prepares the pwm-ntxec 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/c0c9d6cb3a6662268e660f4f6c89b32268ecf019.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
2ae7039fa7
commit
8c01031abe
1 changed files with 5 additions and 9 deletions
|
@ -25,12 +25,11 @@
|
||||||
|
|
||||||
struct ntxec_pwm {
|
struct ntxec_pwm {
|
||||||
struct ntxec *ec;
|
struct ntxec *ec;
|
||||||
struct pwm_chip chip;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct ntxec_pwm *ntxec_pwm_from_chip(struct pwm_chip *chip)
|
static struct ntxec_pwm *ntxec_pwm_from_chip(struct pwm_chip *chip)
|
||||||
{
|
{
|
||||||
return container_of(chip, struct ntxec_pwm, chip);
|
return pwmchip_get_drvdata(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NTXEC_REG_AUTO_OFF_HI 0xa1
|
#define NTXEC_REG_AUTO_OFF_HI 0xa1
|
||||||
|
@ -141,16 +140,13 @@ static int ntxec_pwm_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
|
device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
|
||||||
|
|
||||||
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 = ntxec_pwm_from_chip(chip);
|
||||||
|
|
||||||
priv->ec = ec;
|
priv->ec = ec;
|
||||||
|
|
||||||
chip = &priv->chip;
|
|
||||||
chip->dev = &pdev->dev;
|
|
||||||
chip->ops = &ntxec_pwm_ops;
|
chip->ops = &ntxec_pwm_ops;
|
||||||
chip->npwm = 1;
|
|
||||||
|
|
||||||
return devm_pwmchip_add(&pdev->dev, chip);
|
return devm_pwmchip_add(&pdev->dev, chip);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue