Commit 1647e506 authored by Uwe Kleine-König's avatar Uwe Kleine-König

pwm: dwc: Make use of devm_pwmchip_alloc() function

This prepares the pwm-dwc 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_dwc_pwm() helper macro to a static inline to get
some type safety.

Link: https://lore.kernel.org/r/64e64a9a8644600d51b234ad9bcae951b5748998.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent aaa3cc29
......@@ -164,15 +164,13 @@ struct pwm_chip *dwc_pwm_alloc(struct device *dev)
struct pwm_chip *chip;
struct dwc_pwm *dwc;
dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL);
if (!dwc)
return ERR_PTR(-ENOMEM);
chip = &dwc->chip;
chip = devm_pwmchip_alloc(dev, DWC_TIMERS_TOTAL, sizeof(*dwc));
if (IS_ERR(chip))
return chip;
dwc = to_dwc_pwm(chip);
dwc->clk_ns = 10;
chip->dev = dev;
chip->ops = &dwc_pwm_ops;
chip->npwm = DWC_TIMERS_TOTAL;
dev_set_drvdata(dev, chip);
return chip;
......
......@@ -40,12 +40,15 @@ struct dwc_pwm_ctx {
};
struct dwc_pwm {
struct pwm_chip chip;
void __iomem *base;
unsigned int clk_ns;
struct dwc_pwm_ctx ctx[DWC_TIMERS_TOTAL];
};
#define to_dwc_pwm(p) (container_of((p), struct dwc_pwm, chip))
static inline struct dwc_pwm *to_dwc_pwm(struct pwm_chip *chip)
{
return pwmchip_get_drvdata(chip);
}
static inline u32 dwc_pwm_readl(struct dwc_pwm *dwc, u32 offset)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment