diff mbox series

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

Message ID 20230729005133.1095051-3-dmitry.torokhov@gmail.com
State Accepted
Commit 09adb31f6f6cf73d9be7a695ff030144fb64c91d
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/misc/iqs269a.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Comments

Jeff LaBundy July 31, 2023, 3:41 p.m. UTC | #1
On Fri, Jul 28, 2023 at 05:51:12PM -0700, Dmitry Torokhov wrote:
> 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>

Reviewed-by: Jeff LaBundy <jeff@labundy.com>

> ---
>  drivers/input/misc/iqs269a.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c
> index c0a085639870..3c636c75e8a1 100644
> --- a/drivers/input/misc/iqs269a.c
> +++ b/drivers/input/misc/iqs269a.c
> @@ -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),
>  	},
> -- 
> 2.41.0.487.g6d72f3e995-goog
>
Mattijs Korpershoek Aug. 2, 2023, 1:01 p.m. UTC | #2
On ven., juil. 28, 2023 at 17:51, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:

> 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>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
>  drivers/input/misc/iqs269a.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c
> index c0a085639870..3c636c75e8a1 100644
> --- a/drivers/input/misc/iqs269a.c
> +++ b/drivers/input/misc/iqs269a.c
> @@ -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),
>  	},
> -- 
> 2.41.0.487.g6d72f3e995-goog
diff mbox series

Patch

diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c
index c0a085639870..3c636c75e8a1 100644
--- a/drivers/input/misc/iqs269a.c
+++ b/drivers/input/misc/iqs269a.c
@@ -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),
 	},