aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/mos7720.c
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-10-13 05:39:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 12:51:41 -0400
commit4a90f09b20f4622dcbff1f0e1e6bae1704f8ad8c (patch)
tree9b275f88f2705cb10121d5982741aef3a088a7c8 /drivers/usb/serial/mos7720.c
parent95f9bfc6b76e862265a2d70ae061eec18fe14140 (diff)
tty: usb-serial krefs
Use kref in the USB serial drivers so that we don't free tty structures from under the URB receive handlers as has historically been the case if you were unlucky. This also gives us a framework for general tty drivers to use tty_port objects and refcount. Contains two err->dev_err changes merged together to fix clashes in the -next tree. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial/mos7720.c')
-rw-r--r--drivers/usb/serial/mos7720.c36
1 files changed, 4 insertions, 32 deletions
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 7c4917d77c0a..7b538caec37f 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -216,12 +216,13 @@ static void mos7720_bulk_in_callback(struct urb *urb)
216 216
217 data = urb->transfer_buffer; 217 data = urb->transfer_buffer;
218 218
219 tty = port->port.tty; 219 tty = tty_port_tty_get(&port->port);
220 if (tty && urb->actual_length) { 220 if (tty && urb->actual_length) {
221 tty_buffer_request_room(tty, urb->actual_length); 221 tty_buffer_request_room(tty, urb->actual_length);
222 tty_insert_flip_string(tty, data, urb->actual_length); 222 tty_insert_flip_string(tty, data, urb->actual_length);
223 tty_flip_buffer_push(tty); 223 tty_flip_buffer_push(tty);
224 } 224 }
225 tty_kref_put(tty);
225 226
226 if (!port->read_urb) { 227 if (!port->read_urb) {
227 dbg("URB KILLED !!!"); 228 dbg("URB KILLED !!!");
@@ -262,10 +263,11 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
262 263
263 dbg("Entering ........."); 264 dbg("Entering .........");
264 265
265 tty = mos7720_port->port->port.tty; 266 tty = tty_port_tty_get(&mos7720_port->port->port);
266 267
267 if (tty && mos7720_port->open) 268 if (tty && mos7720_port->open)
268 tty_wakeup(tty); 269 tty_wakeup(tty);
270 tty_kref_put(tty);
269} 271}
270 272
271/* 273/*
@@ -1267,29 +1269,6 @@ static int get_lsr_info(struct tty_struct *tty,
1267 return 0; 1269 return 0;
1268} 1270}
1269 1271
1270/*
1271 * get_number_bytes_avail - get number of bytes available
1272 *
1273 * Purpose: Let user call ioctl to get the count of number of bytes available.
1274 */
1275static int get_number_bytes_avail(struct moschip_port *mos7720_port,
1276 unsigned int __user *value)
1277{
1278 unsigned int result = 0;
1279 struct tty_struct *tty = mos7720_port->port->port.tty;
1280
1281 if (!tty)
1282 return -ENOIOCTLCMD;
1283
1284 result = tty->read_cnt;
1285
1286 dbg("%s(%d) = %d", __func__, mos7720_port->port->number, result);
1287 if (copy_to_user(value, &result, sizeof(int)))
1288 return -EFAULT;
1289
1290 return -ENOIOCTLCMD;
1291}
1292
1293static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, 1272static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd,
1294 unsigned int __user *value) 1273 unsigned int __user *value)
1295{ 1274{
@@ -1409,13 +1388,6 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file,
1409 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 1388 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
1410 1389
1411 switch (cmd) { 1390 switch (cmd) {
1412 case TIOCINQ:
1413 /* return number of bytes available */
1414 dbg("%s (%d) TIOCINQ", __func__, port->number);
1415 return get_number_bytes_avail(mos7720_port,
1416 (unsigned int __user *)arg);
1417 break;
1418
1419 case TIOCSERGETLSR: 1391 case TIOCSERGETLSR:
1420 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); 1392 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
1421 return get_lsr_info(tty, mos7720_port, 1393 return get_lsr_info(tty, mos7720_port,