sysfs.c (92320cec611d4ed44a9bd635727d61f6caa669a7) | sysfs.c (eaafbc3a8adab16babe2c20e54ad3ba40d1fbbc9) |
---|---|
1/* 2 * drivers/usb/core/sysfs.c 3 * 4 * (C) Copyright 2002 David Brownell 5 * (C) Copyright 2002,2004 Greg Kroah-Hartman 6 * (C) Copyright 2002,2004 IBM Corp. 7 * 8 * All of the sysfs file attributes for usb devices and interfaces. --- 151 unchanged lines hidden (view full) --- 160 161#ifdef CONFIG_USB_SUSPEND 162 163static ssize_t 164show_autosuspend(struct device *dev, struct device_attribute *attr, char *buf) 165{ 166 struct usb_device *udev = to_usb_device(dev); 167 | 1/* 2 * drivers/usb/core/sysfs.c 3 * 4 * (C) Copyright 2002 David Brownell 5 * (C) Copyright 2002,2004 Greg Kroah-Hartman 6 * (C) Copyright 2002,2004 IBM Corp. 7 * 8 * All of the sysfs file attributes for usb devices and interfaces. --- 151 unchanged lines hidden (view full) --- 160 161#ifdef CONFIG_USB_SUSPEND 162 163static ssize_t 164show_autosuspend(struct device *dev, struct device_attribute *attr, char *buf) 165{ 166 struct usb_device *udev = to_usb_device(dev); 167 |
168 return sprintf(buf, "%u\n", udev->autosuspend_delay / HZ); | 168 return sprintf(buf, "%d\n", udev->autosuspend_delay / HZ); |
169} 170 171static ssize_t 172set_autosuspend(struct device *dev, struct device_attribute *attr, 173 const char *buf, size_t count) 174{ 175 struct usb_device *udev = to_usb_device(dev); | 169} 170 171static ssize_t 172set_autosuspend(struct device *dev, struct device_attribute *attr, 173 const char *buf, size_t count) 174{ 175 struct usb_device *udev = to_usb_device(dev); |
176 unsigned value, old; | 176 int value; |
177 | 177 |
178 if (sscanf(buf, "%u", &value) != 1 || value >= INT_MAX/HZ) | 178 if (sscanf(buf, "%d", &value) != 1 || value >= INT_MAX/HZ || 179 value <= - INT_MAX/HZ) |
179 return -EINVAL; 180 value *= HZ; 181 | 180 return -EINVAL; 181 value *= HZ; 182 |
182 old = udev->autosuspend_delay; | |
183 udev->autosuspend_delay = value; | 183 udev->autosuspend_delay = value; |
184 if (value > 0 && old == 0) | 184 if (value >= 0) |
185 usb_try_autosuspend_device(udev); | 185 usb_try_autosuspend_device(udev); |
186 | 186 else { 187 usb_lock_device(udev); 188 usb_external_resume_device(udev); 189 usb_unlock_device(udev); 190 } |
187 return count; 188} 189 190static DEVICE_ATTR(autosuspend, S_IRUGO | S_IWUSR, 191 show_autosuspend, set_autosuspend); 192 193static char power_group[] = "power"; 194 --- 263 unchanged lines hidden --- | 191 return count; 192} 193 194static DEVICE_ATTR(autosuspend, S_IRUGO | S_IWUSR, 195 show_autosuspend, set_autosuspend); 196 197static char power_group[] = "power"; 198 --- 263 unchanged lines hidden --- |