On Tue, 26 Jun 2007, Jüri Reitel wrote:

> Hello.
> How to correctly turn off the port power of usb hub (assuming hub 
> supports individual port power switching). Correctly means that all 
> drivers using the device on that port are notified before the power is 
> removed. Removed device could also be a usb hub.
> 
> My experiments with function
> usb_control_msg(
>     hdev, usb_sndctrlpipe(hdev, 0),
>     USB_REQ_CLEAR_FEATURE,
>     USB_RT_PORT,
>     USB_PORT_FEAT_POWER,
>     port1,
>     NULL, 0, 1000);
> 
> will not give desired results.
> When I try to turn off port power with usb_control_msg, the port resides 
> on usb hub (not root hub), then the power is indeed switched off but 
> drivers are not notified.

You don't just want to notify the drivers; you want to destroy the
entire device data structure.  The only way to do it is to acquire the
hub's device lock and call usb_disconnect() in hub.c.  (Note that
usb_disconnect is not EXPORT'ed.)  Then turn off the
USB_PORT_FEAT_C_CONNECTION and USB_PORT_FEAT_C_ENABLE status bits for
that port in the hub and release the hub's lock.

> The devices I use are usb 1.1 and 2.0 mass 
> storage devices, linux kernel 2.6.18. After the feat power feature was 
> cleared the power went away for a couple of seconds but then (i think 
> this was the scsi subsystem who wanted to perform IO with the device) 
> usb subsystem found logical disconnect on port and the device was 
> re-powered... Things get more complicated if port power must be switched 
> off on root hub that has kind of controller where each port is shared by 
> ohci - ehci driver. Most 2.0 pci to usb root hubs fall to that category. 
> If the port is used by both drivers (actually the sharing starts from 
> hardware) then the power must be turned off (port power feature cleared) 
> on both controllers. I don't know the generic solution how to set up 
> port mapping, except looking to the datasheet.

Things are much worse with root hubs.  In general they do _not_ support 
port power switching.

> My question is how can I notify all drivers related to given usb hub 
> port when i have (struct usb_device *dev)
> where dev is the device on hub port where the power must be switched off?

usb_disconnect() will notify all those drivers for you.

Alan Stern


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to