Skip to content

Commit ae8635e

Browse files
author
Uwe Kleine-König
committed
pwm: vt8500: Make use of devm_pwmchip_alloc() function
This prepares the pwm-vt8500 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. Also convert the to_vt8500_chip() helper macro to a static inline to get some type safety. Link: https://lore.kernel.org/r/b203c4448db23ebad1165b7bce43ac41468c4e89.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 68e34b3 commit ae8635e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/pwm/pwm-vt8500.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@
4545
#define STATUS_ALL_UPDATE 0x0F
4646

4747
struct vt8500_chip {
48-
struct pwm_chip chip;
4948
void __iomem *base;
5049
struct clk *clk;
5150
};
5251

53-
#define to_vt8500_chip(chip) container_of(chip, struct vt8500_chip, chip)
52+
static inline struct vt8500_chip *to_vt8500_chip(struct pwm_chip *chip)
53+
{
54+
return pwmchip_get_drvdata(chip);
55+
}
5456

5557
#define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
5658
static inline void vt8500_pwm_busy_wait(struct pwm_chip *chip, int nr, u8 bitmask)
@@ -240,14 +242,12 @@ static int vt8500_pwm_probe(struct platform_device *pdev)
240242
if (!np)
241243
return dev_err_probe(&pdev->dev, -EINVAL, "invalid devicetree node\n");
242244

243-
vt8500 = devm_kzalloc(&pdev->dev, sizeof(*vt8500), GFP_KERNEL);
244-
if (vt8500 == NULL)
245-
return -ENOMEM;
245+
chip = devm_pwmchip_alloc(&pdev->dev, VT8500_NR_PWMS, sizeof(*vt8500));
246+
if (IS_ERR(chip))
247+
return PTR_ERR(chip);
248+
vt8500 = to_vt8500_chip(chip);
246249

247-
chip = &vt8500->chip;
248-
chip->dev = &pdev->dev;
249250
chip->ops = &vt8500_pwm_ops;
250-
chip->npwm = VT8500_NR_PWMS;
251251

252252
vt8500->clk = devm_clk_get_prepared(&pdev->dev, NULL);
253253
if (IS_ERR(vt8500->clk))

0 commit comments

Comments
 (0)