On Thursday 24 August 2006 11:17, Alan Stern wrote:
> On Thu, 24 Aug 2006, Perez-Gonzalez, Inaky wrote:

> > Nothing that exporting something like a safe_hdev_to_hub() to the
> > host API cannot do.
>
> 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.

> > >Are you sure you need to store this information in the hub structure?
> >
> > Yes, the point is I need to access it from hub_port_wait_reset()
> > to establish that the device speed is USB_SPEED_VARIABLE.
>
> I'm still confused.  Which devices need to be variable speed?  Is it only
> top-level devices on a wireless bus (i.e., those attached directly to the
> root hub)?  Or is it everything below a wireless port on any hub?  Or
> something else?

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'.

> As you can guess, I don't understand how wireless USB works.

I am not so far from there, believe me :)

> > >Wouldn't it make more sense to store it in the hcd structure instead?
> > >After all, it is a property of the entire bus and not just one
> > >particular hub, right?
> >
> > I could dig hub->hdev and then play something to guess if that
> > is a root hub and dig out a back pointer to hcd->self.root_hub.
> > But that'd be even more painful.
>
> No, it's easy.  To test for a root hub, all you need to do is see whether
> hub->hdev->parent is NULL (root hubs don't have parent hubs).  To go from
> a hub to its hcd is a little harder because it involves a routine that has
> been submitted but not yet accepted.  :-)  For now, you can do:
>
>       container_of(hub->hdev->bus, struct usb_hcd, self)
>
> With the new routine (in Greg's queue) you'll be able to write:
>
>       bus_to_hcd(hub->hdev->bus)

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?
                        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?

> > For now, as far as I can tell, the rest of the bus could care less;
> > maybe in the future it is needed? I don't know. The thing is the
> > decoupling between the bus and the root hub for this case is too
> > decoupled :)
>
> There's a reason for it to be that way.  If this is causing you problems,
> it's probably because you're trying to work against the design of Linux's
> USB stack.

Yep -- it was like that already loooong time ago; but takes some time to break 
into new code when you don't know some of the tricks and bits :)

-------------------------------------------------------------------------
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
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to