When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.
Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/input/touchscreen/bu21013_ts.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 2f1f0d7607f8..43cc7efd4e38 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -477,10 +477,9 @@ static int bu21013_probe(struct i2c_client *client,
}
ts->regulator = devm_regulator_get(&client->dev, "avdd");
- if (IS_ERR(ts->regulator)) {
- dev_err(&client->dev, "regulator_get failed\n");
- return PTR_ERR(ts->regulator);
- }
+ if (IS_ERR(ts->regulator))
+ return dev_err_probe(&client->dev, PTR_ERR(ts->regulator),
+ "regulator_get failed\n");
error = regulator_enable(ts->regulator);
if (error) {
@@ -497,11 +496,9 @@ static int bu21013_probe(struct i2c_client *client,
/* Named "CS" on the chip, DT binding is "reset" */
ts->cs_gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
error = PTR_ERR_OR_ZERO(ts->cs_gpiod);
- if (error) {
- if (error != -EPROBE_DEFER)
- dev_err(&client->dev, "failed to get CS GPIO\n");
- return error;
- }
+ if (error)
+ return dev_err_probe(&client->dev, error,
+ "failed to get CS GPIO\n");
gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS");
error = devm_add_action_or_reset(&client->dev,
@@ -516,11 +513,8 @@ static int bu21013_probe(struct i2c_client *client,
ts->int_gpiod = devm_gpiod_get_optional(&client->dev,
"touch", GPIOD_IN);
error = PTR_ERR_OR_ZERO(ts->int_gpiod);
- if (error) {
- if (error != -EPROBE_DEFER)
- dev_err(&client->dev, "failed to get INT GPIO\n");
- return error;
- }
+ if (error)
+ return dev_err_probe(&client->dev, error, "failed to get INT GPIO\n");
if (ts->int_gpiod)
gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT");
--
2.25.1