aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/serial.c')
-rw-r--r--drivers/usb/gadget/serial.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 65e084a2c87e..2e6926b33455 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -1271,6 +1271,7 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet, unsigned int size)
1271 unsigned int len; 1271 unsigned int len;
1272 struct gs_port *port; 1272 struct gs_port *port;
1273 int ret; 1273 int ret;
1274 struct tty_struct *tty;
1274 1275
1275 /* TEMPORARY -- only port 0 is supported right now */ 1276 /* TEMPORARY -- only port 0 is supported right now */
1276 port = dev->dev_port[0]; 1277 port = dev->dev_port[0];
@@ -1290,7 +1291,10 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet, unsigned int size)
1290 goto exit; 1291 goto exit;
1291 } 1292 }
1292 1293
1293 if (port->port_tty == NULL) { 1294
1295 tty = port->port_tty;
1296
1297 if (tty == NULL) {
1294 printk(KERN_ERR "gs_recv_packet: port=%d, NULL tty pointer\n", 1298 printk(KERN_ERR "gs_recv_packet: port=%d, NULL tty pointer\n",
1295 port->port_num); 1299 port->port_num);
1296 ret = -EIO; 1300 ret = -EIO;
@@ -1304,20 +1308,13 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet, unsigned int size)
1304 goto exit; 1308 goto exit;
1305 } 1309 }
1306 1310
1307 len = (unsigned int)(TTY_FLIPBUF_SIZE - port->port_tty->flip.count); 1311 len = tty_buffer_request_room(tty, size);
1308 if (len < size) 1312 if (len > 0) {
1309 size = len; 1313 tty_insert_flip_string(tty, packet, len);
1310
1311 if (size > 0) {
1312 memcpy(port->port_tty->flip.char_buf_ptr, packet, size);
1313 port->port_tty->flip.char_buf_ptr += size;
1314 port->port_tty->flip.count += size;
1315 tty_flip_buffer_push(port->port_tty); 1314 tty_flip_buffer_push(port->port_tty);
1316 wake_up_interruptible(&port->port_tty->read_wait); 1315 wake_up_interruptible(&port->port_tty->read_wait);
1317 } 1316 }
1318
1319 ret = 0; 1317 ret = 0;
1320
1321exit: 1318exit:
1322 spin_unlock(&port->port_lock); 1319 spin_unlock(&port->port_lock);
1323 return ret; 1320 return ret;