mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-28 16:56:26 +00:00
pwm: brcmstb: Make use of devm_pwmchip_alloc() function
This prepares the pwm-brcmstb 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/adf9cb04f5d84ae604e97d4dc0708ff3677d72d7.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
bf756bfd24
commit
f3d1efd083
@ -54,7 +54,6 @@
|
||||
struct brcmstb_pwm {
|
||||
void __iomem *base;
|
||||
struct clk *clk;
|
||||
struct pwm_chip chip;
|
||||
};
|
||||
|
||||
static inline u32 brcmstb_pwm_readl(struct brcmstb_pwm *p,
|
||||
@ -77,7 +76,7 @@ static inline void brcmstb_pwm_writel(struct brcmstb_pwm *p, u32 value,
|
||||
|
||||
static inline struct brcmstb_pwm *to_brcmstb_pwm(struct pwm_chip *chip)
|
||||
{
|
||||
return container_of(chip, struct brcmstb_pwm, chip);
|
||||
return pwmchip_get_drvdata(chip);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -230,12 +229,14 @@ MODULE_DEVICE_TABLE(of, brcmstb_pwm_of_match);
|
||||
|
||||
static int brcmstb_pwm_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct pwm_chip *chip;
|
||||
struct brcmstb_pwm *p;
|
||||
int ret;
|
||||
|
||||
p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
chip = devm_pwmchip_alloc(&pdev->dev, 2, sizeof(*p));
|
||||
if (IS_ERR(chip))
|
||||
return PTR_ERR(chip);
|
||||
p = to_brcmstb_pwm(chip);
|
||||
|
||||
p->clk = devm_clk_get_enabled(&pdev->dev, NULL);
|
||||
if (IS_ERR(p->clk))
|
||||
@ -244,15 +245,13 @@ static int brcmstb_pwm_probe(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, p);
|
||||
|
||||
p->chip.dev = &pdev->dev;
|
||||
p->chip.ops = &brcmstb_pwm_ops;
|
||||
p->chip.npwm = 2;
|
||||
chip->ops = &brcmstb_pwm_ops;
|
||||
|
||||
p->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(p->base))
|
||||
return PTR_ERR(p->base);
|
||||
|
||||
ret = devm_pwmchip_add(&pdev->dev, &p->chip);
|
||||
ret = devm_pwmchip_add(&pdev->dev, chip);
|
||||
if (ret)
|
||||
return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user