* [PATCH] Input: bu21013_ts - Make use of the helper function dev_err_probe()
@ 2021-09-16 15:31 Cai Huoqing
0 siblings, 0 replies; only message in thread
From: Cai Huoqing @ 2021-09-16 15:31 UTC (permalink / raw)
To: caihuoqing; +Cc: Dmitry Torokhov, linux-input, linux-kernel
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 --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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-09-16 15:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16 15:31 [PATCH] Input: bu21013_ts - Make use of the helper function dev_err_probe() Cai Huoqing
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).