diff options
author | Matthias Kaehlcke <matthias.kaehlcke@gmail.com> | 2007-12-04 10:15:40 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-02-01 17:34:53 -0500 |
commit | 241ca64fc55bd2b676890472880e2d2d86cfae82 (patch) | |
tree | 8aeb96dc067904ea8e2e812dac9290545feadb9c | |
parent | 852c4b43bdd0953483e93bb97ca2fac7e5111dcb (diff) |
USB: Edgeport USB Serial Converter: convert es_sem to mutex
Edgeport USB Serial Converter: convert semaphore es_sem to the
mutex API
Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/serial/io_ti.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index b8670905bc3..f7fdf1ce6bf 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/tty_flip.h> | 34 | #include <linux/tty_flip.h> |
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/spinlock.h> | 36 | #include <linux/spinlock.h> |
37 | #include <linux/mutex.h> | ||
37 | #include <linux/serial.h> | 38 | #include <linux/serial.h> |
38 | #include <linux/ioctl.h> | 39 | #include <linux/ioctl.h> |
39 | #include <asm/uaccess.h> | 40 | #include <asm/uaccess.h> |
@@ -133,7 +134,7 @@ struct edgeport_serial { | |||
133 | struct product_info product_info; | 134 | struct product_info product_info; |
134 | u8 TI_I2C_Type; // Type of I2C in UMP | 135 | u8 TI_I2C_Type; // Type of I2C in UMP |
135 | u8 TiReadI2C; // Set to TRUE if we have read the I2c in Boot Mode | 136 | u8 TiReadI2C; // Set to TRUE if we have read the I2c in Boot Mode |
136 | struct semaphore es_sem; | 137 | struct mutex es_lock; |
137 | int num_ports_open; | 138 | int num_ports_open; |
138 | struct usb_serial *serial; | 139 | struct usb_serial *serial; |
139 | }; | 140 | }; |
@@ -2044,7 +2045,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
2044 | dbg ("ShadowMCR 0x%X", edge_port->shadow_mcr); | 2045 | dbg ("ShadowMCR 0x%X", edge_port->shadow_mcr); |
2045 | 2046 | ||
2046 | edge_serial = edge_port->edge_serial; | 2047 | edge_serial = edge_port->edge_serial; |
2047 | if (down_interruptible(&edge_serial->es_sem)) | 2048 | if (mutex_lock_interruptible(&edge_serial->es_lock)) |
2048 | return -ERESTARTSYS; | 2049 | return -ERESTARTSYS; |
2049 | if (edge_serial->num_ports_open == 0) { | 2050 | if (edge_serial->num_ports_open == 0) { |
2050 | /* we are the first port to be opened, let's post the interrupt urb */ | 2051 | /* we are the first port to be opened, let's post the interrupt urb */ |
@@ -2052,7 +2053,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
2052 | if (!urb) { | 2053 | if (!urb) { |
2053 | dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __FUNCTION__); | 2054 | dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __FUNCTION__); |
2054 | status = -EINVAL; | 2055 | status = -EINVAL; |
2055 | goto up_es_sem; | 2056 | goto release_es_lock; |
2056 | } | 2057 | } |
2057 | urb->complete = edge_interrupt_callback; | 2058 | urb->complete = edge_interrupt_callback; |
2058 | urb->context = edge_serial; | 2059 | urb->context = edge_serial; |
@@ -2060,7 +2061,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
2060 | status = usb_submit_urb (urb, GFP_KERNEL); | 2061 | status = usb_submit_urb (urb, GFP_KERNEL); |
2061 | if (status) { | 2062 | if (status) { |
2062 | dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __FUNCTION__, status); | 2063 | dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __FUNCTION__, status); |
2063 | goto up_es_sem; | 2064 | goto release_es_lock; |
2064 | } | 2065 | } |
2065 | } | 2066 | } |
2066 | 2067 | ||
@@ -2092,13 +2093,13 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
2092 | 2093 | ||
2093 | dbg("%s - exited", __FUNCTION__); | 2094 | dbg("%s - exited", __FUNCTION__); |
2094 | 2095 | ||
2095 | goto up_es_sem; | 2096 | goto release_es_lock; |
2096 | 2097 | ||
2097 | unlink_int_urb: | 2098 | unlink_int_urb: |
2098 | if (edge_port->edge_serial->num_ports_open == 0) | 2099 | if (edge_port->edge_serial->num_ports_open == 0) |
2099 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); | 2100 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); |
2100 | up_es_sem: | 2101 | release_es_lock: |
2101 | up(&edge_serial->es_sem); | 2102 | mutex_unlock(&edge_serial->es_lock); |
2102 | return status; | 2103 | return status; |
2103 | } | 2104 | } |
2104 | 2105 | ||
@@ -2137,14 +2138,14 @@ static void edge_close (struct usb_serial_port *port, struct file *filp) | |||
2137 | 0, | 2138 | 0, |
2138 | NULL, | 2139 | NULL, |
2139 | 0); | 2140 | 0); |
2140 | down(&edge_serial->es_sem); | 2141 | mutex_lock(&edge_serial->es_lock); |
2141 | --edge_port->edge_serial->num_ports_open; | 2142 | --edge_port->edge_serial->num_ports_open; |
2142 | if (edge_port->edge_serial->num_ports_open <= 0) { | 2143 | if (edge_port->edge_serial->num_ports_open <= 0) { |
2143 | /* last port is now closed, let's shut down our interrupt urb */ | 2144 | /* last port is now closed, let's shut down our interrupt urb */ |
2144 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); | 2145 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); |
2145 | edge_port->edge_serial->num_ports_open = 0; | 2146 | edge_port->edge_serial->num_ports_open = 0; |
2146 | } | 2147 | } |
2147 | up(&edge_serial->es_sem); | 2148 | mutex_unlock(&edge_serial->es_lock); |
2148 | edge_port->close_pending = 0; | 2149 | edge_port->close_pending = 0; |
2149 | 2150 | ||
2150 | dbg("%s - exited", __FUNCTION__); | 2151 | dbg("%s - exited", __FUNCTION__); |
@@ -2743,7 +2744,7 @@ static int edge_startup (struct usb_serial *serial) | |||
2743 | dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); | 2744 | dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); |
2744 | return -ENOMEM; | 2745 | return -ENOMEM; |
2745 | } | 2746 | } |
2746 | sema_init(&edge_serial->es_sem, 1); | 2747 | mutex_init(&edge_serial->es_lock); |
2747 | edge_serial->serial = serial; | 2748 | edge_serial->serial = serial; |
2748 | usb_set_serial_data(serial, edge_serial); | 2749 | usb_set_serial_data(serial, edge_serial); |
2749 | 2750 | ||