diff mbox series

Input: bu21013_ts - Make use of the helper function dev_err_probe()

Message ID 20210916153134.13939-1-caihuoqing@baidu.com (mailing list archive)
State New, archived
Headers show
Series Input: bu21013_ts - Make use of the helper function dev_err_probe() | expand

Commit Message

Cai,Huoqing Sept. 16, 2021, 3:31 p.m. UTC
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 <caihuoqing@baidu.com>
---
 drivers/input/touchscreen/bu21013_ts.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)
diff mbox series

Patch

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");