Commit a07e68df authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Dmitry Torokhov

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: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230625162817.100397-4-krzysztof.kozlowski@linaro.orgSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent c4834f4a
...@@ -140,32 +140,20 @@ static int pwm_vibrator_probe(struct platform_device *pdev) ...@@ -140,32 +140,20 @@ static int pwm_vibrator_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc"); vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc");
err = PTR_ERR_OR_ZERO(vibrator->vcc); if (IS_ERR(vibrator->vcc))
if (err) { return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->vcc),
if (err != -EPROBE_DEFER) "Failed to request regulator\n");
dev_err(&pdev->dev, "Failed to request regulator: %d\n",
err);
return err;
}
vibrator->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", vibrator->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
GPIOD_OUT_LOW); GPIOD_OUT_LOW);
err = PTR_ERR_OR_ZERO(vibrator->enable_gpio); if (IS_ERR(vibrator->enable_gpio))
if (err) { return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->enable_gpio),
if (err != -EPROBE_DEFER) "Failed to request enable gpio\n");
dev_err(&pdev->dev, "Failed to request enable gpio: %d\n",
err);
return err;
}
vibrator->pwm = devm_pwm_get(&pdev->dev, "enable"); vibrator->pwm = devm_pwm_get(&pdev->dev, "enable");
err = PTR_ERR_OR_ZERO(vibrator->pwm); if (IS_ERR(vibrator->pwm))
if (err) { return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->pwm),
if (err != -EPROBE_DEFER) "Failed to request main pwm\n");
dev_err(&pdev->dev, "Failed to request main pwm: %d\n",
err);
return err;
}
INIT_WORK(&vibrator->play_work, pwm_vibrator_play_work); INIT_WORK(&vibrator->play_work, pwm_vibrator_play_work);
......
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