]> git.hungrycats.org Git - linux/commitdiff
usb serial drivers:
authorGreg Kroah-Hartman <greg@kroah.com>
Wed, 27 Feb 2002 07:25:12 +0000 (23:25 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 27 Feb 2002 07:25:12 +0000 (23:25 -0800)
- removed all usage of port->sem as the usb serial core now does this.

12 files changed:
drivers/usb/serial/belkin_sa.c
drivers/usb/serial/cyberjack.c
drivers/usb/serial/empeg.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/ir-usb.c
drivers/usb/serial/keyspan.c
drivers/usb/serial/keyspan_pda.c
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/mct_u232.c
drivers/usb/serial/omninet.c
drivers/usb/serial/pl2303.c
drivers/usb/serial/whiteheat.c

index 8b3f1ecf919870673a54417fd044976dd0cb490e..86683cc20c69da6f0a6ebbefa6d21f764aa9ee48 100644 (file)
@@ -207,8 +207,6 @@ static int  belkin_sa_open (struct usb_serial_port *port, struct file *filp)
 
        dbg(__FUNCTION__" port %d", port->number);
 
-       down (&port->sem);
-       
        ++port->open_count;
        
        if (port->open_count == 1) {
@@ -230,8 +228,6 @@ static int  belkin_sa_open (struct usb_serial_port *port, struct file *filp)
        }
        
 exit:
-       up (&port->sem);
-
        return retval;
 } /* belkin_sa_open */
 
@@ -249,8 +245,6 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
 
        dbg(__FUNCTION__" port %d", port->number);
 
-       down (&port->sem);
-
        --port->open_count;
 
        if (port->open_count <= 0) {
@@ -262,8 +256,6 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
                }
                port->open_count = 0;
        }
-       
-       up (&port->sem);
 } /* belkin_sa_close */
 
 
index e2c0536d6a7dd2565f79013dd0e597275b159c13..f185987c6541545eadc24c6a9c70bec61d3285fd 100644 (file)
@@ -151,8 +151,6 @@ static int  cyberjack_open (struct usb_serial_port *port, struct file *filp)
 
        dbg(__FUNCTION__ " - port %d", port->number);
 
-       down (&port->sem);
-
        ++port->open_count;
 
        if (port->open_count == 1) {
@@ -179,8 +177,6 @@ static int  cyberjack_open (struct usb_serial_port *port, struct file *filp)
                dbg(__FUNCTION__ " - usb_submit_urb(int urb)");
        }
 
-       up (&port->sem);
-
        return result;
 }
 
@@ -188,8 +184,6 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp)
 {
        dbg(__FUNCTION__ " - port %d", port->number);
 
-       down (&port->sem);
-
        --port->open_count;
 
        if (port->open_count <= 0) {
@@ -201,8 +195,6 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp)
                }
                port->open_count = 0;
        }
-
-       up (&port->sem);
 }
 
 static int cyberjack_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
@@ -225,8 +217,6 @@ static int cyberjack_write (struct usb_serial_port *port, int from_user, const u
                return (0);
        }
 
-       down (&port->sem);
-
        if( (count+priv->wrfilled)>sizeof(priv->wrbuf) ) {
                /* To much data  for buffer. Reset buffer. */
                priv->wrfilled=0;
@@ -235,8 +225,9 @@ static int cyberjack_write (struct usb_serial_port *port, int from_user, const u
 
        /* Copy data */
        if (from_user) {
-               if (copy_from_user(priv->wrbuf+priv->wrfilled, buf, count))
+               if (copy_from_user(priv->wrbuf+priv->wrfilled, buf, count)) {
                        return -EFAULT;
+               }
        } else {
                memcpy (priv->wrbuf+priv->wrfilled, buf, count);
        }  
@@ -277,7 +268,6 @@ static int cyberjack_write (struct usb_serial_port *port, int from_user, const u
                        /* Throw away data. No better idea what to do with it. */
                        priv->wrfilled=0;
                        priv->wrsent=0;
-                       up (&port->sem);
                        return 0;
                }
 
@@ -292,7 +282,6 @@ static int cyberjack_write (struct usb_serial_port *port, int from_user, const u
                }
        }
 
-       up (&port->sem);
        return (count);
 } 
 
@@ -432,8 +421,6 @@ static void cyberjack_write_bulk_callback (struct urb *urb)
                        return;
                }
 
