diff mbox series

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

Message ID 20230729005133.1095051-13-dmitry.torokhov@gmail.com (mailing list archive)
State Mainlined
Commit 6a539138be69ae814e332556663f639d4ac31880
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/ili210x.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Comments

Marek Vasut July 29, 2023, 3:07 p.m. UTC | #1
On 7/29/23 02:51, 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>
> ---
>   drivers/input/touchscreen/ili210x.c | 15 +++++----------
>   1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
> index ad6828e4f2e2..31ffdc2a93f3 100644
> --- a/drivers/input/touchscreen/ili210x.c
> +++ b/drivers/input/touchscreen/ili210x.c
> @@ -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 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
Greg Kroah-Hartman July 30, 2023, 11:38 a.m. UTC | #2
On Sat, Jul 29, 2023 at 05:07:17PM +0200, Marek Vasut wrote:
> On 7/29/23 02:51, 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>
> > ---
> >   drivers/input/touchscreen/ili210x.c | 15 +++++----------
> >   1 file changed, 5 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
> > index ad6828e4f2e2..31ffdc2a93f3 100644
> > --- a/drivers/input/touchscreen/ili210x.c
> > +++ b/drivers/input/touchscreen/ili210x.c
> > @@ -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 all the renaming really necessary and relevant to this patch ?

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

thanks,

greg k-h
Marek Vasut July 30, 2023, 12:24 p.m. UTC | #3
On 7/30/23 13:38, Greg Kroah-Hartman wrote:
> On Sat, Jul 29, 2023 at 05:07:17PM +0200, Marek Vasut wrote:
>> On 7/29/23 02:51, 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>
>>> ---
>>>    drivers/input/touchscreen/ili210x.c | 15 +++++----------
>>>    1 file changed, 5 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
>>> index ad6828e4f2e2..31ffdc2a93f3 100644
>>> --- a/drivers/input/touchscreen/ili210x.c
>>> +++ b/drivers/input/touchscreen/ili210x.c
>>> @@ -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 all the renaming really necessary and relevant to this patch ?
> 
> Yes, it's needed for the __ATTRIBUTE_GROUPS() macro.

Ah ok
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
index ad6828e4f2e2..31ffdc2a93f3 100644
--- a/drivers/input/touchscreen/ili210x.c
+++ b/drivers/input/touchscreen/ili210x.c
@@ -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,