@@ -135,21 +135,15 @@ static int pwm_vibrator_probe(struct platform_device *pdev)
vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc");
err = PTR_ERR_OR_ZERO(vibrator->vcc);
- if (err) {
- if (err != -EPROBE_DEFER)
- dev_err(&pdev->dev, "Failed to request regulator: %d",
- err);
- return err;
- }
+ if (err)
+ return dev_err_probe(&pdev->dev, err,
+ "Failed to request regulator\n");
vibrator->pwm = devm_pwm_get(&pdev->dev, "enable");
err = PTR_ERR_OR_ZERO(vibrator->pwm);
- if (err) {
- if (err != -EPROBE_DEFER)
- dev_err(&pdev->dev, "Failed to request main pwm: %d",
- err);
- return err;
- }
+ if (err)
+ return dev_err_probe(&pdev->dev, err,
+ "Failed to request main pwm\n");
INIT_WORK(&vibrator->play_work, pwm_vibrator_play_work);
In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs. Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/input/misc/pwm-vibra.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)