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 <u.kleine-koenig@pengutronix.de>
This commit is contained in:
parent
68e34b3e66
commit
ae8635e99c
1 changed files with 8 additions and 8 deletions
|
@ -45,12 +45,14 @@
|
||||||
#define STATUS_ALL_UPDATE 0x0F
|
#define STATUS_ALL_UPDATE 0x0F
|
||||||
|
|
||||||
struct vt8500_chip {
|
struct vt8500_chip {
|
||||||
struct pwm_chip chip;
|
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define to_vt8500_chip(chip) container_of(chip, struct vt8500_chip, chip)
|
static inline struct vt8500_chip *to_vt8500_chip(struct pwm_chip *chip)
|
||||||
|
{
|
||||||
|
return pwmchip_get_drvdata(chip);
|
||||||
|
}
|
||||||
|
|
||||||
#define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
|
#define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
|
||||||
static inline void vt8500_pwm_busy_wait(struct pwm_chip *chip, int nr, u8 bitmask)
|
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)
|
||||||
if (!np)
|
if (!np)
|
||||||
return dev_err_probe(&pdev->dev, -EINVAL, "invalid devicetree node\n");
|
return dev_err_probe(&pdev->dev, -EINVAL, "invalid devicetree node\n");
|
||||||
|
|
||||||
vt8500 = devm_kzalloc(&pdev->dev, sizeof(*vt8500), GFP_KERNEL);
|
chip = devm_pwmchip_alloc(&pdev->dev, VT8500_NR_PWMS, sizeof(*vt8500));
|
||||||
if (vt8500 == NULL)
|
if (IS_ERR(chip))
|
||||||
return -ENOMEM;
|
return PTR_ERR(chip);
|
||||||
|
vt8500 = to_vt8500_chip(chip);
|
||||||
|
|
||||||
chip = &vt8500->chip;
|
|
||||||
chip->dev = &pdev->dev;
|
|
||||||
chip->ops = &vt8500_pwm_ops;
|
chip->ops = &vt8500_pwm_ops;
|
||||||
chip->npwm = VT8500_NR_PWMS;
|
|
||||||
|
|
||||||
vt8500->clk = devm_clk_get_prepared(&pdev->dev, NULL);
|
vt8500->clk = devm_clk_get_prepared(&pdev->dev, NULL);
|
||||||
if (IS_ERR(vt8500->clk))
|
if (IS_ERR(vt8500->clk))
|
||||||
|
|
Loading…
Add table
Reference in a new issue