-               down (&port->sem);
-
                dbg(__FUNCTION__ " - transmitting data (frame n)");
 
                length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ?
@@ -459,7 +446,6 @@ static void cyberjack_write_bulk_callback (struct urb *urb)
                        /* Throw away data. No better idea what to do with it. */
                        priv->wrfilled=0;
                        priv->wrsent=0;
-                       up (&port->sem);
                        queue_task(&port->tqueue, &tq_immediate);
                        mark_bh(IMMEDIATE_BH);
                        return;
@@ -477,7 +463,6 @@ static void cyberjack_write_bulk_callback (struct urb *urb)
                        priv->wrsent=0;
                }
 
-               up (&port->sem);
                queue_task(&port->tqueue, &tq_immediate);
                mark_bh(IMMEDIATE_BH);
                return;
index 892ad71fa26eff1e7f3cc1a65979b8fa93d3d171..3a636d7a474057028f7f5df50dde3158a71c8b9c 100644 (file)
@@ -157,8 +157,6 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
 
        dbg(__FUNCTION__ " - port %d", port->number);
 
-       down (&port->sem);
-
        ++port->open_count;
 
        if (port->open_count == 1) {
@@ -189,8 +187,6 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
 
        }
 
-       up (&port->sem);
-
        return result;
 }
 
@@ -208,8 +204,6 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp)
        if (!serial)
                return;
 
-       down (&port->sem);
-
        --port->open_count;
 
        if (port->open_count <= 0) {
@@ -220,8 +214,6 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp)
                port->open_count = 0;
        }
 
-       up (&port->sem);
-
        /* Uncomment the following line if you want to see some statistics in your syslog */
        /* info ("Bytes In = %d  Bytes Out = %d", bytes_in, bytes_out); */
 }
@@ -462,15 +454,7 @@ static void empeg_read_bulk_callback (struct urb *urb)
 static void empeg_throttle (struct usb_serial_port *port)
 {
        dbg(__FUNCTION__ " - port %d", port->number);
-
-       down (&port->sem);
-
        usb_unlink_urb (port->read_urb);
-
-       up (&port->sem);
-
-       return;
-
 }
 
 
@@ -480,8 +464,6 @@ static void empeg_unthrottle (struct usb_serial_port *port)
 
        dbg(__FUNCTION__ " - port %d", port->number);
 
-       down (&port->sem);
-
        port->read_urb->dev = port->serial->dev;
 
        result = usb_submit_urb(port->read_urb, GFP_KERNEL);
@@ -489,10 +471,7 @@ static void empeg_unthrottle (struct usb_serial_port *port)
        if (result)
                err(__FUNCTION__ " - failed submitting read urb, error %d", result);
 
-       up (&port->sem);
-
        return;
-
 }
 
 
index 7c7b5d87ea82f3b277167eb57fb6308b58be47e8..911d3ac53f94faca9d3473308539ac76898ad4d0 100644 (file)
@@ -319,8 +319,6 @@ static int  ftdi_sio_open (struct usb_serial_port *port, struct file *filp)
 
        dbg(__FUNCTION__);
 
-       down (&port->sem);
-       
        ++port->open_count;
 
        if (port->open_count == 1){
@@ -361,7 +359,6 @@ static int  ftdi_sio_open (struct usb_serial_port *port, struct file *filp)
                        err(__FUNCTION__ " - failed submitting read urb, error %d", result);
        }
 
-       up (&port->sem);
        return result;
 } /* ftdi_sio_open */
 
@@ -374,7 +371,6 @@ static void ftdi_sio_close (struct usb_serial_port *port, struct file *filp)
 
        dbg( __FUNCTION__);
 
-       down (&port->sem);
        --port->open_count;
 
        if (port->open_count <= 0) {
@@ -411,9 +407,6 @@ static void ftdi_sio_close (struct usb_serial_port *port, struct file *filp)
                        tty_hangup(port->tty);
                }
        }
-
-       up (&port->sem);
-
 } /* ftdi_sio_close */
 
 
@@ -447,8 +440,6 @@ static int ftdi_sio_write (struct usb_serial_port *port, int from_user,
                return (0);
        }               
 
-       down(&port->sem);
-
        count += data_offset;
        count = (count > port->bulk_out_size) ? port->bulk_out_size : count;
 
