Skip to contentSkip to conversation

Input: wdt87xx_i2c - a couple of cleanups

PATCH RESEND Superseded Andy Shevchenko 1 participant 4 messages Jan 13

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Input: wdt87xx_i2c - a couple of cleanups

A couple of cleanups related to ACPI ID table and probe function.

Andy Shevchenko (2):
Input: wdt87xx_i2c - tidy up ACPI ID table
Input: wdt87xx_i2c - switch to use dev_err_probe()

 drivers/input/touchscreen/wdt87xx_i2c.c | 40 ++++++++++++-------------
 1 file changed, 20 insertions(+), 20 deletions(-)
Signature · 1 line
2.50.1
#1 lore raw

PATCH 1/2 Input: wdt87xx_i2c - tidy up ACPI ID table

Tidy up ACPI ID table:
- drop ACPI_PTR() and hence replace acpi.h with mod_devicetable.h et al.
- remove explicit driver_data initializer

---
 drivers/input/touchscreen/wdt87xx_i2c.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/input/touchscreen/wdt87xx_i2c.c +13 -8
index 88d376090e6e..99636d6eb0f3 100644
@@ -9,17 +9,24 @@
  * may be copied, distributed, and modified under those terms.
  */
 
+#include <linux/array_size.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/firmware.h>
 #include <linux/i2c.h>
 #include <linux/input.h>
+#include <linux/input/mt.h>
 #include <linux/interrupt.h>
-#include <linux/delay.h>
 #include <linux/irq.h>
 #include <linux/io.h>
+#include <linux/math.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/pm.h>
 #include <linux/slab.h>
-#include <linux/firmware.h>
-#include <linux/input/mt.h>
-#include <linux/acpi.h>
+#include <linux/sysfs.h>
+#include <linux/types.h>
 #include <linux/unaligned.h>
 
 #define WDT87XX_NAME		"wdt87xx_i2c"
@@ -1153,13 +1160,11 @@ static const struct i2c_device_id wdt87xx_dev_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, wdt87xx_dev_id);
 
-#ifdef CONFIG_ACPI
 static const struct acpi_device_id wdt87xx_acpi_id[] = {
-	{ "WDHT0001", 0 },
+	{ "WDHT0001" },
 	{ }
 };
 MODULE_DEVICE_TABLE(acpi, wdt87xx_acpi_id);
-#endif
 
 static struct i2c_driver wdt87xx_driver = {
 	.probe		= wdt87xx_ts_probe,
@@ -1168,7 +1173,7 @@ static struct i2c_driver wdt87xx_driver = {
 		.name = WDT87XX_NAME,
 		.dev_groups = wdt87xx_groups,
 		.pm = pm_sleep_ptr(&wdt87xx_pm_ops),
-		.acpi_match_table = ACPI_PTR(wdt87xx_acpi_id),
+		.acpi_match_table = wdt87xx_acpi_id,
 	},
 };
 module_i2c_driver(wdt87xx_driver);
Signature · 1 line
2.50.1
#2 lore raw

PATCH 2/2 Input: wdt87xx_i2c - switch to use dev_err_probe()

In reply to Andy Shevchenko

Switch to use dev_err_probe() to simplify the error path and unify a message template.

---
 drivers/input/touchscreen/wdt87xx_i2c.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/input/touchscreen/wdt87xx_i2c.c +7 -12
index 99636d6eb0f3..3e7fbc4d7549 100644
@@ -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;
 }
Signature · 1 line
2.50.1
#3 lore raw

Re: [PATCH v1 2/2] Input: wdt87xx_i2c - switch to use dev_err_probe()

Quoted 2 lines · Andy Shevchenko

Switch to use dev_err_probe() to simplify the error path and unify a message template.

Actually this needs a revisit as it makes some differences and also some can be amended.

Signature · 2 lines
With Best Regards,
Andy Shevchenko