From: Bastien Nocera <hadess@hadess.net>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: USB <linux-usb@vger.kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>
Subject: Re: [PATCH v4] USB: Fix device driver race
Date: Fri, 24 Jul 2020 17:19:41 +0200 [thread overview]
Message-ID: <a5597e782ad99956ba0ac84af6bc2a9281a7af14.camel@hadess.net> (raw)
In-Reply-To: <CAHp75VeKgxcq8J8WFPhH8EBUoE3-TxGU0Tanc=Vb5ib_0VMVLA@mail.gmail.com>
On Fri, 2020-07-24 at 13:39 +0300, Andy Shevchenko wrote:
> On Fri, Jul 24, 2020 at 1:32 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Fri, Jul 24, 2020 at 12:03 PM Bastien Nocera <hadess@hadess.net>
> > wrote:
>
> ...
>
> > > +static int __usb_bus_reprobe_drivers(struct device *dev, void
> > > *data)
> > > +{
> > > + struct usb_device_driver *new_udriver = data;
> > > + struct usb_device_driver *udriver;
> > > + struct usb_device *udev;
> > > +
> > > + if (!dev->driver)
> > > + return 0;
> > > +
> > > + udriver = to_usb_device_driver(dev->driver);
> > > + if (udriver != &usb_generic_driver)
> > > + return 0;
> >
> > What about
> >
> > static bool is_dev_usb_generic_driver(dev)
> > {
> > struct usb_device_driver *udd = dev->driver ?
> > to_usb_device_driver(dev->driver) : NULL;
> >
> > return udd == &usb_generic_driver;
> > }
> >
> > if (!is_dev_usb_generic_driver)
> > return 0;
> >
> > ?
> >
> > > + udev = to_usb_device(dev);
> > > + if (usb_device_match_id(udev, new_udriver->id_table) !=
> > > NULL ||
> > > + (new_udriver->match && new_udriver->match(udev) ==
> > > 0))
> > > + device_reprobe(dev);
> > > +
> > > + return 0;
> >
> > What about
> >
> > udev = to_usb_device(dev);
> > if (usb_device_match_id(udev, new_udriver->id_table) == NULL)
> > return 0;
> > ?
> >
> > if (new_udriver->match && new_udriver->match(udev) == 0))
> > device_reprobe(dev);
> > return 0;
> >
> > > +}
>
> It actually sparks a lot of similarities with
> __check_usb_generic(). Perhaps you may unify them?
They might look alike, but apart from that last check (id_table and
match), they're really not. It's a different device driver that's
getting checked against the generic driver.
I tried to merge those, and it ended up being either completely wrong,
or just as long as the code that used to be there before.
next prev parent reply other threads:[~2020-07-24 15:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-24 8:59 [PATCH v4] USB: Fix device driver race Bastien Nocera
2020-07-24 10:18 ` Sergei Shtylyov
2020-07-24 15:16 ` Bastien Nocera
2020-07-24 10:32 ` Andy Shevchenko
2020-07-24 10:39 ` Andy Shevchenko
2020-07-24 15:19 ` Bastien Nocera [this message]
2020-07-24 15:19 ` Bastien Nocera
2020-07-24 15:27 ` Alan Stern
2020-07-24 16:52 ` Bastien Nocera
2020-07-24 17:08 ` Alan Stern
2020-07-24 17:14 ` Bastien Nocera
2020-07-25 9:17 ` Bastien Nocera
2020-07-24 20:05 ` Andy Shevchenko
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=a5597e782ad99956ba0ac84af6bc2a9281a7af14.camel@hadess.net \
--to=hadess@hadess.net \
--cc=andy.shevchenko@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--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