RE: [PATCH v8 1/5] usb: phy: add usb phy notify port status API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alan,

> > --- a/drivers/usb/core/hub.c
> > +++ b/drivers/usb/core/hub.c
> > @@ -614,6 +614,30 @@ static int hub_ext_port_status(struct usb_hub *hub,
> int port1, int type,
> >               ret = 0;
> >       }
> >       mutex_unlock(&hub->status_mutex);
> > +
> > +     /*
> > +      * There is no need to lock status_mutex here, because status_mutex
> > +      * protects hub->status, and the phy driver only checks the port
> > +      * status without changing the status.
> > +      */
> > +     if (!ret) {
> > +             struct usb_device *hdev = hub->hdev;
> > +
> > +             /*
> > +              * Applies to roothub only. That is, when hdev->parent is
> > +              * empty. Only roothub will be notified of port state
> > +              * changes, since the USB PHY only cares about changes at
> > +              * the next level.
> > +              */
> > +             if (hdev && !hdev->parent) {
> 
> hdev can never be NULL, so you don't need to test it.  Also, there is an
> is_root_hub() routine you can call here -- it's an inline defined in usb.h.  If you
> use that then you won't have to explain it in the comment.
> 
> To be fair, there are plenty of other places in the driver that test !hdev->parent
> (or !udev->parent) with no explanation.
> 

Using is_root_hub() is a good choice.

Thanks,
Stanley





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux