Commit 2528428e authored by Uwe Kleine-König's avatar Uwe Kleine-König

pwm: rockchip: Make use of devm_pwmchip_alloc() function

This prepares the pwm-rockchip 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/61a3f48710e3e795beb2e496c8c673bbc0f6c932.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 77e94c37
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#define PWM_LP_DISABLE (0 << 8) #define PWM_LP_DISABLE (0 << 8)
struct rockchip_pwm_chip { struct rockchip_pwm_chip {
struct pwm_chip chip;
struct clk *clk; struct clk *clk;
struct clk *pclk; struct clk *pclk;
const struct rockchip_pwm_data *data; const struct rockchip_pwm_data *data;
...@@ -54,7 +53,7 @@ struct rockchip_pwm_data { ...@@ -54,7 +53,7 @@ struct rockchip_pwm_data {
static inline struct rockchip_pwm_chip *to_rockchip_pwm_chip(struct pwm_chip *chip) static inline struct rockchip_pwm_chip *to_rockchip_pwm_chip(struct pwm_chip *chip)
{ {
return container_of(chip, struct rockchip_pwm_chip, chip); return pwmchip_get_drvdata(chip);
} }
static int rockchip_pwm_get_state(struct pwm_chip *chip, static int rockchip_pwm_get_state(struct pwm_chip *chip,
...@@ -302,10 +301,10 @@ static int rockchip_pwm_probe(struct platform_device *pdev) ...@@ -302,10 +301,10 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
bool enabled; bool enabled;
int ret, count; int ret, count;
pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*pc));
if (!pc) if (IS_ERR(chip))
return -ENOMEM; return PTR_ERR(chip);
chip = &pc->chip; pc = to_rockchip_pwm_chip(chip);
pc->base = devm_platform_ioremap_resource(pdev, 0); pc->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(pc->base)) if (IS_ERR(pc->base))
...@@ -342,9 +341,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev) ...@@ -342,9 +341,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, chip); platform_set_drvdata(pdev, chip);
pc->data = device_get_match_data(&pdev->dev); pc->data = device_get_match_data(&pdev->dev);
chip->dev = &pdev->dev;
chip->ops = &rockchip_pwm_ops; chip->ops = &rockchip_pwm_ops;
chip->npwm = 1;
enable_conf = pc->data->enable_conf; enable_conf = pc->data->enable_conf;
ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl); ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl);
......
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