]> git.baikalelectronics.ru Git - kernel.git/commit
USB: add a "remove hardware" sysfs attribute
authorAlan Stern <stern@rowland.harvard.edu>
Tue, 27 Oct 2009 19:20:13 +0000 (15:20 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 11 Dec 2009 19:55:18 +0000 (11:55 -0800)
commitf5ccf072cd94a5fa8e61b0ce5ed7390fa6a46328
treeff29ac01c681b183db2ad4b18b95b6c3dbe0ca0b
parent8a0e12fd52215dbd7f8119c8b04598742e65d953
USB: add a "remove hardware" sysfs attribute

This patch (as1297) adds a "remove" attribute to each USB device's
directory in sysfs.  Writing to this attribute causes the device to be
deconfigured (the same as writing 0 to the "bConfigurationValue"
attribute) and then tells the hub driver to disable the device's
upstream port.  The device remains locked during these activities so
there is no possibility of it getting reconfigured in between.  The
port will remain disabled until after the device is unplugged.

The purpose of this is to provide a means for user programs to imitate
the "Safely remove hardware" applet in Windows.  Some devices do
expect their ports to be disabled before they are unplugged, and they
provide visual feedback to users indicating when they can safely be
unplugged.

The security implications are minimal.  Writing to the "remove"
attribute is no more dangerous than writing to the
"bConfigurationValue" attribute.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: David Zeuthen <davidz@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/hub.c
drivers/usb/core/sysfs.c
drivers/usb/core/usb.h