Hi,

this adds error handling to the open method of the cdc acm driver.
The change set is relative to my last patch rewriting probe.

        Regards
                Oliver

Signed-off-by: Oliver Neukum <[EMAIL PROTECTED]>

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-31 13:52:35+02:00, [EMAIL PROTECTED]
  - add error handling to open method


 cdc-acm.c |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)


diff -Nru a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
--- a/drivers/usb/class/cdc-acm.c       Mon May 31 13:54:36 2004
+++ b/drivers/usb/class/cdc-acm.c       Mon May 31 13:54:36 2004
@@ -27,6 +27,7 @@
  *     v0.22 - probe only the control interface. if usbcore doesn't choose the
  *             config we want, sysadmin changes bConfigurationValue in sysfs.
  *     v0.23 - use softirq for rx processing, as needed by tty layer
+ *     v0.24 - change probe method to evaluate CDC union descriptor
  */
 
 /*
@@ -73,6 +74,8 @@
 static struct tty_driver *acm_tty_driver;
 static struct acm *acm_table[ACM_TTY_MINORS];
 
+static DECLARE_MUTEX(open_sem);
+
 #define ACM_READY(acm) (acm && acm->dev && acm->used)
 
 /*
@@ -256,22 +259,23 @@
        tty->driver_data = acm;
        acm->tty = tty;
 
-        lock_kernel();
+        down(&open_sem);
 
-       if (acm->used++) {
-                unlock_kernel();
-                return 0;
+       if (acm->used) {
+               goto done;
         }
 
-        unlock_kernel();
-
        acm->ctrlurb->dev = acm->dev;
-       if (usb_submit_urb(acm->ctrlurb, GFP_KERNEL))
+       if (usb_submit_urb(acm->ctrlurb, GFP_KERNEL)) {
                dbg("usb_submit_urb(ctrl irq) failed");
+               goto bail_out;
+       }
 
        acm->readurb->dev = acm->dev;
-       if (usb_submit_urb(acm->readurb, GFP_KERNEL))
+       if (usb_submit_urb(acm->readurb, GFP_KERNEL)) {
                dbg("usb_submit_urb(read bulk) failed");
+               goto bail_out_and_unlink;
+       }
 
        acm_set_control(acm, acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS);
 
@@ -279,7 +283,16 @@
           otherwise it is scheduled, and with high data rates data can get lost. */
        tty->low_latency = 1;
 
+done:
+       acm->used++;
+       up(&open_sem);
        return 0;
+
+bail_out_and_unlink:
+       usb_unlink_urb(acm->ctrlurb);
+bail_out:
+       up(&open_sem);
+       return -EIO;
 }
 
 static void acm_tty_close(struct tty_struct *tty, struct file *filp)
@@ -289,6 +302,7 @@
        if (!acm || !acm->used)
                return;
 
+       down(&open_sem);
        if (!--acm->used) {
                if (acm->dev) {
                        acm_set_control(acm, acm->ctrlout = 0);
@@ -304,6 +318,7 @@
                        kfree(acm);
                }
        }
+       up(&open_sem);
 }
 
 static int acm_tty_write(struct tty_struct *tty, int from_user, const unsigned char 
*buf, int count)

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


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


M'XL( /P<NT   \55VT[;[EMAIL PROTECTED]";>BR^)41!MDM((6A %J0^5HO5Z
M0R)B;[1>@ZJF_]ZQ0U-H"K2H4FU+*WMFSLPY<Y1LP46I;>*9^>Q:6[(%[TSI
M$B^7*M5NVBYT=57E;6,O,71F#(;\J<FUO\KWSZW6I>\D)[EMAIL PROTECTED] 3^7B<?:
M8OW%?5GHQ#L;'EX<OSXCI->#_E06E_JC=M#K$6?LM9QGY8%TT[DIVL[*HLRU
MDVUE\N4Z=<DIY7B'+!8TC)8LHD&\5"QC3 9,9Y0'G2@@[EMAIL PROTECTED]<1PIH*"CM
[EMAIL PROTECTED] &NS..P"#7P:^H(!$TG($Q'N4IY0"@\BPRZ#%B5OX-\RZ1,%
M+9!9!MI:8P'+L_FLN,0V8!:Z $2>FHP< 1)@C)S^E)6T_O([EMAIL PROTECTED]:
[EMAIL PROTECTED]"RE#)*.Y&RU2)<,+8A =B(G2</JS</40UEV7IJTRUUMCU
MEAAC(>>=)>.BVVW<\TC1TWYZ)H='?/4''-!I 9)8AF$D6..T39_QSM,^XP):
MG?]HM-4.3J!E;YH'C7/ZV#J>X<,1[P(C\-*[IFT>X%RJ80,+:U)].TD]F$8!
M*NDT] =]J(J9*2#3I;*S!8I#1G$(G)1.NIF"P;"//SS#\?N+\^&G[9K1N-3Y
MSA[Y3 [EMAIL PROTECTED]<7IFY*;9?W$D<\(B!P+1((*PWF\ V\FOM5Z7.=N K\;Q+
[EMAIL PROTECTED]<H19>[EMAIL PROTECTED]&997F,S>N;+J"4,[.\>45'+X]'1\-SSX,CW=J
MR!&/:=UKA9S*V7QL*K='O&^('(L&N3D>1+9:[EMAIL PROTECTED]@!YO(8USZN"IP[U=-DQ'O
MU)[EMAIL PROTECTED]:+>[EMAIL PROTECTED]<(E3S-UA86\^V>[EMAIL 
PROTECTED]<4_:I(-6,]J5]D"6L/1
I2=VDRVJV&[L9"[EMAIL PROTECTED]:JK555GEO33-V"3HAN0[N2V4.?0&    


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&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