Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+8 -9
+8 -9
drivers/pwm/pwm-brcmstb.c
··· 54 54 struct brcmstb_pwm { 55 55 void __iomem *base; 56 56 struct clk *clk; 57 - struct pwm_chip chip; 58 57 }; 59 58 60 59 static inline u32 brcmstb_pwm_readl(struct brcmstb_pwm *p, ··· 76 77 77 78 static inline struct brcmstb_pwm *to_brcmstb_pwm(struct pwm_chip *chip) 78 79 { 79 - return container_of(chip, struct brcmstb_pwm, chip); 80 + return pwmchip_get_drvdata(chip); 80 81 } 81 82 82 83 /* ··· 229 230 230 231 static int brcmstb_pwm_probe(struct platform_device *pdev) 231 232 { 233 + struct pwm_chip *chip; 232 234 struct brcmstb_pwm *p; 233 235 int ret; 234 236 235 - p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); 236 - if (!p) 237 - return -ENOMEM; 237 + chip = devm_pwmchip_alloc(&pdev->dev, 2, sizeof(*p)); 238 + if (IS_ERR(chip)) 239 + return PTR_ERR(chip); 240 + p = to_brcmstb_pwm(chip); 238 241 239 242 p->clk = devm_clk_get_enabled(&pdev->dev, NULL); 240 243 if (IS_ERR(p->clk)) ··· 245 244 246 245 platform_set_drvdata(pdev, p); 247 246 248 - p->chip.dev = &pdev->dev; 249 - p->chip.ops = &brcmstb_pwm_ops; 250 - p->chip.npwm = 2; 247 + chip->ops = &brcmstb_pwm_ops; 251 248 252 249 p->base = devm_platform_ioremap_resource(pdev, 0); 253 250 if (IS_ERR(p->base)) 254 251 return PTR_ERR(p->base); 255 252 256 - ret = devm_pwmchip_add(&pdev->dev, &p->chip); 253 + ret = devm_pwmchip_add(&pdev->dev, chip); 257 254 if (ret) 258 255 return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); 259 256