diff options
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index a3665659d13b..9bf01a5efc84 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -60,19 +60,19 @@ static struct usb_driver usb_serial_driver = { | |||
60 | 60 | ||
61 | static int debug; | 61 | static int debug; |
62 | static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */ | 62 | static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */ |
63 | static spinlock_t table_lock; | 63 | static DEFINE_MUTEX(table_lock); |
64 | static LIST_HEAD(usb_serial_driver_list); | 64 | static LIST_HEAD(usb_serial_driver_list); |
65 | 65 | ||
66 | struct usb_serial *usb_serial_get_by_index(unsigned index) | 66 | struct usb_serial *usb_serial_get_by_index(unsigned index) |
67 | { | 67 | { |
68 | struct usb_serial *serial; | 68 | struct usb_serial *serial; |
69 | 69 | ||
70 | spin_lock(&table_lock); | 70 | mutex_lock(&table_lock); |
71 | serial = serial_table[index]; | 71 | serial = serial_table[index]; |
72 | 72 | ||
73 | if (serial) | 73 | if (serial) |
74 | kref_get(&serial->kref); | 74 | kref_get(&serial->kref); |
75 | spin_unlock(&table_lock); | 75 | mutex_unlock(&table_lock); |
76 | return serial; | 76 | return serial; |
77 | } | 77 | } |
78 | 78 | ||
@@ -84,7 +84,7 @@ static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_po | |||
84 | dbg("%s %d", __FUNCTION__, num_ports); | 84 | dbg("%s %d", __FUNCTION__, num_ports); |
85 | 85 | ||
86 | *minor = 0; | 86 | *minor = 0; |
87 | spin_lock(&table_lock); | 87 | mutex_lock(&table_lock); |
88 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { | 88 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { |
89 | if (serial_table[i]) | 89 | if (serial_table[i]) |
90 | continue; | 90 | continue; |
@@ -106,10 +106,10 @@ static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_po | |||
106 | serial_table[i] = serial; | 106 | serial_table[i] = serial; |
107 | serial->port[j++]->number = i; | 107 | serial->port[j++]->number = i; |
108 | } | 108 | } |
109 | spin_unlock(&table_lock); | 109 | mutex_unlock(&table_lock); |
110 | return serial; | 110 | return serial; |
111 | } | 111 | } |
112 | spin_unlock(&table_lock); | 112 | mutex_unlock(&table_lock); |
113 | return NULL; | 113 | return NULL; |
114 | } | 114 | } |
115 | 115 | ||
@@ -172,9 +172,9 @@ static void destroy_serial(struct kref *kref) | |||
172 | 172 | ||
173 | void usb_serial_put(struct usb_serial *serial) | 173 | void usb_serial_put(struct usb_serial *serial) |
174 | { | 174 | { |
175 | spin_lock(&table_lock); | 175 | mutex_lock(&table_lock); |
176 | kref_put(&serial->kref, destroy_serial); | 176 | kref_put(&serial->kref, destroy_serial); |
177 | spin_unlock(&table_lock); | 177 | mutex_unlock(&table_lock); |
178 | } | 178 | } |
179 | 179 | ||
180 | /***************************************************************************** | 180 | /***************************************************************************** |
@@ -1077,16 +1077,17 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message) | |||
1077 | struct usb_serial_port *port; | 1077 | struct usb_serial_port *port; |
1078 | int i, r = 0; | 1078 | int i, r = 0; |
1079 | 1079 | ||
1080 | if (serial) { | 1080 | if (!serial) /* device has been disconnected */ |
1081 | for (i = 0; i < serial->num_ports; ++i) { | 1081 | return 0; |
1082 | port = serial->port[i]; | 1082 | |
1083 | if (port) | 1083 | for (i = 0; i < serial->num_ports; ++i) { |
1084 | kill_traffic(port); | 1084 | port = serial->port[i]; |
1085 | } | 1085 | if (port) |
1086 | kill_traffic(port); | ||
1086 | } | 1087 | } |
1087 | 1088 | ||
1088 | if (serial->type->suspend) | 1089 | if (serial->type->suspend) |
1089 | serial->type->suspend(serial, message); | 1090 | r = serial->type->suspend(serial, message); |
1090 | 1091 | ||
1091 | return r; | 1092 | return r; |
1092 | } | 1093 | } |
@@ -1128,7 +1129,6 @@ static int __init usb_serial_init(void) | |||
1128 | return -ENOMEM; | 1129 | return -ENOMEM; |
1129 | 1130 | ||
1130 | /* Initialize our global data */ | 1131 | /* Initialize our global data */ |
1131 | spin_lock_init(&table_lock); | ||
1132 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { | 1132 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { |
1133 | serial_table[i] = NULL; | 1133 | serial_table[i] = NULL; |
1134 | } | 1134 | } |