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.

regulator: pwm-regulator: Use dev_err_probe() for error paths in .probe()

One error path already used the dev_err_probe() helper. Make use of it
in the other error paths, too, for consistent output. This results in a
more compact source code and symbolic output of the error code.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://msgid.link/r/20240216071829.1513748-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Uwe Kleine-König and committed by
Mark Brown
09235bf3 d68ce3aa

+17 -23
+17 -23
drivers/regulator/pwm-regulator.c
··· 271 271 of_find_property(np, "voltage-table", &length); 272 272 273 273 if ((length < sizeof(*duty_cycle_table)) || 274 - (length % sizeof(*duty_cycle_table))) { 275 - dev_err(&pdev->dev, "voltage-table length(%d) is invalid\n", 276 - length); 277 - return -EINVAL; 278 - } 274 + (length % sizeof(*duty_cycle_table))) 275 + return dev_err_probe(&pdev->dev, -EINVAL, 276 + "voltage-table length(%d) is invalid\n", 277 + length); 279 278 280 279 duty_cycle_table = devm_kzalloc(&pdev->dev, length, GFP_KERNEL); 281 280 if (!duty_cycle_table) ··· 283 284 ret = of_property_read_u32_array(np, "voltage-table", 284 285 (u32 *)duty_cycle_table, 285 286 length / sizeof(u32)); 286 - if (ret) { 287 - dev_err(&pdev->dev, "Failed to read voltage-table: %d\n", ret); 288 - return ret; 289 - } 287 + if (ret) 288 + return dev_err_probe(&pdev->dev, ret, 289 + "Failed to read voltage-table\n"); 290 290 291 291 drvdata->state = -ENOTRECOVERABLE; 292 292 drvdata->duty_cycle_table = duty_cycle_table; ··· 357 359 enum gpiod_flags gpio_flags; 358 360 int ret; 359 361 360 - if (!np) { 361 - dev_err(&pdev->dev, "Device Tree node missing\n"); 362 - return -EINVAL; 363 - } 362 + if (!np) 363 + return dev_err_probe(&pdev->dev, -EINVAL, 364 + "Device Tree node missing\n"); 364 365 365 366 drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); 366 367 if (!drvdata) ··· 397 400 gpio_flags); 398 401 if (IS_ERR(drvdata->enb_gpio)) { 399 402 ret = PTR_ERR(drvdata->enb_gpio); 400 - dev_err(&pdev->dev, "Failed to get enable GPIO: %d\n", ret); 401 - return ret; 403 + return dev_err_probe(&pdev->dev, ret, "Failed to get enable GPIO\n"); 402 404 } 403 405 404 406 ret = pwm_adjust_config(drvdata->pwm); ··· 405 409 return ret; 406 410 407 411 ret = pwm_regulator_init_boot_on(pdev, drvdata, init_data); 408 - if (ret) { 409 - dev_err(&pdev->dev, "Failed to apply boot_on settings: %d\n", 410 - ret); 411 - return ret; 412 - } 412 + if (ret) 413 + return dev_err_probe(&pdev->dev, ret, 414 + "Failed to apply boot_on settings\n"); 413 415 414 416 regulator = devm_regulator_register(&pdev->dev, 415 417 &drvdata->desc, &config); 416 418 if (IS_ERR(regulator)) { 417 419 ret = PTR_ERR(regulator); 418 - dev_err(&pdev->dev, "Failed to register regulator %s: %d\n", 419 - drvdata->desc.name, ret); 420 - return ret; 420 + return dev_err_probe(&pdev->dev, ret, 421 + "Failed to register regulator %s\n", 422 + drvdata->desc.name); 421 423 } 422 424 423 425 return 0;