@@ -456,7 +447,6 @@ static int ftdi_sio_write (struct usb_serial_port *port, int from_user,
        if (from_user) {
                if (copy_from_user(port->write_urb->transfer_buffer + data_offset,
                                   buf, count - data_offset )){
-                       up (&port->sem);
                        return -EFAULT;
                }
        } else {
@@ -482,14 +472,11 @@ static int ftdi_sio_write (struct usb_serial_port *port, int from_user,
        result = usb_submit_urb(port->write_urb, GFP_KERNEL);
        if (result) {
                err(__FUNCTION__ " - failed submitting write urb, error %d", result);
-               up (&port->sem);
                return 0;
        }
-       up (&port->sem);
 
        dbg(__FUNCTION__ " write returning: %d", count - data_offset);
        return (count - data_offset);
-
 } /* ftdi_sio_write */
 
 static void ftdi_sio_write_bulk_callback (struct urb *urb)
index 69a572b6d8ac49d52e3d5cf7d1f3c765da544ead..033d90411d2651995256f5955fe118574b151d36 100644 (file)
@@ -252,8 +252,6 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
        
        dbg("%s - port %d", __FUNCTION__, port->number);
 
-       down (&port->sem);
-       
        ++port->open_count;
        
        if (port->open_count == 1) {
@@ -293,9 +291,6 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
                if (result)
                        err("%s - failed submitting read urb, error %d", __FUNCTION__, result);
        }
-       
-       up (&port->sem);
-       
        return result;
 }
 
@@ -312,8 +307,6 @@ static void ir_close (struct usb_serial_port *port, struct file * filp)
        if (!serial)
                return;
        
-       down (&port->sem);
-
        --port->open_count;
 
        if (port->open_count <= 0) {
@@ -324,7 +317,6 @@ static void ir_close (struct usb_serial_port *port, struct file * filp)
                port->open_count = 0;
 
        }
-       up (&port->sem);
 }
 
 static int ir_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
index 9f6f30ed281c537c6a5d2371f1d79f2cd79e2da7..d8d8a2e83bb27a8bc728f2938e0d031045badc49 100644 (file)
@@ -861,10 +861,8 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
        
        dbg("keyspan_open called for port%d.\n", port->number); 
 
-       down (&port->sem);
        already_active = port->open_count;
        ++port->open_count;
-       up (&port->sem);
 
        if (already_active)
                return 0;
@@ -926,8 +924,6 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
        p_priv->out_flip = 0;
        p_priv->in_flip = 0;
 
-       down (&port->sem);
-
        if (--port->open_count <= 0) {
                if (serial->dev) {
                        /* Stop reading/writing urbs */
@@ -941,7 +937,6 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
                port->open_count = 0;
                port->tty = 0;
        }
-       up (&port->sem);
 }
 
 
index e17f1b3bee84d116bea18d370ec9901149789cfd..ae37c1ff9b86c20a016f8b30eef4d021d55623e8 100644 (file)
@@ -662,8 +662,6 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
        int rc = 0;
        struct keyspan_pda_private *priv;
 
-       down (&port->sem);
-
        ++port->open_count;
 
        if (port->open_count == 1) {
@@ -707,12 +705,9 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
 
        }
 
-
-       up (&port->sem);
        return rc;
 error:
        --port->open_count;
-       up (&port->sem);
        return rc;
 }
 
@@ -721,8 +716,6 @@ static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial *serial = port->serial;
 
-       down (&port->sem);
-
        --port->open_count;
 
        if (port->open_count <= 0) {
@@ -737,8 +730,6 @@ static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp)
                }
                port->open_count = 0;
        }
-
-       up (&port->sem);
 }
 
 
index ecb89c7f2e1101af66608ea7797c208d92438026..3aa9c40e2c61b9c20e272aa1465f932f84a413ee 100644 (file)
@@ -358,8 +358,6 @@ static int  klsi_105_open (struct usb_serial_port *port, struct file *filp)
 
        dbg(__FUNCTION__" port %d", port->number);
 
-       down (&port->sem);
-       
        ++port->open_count;
 
        if (port->open_count == 1) {
@@ -437,8 +435,6 @@ static int  klsi_105_open (struct usb_serial_port *port, struct file *filp)
        }
 
 exit:
-       up (&port->sem);
-       
        return retval;
 } /* klsi_105_open */
 
@@ -455,8 +451,6 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
        if(!serial)
                return;
 
