[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251021062629.2919772-1-yicongsrfy@163.com>
Date: Tue, 21 Oct 2025 14:26:29 +0800
From: Yi Cong <yicongsrfy@....com>
To: stern@...land.harvard.edu
Cc: andrew+netdev@...n.ch,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
linux-usb@...r.kernel.org,
michal.pecio@...il.com,
netdev@...r.kernel.org,
oliver@...kum.org,
pabeni@...hat.com
Subject: Re: [PATCH net v5 2/3] net: usb: ax88179_178a: add USB device driver for config selection
On Mon, 20 Oct 2025 22:59:36 -0400, Alan Stern <stern@...land.harvard.edu> wrote:
>
> On Tue, Oct 21, 2025 at 10:29:25AM +0800, Yi Cong wrote:
> > On Mon, 20 Oct 2025 11:56:50 -0400, Alan Stern <stern@...land.harvard.edu> wrote:
> > >
> > > Instead of all this preferred() stuff, why not have the ax88179 driver's
> > > probe routine check for a different configuration with a vendor-specific
> > > interface? If that other config is present and the chip is the right
> > > type then you can call usb_driver_set_configuration() -- this is exactly
> > > what it's meant for.
> >
> > I tried calling usb_driver_set_configuration inside driver's probe()
> > to select the configuration, but my USB network card has three
> > configurations (bNumConfigurations=3), which causes usb_driver_set_configuration
> > to be called twice within probe():
> > ```
> > static int ax88179_probe()
> > {
> > if (bConfigurationValue != I_WANT) {
> > usb_driver_set_configuration(udev, I_WANT)
> > return -ENODEV;
> > }
> > //else really probe
> > }
> > ```
>
> Why is it called twice? The first time probe() runs, it calls
> usb_driver_set_configuration() with the config that you want. Then the
> second time probe() runs, the config you want has been installed, so
> there's no reason to call usb_driver_set_configuration() again.
>
> Unless something is going wrong, that's how it should work. And the
> total number of configurations should not matter.
It might not be caused by the number of configurations, but rather by
the fact that usb_driver_set_configuration handles configuration changes
through a work queue.
I suspect this is the reason (although I haven't verified it further
—I just observed this behavior and switched to a different implementation
by using choose_configuration):
```
int usb_driver_set_configuration(struct usb_device *udev, int config)
{
...
INIT_WORK(&req->work, driver_set_config_work);
schedule_work(&req->work);
return 0;
}
```
Powered by blists - more mailing lists