netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Grundler <grundler@chromium.org>
To: Douglas Anderson <dianders@chromium.org>
Cc: linux-usb@vger.kernel.org,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Grant Grundler" <grundler@chromium.org>,
	"Hayes Wang" <hayeswang@realtek.com>,
	"Simon Horman" <horms@kernel.org>, "Bjørn Mork" <bjorn@mork.no>,
	netdev@vger.kernel.org, "Brian Geffon" <bgeffon@google.com>,
	"Alan Stern" <stern@rowland.harvard.edu>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2 3/3] r8152: Choose our USB config with choose_configuration() rather than probe()
Date: Fri, 1 Dec 2023 22:28:11 -0800	[thread overview]
Message-ID: <CANEJEGvVSrRnZNt_i637CW6ajY_AY+1YDRabhBpb62S9UK1xdA@mail.gmail.com> (raw)
In-Reply-To: <20231201102946.v2.3.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid>

On Fri, Dec 1, 2023 at 10:31 AM Douglas Anderson <dianders@chromium.org> wrote:
>
> If you deauthorize the r8152 device (by writing 0 to the "authorized"
> field in sysfs) and then reauthorize it (by writing a 1) then it no
> longer works. This is because when you do the above we lose the
> special configuration that we set in rtl8152_cfgselector_probe().
> Deauthorizing causes the config to be set to -1 and then reauthorizing
> runs the default logic for choosing the best config.
>
> I made an attempt to fix it so that the config is kept across
> deauthorizing / reauthorizing [1] but it was a bit ugly.
>
> Let's instead use the new USB core feature to override
> choose_configuration().
>
> This patch relies upon the patches ("usb: core: Don't force USB
> generic_subclass drivers to define probe()") and ("usb: core: Allow
> subclassed USB drivers to override usb_choose_configuration()")
>
> [1] https://lore.kernel.org/r/20231130154337.1.Ie00e07f07f87149c9ce0b27ae4e26991d307e14b@changeid
>
> Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
> Suggested-by: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>

Reviewed-by: Grant Grundler <grundler@chromium.org>

> ---
>
> Changes in v2:
> - ("Choose our USB config with choose_configuration()...) new for v2.
>
>  drivers/net/usb/r8152.c | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 2c5c1e91ded6..0da723d11326 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -10053,7 +10053,7 @@ static struct usb_driver rtl8152_driver = {
>         .disable_hub_initiated_lpm = 1,
>  };
>
> -static int rtl8152_cfgselector_probe(struct usb_device *udev)
> +static int rtl8152_cfgselector_choose_configuration(struct usb_device *udev)
>  {
>         struct usb_host_config *c;
>         int i, num_configs;
> @@ -10080,19 +10080,13 @@ static int rtl8152_cfgselector_probe(struct usb_device *udev)
>         if (i == num_configs)
>                 return -ENODEV;
>
> -       if (usb_set_configuration(udev, c->desc.bConfigurationValue)) {
> -               dev_err(&udev->dev, "Failed to set configuration %d\n",
> -                       c->desc.bConfigurationValue);
> -               return -ENODEV;
> -       }
> -
> -       return 0;
> +       return c->desc.bConfigurationValue;
>  }
>
>  static struct usb_device_driver rtl8152_cfgselector_driver = {
> -       .name =         MODULENAME "-cfgselector",
> -       .probe =        rtl8152_cfgselector_probe,
> -       .id_table =     rtl8152_table,
> +       .name = MODULENAME "-cfgselector",
> +       .choose_configuration = rtl8152_cfgselector_choose_configuration,
> +       .id_table = rtl8152_table,
>         .generic_subclass = 1,
>         .supports_autosuspend = 1,
>  };
> --
> 2.43.0.rc2.451.g8631bc7472-goog
>

  reply	other threads:[~2023-12-02  6:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-01 18:29 [PATCH v2 0/3] net: usb: r8152: Fix lost config across deauthorize+authorize Douglas Anderson
2023-12-01 18:29 ` [PATCH v2 1/3] usb: core: Don't force USB generic_subclass drivers to define probe() Douglas Anderson
2023-12-01 19:28   ` Alan Stern
2023-12-02  2:14   ` Grant Grundler
2023-12-01 18:29 ` [PATCH v2 2/3] usb: core: Allow subclassed USB drivers to override usb_choose_configuration() Douglas Anderson
2023-12-01 19:30   ` Alan Stern
2023-12-02 19:11   ` Bjørn Mork
2023-12-01 18:29 ` [PATCH net v2 3/3] r8152: Choose our USB config with choose_configuration() rather than probe() Douglas Anderson
2023-12-02  6:28   ` Grant Grundler [this message]
2023-12-05  2:27   ` Jakub Kicinski
2023-12-05  2:27 ` [PATCH v2 0/3] net: usb: r8152: Fix lost config across deauthorize+authorize Jakub Kicinski
2023-12-05  2:34   ` Greg Kroah-Hartman

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=CANEJEGvVSrRnZNt_i637CW6ajY_AY+1YDRabhBpb62S9UK1xdA@mail.gmail.com \
    --to=grundler@chromium.org \
    --cc=bgeffon@google.com \
    --cc=bjorn@mork.no \
    --cc=davem@davemloft.net \
    --cc=dianders@chromium.org \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hayeswang@realtek.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stern@rowland.harvard.edu \
    /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;
as well as URLs for NNTP newsgroup(s).