-       down (&port->sem);
-
        --port->open_count;
 
        if (port->open_count <= 0) {
@@ -482,8 +476,6 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
                port->open_count = 0;
                info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", priv->bytes_in, priv->bytes_out);
        }
-       
-       up (&port->sem);
 } /* klsi_105_close */
 
 
@@ -505,9 +497,6 @@ static int klsi_105_write (struct usb_serial_port *port, int from_user,
 
        dbg(__FUNCTION__ " - port %d", port->number);
 
-       down (&port->sem);      /* to lock against someone else trying to
-                                  take an URB we just selected from the pool */
-
        while (count > 0) {
                /* try to find a free urb (write 0 bytes if none) */
                struct urb *urb = NULL;
@@ -543,7 +532,6 @@ static int klsi_105_write (struct usb_serial_port *port, int from_user,
                if (from_user) {
                        if (copy_from_user(urb->transfer_buffer
                                           + KLSI_105_DATA_OFFSET, buf, size)) {
-                               up (&port->sem);
                                return -EFAULT;
                        }
                } else {
@@ -578,7 +566,6 @@ static int klsi_105_write (struct usb_serial_port *port, int from_user,
                count -= size;
        }
 exit:
-       up (&port->sem);
        priv->bytes_out+=bytes_sent;
 
        return bytes_sent;      /* that's how much we wrote */
@@ -1021,34 +1008,21 @@ static int klsi_105_ioctl (struct usb_serial_port *port, struct file * file,
 
 static void klsi_105_throttle (struct usb_serial_port *port)
 {
-
        dbg(__FUNCTION__ " - port %d", port->number);
-
-       down (&port->sem);
-
        usb_unlink_urb (port->read_urb);
-
-       up (&port->sem);
-
-       return;
 }
+
 static void klsi_105_unthrottle (struct usb_serial_port *port)
 {
        int result;
 
        dbg(__FUNCTION__ " - port %d", port->number);
 
-       down (&port->sem);
-
        port->read_urb->dev = port->serial->dev;
        result = usb_submit_urb(port->read_urb, GFP_KERNEL);
        if (result)
                err(__FUNCTION__ " - failed submitting read urb, error %d",
                    result);
-
-       up (&port->sem);
-
-       return;
 }
 
 
index 16f32e65f4907aed3e76ea7df459bf7045aba366..1151d0d2170a9707fca23547312a70fa774348ae 100644 (file)
@@ -341,8 +341,6 @@ static int  mct_u232_open (struct usb_serial_port *port, struct file *filp)
 
        dbg(__FUNCTION__" port %d", port->number);
 
-       down (&port->sem);
-       
        ++port->open_count;
 
        if (port->open_count == 1) {
@@ -398,8 +396,6 @@ static int  mct_u232_open (struct usb_serial_port *port, struct file *filp)
        }
 
 exit:
-       up (&port->sem);
-       
        return 0;
 } /* mct_u232_open */
 
@@ -408,8 +404,6 @@ static void mct_u232_close (struct usb_serial_port *port, struct file *filp)
 {
        dbg(__FUNCTION__" port %d", port->number);
 
-       down (&port->sem);
-
        --port->open_count;
 
        if (port->open_count <= 0) {
@@ -421,8 +415,6 @@ static void mct_u232_close (struct usb_serial_port *port, struct file *filp)
                }
                port->open_count = 0;
        }
-       
-       up (&port->sem);
 } /* mct_u232_close */
 
 
@@ -454,16 +446,12 @@ static int mct_u232_write (struct usb_serial_port *port, int from_user,
                
        bytes_sent = 0;
        while (count > 0) {
-               
-               down (&port->sem);
-               
                size = (count > port->bulk_out_size) ? port->bulk_out_size : count;
                
                usb_serial_debug_data (__FILE__, __FUNCTION__, size, buf);
                
                if (from_user) {
                        if (copy_from_user(port->write_urb->transfer_buffer, buf, size)) {
-                               up (&port->sem);
                                return -EFAULT;
                        }
                }
@@ -486,12 +474,9 @@ static int mct_u232_write (struct usb_serial_port *port, int from_user,
                if (result) {
                        err(__FUNCTION__
                            " - failed submitting write urb, error %d", result);
-                       up (&port->sem);
                        return result;
                }
 
-               up (&port->sem);
-
                bytes_sent += size;
                if (write_blocking)
                        interruptible_sleep_on(&port->write_wait);
index 9a778fc3cd41b5a678987c595c9be138db949194..2eb34c55379001b3fa75159869b8ca6d5af0e490 100644 (file)
@@ -157,8 +157,6 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
        if (!serial)
                return -ENODEV;
 
-       down (&port->sem);
-
        ++port->open_count;
 
        if (port->open_count == 1) {
@@ -166,7 +164,6 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
                if( !od ) {
                        err(__FUNCTION__"- kmalloc(%Zd) failed.", sizeof(struct omninet_data));
                        port->open_count = 0;
-                       up (&port->sem);
                        return -ENOMEM;
                }
 
@@ -184,8 +181,6 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
                        err(__FUNCTION__ " - failed submitting read urb, error %d", result);
        }
 
-       up (&port->sem);
-
        return result;
 }
 
@@ -204,8 +199,6 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
        if (!serial)
                return;
 
-       down (&port->sem);
-
        --port->open_count;
 
        if (port->open_count <= 0) {
@@ -220,8 +213,6 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
                if (od)
                        kfree(od);
        }
-
-       up (&port->sem);
 }
 
 
index f6f14f60b6cb93601d64f387d2af694d165a2c05..57dedd00441c63ca90a9d35fd97909b12a6f1f98 100644 (file)
@@ -367,8 +367,6 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
                
        dbg (__FUNCTION__ " -  port %d", port->number);
 
-       down (&port->sem);
-
        ++port->open_count;
 
        if (port->open_count == 1) {
@@ -407,7 +405,6 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
                result = usb_submit_urb (port->read_urb, GFP_KERNEL);
                if (result) {
                        err(__FUNCTION__ " - failed submitting read urb, error %d", result);
-                       up (&port->sem);
                        pl2303_close (port, NULL);
                        return -EPROTO;
                }
@@ -417,12 +414,10 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
                result = usb_submit_urb (port->interrupt_in_urb, GFP_KERNEL);
                if (result) {
                        err(__FUNCTION__ " - failed submitting interrupt urb, error %d", result);
-                       up (&port->sem);
                        pl2303_close (port, NULL);
                        return -EPROTO;
                }
        }
-       up (&port->sem);
        return 0;
 }
 
@@ -442,8 +437,6 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp)
        
        dbg (__FUNCTION__ " - port %d", port->number);
 
-       down (&port->sem);
-
        --port->open_count;
        if (port->open_count <= 0) {
                if (serial->dev) {
@@ -478,8 +471,6 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp)
                }
                port->open_count = 0;
        }
-
-       up (&port->sem);
 }
 
 static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsigned int *value)
