Hi,

this won't be quite to Greg's liking as it introduces holding another
semaphore, but it is needed. You must not probe and reset at the same time.
This can best be assured by the device's semaphore.

        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], 2003-03-26 22:57:56+01:00, [EMAIL PROTECTED]
  - proper mutual exclusion between reset and probe


 hub.c |   10 ++++++++++
 usb.c |    4 ++++
 2 files changed, 14 insertions(+)


diff -Nru a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
--- a/drivers/usb/core/hub.c    Wed Mar 26 22:58:40 2003
+++ b/drivers/usb/core/hub.c    Wed Mar 26 22:58:40 2003
@@ -1196,12 +1196,14 @@
        if (port < 0)
                return -ENOENT;
 
+       down(&dev->serialize);
        down(&usb_address0_sem);
 
        /* Send a reset to the device */
        if (usb_hub_port_reset(parent, port, dev, HUB_SHORT_RESET_TIME)) {
                usb_hub_port_disable(parent, port);
                up(&usb_address0_sem);
+               up(&dev->serialize);
                return(-ENODEV);
        }
 
@@ -1211,6 +1213,7 @@
                err("USB device not accepting new address (error=%d)", ret);
                usb_hub_port_disable(parent, port);
                up(&usb_address0_sem);
+               up(&dev->serialize);
                return ret;
        }
 
@@ -1230,12 +1233,14 @@
         */
        descriptor = kmalloc(sizeof *descriptor, GFP_NOIO);
        if (!descriptor) {
+               up(&dev->serialize);
                return -ENOMEM;
        }
        ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, descriptor,
                        sizeof(*descriptor));
        if (ret < 0) {
                kfree(descriptor);
+               up(&dev->serialize);
                return ret;
        }
 
@@ -1261,6 +1266,7 @@
         
                        clear_bit(dev->devnum, dev->bus->devmap.devicemap);
                        dev->devnum = -1;
+                       up(&dev->serialize);
                        return -EIO;
                }
 
@@ -1270,6 +1276,7 @@
                        usb_destroy_configuration(dev);
                        clear_bit(dev->devnum, dev->bus->devmap.devicemap);
                        dev->devnum = -1;
+                       up(&dev->serialize);
                        return 1;
                }
 
@@ -1285,6 +1292,7 @@
        if (ret < 0) {
                err("failed to set dev %s active configuration (error=%d)",
                        dev->devpath, ret);
+               up(&dev->serialize);
                return ret;
        }
 
@@ -1299,10 +1307,12 @@
                        err("failed to set active alternate setting "
                                "for dev %s interface %d (error=%d)",
                                dev->devpath, i, ret);
+                       up(&dev->serialize);
                        return ret;
                }
        }
 
+       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    Wed Mar 26 22:58:40 2003
+++ b/drivers/usb/core/usb.c    Wed Mar 26 22:58:40 2003
@@ -81,6 +81,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;
 
@@ -89,6 +90,8 @@
        if (!driver->probe)
                return error;
        
+       down (&udev->serialize);
+       
        id = usb_match_id (intf, driver->id_table);
        if (id) {
                dev_dbg (dev, "%s - got id\n", __FUNCTION__);
@@ -98,6 +101,7 @@
        }
        if (!error)
                intf->driver = driver;
+       up (&udev->serialize);
 
        return error;
 }

===================================================================


This BitKeeper patch contains the following changesets:
1.1551
## Wrapped with gzip_uu ##


begin 664 bkpatch22645
M'XL(`)[EMAIL PROTECTED];6O34!3'[EMAIL PROTECTED]>3MO0
M-BDWN=N4?'AO$M<QS%)6Q2:%]/Y/3O[GY'<//8"K`LUDD*_2&S3D`#[D1>E^
M8I9G.%KD:UREF;T;Y6;NQ,L\=^*X7AZW=XRCY;`TB,78%A%7Q`5=A&6\`*<5
MDP$;B>U*^6.#D\'EN_=7G]]<$C*=PMDBS.;X%4N83DFT/$TLKD9+DX>+^GG5
M5JXXI8PQKJA0FJF*^T+(BFD:)>XRX5XPBW1`6D>G7=X?YQ)4<,T9D]*K-.5<
MD'-@(Z84`RK&[N0:.)\H;Z+T,6432J$G-QQS&[EMAIL PROTECTED],2PQ`V)M^@@;4M
M;;@"O(M7MDCS#"(L;Q$S,%BXEH594D=&2#Z!ILKWR,5#0\GPF1]":$C)24<-
MB:DK;]YO_1W%#[5(&C!=<2&5K&+-$97/F1='H:"JKV./<L:YP8?$OU^-\I2N
M9""IV.EI83L\"2:YJ&(6ZIGRA)1)I%S*YWG:)G[D22I?-/!VQW>3O*??>Z(S
MM$N['F7A&K_-#<Z_[S"K.*N/BFOJM6P'WGYD,_IOT2[#)4*"-VF,+PHH<!UN
M%LX^)-:DV;PEV_'<=OD+#,UM<SH^+YYH^!ZD?V0L\(&109+?9D>'SL[PQ`W!
M-%RE/_'E:Z=S*FM]8#?=,A.]LN#]LM\KZS;YD[K'^W7?ZTLO*.N]O=ZZ3N]4
M.[%OMNYN[)\Q.GH'^<[1P027E:2<>NU4WQ=]^5_)OY_D[<S;17Y3\S[D^PU;
M16EL7(++<[EMAIL PROTECTED]@W15,(<U*-+,PQNLROW8!;O7(K<UJ-@(&O-TT<'1H_Z!C
[EMAIL PROTECTED]([EMAIL PROTECTED]"[N>*NHK+9&37XVI]76'"```
`
end



-------------------------------------------------------
This SF.net email is sponsored by:
The Definitive IT and Networking Event. Be There!
NetWorld+Interop Las Vegas 2003 -- Register today!
http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to