public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <syrjala@sci.fi>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] Input: ati-remote2 - use driver core to instantiate device attributes
Date: Thu, 11 Jul 2024 19:18:54 +0300	[thread overview]
Message-ID: <ZpAF7gqeF589IkTA@sci.fi> (raw)
In-Reply-To: <Zo8gaF_lKPAfcye1@google.com>

On Wed, Jul 10, 2024 at 04:59:36PM -0700, Dmitry Torokhov wrote:
> Instead of manually creating driver-specific device attributes
> set struct usb_driver->dev_groups pointer to have the driver core
> do it.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/misc/ati_remote2.c | 50 +++++++++++---------------------
>  1 file changed, 17 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
> index 946bf75aa106..795f69edb4b2 100644
> --- a/drivers/input/misc/ati_remote2.c
> +++ b/drivers/input/misc/ati_remote2.c
> @@ -204,26 +204,7 @@ struct ati_remote2 {
>  	unsigned int mode_mask;
>  };
>  
> -static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id);
> -static void ati_remote2_disconnect(struct usb_interface *interface);
> -static int ati_remote2_suspend(struct usb_interface *interface, pm_message_t message);
> -static int ati_remote2_resume(struct usb_interface *interface);
> -static int ati_remote2_reset_resume(struct usb_interface *interface);
> -static int ati_remote2_pre_reset(struct usb_interface *interface);
> -static int ati_remote2_post_reset(struct usb_interface *interface);
> -
> -static struct usb_driver ati_remote2_driver = {
> -	.name       = "ati_remote2",
> -	.probe      = ati_remote2_probe,
> -	.disconnect = ati_remote2_disconnect,
> -	.id_table   = ati_remote2_id_table,
> -	.suspend    = ati_remote2_suspend,
> -	.resume     = ati_remote2_resume,
> -	.reset_resume = ati_remote2_reset_resume,
> -	.pre_reset  = ati_remote2_pre_reset,
> -	.post_reset = ati_remote2_post_reset,
> -	.supports_autosuspend = 1,
> -};
> +static struct usb_driver ati_remote2_driver;

Would be easier to see what's actually happening if
the rearrangement of the forward declarations was a
separate patch.

Otherwise lgtm
Reviewed-by: Ville Syrjälä <syrjala@sci.fi>

>  
>  static int ati_remote2_submit_urbs(struct ati_remote2 *ar2)
>  {
> @@ -791,10 +772,7 @@ static struct attribute *ati_remote2_attrs[] = {
>  	&dev_attr_mode_mask.attr,
>  	NULL,
>  };
> -
> -static struct attribute_group ati_remote2_attr_group = {
> -	.attrs = ati_remote2_attrs,
> -};
> +ATTRIBUTE_GROUPS(ati_remote2);
>  
>  static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id)
>  {
> @@ -861,13 +839,9 @@ static int ati_remote2_probe(struct usb_interface *interface, const struct usb_d
>  
>  	strlcat(ar2->name, "ATI Remote Wonder II", sizeof(ar2->name));
>  
> -	r = sysfs_create_group(&udev->dev.kobj, &ati_remote2_attr_group);
> -	if (r)
> -		goto fail3;
> -
>  	r = ati_remote2_input_init(ar2);
>  	if (r)
> -		goto fail4;
> +		goto fail3;
>  
>  	usb_set_intfdata(interface, ar2);
>  
> @@ -875,8 +849,6 @@ static int ati_remote2_probe(struct usb_interface *interface, const struct usb_d
>  
>  	return 0;
>  
> - fail4:
> -	sysfs_remove_group(&udev->dev.kobj, &ati_remote2_attr_group);
>   fail3:
>  	ati_remote2_urb_cleanup(ar2);
>   fail2:
> @@ -900,8 +872,6 @@ static void ati_remote2_disconnect(struct usb_interface *interface)
>  
>  	input_unregister_device(ar2->idev);
>  
> -	sysfs_remove_group(&ar2->udev->dev.kobj, &ati_remote2_attr_group);
> -
>  	ati_remote2_urb_cleanup(ar2);
>  
>  	usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]);
> @@ -1032,4 +1002,18 @@ static int ati_remote2_post_reset(struct usb_interface *interface)
>  	return r;
>  }
>  
> +static struct usb_driver ati_remote2_driver = {
> +	.name       = "ati_remote2",
> +	.probe      = ati_remote2_probe,
> +	.disconnect = ati_remote2_disconnect,
> +	.dev_groups = ati_remote2_groups,
> +	.id_table   = ati_remote2_id_table,
> +	.suspend    = ati_remote2_suspend,
> +	.resume     = ati_remote2_resume,
> +	.reset_resume = ati_remote2_reset_resume,
> +	.pre_reset  = ati_remote2_pre_reset,
> +	.post_reset = ati_remote2_post_reset,
> +	.supports_autosuspend = 1,
> +};
> +
>  module_usb_driver(ati_remote2_driver);
> -- 
> 2.45.2.803.g4e1b14247a-goog
> 
> 
> -- 
> Dmitry

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/

      parent reply	other threads:[~2024-07-11 16:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-10 23:59 [PATCH] Input: ati-remote2 - use driver core to instantiate device attributes Dmitry Torokhov
2024-07-11  7:43 ` Greg Kroah-Hartman
2024-07-11 16:18 ` Ville Syrjälä [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZpAF7gqeF589IkTA@sci.fi \
    --to=syrjala@sci.fi \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox