Message ID | 20200826181706.11098-6-krzk@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [01/24] Input: bcm-keypad - Simplify with dev_err_probe() | expand |
On Wed, Aug 26, 2020 at 9:18 PM Krzysztof Kozlowski <krzk@kernel.org> wrote: > > Common pattern of handling deferred probe can be simplified with > dev_err_probe(). Less code and also it prints the error value. > err = PTR_ERR_OR_ZERO(vibrator->vcc); > + if (err) > + return dev_err_probe(&pdev->dev, err, "Failed to request regulator\n"); Same comment, no need to have additional PTR_ERR_OZR_ZERO().
On Thu, Aug 27, 2020 at 12:06:46PM +0300, Andy Shevchenko wrote: > On Wed, Aug 26, 2020 at 9:18 PM Krzysztof Kozlowski <krzk@kernel.org> wrote: > > > > Common pattern of handling deferred probe can be simplified with > > dev_err_probe(). Less code and also it prints the error value. > > > err = PTR_ERR_OR_ZERO(vibrator->vcc); > > + if (err) > > + return dev_err_probe(&pdev->dev, err, "Failed to request regulator\n"); > > Same comment, no need to have additional PTR_ERR_OZR_ZERO(). Yes. Best regards, Krzysztof
diff --git a/drivers/input/misc/pwm-vibra.c b/drivers/input/misc/pwm-vibra.c index 81e777a04b88..e45cd6801208 100644 --- a/drivers/input/misc/pwm-vibra.c +++ b/drivers/input/misc/pwm-vibra.c @@ -135,21 +135,13 @@ 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);
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 <krzk@kernel.org> --- drivers/input/misc/pwm-vibra.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)