On Fri, 1 Dec 2006, Greg KH wrote:
> > 1) With regard to USB in general, how does one logically detach a single
> > device from a built-in driver (that is, NOT physically remove it from the
> > system) without unloading the driver itself? Specifically, I need to detach
> > an MSC device from the Kernel driver so I can claim it with a custom user
> > mode driver (with root privileges) that allows access to a manufacturing
> > interface for re-configuration and diagnostics. I don't want to shut down
> > the Kernel driver because I want the other attached MSC devices to continue
> > to operate. I would need to re-attach the device to the Kernel driver at
> > the close of the app.
>
> Thre are two ways to do it. An ioctl through usbfs (I think there's
> also a libusb call), or through a write to the sysfs directory for the
> device.
More specifically, the usbfs ioctl call is USBDEVFS_DISCONNECT. The
equivalent libusb routine is usb_detach_kernel_driver_np().
Using sysfs, you have to write the appropriate device name to the
"unbind" file in /sys/bus/usb/drivers/DRIVERNAME/. For instance, on my
machine:
# ls /sys/bus/usb/drivers/hub
1-0:1.0 3-0:1.0 5-0:1.0 7-0:1.0 new_id
2-0:1.0 4-0:1.0 6-0:1.0 bind unbind
# echo -n 1-0:1.0 >/sys/bus/usb/drivers/hub/unbind
This would unbind the hub driver from the 1-0:1.0 device. Writing the
device name to the "bind" file will rebind the driver to the device.
Alan Stern
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel