Commit 4caa2115 authored by Uwe Kleine-König's avatar Uwe Kleine-König

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.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent ae8635e9
...@@ -214,6 +214,7 @@ static int xilinx_pwm_probe(struct platform_device *pdev) ...@@ -214,6 +214,7 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct xilinx_timer_priv *priv; struct xilinx_timer_priv *priv;
struct pwm_chip *chip;
struct xilinx_pwm_device *xilinx_pwm; struct xilinx_pwm_device *xilinx_pwm;
u32 pwm_cells, one_timer, width; u32 pwm_cells, one_timer, width;
void __iomem *regs; void __iomem *regs;
...@@ -228,8 +229,9 @@ static int xilinx_pwm_probe(struct platform_device *pdev) ...@@ -228,8 +229,9 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
xilinx_pwm = devm_kzalloc(dev, sizeof(*xilinx_pwm), GFP_KERNEL); xilinx_pwm = devm_kzalloc(dev, sizeof(*xilinx_pwm), GFP_KERNEL);
if (!xilinx_pwm) if (!xilinx_pwm)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, xilinx_pwm);
priv = &xilinx_pwm->priv; priv = &xilinx_pwm->priv;
chip = &xilinx_pwm->chip;
platform_set_drvdata(pdev, chip);
regs = devm_platform_ioremap_resource(pdev, 0); regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(regs)) if (IS_ERR(regs))
...@@ -278,10 +280,10 @@ static int xilinx_pwm_probe(struct platform_device *pdev) ...@@ -278,10 +280,10 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
return dev_err_probe(dev, ret, "Clock enable failed\n"); return dev_err_probe(dev, ret, "Clock enable failed\n");
clk_rate_exclusive_get(priv->clk); clk_rate_exclusive_get(priv->clk);
xilinx_pwm->chip.dev = dev; chip->dev = dev;
xilinx_pwm->chip.ops = &xilinx_pwm_ops; chip->ops = &xilinx_pwm_ops;
xilinx_pwm->chip.npwm = 1; chip->npwm = 1;
ret = pwmchip_add(&xilinx_pwm->chip); ret = pwmchip_add(chip);
if (ret) { if (ret) {
clk_rate_exclusive_put(priv->clk); clk_rate_exclusive_put(priv->clk);
clk_disable_unprepare(priv->clk); clk_disable_unprepare(priv->clk);
...@@ -293,11 +295,12 @@ static int xilinx_pwm_probe(struct platform_device *pdev) ...@@ -293,11 +295,12 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
static void xilinx_pwm_remove(struct platform_device *pdev) static void xilinx_pwm_remove(struct platform_device *pdev)
{ {
struct xilinx_pwm_device *xilinx_pwm = platform_get_drvdata(pdev); struct pwm_chip *chip = platform_get_drvdata(pdev);
struct xilinx_timer_priv *priv = xilinx_pwm_chip_to_priv(chip);
pwmchip_remove(&xilinx_pwm->chip); pwmchip_remove(chip);
clk_rate_exclusive_put(xilinx_pwm->priv.clk); clk_rate_exclusive_put(priv->clk);
clk_disable_unprepare(xilinx_pwm->priv.clk); clk_disable_unprepare(priv->clk);
} }
static const struct of_device_id xilinx_pwm_of_match[] = { static const struct of_device_id xilinx_pwm_of_match[] = {
......
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