commit cab586a29651eaf0f1cd964a0420ffd28b779de1 Author: Oliver Neukum <oliver@xxxxxxxxxx> Date: Fri Dec 18 12:02:09 2009 +0100 usb:Export USB_QUIRK_RESET_MORPHS through sysfs Some devices which use mode switching revert to their primary mode as they are reset. They must not be reset for error handling. As user spaces makes the switch it also has to tell the kernel that a device is quirky. Signed-off-by: Oliver Neukum <oliver@xxxxxxxxxx> diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 1547700..2756c11 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -181,6 +181,36 @@ show_quirks(struct device *dev, struct device_attribute *attr, char *buf) static DEVICE_ATTR(quirks, S_IRUGO, show_quirks, NULL); static ssize_t +show_reset_quirk(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct usb_device *udev; + + udev = to_usb_device(dev); + return sprintf(buf, "%d\n", !!(udev->quirks & USB_QUIRK_RESET_MORPHS)); +} + +static ssize_t +set_reset_quirk(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct usb_device *udev = to_usb_device(dev); + int config, value; + + if (sscanf(buf, "%d", &config) != 1 || config < 0 || config > 1) + return -EINVAL; + usb_lock_device(udev); + if (config) + udev->quirks |= USB_QUIRK_RESET_MORPHS; + else + udev->quirks &= ~USB_QUIRK_RESET_MORPHS; + usb_unlock_device(udev); + return count; +} + +static DEVICE_ATTR(reset_quirk, S_IRUGO | S_IWUSR, + show_reset_quirk, set_reset_quirk); + +static ssize_t show_urbnum(struct device *dev, struct device_attribute *attr, char *buf) { struct usb_device *udev; @@ -548,6 +578,7 @@ static struct attribute *dev_attrs[] = { &dev_attr_version.attr, &dev_attr_maxchild.attr, &dev_attr_quirks.attr, + &dev_attr_reset_quirk.attr, &dev_attr_authorized.attr, &dev_attr_remove.attr, NULL, -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html