linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: elan_i2c - convert to use dev_groups
@ 2022-07-29 13:58 Greg Kroah-Hartman
  2022-07-29 18:43 ` Dmitry Torokhov
  2022-08-02 16:48 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2022-07-29 13:58 UTC (permalink / raw)
  To: linux-input
  Cc: Greg Kroah-Hartman, Dmitry Torokhov, Hans de Goede, jingle.wu,
	linux-kernel

The driver core supports the ability to handle the creation and removal
of device-specific sysfs files in a race-free manner.  Take advantage of
that by converting this driver to use this by moving the sysfs
attributes into a group and assigning the dev_groups pointer to it.

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "jingle.wu" <jingle.wu@emc.com.tw>
Cc: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/input/mouse/elan_i2c_core.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index e1758d5ffe42..d4eb59b55bf1 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -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,
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Input: elan_i2c - convert to use dev_groups
  2022-07-29 13:58 [PATCH] Input: elan_i2c - convert to use dev_groups Greg Kroah-Hartman
@ 2022-07-29 18:43 ` Dmitry Torokhov
  2022-07-30  7:37   ` Greg Kroah-Hartman
  2022-08-02 16:48 ` Greg Kroah-Hartman
  1 sibling, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2022-07-29 18:43 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-input, Hans de Goede, jingle.wu, linux-kernel

Hi Greg,

On Fri, Jul 29, 2022 at 03:58:16PM +0200, Greg Kroah-Hartman wrote:
> The driver core supports the ability to handle the creation and removal
> of device-specific sysfs files in a race-free manner.  Take advantage of
> that by converting this driver to use this by moving the sysfs
> attributes into a group and assigning the dev_groups pointer to it.

I obviously like this patch as the less boilerplate code the better, but
I am not sure what race are you talking about in the commit message?
Could you please elaborate?

Thanks!

> 
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "jingle.wu" <jingle.wu@emc.com.tw>
> Cc: linux-input@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/input/mouse/elan_i2c_core.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
> index e1758d5ffe42..d4eb59b55bf1 100644
> --- a/drivers/input/mouse/elan_i2c_core.c
> +++ b/drivers/input/mouse/elan_i2c_core.c
> @@ -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,
> -- 
> 2.37.1
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Input: elan_i2c - convert to use dev_groups
  2022-07-29 18:43 ` Dmitry Torokhov
@ 2022-07-30  7:37   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2022-07-30  7:37 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, Hans de Goede, jingle.wu, linux-kernel

On Fri, Jul 29, 2022 at 11:43:03AM -0700, Dmitry Torokhov wrote:
> Hi Greg,
> 
> On Fri, Jul 29, 2022 at 03:58:16PM +0200, Greg Kroah-Hartman wrote:
> > The driver core supports the ability to handle the creation and removal
> > of device-specific sysfs files in a race-free manner.  Take advantage of
> > that by converting this driver to use this by moving the sysfs
> > attributes into a group and assigning the dev_groups pointer to it.
> 
> I obviously like this patch as the less boilerplate code the better, but
> I am not sure what race are you talking about in the commit message?
> Could you please elaborate?

The race is normally because the device is announced to userspace before
the attributes are added.  But you are right, the race is still the same
here, the attributes are added after probe succeeds, so it's the same
time, so this changelog text is wrong, sorry about that.

I'll rewrite this to just say it's cleaner and simpler with this change
and resend it in a few days.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Input: elan_i2c - convert to use dev_groups
  2022-07-29 13:58 [PATCH] Input: elan_i2c - convert to use dev_groups Greg Kroah-Hartman
  2022-07-29 18:43 ` Dmitry Torokhov
@ 2022-08-02 16:48 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2022-08-02 16:48 UTC (permalink / raw)
  To: linux-input; +Cc: Dmitry Torokhov, Hans de Goede, jingle.wu, linux-kernel

On Fri, Jul 29, 2022 at 03:58:16PM +0200, Greg Kroah-Hartman wrote:
> The driver core supports the ability to handle the creation and removal
> of device-specific sysfs files in a race-free manner.  Take advantage of
> that by converting this driver to use this by moving the sysfs
> attributes into a group and assigning the dev_groups pointer to it.
> 
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "jingle.wu" <jingle.wu@emc.com.tw>
> Cc: linux-input@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/input/mouse/elan_i2c_core.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)

v2 is now here:
	https://lore.kernel.org/r/20220802162854.3015369-1-gregkh@linuxfoundation.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-02 16:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-29 13:58 [PATCH] Input: elan_i2c - convert to use dev_groups Greg Kroah-Hartman
2022-07-29 18:43 ` Dmitry Torokhov
2022-07-30  7:37   ` Greg Kroah-Hartman
2022-08-02 16:48 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).