Input: gpio-vibra - simplify with dev_err_probe()
Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20230625162817.100397-3-krzysztof.kozlowski@linaro.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
caec3d4416
commit
c4834f4ad7
@ -113,22 +113,14 @@ static int gpio_vibrator_probe(struct platform_device *pdev)
|
||||
return -ENOMEM;
|
||||
|
||||
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\n",
|
||||
err);
|
||||
return err;
|
||||
}
|
||||
if (IS_ERR(vibrator->vcc))
|
||||
return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->vcc),
|
||||
"Failed to request regulator\n");
|
||||
|
||||
vibrator->gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW);
|
||||
err = PTR_ERR_OR_ZERO(vibrator->gpio);
|
||||
if (err) {
|
||||
if (err != -EPROBE_DEFER)
|
||||
dev_err(&pdev->dev, "Failed to request main gpio: %d\n",
|
||||
err);
|
||||
return err;
|
||||
}
|
||||
if (IS_ERR(vibrator->gpio))
|
||||
return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->gpio),
|
||||
"Failed to request main gpio\n");
|
||||
|
||||
INIT_WORK(&vibrator->play_work, gpio_vibrator_play_work);
|
||||
|
||||
|
@ -132,13 +132,8 @@ static int pwm_beeper_probe(struct platform_device *pdev)
|
||||
return -ENOMEM;
|
||||
|
||||
beeper->pwm = devm_pwm_get(dev, NULL);
|
||||
if (IS_ERR(beeper->pwm)) {
|
||||
error = PTR_ERR(beeper->pwm);
|
||||
if (error != -EPROBE_DEFER)
|
||||
dev_err(dev, "Failed to request PWM device: %d\n",
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
if (IS_ERR(beeper->pwm))
|
||||
return dev_err_probe(dev, PTR_ERR(beeper->pwm), "Failed to request PWM device\n");
|
||||
|
||||
/* Sync up PWM state and ensure it is off. */
|
||||
pwm_init_state(beeper->pwm, &state);
|
||||
@ -151,13 +146,9 @@ static int pwm_beeper_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
beeper->amplifier = devm_regulator_get(dev, "amp");
|
||||
if (IS_ERR(beeper->amplifier)) {
|
||||
error = PTR_ERR(beeper->amplifier);
|
||||
if (error != -EPROBE_DEFER)
|
||||
dev_err(dev, "Failed to get 'amp' regulator: %d\n",
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
if (IS_ERR(beeper->amplifier))
|
||||
return dev_err_probe(dev, PTR_ERR(beeper->amplifier),
|
||||
"Failed to get 'amp' regulator\n");
|
||||
|
||||
INIT_WORK(&beeper->work, pwm_beeper_work);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user