mirror of
https://github.com/torvalds/linux.git
synced 2024-11-12 23:23:03 +00:00
pwm: berlin: Make use of devm_pwmchip_alloc() function
This prepares the pwm-berlin 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/52866502c96a80d1c30be003dc1f5a89a4d230cc.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
5874eaf869
commit
bf756bfd24
@ -49,7 +49,6 @@ struct berlin_pwm_channel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct berlin_pwm_chip {
|
struct berlin_pwm_chip {
|
||||||
struct pwm_chip chip;
|
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
struct berlin_pwm_channel channel[BERLIN_PWM_NUMPWMS];
|
struct berlin_pwm_channel channel[BERLIN_PWM_NUMPWMS];
|
||||||
@ -57,7 +56,7 @@ struct berlin_pwm_chip {
|
|||||||
|
|
||||||
static inline struct berlin_pwm_chip *to_berlin_pwm_chip(struct pwm_chip *chip)
|
static inline struct berlin_pwm_chip *to_berlin_pwm_chip(struct pwm_chip *chip)
|
||||||
{
|
{
|
||||||
return container_of(chip, struct berlin_pwm_chip, chip);
|
return pwmchip_get_drvdata(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 berlin_pwm_readl(struct berlin_pwm_chip *bpc,
|
static inline u32 berlin_pwm_readl(struct berlin_pwm_chip *bpc,
|
||||||
@ -202,9 +201,10 @@ static int berlin_pwm_probe(struct platform_device *pdev)
|
|||||||
struct berlin_pwm_chip *bpc;
|
struct berlin_pwm_chip *bpc;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
bpc = devm_kzalloc(&pdev->dev, sizeof(*bpc), GFP_KERNEL);
|
chip = devm_pwmchip_alloc(&pdev->dev, BERLIN_PWM_NUMPWMS, sizeof(*bpc));
|
||||||
if (!bpc)
|
if (IS_ERR(chip))
|
||||||
return -ENOMEM;
|
return PTR_ERR(chip);
|
||||||
|
bpc = to_berlin_pwm_chip(chip);
|
||||||
|
|
||||||
bpc->base = devm_platform_ioremap_resource(pdev, 0);
|
bpc->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
if (IS_ERR(bpc->base))
|
if (IS_ERR(bpc->base))
|
||||||
@ -214,10 +214,7 @@ static int berlin_pwm_probe(struct platform_device *pdev)
|
|||||||
if (IS_ERR(bpc->clk))
|
if (IS_ERR(bpc->clk))
|
||||||
return PTR_ERR(bpc->clk);
|
return PTR_ERR(bpc->clk);
|
||||||
|
|
||||||
chip = &bpc->chip;
|
|
||||||
chip->dev = &pdev->dev;
|
|
||||||
chip->ops = &berlin_pwm_ops;
|
chip->ops = &berlin_pwm_ops;
|
||||||
chip->npwm = BERLIN_PWM_NUMPWMS;
|
|
||||||
|
|
||||||
ret = devm_pwmchip_add(&pdev->dev, chip);
|
ret = devm_pwmchip_add(&pdev->dev, chip);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user