> There are plenty of other places in the USB code that could use this sort
> of cleanup.  How about defining and exporting a utility routine in usb.c
> for this purpose?  Something like

OK. It turns out that we have such a function. However, it is buggy.
Here's a version that doesn't inline the thing, uses a proper name
and fixes the bug. 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], 2004-05-13 22:42:05+02:00, [EMAIL PROTECTED]
  - guard against spurious wakeups


 drivers/usb/core/usb.c |   16 +++++++++++++---
 include/linux/usb.h    |   15 +++++++++++----
 2 files changed, 24 insertions(+), 7 deletions(-)


diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c    Thu May 13 23:54:20 2004
+++ b/drivers/usb/core/usb.c    Thu May 13 23:54:20 2004
@@ -1003,6 +1003,15 @@
 }
 
 /**
+ * usb_uninterruptible_sleep_ms - safe sleeping delay
+ * @msecs: minimum time to sleep given in milliseconds
+ */
+void usb_uninterruptible_sleep_ms (unsigned int msecs)
+{
+       wait_ms(msecs);
+}
+
+/**
  * usb_choose_address - pick device address (usbcore-internal)
  * @dev: newly detected device (in DEFAULT state)
  *
@@ -1112,7 +1121,7 @@
                        err = usb_set_address(dev);
                        if (err >= 0)
                                break;
-                       wait_ms(200);
+                       usb_uninterruptible_sleep_ms(200);
                }
                if (err < 0) {
                        dev_err(&dev->dev,
@@ -1121,13 +1130,13 @@
                        goto fail;
                }
 
-               wait_ms(10);    /* Let the SET_ADDRESS settle */
+               usb_uninterruptible_sleep_ms(10);       /* Let the SET_ADDRESS settle 
*/
 
                /* high and low speed devices don't need this... */
                err = usb_get_device_descriptor(dev, 8);
                if (err >= 8)
                        break;
-               wait_ms(100);
+               usb_uninterruptible_sleep_ms(100);
        }
 
        if (err < 8) {
@@ -1658,5 +1667,6 @@
 EXPORT_SYMBOL (usb_buffer_dmasync_sg);
 #endif
 EXPORT_SYMBOL (usb_buffer_unmap_sg);
+EXPORT_SYMBOL (usb_uninterruptible_sleep_ms);
 
 MODULE_LICENSE("GPL");
diff -Nru a/include/linux/usb.h b/include/linux/usb.h
--- a/include/linux/usb.h       Thu May 13 23:54:20 2004
+++ b/include/linux/usb.h       Thu May 13 23:54:20 2004
@@ -18,17 +18,24 @@
 #include <linux/fs.h>          /* for struct file_operations */
 #include <linux/completion.h>  /* for struct completion */
 #include <linux/sched.h>       /* for current && schedule_timeout */
+#include <linux/time.h>                /* for jiffy conversion macros */
 
 
 static __inline__ void wait_ms(unsigned int ms)
 {
        if(!in_interrupt()) {
-               current->state = TASK_UNINTERRUPTIBLE;
-               schedule_timeout(1 + ms * HZ / 1000);
-       }
-       else
+               long timeout = MSEC_TO_JIFFIES(ms);
+
+               while(timeout) {
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       timeout = schedule_timeout(timeout);
+               }
+       } else {
                mdelay(ms);
+       }
 }
+
+void usb_uninterruptible_sleep_ms(unsigned int msecs);
 
 struct usb_device;
 struct usb_driver;

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


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


begin 664 bkpatch9762
M'XL(`(SNHT```[56:T_;2!3]G/D55^)+2I5D9OS(HTL%E+2;+2TH"=*NVBHR
[EMAIL PROTECTED])%VV3*,[,W'OFS/4Y-]Z!,XWYJ)[EMAIL PROTECTED]@._
M9]K0$-,LQ>XR2S!6:?&UF^41+4ZSC!9[U70OBV,E>_,<4?>J&"T=1B&GGO&7
M0%AZU!)=ZV'&W%SBJ#4=OSL[/[EMAIL PROTECTED]<';Y9>&N$,#>SM,9/E5UX<Z'W/+.,L
M[9K<2W6"QNOZ65(^A):2<TEO1_0M[KBE<+G=+WT1".'9`@,[EMAIL PROTECTED]
M\T[B#BXJ^I_NM_CR/9Q-8$+8CFWQ4CI\T&='(+K"[EMAIL PROTECTED]/6&!E"-;CKCS
MDM,WAZ98^^N*!"[EMAIL PROTECTED]/_W0&^8#QV("B\/P(L\E6H#^K+(559HN/8NL+C4
M[#U(U[4M=KHJ+>O\QQ=CW./L]1;Z*O7C(L#ZOG_M%?J\NWQ\D*$M2\&E)4LK
M&`ZMOF_Y?>$,!CS<5+JG4*L;9$EN"\<J71K:6^D%>;6)KB!J&/\1.9N+?FD[
M<[EMAIL PROTECTED]>4%&\D]QO2S'%?`*WYT7ND,>*WN]?';I?Y,[BS*,=J_
MR#-O6<%\JH9?-I*V+"&EZ`NWI(&\5SW_7O1BY,B?$3V%=ZQ?I'KMA0A>&@"&
MH?(5IB3]&/&2]-Z4^P0Z^77](?V>/E'Y9SAA(CAW8,[EMAIL PROTECTED]:0J-9CGQ:51
MYS$N:A*+1-]3K,<JC2#`V+NILO83C;X>0:)2E10)&)[EMAIL PROTECTED]:B)A(AHIJ!26J96
M2I%9&FA*Z[&K3`6;MVP7J591B@'E&ZBW><&^L=:UIPRMMYN95^R6?6:]W5UV
M1"W.`4%':JZM5FL3?ION#V53EK2;K/JZ)4E03JNW"\?4TLT283:>+PZ.CJ;C
MV0PT&A-C=3@"[EMAIL PROTECTED]@E9,)L)UJ^#QGZ<GT_EB]M>'PY-CJL*&3,JJ?+BF
MJ6PWX;/[VWH;/MG85AZT+=L:-!XDS?WH0>NG/"[EMAIL PROTECTED];T%]/H6C=B5R%<
MDRMSA!A#`UD*'E3B^Z?``LF93:/^P9EKZO`<6\I*"3MW8/!;@U9YJ[M\W:H$
M&&8Y_*W"\`;(4U4O4,0O\?P\T[4"I0LVP0RA3^JC$D6U,[."[EMAIL PROTECTED]
M6?PQ>?MV,IZU:R%]IKCKI8JQ?1?X`KY5'B)5+_PBSZDG+;3Q#+;G![/WB[./
MDX_S\71Z=CJ?'!Z/"8!B5UMH?XE!05*]FWH`K>)N6>L6,-9(.TP:@]S2#P&2
A6&QM#.OZPJO58QEM[%_H([EMAIL PROTECTED]"@``
`
end


-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to