Hi folks,
in the long and celebrated tradition of sending in patches which happen
to be completely untested here it is for discussion.
This patch disconnects all interfaces of a device before changing
a configuration and introduces proper locking for that.
Comments?
Regards
Oliver
You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.
===================================================================
[EMAIL PROTECTED], 2002-10-10 12:22:16+02:00, [EMAIL PROTECTED]
- proper handling of configuration changes
diff -Nru a/drivers/usb/core/message.c b/drivers/usb/core/message.c
--- a/drivers/usb/core/message.c Thu Oct 10 12:24:18 2002
+++ b/drivers/usb/core/message.c Thu Oct 10 12:24:18 2002
@@ -871,7 +871,7 @@
{
int i, ret;
struct usb_config_descriptor *cp = NULL;
-
+
for (i=0; i<dev->descriptor.bNumConfigurations; i++) {
if (dev->config[i].bConfigurationValue == configuration) {
cp = &dev->config[i];
@@ -882,6 +882,10 @@
warn("selecting invalid configuration %d", configuration);
return -EINVAL;
}
+
+ down(&dev->serialize);
+
+ usb_reap_interfaces(dev);
if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
USB_REQ_SET_CONFIGURATION, 0, configuration, 0,
@@ -892,6 +896,8 @@
dev->toggle[0] = 0;
dev->toggle[1] = 0;
usb_set_maxpacket(dev);
+
+ up(&dev->serialize);
return 0;
}
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c Thu Oct 10 12:24:18 2002
+++ b/drivers/usb/core/usb.c Thu Oct 10 12:24:18 2002
@@ -75,6 +75,7 @@
{
struct usb_interface * intf = to_usb_interface(dev);
struct usb_driver * driver = to_usb_driver(dev->driver);
+ struct usb_device * udev = interface_to_usbdev(intf);
const struct usb_device_id *id;
int error = -ENODEV;
int m;
@@ -94,7 +95,9 @@
if (id) {
dbg ("%s - got id", __FUNCTION__);
down (&driver->serialize);
+ down (&udev->serialize);
error = driver->probe (intf, id);
+ up (&udev->serialize);
up (&driver->serialize);
}
if (!error)
@@ -317,7 +320,7 @@
* usb_driver_release_interface - unbind a driver from an interface
* @driver: the driver to be unbound
* @iface: the interface from which it will be unbound
- *
+ *
* This should be used by drivers to release their claimed interfaces.
* It is normally called in their disconnect() methods, and only for
* drivers that bound to more than one interface in their probe().
@@ -761,6 +764,26 @@
return -1;
}
+/** usb_reap_interfaces - disconnect all interfaces of a usb device
+ * @dev: pointer to the device whose interfaces shall be disconnected
+ * Context: !in_interrupt ()
+ *
+ * Getting rid of interfaces associated with drivers.
+ * This is for physical disconnection and configuration changes
+ */
+void usb_reap_interfaces(struct usb_device *dev)
+{
+ int i;
+
+ if (dev->actconfig) {
+ for (i = 0; i < dev->actconfig->bNumInterfaces; i++) {
+ struct usb_interface *interface =
+&dev->actconfig->interface[i];
+
+ /* remove this interface */
+ put_device(&interface->dev);
+ }
+ }
+}
/**
* usb_disconnect - disconnect a device (usbcore-internal)
* @pdev: pointer to device being disconnected
@@ -792,14 +815,7 @@
usb_disconnect(child);
}
- if (dev->actconfig) {
- for (i = 0; i < dev->actconfig->bNumInterfaces; i++) {
- struct usb_interface *interface =
&dev->actconfig->interface[i];
-
- /* remove this interface */
- put_device(&interface->dev);
- }
- }
+ usb_reap_interfaces(dev);
/* Free the device number and remove the /proc/bus/usb entry */
if (dev->devnum > 0) {
===================================================================
This BitKeeper patch contains the following changesets:
1.890
## Wrapped with gzip_uu ##
begin 664 bkpatch17853
M'XL(`%-5I3T``ZU7;6_;-A#^+/Z*&PH$C@-;)/7NS$':9.B"#EN0K9_6P9`E
MVB9BBX)$)>VF_O<[EMAIL PROTECTED]'CZ\-])OX&,IBHFEUO)&%.0-_*Q*
MC8\B4YD8K]1&K&56?1ZK8HG"*Z50:)O7=FMASZ]'NA"BM!.5<8^@TF6LDQ6@
MK)Q8;.QT;_277$RLJY_>?_SE[14ATRF<K>)L*7X7&J93,K\^32NQ'E\7*EZ9
M^>I.7'-*&6/<HX[G,Z_FH>.X-?/I/,5ARH-H,?<C4J1IE:WC_%25Z?I;!,XH
M#6G`78_53N`&$3D'-@XC"I3;C.(%C$\XGS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GU.:BUZ^UVW?YN>]\HGB1?B;74_ZKF<M]TOV*_Y!3!B
MKW_:O&^!3_6Q1G>K<K?J0V:8+0*K;F$VQ4;=(,6[.&:C;`Y.W^N#G>OVZ(7G
M>#PQW:B]?<)!Z.+^:9&FOPT.OFE?UG-IA9NO"[S1R7MLN[\SR4HDUV6UF>))
/9[%P`I_\"\<#@9Q,#0``
`
end
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel