Skip to content

Commit 4caa211

Browse files
author
Uwe Kleine-König
committed
pwm: xilinx: Prepare removing pwm_chip from driver data
This prepares the driver for further changes that will drop struct pwm_chip chip from struct xilinx_pwm_device. Use the pwm_chip as driver data instead of the xilinx_pwm_device to get access to the pwm_chip in xilinx_pwm_remove() without using xilinx_pwm->chip. Link: https://lore.kernel.org/r/738b9929c1d13bde64050f8bbc4ce8d85f58cc7a.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent ae8635e commit 4caa211

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

drivers/pwm/pwm-xilinx.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
214214
struct device *dev = &pdev->dev;
215215
struct device_node *np = dev->of_node;
216216
struct xilinx_timer_priv *priv;
217+
struct pwm_chip *chip;
217218
struct xilinx_pwm_device *xilinx_pwm;
218219
u32 pwm_cells, one_timer, width;
219220
void __iomem *regs;
@@ -228,8 +229,9 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
228229
xilinx_pwm = devm_kzalloc(dev, sizeof(*xilinx_pwm), GFP_KERNEL);
229230
if (!xilinx_pwm)
230231
return -ENOMEM;
231-
platform_set_drvdata(pdev, xilinx_pwm);
232232
priv = &xilinx_pwm->priv;
233+
chip = &xilinx_pwm->chip;
234+
platform_set_drvdata(pdev, chip);
233235

234236
regs = devm_platform_ioremap_resource(pdev, 0);
235237
if (IS_ERR(regs))
@@ -278,10 +280,10 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
278280
return dev_err_probe(dev, ret, "Clock enable failed\n");
279281
clk_rate_exclusive_get(priv->clk);
280282

281-
xilinx_pwm->chip.dev = dev;
282-
xilinx_pwm->chip.ops = &xilinx_pwm_ops;
283-
xilinx_pwm->chip.npwm = 1;
284-
ret = pwmchip_add(&xilinx_pwm->chip);
283+
chip->dev = dev;
284+
chip->ops = &xilinx_pwm_ops;
285+
chip->npwm = 1;
286+
ret = pwmchip_add(chip);
285287
if (ret) {
286288
clk_rate_exclusive_put(priv->clk);
287289
clk_disable_unprepare(priv->clk);
@@ -293,11 +295,12 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
293295

294296
static void xilinx_pwm_remove(struct platform_device *pdev)
295297
{
296-
struct xilinx_pwm_device *xilinx_pwm = platform_get_drvdata(pdev);
298+
struct pwm_chip *chip = platform_get_drvdata(pdev);
299+
struct xilinx_timer_priv *priv = xilinx_pwm_chip_to_priv(chip);
297300

298-
pwmchip_remove(&xilinx_pwm->chip);
299-
clk_rate_exclusive_put(xilinx_pwm->priv.clk);
300-
clk_disable_unprepare(xilinx_pwm->priv.clk);
301+
pwmchip_remove(chip);
302+
clk_rate_exclusive_put(priv->clk);
303+
clk_disable_unprepare(priv->clk);
301304
}
302305

303306
static const struct of_device_id xilinx_pwm_of_match[] = {

0 commit comments

Comments
 (0)