[PATCH v1 2/2] Input: wdt87xx_i2c - switch to use dev_err_probe()
From: Andy Shevchenko
Date: Fri Mar 21 2025 - 14:40:48 EST
Switch to use dev_err_probe() to simplify the error path and
unify a message template.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
drivers/input/touchscreen/wdt87xx_i2c.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/input/touchscreen/wdt87xx_i2c.c b/drivers/input/touchscreen/wdt87xx_i2c.c
index 99636d6eb0f3..3e7fbc4d7549 100644
--- a/drivers/input/touchscreen/wdt87xx_i2c.c
+++ b/drivers/input/touchscreen/wdt87xx_i2c.c
@@ -1033,10 +1033,8 @@ static int wdt87xx_ts_create_input_device(struct wdt87xx_data *wdt)
int error;
input = devm_input_allocate_device(dev);
- if (!input) {
- dev_err(dev, "failed to allocate input device\n");
- return -ENOMEM;
- }
+ if (!input)
+ return dev_err_probe(dev, -ENOMEM, "failed to allocate input device\n");
wdt->input = input;
input->name = "WDT87xx Touchscreen";
@@ -1060,16 +1058,15 @@ static int wdt87xx_ts_create_input_device(struct wdt87xx_data *wdt)
INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
error = input_register_device(input);
- if (error) {
- dev_err(dev, "failed to register input device: %d\n", error);
- return error;
- }
+ if (error)
+ return dev_err_probe(dev, error, "failed to register input device\n");
return 0;
}
static int wdt87xx_ts_probe(struct i2c_client *client)
{
+ struct device *dev = &client->dev;
struct wdt87xx_data *wdt;
int error;
@@ -1103,10 +1100,8 @@ static int wdt87xx_ts_probe(struct i2c_client *client)
NULL, wdt87xx_ts_interrupt,
IRQF_ONESHOT,
client->name, wdt);
- if (error) {
- dev_err(&client->dev, "request irq failed: %d\n", error);
- return error;
- }
+ if (error)
+ return dev_err_probe(dev, error, "request irq failed\n");
return 0;
}
--
2.47.2