Skip to contentSkip to conversation

Input: elan_i2c - convert to use dev_groups

PATCH Applied Greg Kroah-Hartman 2 participants 2 messages Aug 2, 2022 – Aug 10, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Input: elan_i2c - convert to use dev_groups

There is no need for a driver to individually add/create device groups, the driver core will do it automatically for you. Convert the elan_i2c driver to use the dev_groups pointer instead of manually calling the driver core to create the group and have it be cleaned up later on by the devm core.

Cc Dmitry Torokhov <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc "jingle.wu" <[email protected]>

---
v2: change text based on Dmitry's review, it's not a race condition,
it's just less code to worry about in a driver.

 drivers/input/mouse/elan_i2c_core.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/input/mouse/elan_i2c_core.c +1 -6
index e1758d5ffe42..d4eb59b55bf1 100644
@@ -1311,12 +1311,6 @@ static int elan_probe(struct i2c_client *client,
 		return error;
 	}
 
-	error = devm_device_add_groups(dev, elan_sysfs_groups);
-	if (error) {
-		dev_err(dev, "failed to create sysfs attributes: %d\n", error);
-		return error;
-	}
-
 	error = input_register_device(data->input);
 	if (error) {
 		dev_err(dev, "failed to register input device: %d\n", error);
@@ -1442,6 +1436,7 @@ static struct i2c_driver elan_driver = {
 		.acpi_match_table = ACPI_PTR(elan_acpi_id),
 		.of_match_table = of_match_ptr(elan_of_match),
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
+		.dev_groups = elan_sysfs_groups,
 	},
 	.probe		= elan_probe,
 	.id_table	= elan_id,
Signature · 1 line
2.37.1
maintainer Applied
#1 lore raw
Quoted 6 lines · Greg Kroah-Hartman

There is no need for a driver to individually add/create device groups, the driver core will do it automatically for you. Convert the elan_i2c driver to use the dev_groups pointer instead of manually calling the driver core to create the group and have it be cleaned up later on by the devm core.

Quoted 7 lines
Cc Dmitry Torokhov <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc "jingle.wu" <[email protected]>

Applied, thank you.

Signature · 1 line
Dmitry