Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 48751
b: refs/heads/master
c: 3f141e2
h: refs/heads/master
i:
  48749: bb740cc
  48747: c3056e4
  48743: d4ad60d
  48735: 50bdc07
v: v3
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Feb 16, 2007
1 parent 4f17ddf commit f7d49a8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d1bbb60007597b920beca72cd0b413d10290310a
refs/heads/master: 3f141e2aed586c41c2666d49c70c1c1bbb6d6abd
4 changes: 2 additions & 2 deletions trunk/drivers/usb/core/devio.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,11 +857,11 @@ static int proc_setintf(struct dev_state *ps, void __user *arg)

static int proc_setconfig(struct dev_state *ps, void __user *arg)
{
unsigned int u;
int u;
int status = 0;
struct usb_host_config *actconfig;

if (get_user(u, (unsigned int __user *)arg))
if (get_user(u, (int __user *)arg))
return -EFAULT;

actconfig = ps->dev->actconfig;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/usb/core/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static void generic_disconnect(struct usb_device *udev)
/* if this is only an unbind, not a physical disconnect, then
* unconfigure the device */
if (udev->actconfig)
usb_set_configuration(udev, 0);
usb_set_configuration(udev, -1);

usb_remove_sysfs_dev_files(udev);
}
Expand Down
22 changes: 18 additions & 4 deletions trunk/drivers/usb/core/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,14 @@ static void release_interface(struct device *dev)
* use this kind of configurability; many devices only have one
* configuration.
*
* @configuration is the value of the configuration to be installed.
* According to the USB spec (e.g. section 9.1.1.5), configuration values
* must be non-zero; a value of zero indicates that the device in
* unconfigured. However some devices erroneously use 0 as one of their
* configuration values. To help manage such devices, this routine will
* accept @configuration = -1 as indicating the device should be put in
* an unconfigured state.
*
* USB device configurations may affect Linux interoperability,
* power consumption and the functionality available. For example,
* the default configuration is limited to using 100mA of bus power,
Expand Down Expand Up @@ -1347,10 +1355,15 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
struct usb_interface **new_interfaces = NULL;
int n, nintf;

for (i = 0; i < dev->descriptor.bNumConfigurations; i++) {
if (dev->config[i].desc.bConfigurationValue == configuration) {
cp = &dev->config[i];
break;
if (configuration == -1)
configuration = 0;
else {
for (i = 0; i < dev->descriptor.bNumConfigurations; i++) {
if (dev->config[i].desc.bConfigurationValue ==
configuration) {
cp = &dev->config[i];
break;
}
}
}
if ((!cp && configuration != 0))
Expand All @@ -1359,6 +1372,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
/* The USB spec says configuration 0 means unconfigured.
* But if a device includes a configuration numbered 0,
* we will accept it as a correctly configured state.
* Use -1 if you really want to unconfigure the device.
*/
if (cp && configuration == 0)
dev_warn(&dev->dev, "config 0 descriptor??\n");
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/usb/core/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ set_bConfigurationValue(struct device *dev, struct device_attribute *attr,
struct usb_device *udev = to_usb_device(dev);
int config, value;

if (sscanf(buf, "%u", &config) != 1 || config > 255)
if (sscanf(buf, "%d", &config) != 1 || config < -1 || config > 255)
return -EINVAL;
usb_lock_device(udev);
value = usb_set_configuration(udev, config);
Expand Down

0 comments on commit f7d49a8

Please sign in to comment.