On Mon, 30 Jul 2012, Lan Tianyu wrote: > 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. You should avoid mentioning things the reader won't understand. The term "reset-resume" is not used in persist.txt, and you shouldn't introduce it like this. Just end the sentence after "can't be reset". > @@ -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; If USB_QUIRK_RESET_MORPHS is set, you should return an error code such as -EINVAL. > usb_unlock_device(udev); > return count; > } Alan Stern -- 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