diff mbox series

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

Message ID 20230729005133.1095051-6-dmitry.torokhov@gmail.com
State Accepted
Commit a32fa4359a7b7766631549db427a183c5c6d032e
Headers show
Series [01/22] Input: cros_ec_keyb - use device core to create driver-specific device attributes | expand

Commit Message

Dmitry Torokhov July 29, 2023, 12:51 a.m. UTC
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.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 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(-)

Comments

Hennerich, Michael July 31, 2023, 5:23 a.m. UTC | #1
> -----Original Message-----
> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Sent: Samstag, 29. Juli 2023 02:51
> To: linux-input@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org; Greg Kroah-Hartman
> <gregkh@linuxfoundation.org>; Hennerich, Michael
> <Michael.Hennerich@analog.com>
> Subject: [PATCH 06/22] Input: ad7879 - 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.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  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(-)
> 
> diff --git a/drivers/input/touchscreen/ad7879-i2c.c
> b/drivers/input/touchscreen/ad7879-i2c.c
> index feaa6f8b01ed..5c094ab74698 100644
> --- a/drivers/input/touchscreen/ad7879-i2c.c
> +++ b/drivers/input/touchscreen/ad7879-i2c.c
> @@ -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,
> diff --git a/drivers/input/touchscreen/ad7879-spi.c
> b/drivers/input/touchscreen/ad7879-spi.c
> index 50e889846800..064968fe57cf 100644
> --- a/drivers/input/touchscreen/ad7879-spi.c
> +++ b/drivers/input/touchscreen/ad7879-spi.c
> @@ -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,
>  };
> diff --git a/drivers/input/touchscreen/ad7879.c
> b/drivers/input/touchscreen/ad7879.c
> index e850853328f1..e5d69bf2276e 100644
> --- a/drivers/input/touchscreen/ad7879.c
> +++ b/drivers/input/touchscreen/ad7879.c
> @@ -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;
> diff --git a/drivers/input/touchscreen/ad7879.h
> b/drivers/input/touchscreen/ad7879.h
> index ae8aa1428e56..d71a8e787290 100644
> --- a/drivers/input/touchscreen/ad7879.h
> +++ b/drivers/input/touchscreen/ad7879.h
> @@ -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
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/ad7879-i2c.c b/drivers/input/touchscreen/ad7879-i2c.c
index feaa6f8b01ed..5c094ab74698 100644
--- a/drivers/input/touchscreen/ad7879-i2c.c
+++ b/drivers/input/touchscreen/ad7879-i2c.c
@@ -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,
diff --git a/drivers/input/touchscreen/ad7879-spi.c b/drivers/input/touchscreen/ad7879-spi.c
index 50e889846800..064968fe57cf 100644
--- a/drivers/input/touchscreen/ad7879-spi.c
+++ b/drivers/input/touchscreen/ad7879-spi.c
@@ -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,
 };
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index e850853328f1..e5d69bf2276e 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -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;
diff --git a/drivers/input/touchscreen/ad7879.h b/drivers/input/touchscreen/ad7879.h
index ae8aa1428e56..d71a8e787290 100644
--- a/drivers/input/touchscreen/ad7879.h
+++ b/drivers/input/touchscreen/ad7879.h
@@ -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,