On Thu, 30 Mar 2000, Johannes Erdfelt wrote:

> On Thu, Mar 30, 2000, Matthew Dharm <[EMAIL PROTECTED]> wrote:
> > How do I do, from kernel space, a port reset on a device?  Apparently
> > there are some devices (ie a CD-ROM which is reading from a dirty disk)
> > which will get into a jammed state and require a port reset to un-jam it.
> > 
> > At least, according to the spec, a port reset is the "more drastic action"
> > that I should try next.
> > 
> > So, how do I do this?
> 
> Nonexistant right now. The code to do it would look something like this:
> 
> int usb_reset_device(struct usb_device *dev)
> {
>       struct usb_device *parent = dev->parent;
>       int i;
> 
>       for (i = 0; i < parent->maxchild; i++) {
>               if (parent->children[i] == dev)
>                       usb_set_port_feature(parent, i,
>                               USB_PORT_FEAT_RESET);
>       }
> 
>       return 0;
> }
> 
> I haven't tested the code (not even tried compiling it), but I think it
> should work. I know the above code won't work on a root hub (it'll
> oops).

Hrm... we'll need a solution that works on root hubs, also.

Does someone want to volunteer to test this code this weekend?  Perhaps
someone with a bus scope?

> The device should disconnect and then reconnect. This will cause it to
> go through the normal connect and disconnect code paths. This means that
> dev, after calling the function is invalid.

Will this disconnect and reconnect be serialized?  Transactions which go
through hubs are serialized, so I expect so.  But I've been wrong before,
so I want to ask explicitly.

Also, will the disconnect and reconnect occur before the function returns?
Just the disconnect?  Neither?

> usb_set_port_feature is part of hub.c (declared static) so you may want
> to throw the function in hub.c and export the symbol from there.

Probably a good idea.  Or, perhaps it could go into usb.c -- tho in either
case it winds up in the core module.

Matt Dharm

-- 
Matthew Dharm                              Home: [EMAIL PROTECTED] 
Engineer, Qualcomm, Inc.                         Work: [EMAIL PROTECTED]

It was a new hope.
                                        -- Dust Puppy
User Friendly, 12/25/1998


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to