On Thu, 24 Aug 2006, Iñaky Pérez-González wrote: > > That's not so easy either. The fact is, hdev_to_hub() _isn't_ safe unless > > you possess some extra prior knowledge. > > which priori knowledge? I had assumed that as long as it has registered, > we were safe.
It's not enough for it to be registered; you have to know also that it is bound to the hub driver. And it can be unbound at almost any time, so you have to be in a context where you know that unbinding is blocked. For instance, if you own the hub's device lock, or the lock for one of its connected children, then you're safe. hub_port_wait_reset is one of those safe places. Although I see below in your new code you don't need to use hdev_to_hub at all. Which is a good thing. > There are no hubs per se in WUSB, hosts only have a 'virtual' root hub with > 'virtual' ports. Devices plug directly to that. > > Now, devices in WUSB are all variable speed. Someone added USB_SPEED_VARIABLE > in usb_ch9.h for wireless, so I reused that. It is kind of like the mark > that says 'these are WUSB devices'. Okay, I get it. > Ok, so then it'd boil down to: > > /** @returns 1 if hub is a WUSB root hub, 0 otherwise */ > static > unsigned hub_is_wusb(struct usb_hub *hub) > { > struct usb_hcd *hcd; > if (hub->hdev->parent != NULL) // no root hub? Make that comment: // not a root hub? > return 0; > hcd = container_of(hub->hdev->bus, struct usb_hcd, self); > return hcd->wireless; > } > > hub_port_wait_reset() > { > ... > if (hub_is_wusb(hub)) > udev->speed = USB_SPEED_VARIABLE; > else if (portstatus & USB_PORT_STAT_HIGH_SPEED) > ... > ... > } > > How does this look? It looks good. Alan Stern ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel