Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20250313072855.3360076-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>

authored by

Uwe Kleine-König and committed by
Uwe Kleine-König
df08fff8 2b62c894

+8 -10
+8 -10
drivers/pwm/pwm-pxa.c
··· 160 160 const struct platform_device_id *id = platform_get_device_id(pdev); 161 161 struct pwm_chip *chip; 162 162 struct pxa_pwm_chip *pc; 163 + struct device *dev = &pdev->dev; 163 164 int ret = 0; 164 165 165 166 if (IS_ENABLED(CONFIG_OF) && id == NULL) 166 - id = of_device_get_match_data(&pdev->dev); 167 + id = of_device_get_match_data(dev); 167 168 168 169 if (id == NULL) 169 170 return -EINVAL; 170 171 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, 173 173 sizeof(*pc)); 174 174 if (IS_ERR(chip)) 175 175 return PTR_ERR(chip); 176 176 pc = to_pxa_pwm_chip(chip); 177 177 178 - pc->clk = devm_clk_get(&pdev->dev, NULL); 178 + pc->clk = devm_clk_get(dev, NULL); 179 179 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"); 181 181 182 182 chip->ops = &pxa_pwm_ops; 183 183 ··· 188 188 if (IS_ERR(pc->mmio_base)) 189 189 return PTR_ERR(pc->mmio_base); 190 190 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"); 196 194 197 195 return 0; 198 196 }