Skip to content

Commit dda59d2

Browse files
author
Uwe Kleine-König
committed
pwm: xilinx: Make use of devm_pwmchip_alloc() function
This prepares the pwm-xilinx 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/7cbc32771e94103b8c1c817cfdd613d7a2fc01b9.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 4caa211 commit dda59d2

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

drivers/pwm/pwm-xilinx.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,10 @@ unsigned int xilinx_timer_get_period(struct xilinx_timer_priv *priv,
8080
#define TCSR_PWM_CLEAR (TCSR_MDT | TCSR_LOAD)
8181
#define TCSR_PWM_MASK (TCSR_PWM_SET | TCSR_PWM_CLEAR)
8282

83-
struct xilinx_pwm_device {
84-
struct pwm_chip chip;
85-
struct xilinx_timer_priv priv;
86-
};
87-
8883
static inline struct xilinx_timer_priv
8984
*xilinx_pwm_chip_to_priv(struct pwm_chip *chip)
9085
{
91-
return &container_of(chip, struct xilinx_pwm_device, chip)->priv;
86+
return pwmchip_get_drvdata(chip);
9287
}
9388

9489
static bool xilinx_timer_pwm_enabled(u32 tcsr0, u32 tcsr1)
@@ -215,7 +210,6 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
215210
struct device_node *np = dev->of_node;
216211
struct xilinx_timer_priv *priv;
217212
struct pwm_chip *chip;
218-
struct xilinx_pwm_device *xilinx_pwm;
219213
u32 pwm_cells, one_timer, width;
220214
void __iomem *regs;
221215

@@ -226,11 +220,10 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
226220
if (ret)
227221
return dev_err_probe(dev, ret, "could not read #pwm-cells\n");
228222

229-
xilinx_pwm = devm_kzalloc(dev, sizeof(*xilinx_pwm), GFP_KERNEL);
230-
if (!xilinx_pwm)
231-
return -ENOMEM;
232-
priv = &xilinx_pwm->priv;
233-
chip = &xilinx_pwm->chip;
223+
chip = devm_pwmchip_alloc(dev, 1, sizeof(*priv));
224+
if (IS_ERR(chip))
225+
return PTR_ERR(chip);
226+
priv = xilinx_pwm_chip_to_priv(chip);
234227
platform_set_drvdata(pdev, chip);
235228

236229
regs = devm_platform_ioremap_resource(pdev, 0);
@@ -280,9 +273,7 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
280273
return dev_err_probe(dev, ret, "Clock enable failed\n");
281274
clk_rate_exclusive_get(priv->clk);
282275

283-
chip->dev = dev;
284276
chip->ops = &xilinx_pwm_ops;
285-
chip->npwm = 1;
286277
ret = pwmchip_add(chip);
287278
if (ret) {
288279
clk_rate_exclusive_put(priv->clk);

0 commit comments

Comments
 (0)