Skip to content

Commit df08fff

Browse files
ukleinekUwe Kleine-König
authored andcommitted
pwm: pxa: Improve using dev_err_probe()
Add a message to the error path of devm_clk_get() and simplify the error path of devm_pwmchip_add() while improving the error message en passant. Signed-off-by: Uwe Kleine-König <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 2b62c89 commit df08fff

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

drivers/pwm/pwm-pxa.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,24 @@ static int pwm_probe(struct platform_device *pdev)
160160
const struct platform_device_id *id = platform_get_device_id(pdev);
161161
struct pwm_chip *chip;
162162
struct pxa_pwm_chip *pc;
163+
struct device *dev = &pdev->dev;
163164
int ret = 0;
164165

165166
if (IS_ENABLED(CONFIG_OF) && id == NULL)
166-
id = of_device_get_match_data(&pdev->dev);
167+
id = of_device_get_match_data(dev);
167168

168169
if (id == NULL)
169170
return -EINVAL;
170171

171-
chip = devm_pwmchip_alloc(&pdev->dev,
172-
(id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1,
172+
chip = devm_pwmchip_alloc(dev, (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1,
173173
sizeof(*pc));
174174
if (IS_ERR(chip))
175175
return PTR_ERR(chip);
176176
pc = to_pxa_pwm_chip(chip);
177177

178-
pc->clk = devm_clk_get(&pdev->dev, NULL);
178+
pc->clk = devm_clk_get(dev, NULL);
179179
if (IS_ERR(pc->clk))
180-
return PTR_ERR(pc->clk);
180+
return dev_err_probe(dev, PTR_ERR(pc->clk), "Failed to get clock\n");
181181

182182
chip->ops = &pxa_pwm_ops;
183183

@@ -188,11 +188,9 @@ static int pwm_probe(struct platform_device *pdev)
188188
if (IS_ERR(pc->mmio_base))
189189
return PTR_ERR(pc->mmio_base);
190190

191-
ret = devm_pwmchip_add(&pdev->dev, chip);
192-
if (ret < 0) {
193-
dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
194-
return ret;
195-
}
191+
ret = devm_pwmchip_add(dev, chip);
192+
if (ret < 0)
193+
return dev_err_probe(dev, ret, "pwmchip_add() failed\n");
196194

197195
return 0;
198196
}

0 commit comments

Comments
 (0)