Re: Blackberry support: Barry vs. usb_storage, round 2

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Thu, 29 Nov 2007, Chris Frey wrote:

> Hi folks,
> 
> Recent Blackberry devices are a rather unique breed, since they provide
> multiple product ID's in one device, and a vendor-specific method
> to change between them.
> 
> The usual way to perform this change is to connect to the device,
> send some vendor specific control messages, and then do a
> usb_set_configuration().  For Classic devices, this causes the
> device to reset itself.  For Pearl devices, it waits for the host
> to call usb_reset().
> 
> The problem is that the new 8830 devices will reset on
> usb_set_configuration(), and a usb_reset() call will just undo the
> intended mode change and go back to the state it was in when you
> first plugged it in.
> 
> This causes the following race conditions between Barry and usb_storage
> on most Linux systems:
> 
> 	- plug in the 8830
> 	- usb_storage sees a Mass Storage interface, and connects with it
> 	- udev sees the device and runs bcharge at the same time
> 	- bcharge connects and sends the vendor specific control messages
> 	- bcharge calls usb_set_configuration() and nothing happens
> 		since usb_storage has an interface claimed
> 	- normally this is ok, for the Pearl, and bcharge calls
> 		usb_reset(), which sets the mode and everyone is happy...
> 
> But...
> 
> 	- for the 8830, usb_reset() goes back to the start, the mode is
> 		not changed, and there is no way to change it while
> 		usb_storage has Mass Storage claimed, since the mode
> 		change occurs on usb_set_configuration().
> 
> Questions:
> 
> 	- is there a safe way to delay usb_storage, perhaps from udev,
> 		so that when Barry is installed the mode is changed
> 		before usb_storage looks for a drive?

No.

> 	- is there a better way to handle this?  perhaps force usb_storage
> 		to release the interface somehow, since this only happens
> 		when the device is first plugged in?

Yes.  The bcharge program can unbind usb-storage from the mass-storage 
interface, if needed.  The libusb call is 
usb_detach_kernel_driver_np().  Or it can be accomplished through 
usbfs directly (USBDEVFS_DISCONNECT ioctl), or through sysfs.

Note that there's no point in doing this if Barry decides that it 
doesn't need to change the device's mode.

Alan Stern


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.