mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-29 09:13:38 +00:00
pwm: clps711x: Make use of devm_pwmchip_alloc() function
This prepares the pwm-clps711x 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/334e633bb8e4c26dc59883b068466387769b65f9.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
8e87e3dcb2
commit
5412170f10
@ -12,7 +12,6 @@
|
||||
#include <linux/pwm.h>
|
||||
|
||||
struct clps711x_chip {
|
||||
struct pwm_chip chip;
|
||||
void __iomem *pmpcon;
|
||||
struct clk *clk;
|
||||
spinlock_t lock;
|
||||
@ -20,7 +19,7 @@ struct clps711x_chip {
|
||||
|
||||
static inline struct clps711x_chip *to_clps711x_chip(struct pwm_chip *chip)
|
||||
{
|
||||
return container_of(chip, struct clps711x_chip, chip);
|
||||
return pwmchip_get_drvdata(chip);
|
||||
}
|
||||
|
||||
static int clps711x_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||
@ -76,11 +75,13 @@ static const struct pwm_ops clps711x_pwm_ops = {
|
||||
|
||||
static int clps711x_pwm_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct pwm_chip *chip;
|
||||
struct clps711x_chip *priv;
|
||||
|
||||
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
chip = devm_pwmchip_alloc(&pdev->dev, 2, sizeof(*priv));
|
||||
if (IS_ERR(chip))
|
||||
return PTR_ERR(chip);
|
||||
priv = to_clps711x_chip(chip);
|
||||
|
||||
priv->pmpcon = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(priv->pmpcon))
|
||||
@ -90,13 +91,11 @@ static int clps711x_pwm_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(priv->clk))
|
||||
return PTR_ERR(priv->clk);
|
||||
|
||||
priv->chip.ops = &clps711x_pwm_ops;
|
||||
priv->chip.dev = &pdev->dev;
|
||||
priv->chip.npwm = 2;
|
||||
chip->ops = &clps711x_pwm_ops;
|
||||
|
||||
spin_lock_init(&priv->lock);
|
||||
|
||||
return devm_pwmchip_add(&pdev->dev, &priv->chip);
|
||||
return devm_pwmchip_add(&pdev->dev, chip);
|
||||
}
|
||||
|
||||
static const struct of_device_id __maybe_unused clps711x_pwm_dt_ids[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user