Commit 09235bf3 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Mark Brown

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: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://msgid.link/r/20240216071829.1513748-2-u.kleine-koenig@pengutronix.deSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent d68ce3aa
...@@ -271,11 +271,10 @@ static int pwm_regulator_init_table(struct platform_device *pdev, ...@@ -271,11 +271,10 @@ static int pwm_regulator_init_table(struct platform_device *pdev,
of_find_property(np, "voltage-table", &length); of_find_property(np, "voltage-table", &length);
if ((length < sizeof(*duty_cycle_table)) || if ((length < sizeof(*duty_cycle_table)) ||
(length % sizeof(*duty_cycle_table))) { (length % sizeof(*duty_cycle_table)))
dev_err(&pdev->dev, "voltage-table length(%d) is invalid\n", return dev_err_probe(&pdev->dev, -EINVAL,
"voltage-table length(%d) is invalid\n",
length); length);
return -EINVAL;
}
duty_cycle_table = devm_kzalloc(&pdev->dev, length, GFP_KERNEL); duty_cycle_table = devm_kzalloc(&pdev->dev, length, GFP_KERNEL);
if (!duty_cycle_table) if (!duty_cycle_table)
...@@ -284,10 +283,9 @@ static int pwm_regulator_init_table(struct platform_device *pdev, ...@@ -284,10 +283,9 @@ static int pwm_regulator_init_table(struct platform_device *pdev,
ret = of_property_read_u32_array(np, "voltage-table", ret = of_property_read_u32_array(np, "voltage-table",
(u32 *)duty_cycle_table, (u32 *)duty_cycle_table,
length / sizeof(u32)); length / sizeof(u32));
if (ret) { if (ret)
dev_err(&pdev->dev, "Failed to read voltage-table: %d\n", ret); return dev_err_probe(&pdev->dev, ret,
return ret; "Failed to read voltage-table\n");
}
drvdata->state = -ENOTRECOVERABLE; drvdata->state = -ENOTRECOVERABLE;
drvdata->duty_cycle_table = duty_cycle_table; drvdata->duty_cycle_table = duty_cycle_table;
...@@ -359,10 +357,9 @@ static int pwm_regulator_probe(struct platform_device *pdev) ...@@ -359,10 +357,9 @@ static int pwm_regulator_probe(struct platform_device *pdev)
enum gpiod_flags gpio_flags; enum gpiod_flags gpio_flags;
int ret; int ret;
if (!np) { if (!np)
dev_err(&pdev->dev, "Device Tree node missing\n"); return dev_err_probe(&pdev->dev, -EINVAL,
return -EINVAL; "Device Tree node missing\n");
}
drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
if (!drvdata) if (!drvdata)
...@@ -400,8 +397,7 @@ static int pwm_regulator_probe(struct platform_device *pdev) ...@@ -400,8 +397,7 @@ static int pwm_regulator_probe(struct platform_device *pdev)
gpio_flags); gpio_flags);
if (IS_ERR(drvdata->enb_gpio)) { if (IS_ERR(drvdata->enb_gpio)) {
ret = PTR_ERR(drvdata->enb_gpio); ret = PTR_ERR(drvdata->enb_gpio);
dev_err(&pdev->dev, "Failed to get enable GPIO: %d\n", ret); return dev_err_probe(&pdev->dev, ret, "Failed to get enable GPIO\n");
return ret;
} }
ret = pwm_adjust_config(drvdata->pwm); ret = pwm_adjust_config(drvdata->pwm);
...@@ -409,19 +405,17 @@ static int pwm_regulator_probe(struct platform_device *pdev) ...@@ -409,19 +405,17 @@ static int pwm_regulator_probe(struct platform_device *pdev)
return ret; return ret;
ret = pwm_regulator_init_boot_on(pdev, drvdata, init_data); ret = pwm_regulator_init_boot_on(pdev, drvdata, init_data);
if (ret) { if (ret)
dev_err(&pdev->dev, "Failed to apply boot_on settings: %d\n", return dev_err_probe(&pdev->dev, ret,
ret); "Failed to apply boot_on settings\n");
return ret;
}
regulator = devm_regulator_register(&pdev->dev, regulator = devm_regulator_register(&pdev->dev,
&drvdata->desc, &config); &drvdata->desc, &config);
if (IS_ERR(regulator)) { if (IS_ERR(regulator)) {
ret = PTR_ERR(regulator); ret = PTR_ERR(regulator);
dev_err(&pdev->dev, "Failed to register regulator %s: %d\n", return dev_err_probe(&pdev->dev, ret,
drvdata->desc.name, ret); "Failed to register regulator %s\n",
return ret; drvdata->desc.name);
} }
return 0; return 0;
......
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