The attribute avoid_reset_quirk means the device should not be reset. when it is set, persist_enabled also should be set to 0 to prevent reset-resume when the device resumes. Current only in the usb_detect_quirks(), persist_enabled will be set depending on whether the dev's flag USB_QUIRK_RESET_MORPHS is set or not. And usb_detect_quirks() is only called in the hub_port_connect_change() when a new device is found. So after a device being enumerated, Changing attribute avod_reset_quirk will not set persist_enabled to 0 to prevent reset-resume. This patch is to change persist_enabled when attribute avoid_reset_quirk is modified. When attribute avoid_reset_quirk is set, attribute persist should be unmoidified and remains 0 since attribute avoid_reset_quirk means not able to be reset. So this patch also adds USB_QUIRK_RESET_MORPHS check before changing persist_enabled in the attribute persist callback(). Signed-off-by: Lan Tianyu <tianyu.lan@xxxxxxxxx> --- Documentation/usb/persist.txt | 5 ++++- drivers/usb/core/sysfs.c | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Documentation/usb/persist.txt b/Documentation/usb/persist.txt index 074b159..0e287d6 100644 --- a/Documentation/usb/persist.txt +++ b/Documentation/usb/persist.txt @@ -107,7 +107,10 @@ where the "..." should be filled in the with the device's ID. Disable the feature by writing 0 instead of 1. For hubs the feature is automatically and permanently enabled and the power/persist file doesn't even exist, so you only have to worry about setting it for -devices where it really matters. +devices where it really matters. When attribute avoid_reset_quirk +is set, the persist can't be changed and remains 0 since +avoid_reset_quirk means the device can't be reset and reset-resume +doesn't work for the device. Is this the best solution? diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 20b0add..37b6367 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -209,10 +209,13 @@ set_avoid_reset_quirk(struct device *dev, struct device_attribute *attr, if (sscanf(buf, "%d", &val) != 1 || val < 0 || val > 1) return -EINVAL; usb_lock_device(udev); - if (val) + if (val) { udev->quirks |= USB_QUIRK_RESET_MORPHS; - else + udev->persist_enabled = 0; + } else { udev->quirks &= ~USB_QUIRK_RESET_MORPHS; + udev->persist_enabled = 1; + } usb_unlock_device(udev); return count; } @@ -311,7 +314,8 @@ set_persist(struct device *dev, struct device_attribute *attr, return -EINVAL; usb_lock_device(udev); - udev->persist_enabled = !!value; + if (!(udev->quirks & USB_QUIRK_RESET_MORPHS)) + udev->persist_enabled = !!value; usb_unlock_device(udev); return count; } -- 1.7.6.rc2.8.g28eb -- 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