Skip to contentSkip to conversation

Input: cros_ec_keyb - use device core to create driver-specific device attributes

PATCH In review Dmitry Torokhov 8 participants 34 messages Jul 29, 2023 – Aug 2, 2023

Subsystems (7)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/22 Input: cros_ec_keyb - use device core to create driver-specific device attributes

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/keyboard/cros_ec_keyb.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/input/keyboard/cros_ec_keyb.c +3 -7
index e7ecfca838df..313b7a69dd69 100644
@@ -686,10 +686,11 @@ static umode_t cros_ec_keyb_attr_is_visible(struct kobject *kobj,
 	return attr->mode;
 }
 
-static const struct attribute_group cros_ec_keyb_attr_group = {
+static const struct attribute_group cros_ec_keyb_group = {
 	.is_visible = cros_ec_keyb_attr_is_visible,
 	.attrs = cros_ec_keyb_attrs,
 };
+__ATTRIBUTE_GROUPS(cros_ec_keyb);
 
 static int cros_ec_keyb_probe(struct platform_device *pdev)
 {
@@ -730,12 +731,6 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
 		return err;
 	}
 
-	err = devm_device_add_group(dev, &cros_ec_keyb_attr_group);
-	if (err) {
-		dev_err(dev, "failed to create attributes: %d\n", err);
-		return err;
-	}
-
 	ckdev->notifier.notifier_call = cros_ec_keyb_work;
 	err = blocking_notifier_chain_register(&ckdev->ec->event_notifier,
 					       &ckdev->notifier);
@@ -782,6 +777,7 @@ static struct platform_driver cros_ec_keyb_driver = {
 	.remove = cros_ec_keyb_remove,
 	.driver = {
 		.name = "cros-ec-keyb",
+		.dev_groups = cros_ec_keyb_groups,
 		.of_match_table = of_match_ptr(cros_ec_keyb_of_match),
 		.acpi_match_table = ACPI_PTR(cros_ec_keyb_acpi_match),
 		.pm = pm_sleep_ptr(&cros_ec_keyb_pm_ops),
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#1 lore raw

PATCH 2/22 Input: cyapa - use device core to create driver-specific device attributes

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/mouse/cyapa.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/input/mouse/cyapa.c +3 -11
index 6a876ba617ef..f9b4a7458b4e 100644
@@ -1225,7 +1225,7 @@ static DEVICE_ATTR(baseline, S_IRUGO, cyapa_show_baseline, NULL);
 static DEVICE_ATTR(calibrate, S_IWUSR, NULL, cyapa_calibrate_store);
 static DEVICE_ATTR(mode, S_IRUGO, cyapa_show_mode, NULL);
 
-static struct attribute *cyapa_sysfs_entries[] = {
+static struct attribute *cyapa_attrs[] = {
 	&dev_attr_firmware_version.attr,
 	&dev_attr_product_id.attr,
 	&dev_attr_update_fw.attr,
@@ -1234,10 +1234,7 @@ static struct attribute *cyapa_sysfs_entries[] = {
 	&dev_attr_mode.attr,
 	NULL,
 };
-
-static const struct attribute_group cyapa_sysfs_group = {
-	.attrs = cyapa_sysfs_entries,
-};
+ATTRIBUTE_GROUPS(cyapa);
 
 static void cyapa_disable_regulator(void *data)
 {
@@ -1304,12 +1301,6 @@ static int cyapa_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(dev, &cyapa_sysfs_group);
-	if (error) {
-		dev_err(dev, "failed to create sysfs entries: %d\n", error);
-		return error;
-	}
-
 	error = cyapa_prepare_wakeup_controls(cyapa);
 	if (error) {
 		dev_err(dev, "failed to prepare wakeup controls: %d\n", error);
@@ -1486,6 +1477,7 @@ MODULE_DEVICE_TABLE(of, cyapa_of_match);
 static struct i2c_driver cyapa_driver = {
 	.driver = {
 		.name = "cyapa",
+		.dev_groups = cyapa_groups,
 		.pm = pm_ptr(&cyapa_pm_ops),
 		.acpi_match_table = ACPI_PTR(cyapa_acpi_id),
 		.of_match_table = of_match_ptr(cyapa_of_match),
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#2 lore raw

PATCH 3/22 Input: iqs269a - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/misc/iqs269a.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/input/misc/iqs269a.c +2 -8
index c0a085639870..3c636c75e8a1 100644
@@ -1586,10 +1586,7 @@ static struct attribute *iqs269_attrs[] = {
 	&dev_attr_ati_trigger.attr,
 	NULL,
 };
-
-static const struct attribute_group iqs269_attr_group = {
-	.attrs = iqs269_attrs,
-};
+ATTRIBUTE_GROUPS(iqs269);
 
 static const struct regmap_config iqs269_regmap_config = {
 	.reg_bits = 8,
@@ -1671,10 +1668,6 @@ static int iqs269_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(&client->dev, &iqs269_attr_group);
-	if (error)
-		dev_err(&client->dev, "Failed to add attributes: %d\n", error);
-
 	return error;
 }
 
@@ -1743,6 +1736,7 @@ MODULE_DEVICE_TABLE(of, iqs269_of_match);
 static struct i2c_driver iqs269_i2c_driver = {
 	.driver = {
 		.name = "iqs269a",
+		.dev_groups = iqs269_groups,
 		.of_match_table = iqs269_of_match,
 		.pm = pm_sleep_ptr(&iqs269_pm),
 	},
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Reviewed-by on v1 3/22
#3 lore raw

Re: [PATCH 03/22] Input: iqs269a - use device core to create driver-specific device attributes

Quoted 5 lines · Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

Quoted 42 lines
---
 drivers/input/misc/iqs269a.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/input/misc/iqs269a.c +2 -8
index c0a085639870..3c636c75e8a1 100644
@@ -1586,10 +1586,7 @@ static struct attribute *iqs269_attrs[] = {
 	&dev_attr_ati_trigger.attr,
 	NULL,
 };
-
-static const struct attribute_group iqs269_attr_group = {
-	.attrs = iqs269_attrs,
-};
+ATTRIBUTE_GROUPS(iqs269);
 
 static const struct regmap_config iqs269_regmap_config = {
 	.reg_bits = 8,
@@ -1671,10 +1668,6 @@ static int iqs269_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(&client->dev, &iqs269_attr_group);
-	if (error)
-		dev_err(&client->dev, "Failed to add attributes: %d\n", error);
-
 	return error;
 }
 
@@ -1743,6 +1736,7 @@ MODULE_DEVICE_TABLE(of, iqs269_of_match);
 static struct i2c_driver iqs269_i2c_driver = {
 	.driver = {
 		.name = "iqs269a",
+		.dev_groups = iqs269_groups,
 		.of_match_table = iqs269_of_match,
 		.pm = pm_sleep_ptr(&iqs269_pm),
 	},
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Reviewed-by on v1 3/22
#4 lore raw

Re: [PATCH 03/22] Input: iqs269a - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov
Quoted 5 lines · Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

Quoted 41 lines
---
 drivers/input/misc/iqs269a.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/input/misc/iqs269a.c +2 -8
index c0a085639870..3c636c75e8a1 100644
@@ -1586,10 +1586,7 @@ static struct attribute *iqs269_attrs[] = {
 	&dev_attr_ati_trigger.attr,
 	NULL,
 };
-
-static const struct attribute_group iqs269_attr_group = {
-	.attrs = iqs269_attrs,
-};
+ATTRIBUTE_GROUPS(iqs269);
 
 static const struct regmap_config iqs269_regmap_config = {
 	.reg_bits = 8,
@@ -1671,10 +1668,6 @@ static int iqs269_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(&client->dev, &iqs269_attr_group);
-	if (error)
-		dev_err(&client->dev, "Failed to add attributes: %d\n", error);
-
 	return error;
 }
 
@@ -1743,6 +1736,7 @@ MODULE_DEVICE_TABLE(of, iqs269_of_match);
 static struct i2c_driver iqs269_i2c_driver = {
 	.driver = {
 		.name = "iqs269a",
+		.dev_groups = iqs269_groups,
 		.of_match_table = iqs269_of_match,
 		.pm = pm_sleep_ptr(&iqs269_pm),
 	},
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#5 lore raw

PATCH 4/22 Input: kxtj9 - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/misc/kxtj9.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/input/misc/kxtj9.c +17 -12
index 912e614d039d..d47269b10e9a 100644
@@ -334,14 +334,25 @@ static ssize_t kxtj9_set_poll(struct device *dev, struct device_attribute *attr,
 
 static DEVICE_ATTR(poll, S_IRUGO|S_IWUSR, kxtj9_get_poll, kxtj9_set_poll);
 
-static struct attribute *kxtj9_attributes[] = {
+static struct attribute *kxtj9_attrs[] = {
 	&dev_attr_poll.attr,
 	NULL
 };
 
-static struct attribute_group kxtj9_attribute_group = {
-	.attrs = kxtj9_attributes
+static umode_t kxtj9_attr_is_visible(struct kobject *kobj,
+				     struct attribute *attr, int n)
+{
+	struct device *dev = kobj_to_dev(kobj);
+	struct i2c_client *client = to_i2c_client(dev);
+
+	return client->irq ? attr->mode : 0;
+}
+
+static struct attribute_group kxtj9_group = {
+	.attrs = kxtj9_attrs,
+	.is_visible = kxtj9_attr_is_visible,
 };
+__ATTRIBUTE_GROUPS(kxtj9);
 
 static void kxtj9_poll(struct input_dev *input)
 {
@@ -482,13 +493,6 @@ static int kxtj9_probe(struct i2c_client *client)
 			dev_err(&client->dev, "request irq failed: %d\n", err);
 			return err;
 		}
-
-		err = devm_device_add_group(&client->dev,
-					    &kxtj9_attribute_group);
-		if (err) {
-			dev_err(&client->dev, "sysfs create failed: %d\n", err);
-			return err;
-		}
 	}
 
 	return 0;
@@ -535,8 +539,9 @@ MODULE_DEVICE_TABLE(i2c, kxtj9_id);
 
 static struct i2c_driver kxtj9_driver = {
 	.driver = {
-		.name	= NAME,
-		.pm	= pm_sleep_ptr(&kxtj9_pm_ops),
+		.name		= NAME,
+		.dev_groups	= kxtj9_groups,
+		.pm		= pm_sleep_ptr(&kxtj9_pm_ops),
 	},
 	.probe		= kxtj9_probe,
 	.id_table	= kxtj9_id,
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#6 lore raw

PATCH 5/22 Input: ad7877 - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/ad7877.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/input/touchscreen/ad7877.c +5 -7
index edb36d663f22..a0598e9c7aff 100644
@@ -612,10 +612,11 @@ static umode_t ad7877_attr_is_visible(struct kobject *kobj,
 	return mode;
 }
 
-static const struct attribute_group ad7877_attr_group = {
+static const struct attribute_group ad7877_group = {
 	.is_visible	= ad7877_attr_is_visible,
 	.attrs		= ad7877_attributes,
 };
+__ATTRIBUTE_GROUPS(ad7877);
 
 static void ad7877_setup_ts_def_msg(struct spi_device *spi, struct ad7877 *ts)
 {
@@ -777,10 +778,6 @@ static int ad7877_probe(struct spi_device *spi)
 		return err;
 	}
 
-	err = devm_device_add_group(&spi->dev, &ad7877_attr_group);
-	if (err)
-		return err;
-
 	err = input_register_device(input_dev);
 	if (err)
 		return err;
@@ -810,8 +807,9 @@ static DEFINE_SIMPLE_DEV_PM_OPS(ad7877_pm, ad7877_suspend, ad7877_resume);
 
 static struct spi_driver ad7877_driver = {
 	.driver = {
-		.name	= "ad7877",
-		.pm	= pm_sleep_ptr(&ad7877_pm),
+		.name		= "ad7877",
+		.dev_groups	= ad7877_groups,
+		.pm		= pm_sleep_ptr(&ad7877_pm),
 	},
 	.probe		= ad7877_probe,
 };
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
maintainer Acked-by on v1 5/22
#7 lore raw

RE: [PATCH 05/22] Input: ad7877 - use device core to create driver-specific device attributes

Quoted 12 lines

-----Original Message-----
From: Dmitry Torokhov <[email protected]>
Sent: Samstag, 29. Juli 2023 02:51
To: [email protected]
Cc: [email protected]; Greg Kroah-Hartman <[email protected]>; Hennerich, Michael <[email protected]>
Subject: [PATCH 05/22] Input: ad7877 - use device core to create driver- specific device attributes

Quoted 5 lines

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

Quoted 49 lines
---
 drivers/input/touchscreen/ad7877.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/input/touchscreen/ad7877.c +2 -1
index edb36d663f22..a0598e9c7aff 100644
@@ -612,10 +612,11 @@ static umode_t ad7877_attr_is_visible(struct
 kobject *kobj,
 	return mode;
 }
 
-static const struct attribute_group ad7877_attr_group = {
+static const struct attribute_group ad7877_group = {
 	.is_visible	= ad7877_attr_is_visible,
 	.attrs		= ad7877_attributes,
 };
+__ATTRIBUTE_GROUPS(ad7877);
 
 static void ad7877_setup_ts_def_msg(struct spi_device *spi, struct ad7877

*ts) { @@ -777,10 +778,6 @@ static int ad7877_probe(struct spi_device *spi)

drivers/input/touchscreen/ad7877.c +3 -6
 		return err;
 	}
 
-	err = devm_device_add_group(&spi->dev, &ad7877_attr_group);
-	if (err)
-		return err;
-
 	err = input_register_device(input_dev);
 	if (err)
 		return err;
@@ -810,8 +807,9 @@ static DEFINE_SIMPLE_DEV_PM_OPS(ad7877_pm,
 ad7877_suspend, ad7877_resume);
 
 static struct spi_driver ad7877_driver = {
 	.driver = {
-		.name	= "ad7877",
-		.pm	= pm_sleep_ptr(&ad7877_pm),
+		.name		= "ad7877",
+		.dev_groups	= ad7877_groups,
+		.pm		= pm_sleep_ptr(&ad7877_pm),
 	},
 	.probe		= ad7877_probe,

};
--
2.41.0.487.g6d72f3e995-goog

author maintainer
#8 lore raw

PATCH 6/22 Input: ad7879 - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/ad7879-i2c.c |  7 ++++---
 drivers/input/touchscreen/ad7879-spi.c |  7 ++++---
 drivers/input/touchscreen/ad7879.c     | 10 ++++++----
 drivers/input/touchscreen/ad7879.h     |  3 +++
 4 files changed, 17 insertions(+), 10 deletions(-)
drivers/input/touchscreen/ad7879-i2c.c +4 -3
index feaa6f8b01ed..5c094ab74698 100644
@@ -58,9 +58,10 @@ MODULE_DEVICE_TABLE(of, ad7879_i2c_dt_ids);
 
 static struct i2c_driver ad7879_i2c_driver = {
 	.driver = {
-		.name	= "ad7879",
-		.pm	= &ad7879_pm_ops,
-		.of_match_table = of_match_ptr(ad7879_i2c_dt_ids),
+		.name		= "ad7879",
+		.dev_groups	= ad7879_groups,
+		.pm		= &ad7879_pm_ops,
+		.of_match_table	= of_match_ptr(ad7879_i2c_dt_ids),
 	},
 	.probe		= ad7879_i2c_probe,
 	.id_table	= ad7879_id,
drivers/input/touchscreen/ad7879-spi.c +4 -3
index 50e889846800..064968fe57cf 100644
@@ -56,9 +56,10 @@ MODULE_DEVICE_TABLE(of, ad7879_spi_dt_ids);
 
 static struct spi_driver ad7879_spi_driver = {
 	.driver = {
-		.name	= "ad7879",
-		.pm	= &ad7879_pm_ops,
-		.of_match_table = of_match_ptr(ad7879_spi_dt_ids),
+		.name		= "ad7879",
+		.dev_groups	= ad7879_groups,
+		.pm		= &ad7879_pm_ops,
+		.of_match_table	= of_match_ptr(ad7879_spi_dt_ids),
 	},
 	.probe		= ad7879_spi_probe,
 };
drivers/input/touchscreen/ad7879.c +6 -4
index e850853328f1..e5d69bf2276e 100644
@@ -391,6 +391,12 @@ static const struct attribute_group ad7879_attr_group = {
 	.attrs = ad7879_attributes,
 };
 
+const struct attribute_group *ad7879_groups[] = {
+	&ad7879_attr_group,
+	NULL
+};
+EXPORT_SYMBOL_GPL(ad7879_groups);
+
 #ifdef CONFIG_GPIOLIB
 static int ad7879_gpio_direction_input(struct gpio_chip *chip,
 					unsigned gpio)
@@ -612,10 +618,6 @@ int ad7879_probe(struct device *dev, struct regmap *regmap,
 
 	__ad7879_disable(ts);
 
-	err = devm_device_add_group(dev, &ad7879_attr_group);
-	if (err)
-		return err;
-
 	err = ad7879_gpio_add(ts);
 	if (err)
 		return err;
drivers/input/touchscreen/ad7879.h +3 -0
index ae8aa1428e56..d71a8e787290 100644
@@ -8,11 +8,14 @@
 #ifndef _AD7879_H_
 #define _AD7879_H_
 
+#include <linux/pm.h>
 #include <linux/types.h>
 
+struct attribute_group;
 struct device;
 struct regmap;
 
+extern const struct attribute_group *ad7879_groups[];
 extern const struct dev_pm_ops ad7879_pm_ops;
 
 int ad7879_probe(struct device *dev, struct regmap *regmap,
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
maintainer Acked-by on v1 6/22
#9 lore raw

RE: [PATCH 06/22] Input: ad7879 - use device core to create driver-specific device attributes

Quoted 12 lines

-----Original Message-----
From: Dmitry Torokhov <[email protected]>
Sent: Samstag, 29. Juli 2023 02:51
To: [email protected]
Cc: [email protected]; Greg Kroah-Hartman <[email protected]>; Hennerich, Michael <[email protected]>
Subject: [PATCH 06/22] Input: ad7879 - use device core to create driver- specific device attributes

Quoted 5 lines

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

Quoted 98 lines
---
 drivers/input/touchscreen/ad7879-i2c.c |  7 ++++---
drivers/input/touchscreen/ad7879-spi.c |  7 ++++---
 drivers/input/touchscreen/ad7879.c     | 10 ++++++----
 drivers/input/touchscreen/ad7879.h     |  3 +++
 4 files changed, 17 insertions(+), 10 deletions(-)
drivers/input/touchscreen/ad7879-i2c.c +4 -3
index feaa6f8b01ed..5c094ab74698 100644
@@ -58,9 +58,10 @@ MODULE_DEVICE_TABLE(of, ad7879_i2c_dt_ids);
 
 static struct i2c_driver ad7879_i2c_driver = {
 	.driver = {
-		.name	= "ad7879",
-		.pm	= &ad7879_pm_ops,
-		.of_match_table = of_match_ptr(ad7879_i2c_dt_ids),
+		.name		= "ad7879",
+		.dev_groups	= ad7879_groups,
+		.pm		= &ad7879_pm_ops,
+		.of_match_table	= of_match_ptr(ad7879_i2c_dt_ids),
 	},
 	.probe		= ad7879_i2c_probe,
 	.id_table	= ad7879_id,
drivers/input/touchscreen/ad7879-spi.c +4 -3
index 50e889846800..064968fe57cf 100644
@@ -56,9 +56,10 @@ MODULE_DEVICE_TABLE(of, ad7879_spi_dt_ids);
 
 static struct spi_driver ad7879_spi_driver = {
 	.driver = {
-		.name	= "ad7879",
-		.pm	= &ad7879_pm_ops,
-		.of_match_table = of_match_ptr(ad7879_spi_dt_ids),
+		.name		= "ad7879",
+		.dev_groups	= ad7879_groups,
+		.pm		= &ad7879_pm_ops,
+		.of_match_table	= of_match_ptr(ad7879_spi_dt_ids),
 	},
 	.probe		= ad7879_spi_probe,
 };
drivers/input/touchscreen/ad7879.c +6 -0
index e850853328f1..e5d69bf2276e 100644
@@ -391,6 +391,12 @@ static const struct attribute_group
 ad7879_attr_group = {
 	.attrs = ad7879_attributes,
 };
 
+const struct attribute_group *ad7879_groups[] = {
+	&ad7879_attr_group,
+	NULL
+};
+EXPORT_SYMBOL_GPL(ad7879_groups);
+
 #ifdef CONFIG_GPIOLIB
 static int ad7879_gpio_direction_input(struct gpio_chip *chip,
drivers/input/touchscreen/ad7879.c +0 -4
 					unsigned gpio)
@@ -612,10 +618,6 @@ int ad7879_probe(struct device *dev, struct regmap
 *regmap,
 
 	__ad7879_disable(ts);
 
-	err = devm_device_add_group(dev, &ad7879_attr_group);
-	if (err)
-		return err;
-
 	err = ad7879_gpio_add(ts);
 	if (err)
drivers/input/touchscreen/ad7879.c +0 -0
 		return err;
drivers/input/touchscreen/ad7879.h +3 -1
index ae8aa1428e56..d71a8e787290 100644
@@ -8,11 +8,14 @@
 #ifndef _AD7879_H_
 #define _AD7879_H_
 
+#include <linux/pm.h>
 #include <linux/types.h>
 
+struct attribute_group;
 struct device;
 struct regmap;
 
+extern const struct attribute_group *ad7879_groups[];
 extern const struct dev_pm_ops ad7879_pm_ops;
 
 int ad7879_probe(struct device *dev, struct regmap *regmap,
--

2.41.0.487.g6d72f3e995-goog

author maintainer
#10 lore raw

PATCH 7/22 Input: ads7846 - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/ads7846.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/input/touchscreen/ads7846.c +6 -12
index bb1058b1e7fd..5601ceb7e26b 100644
@@ -628,15 +628,12 @@ static ssize_t ads7846_disable_store(struct device *dev,
 
 static DEVICE_ATTR(disable, 0664, ads7846_disable_show, ads7846_disable_store);
 
-static struct attribute *ads784x_attributes[] = {
+static struct attribute *ads784x_attrs[] = {
 	&dev_attr_pen_down.attr,
 	&dev_attr_disable.attr,
 	NULL,
 };
-
-static const struct attribute_group ads784x_attr_group = {
-	.attrs = ads784x_attributes,
-};
+ATTRIBUTE_GROUPS(ads784x);
 
 /*--------------------------------------------------------------------------*/
 
@@ -1395,10 +1392,6 @@ static int ads7846_probe(struct spi_device *spi)
 	else
 		(void) ads7846_read12_ser(dev, READ_12BIT_SER(vaux));
 
-	err = devm_device_add_group(dev, &ads784x_attr_group);
-	if (err)
-		return err;
-
 	err = input_register_device(input_dev);
 	if (err)
 		return err;
@@ -1424,9 +1417,10 @@ static void ads7846_remove(struct spi_device *spi)
 
 static struct spi_driver ads7846_driver = {
 	.driver = {
-		.name	= "ads7846",
-		.pm	= pm_sleep_ptr(&ads7846_pm),
-		.of_match_table = of_match_ptr(ads7846_dt_ids),
+		.name		= "ads7846",
+		.dev_groups	= ads784x_groups,
+		.pm		= pm_sleep_ptr(&ads7846_pm),
+		.of_match_table	= of_match_ptr(ads7846_dt_ids),
 	},
 	.probe		= ads7846_probe,
 	.remove		= ads7846_remove,
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#11 lore raw

PATCH 8/22 Input: edt-ft5x06 - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/edt-ft5x06.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/input/touchscreen/edt-ft5x06.c +2 -8
index 457d53337fbb..3e102bcc4a1c 100644
@@ -580,10 +580,7 @@ static struct attribute *edt_ft5x06_attrs[] = {
 	&dev_attr_crc_errors.attr,
 	NULL
 };
-
-static const struct attribute_group edt_ft5x06_attr_group = {
-	.attrs = edt_ft5x06_attrs,
-};
+ATTRIBUTE_GROUPS(edt_ft5x06);
 
 static void edt_ft5x06_restore_reg_parameters(struct edt_ft5x06_ts_data *tsdata)
 {
@@ -1330,10 +1327,6 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(&client->dev, &edt_ft5x06_attr_group);
-	if (error)
-		return error;
-
 	error = input_register_device(input);
 	if (error)
 		return error;
@@ -1502,6 +1495,7 @@ MODULE_DEVICE_TABLE(of, edt_ft5x06_of_match);
 static struct i2c_driver edt_ft5x06_ts_driver = {
 	.driver = {
 		.name = "edt_ft5x06",
+		.dev_groups = edt_ft5x06_groups,
 		.of_match_table = edt_ft5x06_of_match,
 		.pm = pm_sleep_ptr(&edt_ft5x06_ts_pm_ops),
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#12 lore raw

PATCH 9/22 Input: elants_i2c - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/elants_i2c.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/input/touchscreen/elants_i2c.c +3 -12
index a1af3de9f310..365765d40e62 100644
@@ -1299,7 +1299,7 @@ static ELANTS_VERSION_ATTR(solution_version);
 static ELANTS_VERSION_ATTR(bc_version);
 static ELANTS_VERSION_ATTR(iap_version);
 
-static struct attribute *elants_attributes[] = {
+static struct attribute *elants_i2c_attrs[] = {
 	&dev_attr_calibrate.attr,
 	&dev_attr_update_fw.attr,
 	&dev_attr_iap_mode.attr,
@@ -1313,10 +1313,7 @@ static struct attribute *elants_attributes[] = {
 	&elants_ver_attr_iap_version.dattr.attr,
 	NULL
 };
-
-static const struct attribute_group elants_attribute_group = {
-	.attrs = elants_attributes,
-};
+ATTRIBUTE_GROUPS(elants_i2c);
 
 static int elants_i2c_power_on(struct elants_data *ts)
 {
@@ -1552,13 +1549,6 @@ static int elants_i2c_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(&client->dev, &elants_attribute_group);
-	if (error) {
-		dev_err(&client->dev, "failed to create sysfs attributes: %d\n",
-			error);
-		return error;
-	}
-
 	return 0;
 }
 
@@ -1667,6 +1657,7 @@ static struct i2c_driver elants_i2c_driver = {
 	.id_table = elants_i2c_id,
 	.driver = {
 		.name = DEVICE_NAME,
+		.dev_groups = elants_i2c_groups,
 		.pm = pm_sleep_ptr(&elants_i2c_pm_ops),
 		.acpi_match_table = ACPI_PTR(elants_acpi_id),
 		.of_match_table = of_match_ptr(elants_of_match),
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#13 lore raw

PATCH 10/22 Input: exc3000 - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/exc3000.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/input/touchscreen/exc3000.c +3 -9
index 4c0d99aae9e0..a4030cc9ff60 100644
@@ -325,16 +325,13 @@ static ssize_t type_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(type);
 
-static struct attribute *sysfs_attrs[] = {
+static struct attribute *exc3000_attrs[] = {
 	&dev_attr_fw_version.attr,
 	&dev_attr_model.attr,
 	&dev_attr_type.attr,
 	NULL
 };
-
-static struct attribute_group exc3000_attribute_group = {
-	.attrs = sysfs_attrs
-};
+ATTRIBUTE_GROUPS(exc3000);
 
 static int exc3000_probe(struct i2c_client *client)
 {
@@ -437,10 +434,6 @@ static int exc3000_probe(struct i2c_client *client)
 
 	i2c_set_clientdata(client, data);
 
-	error = devm_device_add_group(&client->dev, &exc3000_attribute_group);
-	if (error)
-		return error;
-
 	return 0;
 }
 
@@ -473,6 +466,7 @@ MODULE_DEVICE_TABLE(acpi, exc3000_acpi_match);
 static struct i2c_driver exc3000_driver = {
 	.driver = {
 		.name	= "exc3000",
+		.dev_groups = exc3000_groups,
 		.of_match_table = of_match_ptr(exc3000_of_match),
 		.acpi_match_table = ACPI_PTR(exc3000_acpi_match),
 	},
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#14 lore raw

PATCH 11/22 Input: hideep - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/hideep.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/input/touchscreen/hideep.c +3 -12
index 404153338df7..0f58258306bf 100644
@@ -954,16 +954,13 @@ static DEVICE_ATTR(version, 0664, hideep_fw_version_show, NULL);
 static DEVICE_ATTR(product_id, 0664, hideep_product_id_show, NULL);
 static DEVICE_ATTR(update_fw, 0664, NULL, hideep_update_fw);
 
-static struct attribute *hideep_ts_sysfs_entries[] = {
+static struct attribute *hideep_ts_attrs[] = {
 	&dev_attr_version.attr,
 	&dev_attr_product_id.attr,
 	&dev_attr_update_fw.attr,
 	NULL,
 };
-
-static const struct attribute_group hideep_ts_attr_group = {
-	.attrs = hideep_ts_sysfs_entries,
-};
+ATTRIBUTE_GROUPS(hideep_ts);
 
 static void hideep_set_work_mode(struct hideep_ts *ts)
 {
@@ -1096,13 +1093,6 @@ static int hideep_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(&client->dev, &hideep_ts_attr_group);
-	if (error) {
-		dev_err(&client->dev,
-			"failed to add sysfs attributes: %d\n", error);
-		return error;
-	}
-
 	return 0;
 }
 
@@ -1131,6 +1121,7 @@ MODULE_DEVICE_TABLE(of, hideep_match_table);
 static struct i2c_driver hideep_driver = {
 	.driver = {
 		.name			= HIDEEP_I2C_NAME,
+		.dev_groups		= hideep_ts_groups,
 		.of_match_table		= of_match_ptr(hideep_match_table),
 		.acpi_match_table	= ACPI_PTR(hideep_acpi_id),
 		.pm			= pm_sleep_ptr(&hideep_pm_ops),
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#15 lore raw

PATCH 12/22 Input: hycon-hy46xx - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/hycon-hy46xx.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/input/touchscreen/hycon-hy46xx.c +2 -8
index 2450cfa14de9..d0f257989fd6 100644
@@ -274,10 +274,7 @@ static struct attribute *hycon_hy46xx_attrs[] = {
 	&hycon_hy46xx_attr_bootloader_version.dattr.attr,
 	NULL
 };
-
-static const struct attribute_group hycon_hy46xx_attr_group = {
-	.attrs = hycon_hy46xx_attrs,
-};
+ATTRIBUTE_GROUPS(hycon_hy46xx);
 
 static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata)
 {
@@ -535,10 +532,6 @@ static int hycon_hy46xx_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(&client->dev, &hycon_hy46xx_attr_group);
-	if (error)
-		return error;
-
 	error = input_register_device(input);
 	if (error)
 		return error;
@@ -576,6 +569,7 @@ MODULE_DEVICE_TABLE(of, hycon_hy46xx_of_match);
 static struct i2c_driver hycon_hy46xx_driver = {
 	.driver = {
 		.name = "hycon_hy46xx",
+		.dev_groups = hycon_hy46xx_groups,
 		.of_match_table = hycon_hy46xx_of_match,
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 	},
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#16 lore raw

PATCH 13/22 Input: ili210x - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/ili210x.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/input/touchscreen/ili210x.c +5 -10
index ad6828e4f2e2..31ffdc2a93f3 100644
@@ -876,7 +876,7 @@ static ssize_t ili210x_firmware_update_store(struct device *dev,
 
 static DEVICE_ATTR(firmware_update, 0200, NULL, ili210x_firmware_update_store);
 
-static struct attribute *ili210x_attributes[] = {
+static struct attribute *ili210x_attrs[] = {
 	&dev_attr_calibrate.attr,
 	&dev_attr_firmware_update.attr,
 	&dev_attr_firmware_version.attr,
@@ -904,10 +904,11 @@ static umode_t ili210x_attributes_visible(struct kobject *kobj,
 	return attr->mode;
 }
 
-static const struct attribute_group ili210x_attr_group = {
-	.attrs = ili210x_attributes,
+static const struct attribute_group ili210x_group = {
+	.attrs = ili210x_attrs,
 	.is_visible = ili210x_attributes_visible,
 };
+__ATTRIBUTE_GROUPS(ili210x);
 
 static void ili210x_power_down(void *data)
 {
@@ -1013,13 +1014,6 @@ static int ili210x_i2c_probe(struct i2c_client *client)
 	if (error)
 		return error;
 
-	error = devm_device_add_group(dev, &ili210x_attr_group);
-	if (error) {
-		dev_err(dev, "Unable to create sysfs attributes, err: %d\n",
-			error);
-		return error;
-	}
-
 	error = input_register_device(priv->input);
 	if (error) {
 		dev_err(dev, "Cannot register input device, err: %d\n", error);
@@ -1050,6 +1044,7 @@ MODULE_DEVICE_TABLE(of, ili210x_dt_ids);
 static struct i2c_driver ili210x_ts_driver = {
 	.driver = {
 		.name = "ili210x_i2c",
+		.dev_groups = ili210x_groups,
 		.of_match_table = ili210x_dt_ids,
 	},
 	.id_table = ili210x_i2c_id,
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#17 lore raw

Re: [PATCH 13/22] Input: ili210x - use device core to create driver-specific device attributes

Quoted 23 lines · Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
  drivers/input/touchscreen/ili210x.c | 15 +++++----------
  1 file changed, 5 insertions(+), 10 deletions(-)
drivers/input/touchscreen/ili210x.c +1 -1
index ad6828e4f2e2..31ffdc2a93f3 100644
@@ -876,7 +876,7 @@ static ssize_t ili210x_firmware_update_store(struct device *dev,
 
  static DEVICE_ATTR(firmware_update, 0200, NULL, ili210x_firmware_update_store);
 
-static struct attribute *ili210x_attributes[] = {
+static struct attribute *ili210x_attrs[] = {
  	&dev_attr_calibrate.attr,
  	&dev_attr_firmware_update.attr,
  	&dev_attr_firmware_version.attr,

drivers/input/touchscreen/ili210x.c static umode_t ili210x_attributes_visible(struct kobject *kobj, · line 908

Quoted 7 lines
drivers/input/touchscreen/ili210x.c +2 -2
@@ -904,10 +904,11 @@ static umode_t ili210x_attributes_visible(struct kobject *kobj,
  	return attr->mode;
  }
 
-static const struct attribute_group ili210x_attr_group = {
-	.attrs = ili210x_attributes,
+static const struct attribute_group ili210x_group = {
+	.attrs = ili210x_attrs,

Is all the renaming really necessary and relevant to this patch ?

btw since I have your attention, could you also look at discussion [PATCH] Input: pwm-beeper - Support volume setting via sysfs ? I've been waiting for any maintainer input for over two months now.

Thanks

#18 lore raw

Re: [PATCH 13/22] Input: ili210x - use device core to create driver-specific device attributes

Quoted 22 lines · Marek Vasut
Quoted 21 lines · Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
  drivers/input/touchscreen/ili210x.c | 15 +++++----------
  1 file changed, 5 insertions(+), 10 deletions(-)
drivers/input/touchscreen/ili210x.c +1 -1
index ad6828e4f2e2..31ffdc2a93f3 100644
@@ -876,7 +876,7 @@ static ssize_t ili210x_firmware_update_store(struct device *dev,
  static DEVICE_ATTR(firmware_update, 0200, NULL, ili210x_firmware_update_store);
-static struct attribute *ili210x_attributes[] = {
+static struct attribute *ili210x_attrs[] = {
  	&dev_attr_calibrate.attr,
  	&dev_attr_firmware_update.attr,
  	&dev_attr_firmware_version.attr,
@@ -904,10 +904,11 @@ static umode_t ili210x_attributes_visible(struct kobject *kobj,
Quoted 8 lines

drivers/input/touchscreen/ili210x.c static umode_t ili210x_attributes_visible(struct kobject *kobj, · line 908

Quoted 6 lines
drivers/input/touchscreen/ili210x.c +2 -2
  	return attr->mode;
  }
-static const struct attribute_group ili210x_attr_group = {
-	.attrs = ili210x_attributes,
+static const struct attribute_group ili210x_group = {
+	.attrs = ili210x_attrs,

Is all the renaming really necessary and relevant to this patch ?

Yes, it's needed for the __ATTRIBUTE_GROUPS() macro.

thanks,

greg k-h

#19 lore raw

Re: [PATCH 13/22] Input: ili210x - use device core to create driver-specific device attributes

Quoted 32 lines · Greg Kroah-Hartman
Quoted 22 lines · Marek Vasut
Quoted 21 lines · Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
   drivers/input/touchscreen/ili210x.c | 15 +++++----------
   1 file changed, 5 insertions(+), 10 deletions(-)
drivers/input/touchscreen/ili210x.c +1 -1
index ad6828e4f2e2..31ffdc2a93f3 100644
@@ -876,7 +876,7 @@ static ssize_t ili210x_firmware_update_store(struct device *dev,
   static DEVICE_ATTR(firmware_update, 0200, NULL, ili210x_firmware_update_store);
-static struct attribute *ili210x_attributes[] = {
+static struct attribute *ili210x_attrs[] = {
   	&dev_attr_calibrate.attr,
   	&dev_attr_firmware_update.attr,
   	&dev_attr_firmware_version.attr,
@@ -904,10 +904,11 @@ static umode_t ili210x_attributes_visible(struct kobject *kobj,
Quoted 8 lines

drivers/input/touchscreen/ili210x.c static umode_t ili210x_attributes_visible(struct kobject *kobj, · line 908

Quoted 6 lines
drivers/input/touchscreen/ili210x.c +2 -2
   	return attr->mode;
   }
-static const struct attribute_group ili210x_attr_group = {
-	.attrs = ili210x_attributes,
+static const struct attribute_group ili210x_group = {
+	.attrs = ili210x_attrs,

Is all the renaming really necessary and relevant to this patch ?

Quoted 1 line

Yes, it's needed for the __ATTRIBUTE_GROUPS() macro.

Ah ok

author maintainer
#20 lore raw

PATCH 14/22 Input: ilitek_ts_i2c - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/ilitek_ts_i2c.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/input/touchscreen/ilitek_ts_i2c.c +2 -10
index 2f872e95fbba..90c4934e750a 100644
@@ -537,10 +537,7 @@ static struct attribute *ilitek_sysfs_attrs[] = {
 	&dev_attr_product_id.attr,
 	NULL
 };
-
-static struct attribute_group ilitek_attrs_group = {
-	.attrs = ilitek_sysfs_attrs,
-};
+ATTRIBUTE_GROUPS(ilitek_sysfs);
 
 static int ilitek_ts_i2c_probe(struct i2c_client *client)
 {
@@ -595,12 +592,6 @@ static int ilitek_ts_i2c_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(dev, &ilitek_attrs_group);
-	if (error) {
-		dev_err(dev, "sysfs create group failed: %d\n", error);
-		return error;
-	}
-
 	return 0;
 }
 
@@ -675,6 +666,7 @@ MODULE_DEVICE_TABLE(of, ilitek_ts_i2c_match);
 static struct i2c_driver ilitek_ts_i2c_driver = {
 	.driver = {
 		.name = ILITEK_TS_NAME,
+		.dev_groups = ilitek_sysfs_groups,
 		.pm = pm_sleep_ptr(&ilitek_pm_ops),
 		.of_match_table = of_match_ptr(ilitek_ts_i2c_match),
 		.acpi_match_table = ACPI_PTR(ilitekts_acpi_id),
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#21 lore raw

PATCH 15/22 Input: iqs5xx - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/iqs5xx.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/input/touchscreen/iqs5xx.c +3 -7
index b4768b66eb10..a3f4fb85bee5 100644
@@ -974,10 +974,11 @@ static umode_t iqs5xx_attr_is_visible(struct kobject *kobj,
 	return attr->mode;
 }
 
-static const struct attribute_group iqs5xx_attr_group = {
+static const struct attribute_group iqs5xx_group = {
 	.is_visible = iqs5xx_attr_is_visible,
 	.attrs = iqs5xx_attrs,
 };
+__ATTRIBUTE_GROUPS(iqs5xx);
 
 static int iqs5xx_suspend(struct device *dev)
 {
@@ -1053,12 +1054,6 @@ static int iqs5xx_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(&client->dev, &iqs5xx_attr_group);
-	if (error) {
-		dev_err(&client->dev, "Failed to add attributes: %d\n", error);
-		return error;
-	}
-
 	if (iqs5xx->input) {
 		error = input_register_device(iqs5xx->input);
 		if (error)
@@ -1089,6 +1084,7 @@ MODULE_DEVICE_TABLE(of, iqs5xx_of_match);
 static struct i2c_driver iqs5xx_i2c_driver = {
 	.driver = {
 		.name		= "iqs5xx",
+		.dev_groups	= iqs5xx_groups,
 		.of_match_table	= iqs5xx_of_match,
 		.pm		= pm_sleep_ptr(&iqs5xx_pm),
 	},
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Reviewed-by on v1 15/22
#22 lore raw

Re: [PATCH 15/22] Input: iqs5xx - use device core to create driver-specific device attributes

Quoted 5 lines · Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

Quoted 45 lines
---
 drivers/input/touchscreen/iqs5xx.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/input/touchscreen/iqs5xx.c +3 -7
index b4768b66eb10..a3f4fb85bee5 100644
@@ -974,10 +974,11 @@ static umode_t iqs5xx_attr_is_visible(struct kobject *kobj,
 	return attr->mode;
 }
 
-static const struct attribute_group iqs5xx_attr_group = {
+static const struct attribute_group iqs5xx_group = {
 	.is_visible = iqs5xx_attr_is_visible,
 	.attrs = iqs5xx_attrs,
 };
+__ATTRIBUTE_GROUPS(iqs5xx);
 
 static int iqs5xx_suspend(struct device *dev)
 {
@@ -1053,12 +1054,6 @@ static int iqs5xx_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(&client->dev, &iqs5xx_attr_group);
-	if (error) {
-		dev_err(&client->dev, "Failed to add attributes: %d\n", error);
-		return error;
-	}
-
 	if (iqs5xx->input) {
 		error = input_register_device(iqs5xx->input);
 		if (error)
@@ -1089,6 +1084,7 @@ MODULE_DEVICE_TABLE(of, iqs5xx_of_match);
 static struct i2c_driver iqs5xx_i2c_driver = {
 	.driver = {
 		.name		= "iqs5xx",
+		.dev_groups	= iqs5xx_groups,
 		.of_match_table	= iqs5xx_of_match,
 		.pm		= pm_sleep_ptr(&iqs5xx_pm),
 	},
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#23 lore raw

PATCH 16/22 Input: melfas-mip4 - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/melfas_mip4.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/input/touchscreen/melfas_mip4.c +2 -11
index 2ac4483fbc25..aa325486f618 100644
@@ -1419,10 +1419,7 @@ static struct attribute *mip4_attrs[] = {
 	&dev_attr_update_fw.attr,
 	NULL,
 };
-
-static const struct attribute_group mip4_attr_group = {
-	.attrs = mip4_attrs,
-};
+ATTRIBUTE_GROUPS(mip4);
 
 static int mip4_probe(struct i2c_client *client)
 {
@@ -1514,13 +1511,6 @@ static int mip4_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(&client->dev, &mip4_attr_group);
-	if (error) {
-		dev_err(&client->dev,
-			"Failed to create sysfs attribute group: %d\n", error);
-		return error;
-	}
-
 	return 0;
 }
 
@@ -1589,6 +1579,7 @@ static struct i2c_driver mip4_driver = {
 	.probe = mip4_probe,
 	.driver = {
 		.name = MIP4_DEVICE_NAME,
+		.dev_groups = mip4_groups,
 		.of_match_table = of_match_ptr(mip4_of_match),
 		.acpi_match_table = ACPI_PTR(mip4_acpi_match),
 		.pm = pm_sleep_ptr(&mip4_pm_ops),
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#24 lore raw

PATCH 17/22 Input: raydium_i2c_ts - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/raydium_i2c_ts.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/input/touchscreen/raydium_i2c_ts.c +3 -13
index 78dd3059d585..13c500e776f6 100644
@@ -1004,7 +1004,7 @@ static DEVICE_ATTR(boot_mode, S_IRUGO, raydium_i2c_boot_mode_show, NULL);
 static DEVICE_ATTR(update_fw, S_IWUSR, NULL, raydium_i2c_update_fw_store);
 static DEVICE_ATTR(calibrate, S_IWUSR, NULL, raydium_i2c_calibrate_store);
 
-static struct attribute *raydium_i2c_attributes[] = {
+static struct attribute *raydium_i2c_attrs[] = {
 	&dev_attr_update_fw.attr,
 	&dev_attr_boot_mode.attr,
 	&dev_attr_fw_version.attr,
@@ -1012,10 +1012,7 @@ static struct attribute *raydium_i2c_attributes[] = {
 	&dev_attr_calibrate.attr,
 	NULL
 };
-
-static const struct attribute_group raydium_i2c_attribute_group = {
-	.attrs = raydium_i2c_attributes,
-};
+ATTRIBUTE_GROUPS(raydium_i2c);
 
 static int raydium_i2c_power_on(struct raydium_data *ts)
 {
@@ -1174,14 +1171,6 @@ static int raydium_i2c_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(&client->dev,
-				   &raydium_i2c_attribute_group);
-	if (error) {
-		dev_err(&client->dev, "failed to create sysfs attributes: %d\n",
-			error);
-		return error;
-	}
-
 	return 0;
 }
 
@@ -1265,6 +1254,7 @@ static struct i2c_driver raydium_i2c_driver = {
 	.id_table = raydium_i2c_id,
 	.driver = {
 		.name = "raydium_ts",
+		.dev_groups = raydium_i2c_groups,
 		.pm = pm_sleep_ptr(&raydium_i2c_pm_ops),
 		.acpi_match_table = ACPI_PTR(raydium_acpi_id),
 		.of_match_table = of_match_ptr(raydium_of_match),
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#25 lore raw

PATCH 18/22 Input: rohm_bu21023 - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/rohm_bu21023.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/input/touchscreen/rohm_bu21023.c +2 -10
index 240424f06b98..4493ad0c9322 100644
@@ -854,10 +854,7 @@ static struct attribute *rohm_ts_attrs[] = {
 	&dev_attr_inv_y.attr,
 	NULL,
 };
-
-static const struct attribute_group rohm_ts_attr_group = {
-	.attrs = rohm_ts_attrs,
-};
+ATTRIBUTE_GROUPS(rohm_ts);
 
 static int rohm_ts_device_init(struct i2c_client *client, u8 setup2)
 {
@@ -1164,12 +1161,6 @@ static int rohm_bu21023_i2c_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(dev, &rohm_ts_attr_group);
-	if (error) {
-		dev_err(dev, "failed to create sysfs group: %d\n", error);
-		return error;
-	}
-
 	return error;
 }
 
@@ -1182,6 +1173,7 @@ MODULE_DEVICE_TABLE(i2c, rohm_bu21023_i2c_id);
 static struct i2c_driver rohm_bu21023_i2c_driver = {
 	.driver = {
 		.name = BU21023_NAME,
+		.dev_groups = rohm_ts_groups,
 	},
 	.probe = rohm_bu21023_i2c_probe,
 	.id_table = rohm_bu21023_i2c_id,
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#26 lore raw

PATCH 19/22 Input: s6sy761 - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/s6sy761.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/input/touchscreen/s6sy761.c +2 -8
index 998d99d18911..149cc2c4925e 100644
@@ -286,10 +286,7 @@ static struct attribute *s6sy761_sysfs_attrs[] = {
 	&dev_attr_devid.attr,
 	NULL
 };
-
-static struct attribute_group s6sy761_attribute_group = {
-	.attrs = s6sy761_sysfs_attrs
-};
+ATTRIBUTE_GROUPS(s6sy761_sysfs);
 
 static int s6sy761_power_on(struct s6sy761_data *sdata)
 {
@@ -465,10 +462,6 @@ static int s6sy761_probe(struct i2c_client *client)
 	if (err)
 		return err;
 
-	err = devm_device_add_group(&client->dev, &s6sy761_attribute_group);
-	if (err)
-		return err;
-
 	pm_runtime_enable(&client->dev);
 
 	return 0;
@@ -535,6 +528,7 @@ MODULE_DEVICE_TABLE(i2c, s6sy761_id);
 static struct i2c_driver s6sy761_driver = {
 	.driver = {
 		.name = S6SY761_DEV_NAME,
+		.dev_groups = s6sy761_sysfs_groups,
 		.of_match_table = of_match_ptr(s6sy761_of_match),
 		.pm = pm_ptr(&s6sy761_pm_ops),
 	},
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Reviewed-by on v1 19/22
#27 lore raw

Re: [PATCH 19/22] Input: s6sy761 - use device core to create driver-specific device attributes

Hi Dmitry,

Quoted 5 lines · Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

Andi

Quoted 42 lines
---
 drivers/input/touchscreen/s6sy761.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/input/touchscreen/s6sy761.c +2 -8
index 998d99d18911..149cc2c4925e 100644
@@ -286,10 +286,7 @@ static struct attribute *s6sy761_sysfs_attrs[] = {
 	&dev_attr_devid.attr,
 	NULL
 };
-
-static struct attribute_group s6sy761_attribute_group = {
-	.attrs = s6sy761_sysfs_attrs
-};
+ATTRIBUTE_GROUPS(s6sy761_sysfs);
 
 static int s6sy761_power_on(struct s6sy761_data *sdata)
 {
@@ -465,10 +462,6 @@ static int s6sy761_probe(struct i2c_client *client)
 	if (err)
 		return err;
 
-	err = devm_device_add_group(&client->dev, &s6sy761_attribute_group);
-	if (err)
-		return err;
-
 	pm_runtime_enable(&client->dev);
 
 	return 0;
@@ -535,6 +528,7 @@ MODULE_DEVICE_TABLE(i2c, s6sy761_id);
 static struct i2c_driver s6sy761_driver = {
 	.driver = {
 		.name = S6SY761_DEV_NAME,
+		.dev_groups = s6sy761_sysfs_groups,
 		.of_match_table = of_match_ptr(s6sy761_of_match),
 		.pm = pm_ptr(&s6sy761_pm_ops),
 	},
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#28 lore raw

PATCH 20/22 Input: stmfts - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/stmfts.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/input/touchscreen/stmfts.c +2 -8
index 56e371fd88fa..85010fa07908 100644
@@ -517,10 +517,7 @@ static struct attribute *stmfts_sysfs_attrs[] = {
 	&dev_attr_hover_enable.attr,
 	NULL
 };
-
-static struct attribute_group stmfts_attribute_group = {
-	.attrs = stmfts_sysfs_attrs
-};
+ATTRIBUTE_GROUPS(stmfts_sysfs);
 
 static int stmfts_power_on(struct stmfts_data *sdata)
 {
@@ -727,10 +724,6 @@ static int stmfts_probe(struct i2c_client *client)
 		}
 	}
 
-	err = devm_device_add_group(&client->dev, &stmfts_attribute_group);
-	if (err)
-		return err;
-
 	pm_runtime_enable(&client->dev);
 	device_enable_async_suspend(&client->dev);
 
@@ -804,6 +797,7 @@ MODULE_DEVICE_TABLE(i2c, stmfts_id);
 static struct i2c_driver stmfts_driver = {
 	.driver = {
 		.name = STMFTS_DEV_NAME,
+		.dev_groups = stmfts_sysfs_groups,
 		.of_match_table = of_match_ptr(stmfts_of_match),
 		.pm = pm_ptr(&stmfts_pm_ops),
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Reviewed-by on v1 20/22
#29 lore raw

Re: [PATCH 20/22] Input: stmfts - use device core to create driver-specific device attributes

Hi Dmitry,

Quoted 5 lines · Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

Andi

author maintainer
#30 lore raw

PATCH 21/22 Input: tsc2004/5 - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with sysfs_create_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/tsc2004.c      |  7 ++++---
 drivers/input/touchscreen/tsc2005.c      |  7 ++++---
 drivers/input/touchscreen/tsc200x-core.c | 18 +++++++-----------
 drivers/input/touchscreen/tsc200x-core.h |  1 +
 4 files changed, 16 insertions(+), 17 deletions(-)
drivers/input/touchscreen/tsc2004.c +4 -3
index b5e904c5b7c4..89c5248f66f6 100644
@@ -63,9 +63,10 @@ MODULE_DEVICE_TABLE(of, tsc2004_of_match);
 
 static struct i2c_driver tsc2004_driver = {
 	.driver = {
-		.name   = "tsc2004",
-		.of_match_table = of_match_ptr(tsc2004_of_match),
-		.pm     = pm_sleep_ptr(&tsc200x_pm_ops),
+		.name		= "tsc2004",
+		.dev_groups	= tsc200x_groups,
+		.of_match_table	= of_match_ptr(tsc2004_of_match),
+		.pm		= pm_sleep_ptr(&tsc200x_pm_ops),
 	},
 	.id_table       = tsc2004_idtable,
 	.probe          = tsc2004_probe,
drivers/input/touchscreen/tsc2005.c +4 -3
index b6dfbcfc8c19..1b40ce0ca1b9 100644
@@ -79,9 +79,10 @@ MODULE_DEVICE_TABLE(of, tsc2005_of_match);
 
 static struct spi_driver tsc2005_driver = {
 	.driver	= {
-		.name	= "tsc2005",
-		.of_match_table = of_match_ptr(tsc2005_of_match),
-		.pm	= pm_sleep_ptr(&tsc200x_pm_ops),
+		.name		= "tsc2005",
+		.dev_groups	= tsc200x_groups,
+		.of_match_table	= of_match_ptr(tsc2005_of_match),
+		.pm		= pm_sleep_ptr(&tsc200x_pm_ops),
 	},
 	.probe	= tsc2005_probe,
 	.remove	= tsc2005_remove,
drivers/input/touchscreen/tsc200x-core.c +7 -11
index b799f26fcf8f..a4c0e9db9bb9 100644
@@ -356,6 +356,12 @@ static const struct attribute_group tsc200x_attr_group = {
 	.attrs		= tsc200x_attrs,
 };
 
+const struct attribute_group *tsc200x_groups[] = {
+	&tsc200x_attr_group,
+	NULL
+};
+EXPORT_SYMBOL_GPL(tsc200x_groups);
+
 static void tsc200x_esd_work(struct work_struct *work)
 {
 	struct tsc200x *ts = container_of(work, struct tsc200x, esd_work.work);
@@ -553,25 +559,17 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
 		return error;
 
 	dev_set_drvdata(dev, ts);
-	error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group);
-	if (error) {
-		dev_err(dev,
-			"Failed to create sysfs attributes, err: %d\n", error);
-		goto disable_regulator;
-	}
 
 	error = input_register_device(ts->idev);
 	if (error) {
 		dev_err(dev,
 			"Failed to register input device, err: %d\n", error);
-		goto err_remove_sysfs;
+		goto disable_regulator;
 	}
 
 	irq_set_irq_wake(irq, 1);
 	return 0;
 
-err_remove_sysfs:
-	sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
 disable_regulator:
 	regulator_disable(ts->vio);
 	return error;
@@ -582,8 +580,6 @@ void tsc200x_remove(struct device *dev)
 {
 	struct tsc200x *ts = dev_get_drvdata(dev);
 
-	sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
-
 	regulator_disable(ts->vio);
 }
 EXPORT_SYMBOL_GPL(tsc200x_remove);
drivers/input/touchscreen/tsc200x-core.h +1 -0
index 4ded34425b21..37de91efd78e 100644
@@ -70,6 +70,7 @@
 
 extern const struct regmap_config tsc200x_regmap_config;
 extern const struct dev_pm_ops tsc200x_pm_ops;
+extern const struct attribute_group *tsc200x_groups[];
 
 int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
 		  struct regmap *regmap,
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
author maintainer
#31 lore raw

PATCH 22/22 Input: wdt87xx_i2c - use device core to create driver-specific device attributes

In reply to Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/touchscreen/wdt87xx_i2c.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/input/touchscreen/wdt87xx_i2c.c +4 -12
index cbc4750c53f9..128341a6696b 100644
@@ -944,10 +944,7 @@ static struct attribute *wdt87xx_attrs[] = {
 	&dev_attr_update_fw.attr,
 	NULL
 };
-
-static const struct attribute_group wdt87xx_attr_group = {
-	.attrs = wdt87xx_attrs,
-};
+ATTRIBUTE_GROUPS(wdt87xx);
 
 static void wdt87xx_report_contact(struct input_dev *input,
 				   struct wdt87xx_sys_param *param,
@@ -1104,12 +1101,6 @@ static int wdt87xx_ts_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = devm_device_add_group(&client->dev, &wdt87xx_attr_group);
-	if (error) {
-		dev_err(&client->dev, "create sysfs failed: %d\n", error);
-		return error;
-	}
-
 	return 0;
 }
 
@@ -1172,8 +1163,9 @@ static struct i2c_driver wdt87xx_driver = {
 	.probe		= wdt87xx_ts_probe,
 	.id_table	= wdt87xx_dev_id,
 	.driver	= {
-		.name	= WDT87XX_NAME,
-		.pm     = pm_sleep_ptr(&wdt87xx_pm_ops),
+		.name = WDT87XX_NAME,
+		.dev_groups = wdt87xx_groups,
+		.pm = pm_sleep_ptr(&wdt87xx_pm_ops),
 		.acpi_match_table = ACPI_PTR(wdt87xx_acpi_id),
 	},
 };
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Reviewed-by on v1 1/22
#32 lore raw
In reply to Dmitry Torokhov
Quoted 6 lines · Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

Quoted 45 lines
---
 drivers/input/keyboard/cros_ec_keyb.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/input/keyboard/cros_ec_keyb.c +3 -8
index e7ecfca838df..313b7a69dd69 100644
@@ -686,10 +686,11 @@ static umode_t cros_ec_keyb_attr_is_visible(struct kobject *kobj,
        return attr->mode;
 }
 
-static const struct attribute_group cros_ec_keyb_attr_group = {
+static const struct attribute_group cros_ec_keyb_group = {
        .is_visible = cros_ec_keyb_attr_is_visible,
        .attrs = cros_ec_keyb_attrs,
 };
+__ATTRIBUTE_GROUPS(cros_ec_keyb);
 
 static int cros_ec_keyb_probe(struct platform_device *pdev)
 {
@@ -730,12 +731,6 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
                return err;
        }
 
-       err = devm_device_add_group(dev, &cros_ec_keyb_attr_group);
-       if (err) {
-               dev_err(dev, "failed to create attributes: %d\n", err);
-               return err;
-       }
-
        ckdev->notifier.notifier_call = cros_ec_keyb_work;
        err = blocking_notifier_chain_register(&ckdev->ec->event_notifier,
                                               &ckdev->notifier);
@@ -782,6 +777,7 @@ static struct platform_driver cros_ec_keyb_driver = {
        .remove = cros_ec_keyb_remove,
        .driver = {
                .name = "cros-ec-keyb",
+               .dev_groups = cros_ec_keyb_groups,
                .of_match_table = of_match_ptr(cros_ec_keyb_of_match),
                .acpi_match_table = ACPI_PTR(cros_ec_keyb_acpi_match),
                .pm = pm_sleep_ptr(&cros_ec_keyb_pm_ops),
--

2.41.0.487.g6d72f3e995-goog

Reviewed-by on v1 1/22
#33 lore raw
In reply to Dmitry Torokhov
Quoted 8 lines · Dmitry Torokhov

Instead of creating driver-specific device attributes with devm_device_add_group() have device core do this by setting up dev_groups pointer in the driver structure.

---
 drivers/input/keyboard/cros_ec_keyb.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

All of these look great, thanks for doing them: