This patch (as906) improves the error handling for the USB power/level
attribute file.  If an error occurs, the original power-level settings
will be restored.

Signed-off-by: Alan Stern <[EMAIL PROTECTED]>

---

Index: usb-2.6/drivers/usb/core/sysfs.c
===================================================================
--- usb-2.6.orig/drivers/usb/core/sysfs.c
+++ usb-2.6/drivers/usb/core/sysfs.c
@@ -232,12 +232,15 @@ set_level(struct device *dev, struct dev
        int len = count;
        char *cp;
        int rc = 0;
+       int old_autosuspend_disabled, old_autoresume_disabled;
 
        cp = memchr(buf, '\n', count);
        if (cp)
                len = cp - buf;
 
        usb_lock_device(udev);
+       old_autosuspend_disabled = udev->autosuspend_disabled;
+       old_autoresume_disabled = udev->autoresume_disabled;
 
        /* Setting the flags without calling usb_pm_lock is a subject to
         * races, but who cares...
@@ -263,6 +266,10 @@ set_level(struct device *dev, struct dev
        } else
                rc = -EINVAL;
 
+       if (rc) {
+               udev->autosuspend_disabled = old_autosuspend_disabled;
+               udev->autoresume_disabled = old_autoresume_disabled;
+       }
        usb_unlock_device(udev);
        return (rc < 0 ? rc : count);
 }


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to