mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 03:53:37 +02:00
Input: pwm-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> Link: https://lore.kernel.org/r/20230625162817.100397-4-krzysztof.kozlowski@linaro.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
c4834f4ad7
commit
a07e68dff5
|
|
@ -140,32 +140,20 @@ static int pwm_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->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
|
||||
GPIOD_OUT_LOW);
|
||||
err = PTR_ERR_OR_ZERO(vibrator->enable_gpio);
|
||||
if (err) {
|
||||
if (err != -EPROBE_DEFER)
|
||||
dev_err(&pdev->dev, "Failed to request enable gpio: %d\n",
|
||||
err);
|
||||
return err;
|
||||
}
|
||||
if (IS_ERR(vibrator->enable_gpio))
|
||||
return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->enable_gpio),
|
||||
"Failed to request enable gpio\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\n",
|
||||
err);
|
||||
return err;
|
||||
}
|
||||
if (IS_ERR(vibrator->pwm))
|
||||
return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->pwm),
|
||||
"Failed to request main pwm\n");
|
||||
|
||||
INIT_WORK(&vibrator->play_work, pwm_vibrator_play_work);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user