From 3f141e2aed586c41c2666d49c70c1c1bbb6d6abd Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Thu, 8 Feb 2007 16:40:43 -0500 Subject: USB: unconfigure devices which have config 0 Some USB devices do have a configuration 0, in contravention of the USB spec. Normally 0 is supposed to indicate that a device is unconfigured. While we can't change what the device is doing, we can change usbcore. This patch (as852) allows usb_set_configuration() to accept a config value of -1 as indicating that the device should be unconfigured. The request actually sent to the device will still contain 0 as the value. But even if the device does have a configuration 0, dev->actconfig will be set to NULL and dev->state will be set to USB_STATE_ADDRESS. Without some sort of special-case handling like this, there is no way to unconfigure these non-compliant devices. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/core/sysfs.c') diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 4eaa0ee8e72..0edfbafd702 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -63,7 +63,7 @@ set_bConfigurationValue(struct device *dev, struct device_attribute *attr, struct usb_device *udev = to_usb_device(dev); int config, value; - if (sscanf(buf, "%u", &config) != 1 || config > 255) + if (sscanf(buf, "%d", &config) != 1 || config < -1 || config > 255) return -EINVAL; usb_lock_device(udev); value = usb_set_configuration(udev, config); -- cgit v1.2.3