aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Kaehlcke <matthias.kaehlcke@gmail.com>2007-11-21 18:13:16 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-02-01 17:34:48 -0500
commit9da0068a4964540d8d1caa8455fe193b544d846d (patch)
tree13ab0571b740d46a0451ee0e24fa61fca1ac4900
parent527ea73eaea4600120117edd19ac88864a488d57 (diff)
USB: TI 3410/5052 USB Serial: convert td_open_close_lock to mutex
TI 3410/5052 USB Serial: convert semaphore td_open_close_lock to the mutex API. Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 1f0149495fb4..995fdf3c4898 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -80,6 +80,7 @@
80#include <linux/ioctl.h> 80#include <linux/ioctl.h>
81#include <linux/serial.h> 81#include <linux/serial.h>
82#include <linux/circ_buf.h> 82#include <linux/circ_buf.h>
83#include <linux/mutex.h>
83#include <asm/uaccess.h> 84#include <asm/uaccess.h>
84#include <asm/semaphore.h> 85#include <asm/semaphore.h>
85#include <linux/usb.h> 86#include <linux/usb.h>
@@ -139,7 +140,7 @@ struct ti_port {
139}; 140};
140 141
141struct ti_device { 142struct ti_device {
142 struct semaphore td_open_close_sem; 143 struct mutex td_open_close_lock;
143 int td_open_port_count; 144 int td_open_port_count;
144 struct usb_serial *td_serial; 145 struct usb_serial *td_serial;
145 int td_is_3410; 146 int td_is_3410;
@@ -424,7 +425,7 @@ static int ti_startup(struct usb_serial *serial)
424 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); 425 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__);
425 return -ENOMEM; 426 return -ENOMEM;
426 } 427 }
427 sema_init(&tdev->td_open_close_sem, 1); 428 mutex_init(&tdev->td_open_close_lock);
428 tdev->td_serial = serial; 429 tdev->td_serial = serial;
429 usb_set_serial_data(serial, tdev); 430 usb_set_serial_data(serial, tdev);
430 431
@@ -547,7 +548,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
547 tdev = tport->tp_tdev; 548 tdev = tport->tp_tdev;
548 549
549 /* only one open on any port on a device at a time */ 550 /* only one open on any port on a device at a time */
550 if (down_interruptible(&tdev->td_open_close_sem)) 551 if (mutex_lock_interruptible(&tdev->td_open_close_lock))
551 return -ERESTARTSYS; 552 return -ERESTARTSYS;
552 553
553 if (port->tty) 554 if (port->tty)
@@ -568,7 +569,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
568 if (!urb) { 569 if (!urb) {
569 dev_err(&port->dev, "%s - no interrupt urb\n", __FUNCTION__); 570 dev_err(&port->dev, "%s - no interrupt urb\n", __FUNCTION__);
570 status = -EINVAL; 571 status = -EINVAL;
571 goto up_sem; 572 goto release_lock;
572 } 573 }
573 urb->complete = ti_interrupt_callback; 574 urb->complete = ti_interrupt_callback;
574 urb->context = tdev; 575 urb->context = tdev;
@@ -576,7 +577,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
576 status = usb_submit_urb(urb, GFP_KERNEL); 577 status = usb_submit_urb(urb, GFP_KERNEL);
577 if (status) { 578 if (status) {
578 dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __FUNCTION__, status); 579 dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __FUNCTION__, status);
579 goto up_sem; 580 goto release_lock;
580 } 581 }
581 } 582 }
582 583
@@ -656,13 +657,13 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
656 tport->tp_is_open = 1; 657 tport->tp_is_open = 1;
657 ++tdev->td_open_port_count; 658 ++tdev->td_open_port_count;
658 659
659 goto up_sem; 660 goto release_lock;
660 661
661unlink_int_urb: 662unlink_int_urb:
662 if (tdev->td_open_port_count == 0) 663 if (tdev->td_open_port_count == 0)
663 usb_kill_urb(port->serial->port[0]->interrupt_in_urb); 664 usb_kill_urb(port->serial->port[0]->interrupt_in_urb);
664up_sem: 665release_lock:
665 up(&tdev->td_open_close_sem); 666 mutex_unlock(&tdev->td_open_close_lock);
666 dbg("%s - exit %d", __FUNCTION__, status); 667 dbg("%s - exit %d", __FUNCTION__, status);
667 return status; 668 return status;
668} 669}
@@ -674,7 +675,7 @@ static void ti_close(struct usb_serial_port *port, struct file *file)
674 struct ti_port *tport; 675 struct ti_port *tport;
675 int port_number; 676 int port_number;
676 int status; 677 int status;
677 int do_up; 678 int do_unlock;
678 679
679 dbg("%s - port %d", __FUNCTION__, port->number); 680 dbg("%s - port %d", __FUNCTION__, port->number);
680 681
@@ -699,16 +700,16 @@ static void ti_close(struct usb_serial_port *port, struct file *file)
699 if (status) 700 if (status)
700 dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __FUNCTION__, status); 701 dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __FUNCTION__, status);
701 702
702 /* if down is interrupted, continue anyway */ 703 /* if mutex_lock is interrupted, continue anyway */
703 do_up = !down_interruptible(&tdev->td_open_close_sem); 704 do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock);
704 --tport->tp_tdev->td_open_port_count; 705 --tport->tp_tdev->td_open_port_count;
705 if (tport->tp_tdev->td_open_port_count <= 0) { 706 if (tport->tp_tdev->td_open_port_count <= 0) {
706 /* last port is closed, shut down interrupt urb */ 707 /* last port is closed, shut down interrupt urb */
707 usb_kill_urb(port->serial->port[0]->interrupt_in_urb); 708 usb_kill_urb(port->serial->port[0]->interrupt_in_urb);
708 tport->tp_tdev->td_open_port_count = 0; 709 tport->tp_tdev->td_open_port_count = 0;
709 } 710 }
710 if (do_up) 711 if (do_unlock)
711 up(&tdev->td_open_close_sem); 712 mutex_unlock(&tdev->td_open_close_lock);
712 713
713 dbg("%s - exit", __FUNCTION__); 714 dbg("%s - exit", __FUNCTION__);
714} 715}