diff options
| -rw-r--r-- | drivers/usb/core/sysfs.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index e7c982377488..be37c863fdfb 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
| @@ -232,12 +232,15 @@ set_level(struct device *dev, struct device_attribute *attr, | |||
| 232 | int len = count; | 232 | int len = count; |
| 233 | char *cp; | 233 | char *cp; |
| 234 | int rc = 0; | 234 | int rc = 0; |
| 235 | int old_autosuspend_disabled, old_autoresume_disabled; | ||
| 235 | 236 | ||
| 236 | cp = memchr(buf, '\n', count); | 237 | cp = memchr(buf, '\n', count); |
| 237 | if (cp) | 238 | if (cp) |
| 238 | len = cp - buf; | 239 | len = cp - buf; |
| 239 | 240 | ||
| 240 | usb_lock_device(udev); | 241 | usb_lock_device(udev); |
| 242 | old_autosuspend_disabled = udev->autosuspend_disabled; | ||
| 243 | old_autoresume_disabled = udev->autoresume_disabled; | ||
| 241 | 244 | ||
| 242 | /* Setting the flags without calling usb_pm_lock is a subject to | 245 | /* Setting the flags without calling usb_pm_lock is a subject to |
| 243 | * races, but who cares... | 246 | * races, but who cares... |
| @@ -263,6 +266,10 @@ set_level(struct device *dev, struct device_attribute *attr, | |||
| 263 | } else | 266 | } else |
| 264 | rc = -EINVAL; | 267 | rc = -EINVAL; |
| 265 | 268 | ||
| 269 | if (rc) { | ||
| 270 | udev->autosuspend_disabled = old_autosuspend_disabled; | ||
| 271 | udev->autoresume_disabled = old_autoresume_disabled; | ||
| 272 | } | ||
| 266 | usb_unlock_device(udev); | 273 | usb_unlock_device(udev); |
| 267 | return (rc < 0 ? rc : count); | 274 | return (rc < 0 ? rc : count); |
| 268 | } | 275 | } |
