dev->some_urb = ... alloc+save, locked against disconnect ...
	sync_control_message (urb, bRequest, bRequestType, ...,
		INTERRUPTIBLE or maybe not, TIMEOUT or zero)
	switch (urb->status) {
	...
	}
	free dev->some_urb

and the disconnect code could just unlink all active/submitted urbs.

Is this intended to be pseudocode that is executed in the driver?  What's
Yes, though actually I recall the timeout logic was in the sync() wrapper
not separate (I'd have to dig out that code) so I tweaked it above ... :)


the advantage of this over a roll-your-own synchronous message using
usb_submit_urb()?  The only reason for having the synchronous message
routines in the core was to provide the convenience of not having to
allocate a URB, not having to set up a timeout, and not having to
deallocate everything at the end.  This just puts all that overhead back
into the driver.
I wouldn't say the "only" reason (think about code size reductions too,
getting the setup packet right, making sure _everything_ is done right,
and so on), or that those are all equally important.

Put it this way:  using a primitive like gives the abilities to

 (a) let interrupts cancel I/O, when appropriate;
 (b) let other things do so too, like a "scsi_eh" thread;
 (c) see complete status: "got ETIMEDOUT after delivering 196 bytes";
 (d) handle disconnect correctly without other usbcore/hcd changes.

And the cost is only adding urb alloc/free; cheap at the price.


But as Matt Dharm pointed out, having the core/HCD automatically cancel
any URBs for a disconnected device (and refuse to accept new submissions
as well) would provide the most straightforward solution -- at least, from
a device driver author's point of view.
I'd like to see that, but it only addresses the disconnect part of the
puzzle, not the others I mentioned above.

- Dave




-------------------------------------------------------
This sf.net email is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0002en

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to