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

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: 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>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230625162817.100397-3-krzysztof.kozlowski@linaro.orgSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent caec3d44
...@@ -113,22 +113,14 @@ static int gpio_vibrator_probe(struct platform_device *pdev) ...@@ -113,22 +113,14 @@ static int gpio_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->gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW); vibrator->gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW);
err = PTR_ERR_OR_ZERO(vibrator->gpio); if (IS_ERR(vibrator->gpio))
if (err) { return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->gpio),
if (err != -EPROBE_DEFER) "Failed to request main gpio\n");
dev_err(&pdev->dev, "Failed to request main gpio: %d\n",
err);
return err;
}
INIT_WORK(&vibrator->play_work, gpio_vibrator_play_work); INIT_WORK(&vibrator->play_work, gpio_vibrator_play_work);
......
...@@ -132,13 +132,8 @@ static int pwm_beeper_probe(struct platform_device *pdev) ...@@ -132,13 +132,8 @@ static int pwm_beeper_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
beeper->pwm = devm_pwm_get(dev, NULL); beeper->pwm = devm_pwm_get(dev, NULL);
if (IS_ERR(beeper->pwm)) { if (IS_ERR(beeper->pwm))
error = PTR_ERR(beeper->pwm); return dev_err_probe(dev, PTR_ERR(beeper->pwm), "Failed to request PWM device\n");
if (error != -EPROBE_DEFER)
dev_err(dev, "Failed to request PWM device: %d\n",
error);
return error;
}
/* Sync up PWM state and ensure it is off. */ /* Sync up PWM state and ensure it is off. */
pwm_init_state(beeper->pwm, &state); pwm_init_state(beeper->pwm, &state);
...@@ -151,13 +146,9 @@ static int pwm_beeper_probe(struct platform_device *pdev) ...@@ -151,13 +146,9 @@ static int pwm_beeper_probe(struct platform_device *pdev)
} }
beeper->amplifier = devm_regulator_get(dev, "amp"); beeper->amplifier = devm_regulator_get(dev, "amp");
if (IS_ERR(beeper->amplifier)) { if (IS_ERR(beeper->amplifier))
error = PTR_ERR(beeper->amplifier); return dev_err_probe(dev, PTR_ERR(beeper->amplifier),
if (error != -EPROBE_DEFER) "Failed to get 'amp' regulator\n");
dev_err(dev, "Failed to get 'amp' regulator: %d\n",
error);
return error;
}
INIT_WORK(&beeper->work, pwm_beeper_work); INIT_WORK(&beeper->work, pwm_beeper_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