index e90ea4a33b8e20446014614ab4617b892a85a59b..4485b3d2693692e28ef8fdaae39a459dee05ef5d 100644 (file)
@@ -306,8 +306,6 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
 
        dbg(__FUNCTION__" - port %d", port->number);
 
-       down (&port->sem);
-
        ++port->open_count;
        
        if (port->open_count == 1) {
@@ -354,16 +352,12 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
        }
 
        dbg(__FUNCTION__ " - exit");
-       up (&port->sem);
-       
        return retval;
 
 error_exit:
        --port->open_count;
 
        dbg(__FUNCTION__ " - error_exit");
-       up (&port->sem);
-       
        return retval;
 }
 
@@ -374,7 +368,6 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
        
        dbg(__FUNCTION__ " - port %d", port->number);
        
-       down (&port->sem);
        --port->open_count;
 
        if (port->open_count <= 0) {
@@ -391,7 +384,6 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
                usb_unlink_urb (port->read_urb);
                port->open_count = 0;
        }
-       up (&port->sem);
 }
 
 
@@ -410,8 +402,6 @@ static void whiteheat_set_termios (struct usb_serial_port *port, struct termios
 
        dbg(__FUNCTION__ " -port %d", port->number);
 
-       down (&port->sem);
-
        if ((!port->tty) || (!port->tty->termios)) {
                dbg(__FUNCTION__" - no tty structures");
                goto exit;
@@ -492,7 +482,6 @@ static void whiteheat_set_termios (struct usb_serial_port *port, struct termios
        whiteheat_send_cmd (port->serial, WHITEHEAT_SETUP_PORT, (__u8 *)&port_settings, sizeof(port_settings));
        
 exit:
-       up (&port->sem);
        return;
 }