Lines Matching +full:out +full:- +full:ports

1 // SPDX-License-Identifier: GPL-2.0+
3 * u_serial.c - utilities for USB gadget "serial port"/TTY support
10 * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com)
64 * gserial <---> gs_port ... links will be null when the USB link is
67 * gserial->ioport == usb_ep->driver_data ... gs_port
68 * gs_port->port_usb ... gserial
70 * gs_port <---> tty_struct ... links will be null when the TTY file
72 * gserial->port_tty ... tty_struct
73 * tty_struct->driver_data ... gserial
127 struct usb_cdc_line_coding port_line_coding; /* 8-N-1 etc */
133 } ports[MAX_U_SERIAL_PORTS]; variable
151 /*-------------------------------------------------------------------------*/
169 req->length = len; in gs_alloc_req()
170 req->buf = kmalloc(len, kmalloc_flags); in gs_alloc_req()
171 if (req->buf == NULL) { in gs_alloc_req()
188 kfree(req->buf); in gs_free_req()
207 len = kfifo_len(&port->port_write_buf); in gs_send_packet()
211 size = kfifo_out(&port->port_write_buf, packet, size); in gs_send_packet()
224 * Context: caller owns port_lock; port_usb is non-null.
228 __releases(&port->port_lock) in gs_start_tx()
229 __acquires(&port->port_lock) in gs_start_tx()
232 struct list_head *pool = &port->write_pool; in gs_start_tx()
237 if (!port->port_usb) in gs_start_tx()
240 in = port->port_usb->in; in gs_start_tx()
242 while (!port->write_busy && !list_empty(pool)) { in gs_start_tx()
246 if (port->write_started >= QUEUE_SIZE) in gs_start_tx()
249 req = list_entry(pool->next, struct usb_request, list); in gs_start_tx()
250 len = gs_send_packet(port, req->buf, in->maxpacket); in gs_start_tx()
252 wake_up_interruptible(&port->drain_wait); in gs_start_tx()
257 req->length = len; in gs_start_tx()
258 list_del(&req->list); in gs_start_tx()
259 req->zero = kfifo_is_empty(&port->port_write_buf); in gs_start_tx()
261 pr_vdebug("ttyGS%d: tx len=%d, %3ph ...\n", port->port_num, len, req->buf); in gs_start_tx()
263 /* Drop lock while we call out of driver; completions in gs_start_tx()
268 * the TTY closed (dev->ioport->port_tty is NULL). in gs_start_tx()
270 port->write_busy = true; in gs_start_tx()
271 spin_unlock(&port->port_lock); in gs_start_tx()
273 spin_lock(&port->port_lock); in gs_start_tx()
274 port->write_busy = false; in gs_start_tx()
278 __func__, "queue", in->name, status); in gs_start_tx()
279 list_add(&req->list, pool); in gs_start_tx()
283 port->write_started++; in gs_start_tx()
286 if (!port->port_usb) in gs_start_tx()
290 if (do_tty_wake && port->port.tty) in gs_start_tx()
291 tty_wakeup(port->port.tty); in gs_start_tx()
300 __releases(&port->port_lock) in gs_start_rx()
301 __acquires(&port->port_lock) in gs_start_rx()
304 struct list_head *pool = &port->read_pool; in gs_start_rx()
305 struct usb_ep *out = port->port_usb->out; in gs_start_rx() local
313 tty = port->port.tty; in gs_start_rx()
317 if (port->read_started >= QUEUE_SIZE) in gs_start_rx()
320 req = list_entry(pool->next, struct usb_request, list); in gs_start_rx()
321 list_del(&req->list); in gs_start_rx()
322 req->length = out->maxpacket; in gs_start_rx()
324 /* drop lock while we call out; the controller driver in gs_start_rx()
327 spin_unlock(&port->port_lock); in gs_start_rx()
328 status = usb_ep_queue(out, req, GFP_ATOMIC); in gs_start_rx()
329 spin_lock(&port->port_lock); in gs_start_rx()
333 __func__, "queue", out->name, status); in gs_start_rx()
334 list_add(&req->list, pool); in gs_start_rx()
337 port->read_started++; in gs_start_rx()
340 if (!port->port_usb) in gs_start_rx()
343 return port->read_started; in gs_start_rx()
347 * RX work takes data out of the RX queue and hands it up to the TTY
352 * the OUT endpoint may begin NAKing as soon as its FIFO fills up.
361 struct list_head *queue = &port->read_queue; in gs_rx_push()
366 spin_lock_irq(&port->port_lock); in gs_rx_push()
367 tty = port->port.tty; in gs_rx_push()
377 switch (req->status) { in gs_rx_push()
378 case -ESHUTDOWN: in gs_rx_push()
380 pr_vdebug("ttyGS%d: shutdown\n", port->port_num); in gs_rx_push()
386 port->port_num, req->status); in gs_rx_push()
394 if (req->actual && tty) { in gs_rx_push()
395 char *packet = req->buf; in gs_rx_push()
396 unsigned size = req->actual; in gs_rx_push()
401 n = port->n_read; in gs_rx_push()
404 size -= n; in gs_rx_push()
407 count = tty_insert_flip_string(&port->port, packet, in gs_rx_push()
413 port->n_read += count; in gs_rx_push()
415 port->port_num, count, req->actual); in gs_rx_push()
418 port->n_read = 0; in gs_rx_push()
421 list_move(&req->list, &port->read_pool); in gs_rx_push()
422 port->read_started--; in gs_rx_push()
429 tty_flip_buffer_push(&port->port); in gs_rx_push()
436 * We may leave non-empty queue only when there is a tty, and in gs_rx_push()
440 schedule_delayed_work(&port->push, 1); in gs_rx_push()
443 if (!disconnect && port->port_usb) in gs_rx_push()
446 spin_unlock_irq(&port->port_lock); in gs_rx_push()
451 struct gs_port *port = ep->driver_data; in gs_read_complete()
454 spin_lock(&port->port_lock); in gs_read_complete()
455 list_add_tail(&req->list, &port->read_queue); in gs_read_complete()
456 schedule_delayed_work(&port->push, 0); in gs_read_complete()
457 spin_unlock(&port->port_lock); in gs_read_complete()
462 struct gs_port *port = ep->driver_data; in gs_write_complete()
464 spin_lock(&port->port_lock); in gs_write_complete()
465 list_add(&req->list, &port->write_pool); in gs_write_complete()
466 port->write_started--; in gs_write_complete()
468 switch (req->status) { in gs_write_complete()
472 __func__, ep->name, req->status); in gs_write_complete()
479 case -ESHUTDOWN: in gs_write_complete()
481 pr_vdebug("%s: %s shutdown\n", __func__, ep->name); in gs_write_complete()
485 spin_unlock(&port->port_lock); in gs_write_complete()
494 req = list_entry(head->next, struct usb_request, list); in gs_free_requests()
495 list_del(&req->list); in gs_free_requests()
498 (*allocated)--; in gs_free_requests()
508 int n = allocated ? QUEUE_SIZE - *allocated : QUEUE_SIZE; in gs_alloc_requests()
510 /* Pre-allocate up to QUEUE_SIZE transfers, but if we can't in gs_alloc_requests()
515 req = gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC); in gs_alloc_requests()
517 return list_empty(head) ? -ENOMEM : 0; in gs_alloc_requests()
518 req->complete = fn; in gs_alloc_requests()
519 list_add_tail(&req->list, head); in gs_alloc_requests()
527 * gs_start_io - start USB I/O streams
529 * Context: holding port_lock; port_tty and port_usb are non-null
537 struct list_head *head = &port->read_pool; in gs_start_io()
538 struct usb_ep *ep = port->port_usb->out; in gs_start_io()
549 &port->read_allocated); in gs_start_io()
553 status = gs_alloc_requests(port->port_usb->in, &port->write_pool, in gs_start_io()
554 gs_write_complete, &port->write_allocated); in gs_start_io()
556 gs_free_requests(ep, head, &port->read_allocated); in gs_start_io()
561 port->n_read = 0; in gs_start_io()
568 tty_wakeup(port->port.tty); in gs_start_io()
570 gs_free_requests(ep, head, &port->read_allocated); in gs_start_io()
571 gs_free_requests(port->port_usb->in, &port->write_pool, in gs_start_io()
572 &port->write_allocated); in gs_start_io()
573 status = -EIO; in gs_start_io()
579 /*-------------------------------------------------------------------------*/
590 int port_num = tty->index; in gs_open()
594 mutex_lock(&ports[port_num].lock); in gs_open()
595 port = ports[port_num].port; in gs_open()
597 status = -ENODEV; in gs_open()
598 goto out; in gs_open()
601 spin_lock_irq(&port->port_lock); in gs_open()
604 if (!kfifo_initialized(&port->port_write_buf)) { in gs_open()
606 spin_unlock_irq(&port->port_lock); in gs_open()
613 status = kfifo_alloc(&port->port_write_buf, in gs_open()
618 goto out; in gs_open()
621 spin_lock_irq(&port->port_lock); in gs_open()
625 if (port->port.count++) in gs_open()
628 tty->driver_data = port; in gs_open()
629 port->port.tty = tty; in gs_open()
632 if (port->port_usb) { in gs_open()
634 if (!port->suspended) { in gs_open()
635 struct gserial *gser = port->port_usb; in gs_open()
637 pr_debug("gs_open: start ttyGS%d\n", port->port_num); in gs_open()
640 if (gser->connect) in gs_open()
641 gser->connect(gser); in gs_open()
643 pr_debug("delay start of ttyGS%d\n", port->port_num); in gs_open()
644 port->start_delayed = true; in gs_open()
648 pr_debug("gs_open: ttyGS%d (%p,%p)\n", port->port_num, tty, file); in gs_open()
651 spin_unlock_irq(&port->port_lock); in gs_open()
652 out: in gs_open()
653 mutex_unlock(&ports[port_num].lock); in gs_open()
662 spin_lock_irq(&p->port_lock); in gs_close_flush_done()
663 cond = p->port_usb == NULL || !kfifo_len(&p->port_write_buf) || in gs_close_flush_done()
664 p->port.count > 1; in gs_close_flush_done()
665 spin_unlock_irq(&p->port_lock); in gs_close_flush_done()
672 struct gs_port *port = tty->driver_data; in gs_close()
675 spin_lock_irq(&port->port_lock); in gs_close()
677 if (port->port.count != 1) { in gs_close()
679 if (port->port.count == 0) in gs_close()
682 --port->port.count; in gs_close()
686 pr_debug("gs_close: ttyGS%d (%p,%p) ...\n", port->port_num, tty, file); in gs_close()
688 gser = port->port_usb; in gs_close()
689 if (gser && !port->suspended && gser->disconnect) in gs_close()
690 gser->disconnect(gser); in gs_close()
695 if (kfifo_len(&port->port_write_buf) > 0 && gser) { in gs_close()
696 spin_unlock_irq(&port->port_lock); in gs_close()
697 wait_event_interruptible_timeout(port->drain_wait, in gs_close()
700 spin_lock_irq(&port->port_lock); in gs_close()
702 if (port->port.count != 1) in gs_close()
705 gser = port->port_usb; in gs_close()
710 * let the push async work fire again until we're re-opened. in gs_close()
713 kfifo_free(&port->port_write_buf); in gs_close()
715 kfifo_reset(&port->port_write_buf); in gs_close()
717 port->start_delayed = false; in gs_close()
718 port->port.count = 0; in gs_close()
719 port->port.tty = NULL; in gs_close()
722 port->port_num, tty, file); in gs_close()
724 wake_up(&port->close_wait); in gs_close()
726 spin_unlock_irq(&port->port_lock); in gs_close()
731 struct gs_port *port = tty->driver_data; in gs_write()
735 port->port_num, tty, count); in gs_write()
737 spin_lock_irqsave(&port->port_lock, flags); in gs_write()
739 count = kfifo_in(&port->port_write_buf, buf, count); in gs_write()
741 if (port->port_usb) in gs_write()
743 spin_unlock_irqrestore(&port->port_lock, flags); in gs_write()
750 struct gs_port *port = tty->driver_data; in gs_put_char()
755 port->port_num, tty, ch, __builtin_return_address(0)); in gs_put_char()
757 spin_lock_irqsave(&port->port_lock, flags); in gs_put_char()
758 status = kfifo_put(&port->port_write_buf, ch); in gs_put_char()
759 spin_unlock_irqrestore(&port->port_lock, flags); in gs_put_char()
766 struct gs_port *port = tty->driver_data; in gs_flush_chars()
769 pr_vdebug("gs_flush_chars: (%d,%p)\n", port->port_num, tty); in gs_flush_chars()
771 spin_lock_irqsave(&port->port_lock, flags); in gs_flush_chars()
772 if (port->port_usb) in gs_flush_chars()
774 spin_unlock_irqrestore(&port->port_lock, flags); in gs_flush_chars()
779 struct gs_port *port = tty->driver_data; in gs_write_room()
783 spin_lock_irqsave(&port->port_lock, flags); in gs_write_room()
784 if (port->port_usb) in gs_write_room()
785 room = kfifo_avail(&port->port_write_buf); in gs_write_room()
786 spin_unlock_irqrestore(&port->port_lock, flags); in gs_write_room()
789 port->port_num, tty, room); in gs_write_room()
796 struct gs_port *port = tty->driver_data; in gs_chars_in_buffer()
800 spin_lock_irqsave(&port->port_lock, flags); in gs_chars_in_buffer()
801 chars = kfifo_len(&port->port_write_buf); in gs_chars_in_buffer()
802 spin_unlock_irqrestore(&port->port_lock, flags); in gs_chars_in_buffer()
805 port->port_num, tty, chars); in gs_chars_in_buffer()
813 struct gs_port *port = tty->driver_data; in gs_unthrottle()
816 spin_lock_irqsave(&port->port_lock, flags); in gs_unthrottle()
817 if (port->port_usb) { in gs_unthrottle()
820 * read queue backs up enough we'll be NAKing OUT packets. in gs_unthrottle()
822 pr_vdebug("ttyGS%d: unthrottle\n", port->port_num); in gs_unthrottle()
823 schedule_delayed_work(&port->push, 0); in gs_unthrottle()
825 spin_unlock_irqrestore(&port->port_lock, flags); in gs_unthrottle()
830 struct gs_port *port = tty->driver_data; in gs_break_ctl()
835 port->port_num, duration); in gs_break_ctl()
837 spin_lock_irq(&port->port_lock); in gs_break_ctl()
838 gser = port->port_usb; in gs_break_ctl()
839 if (gser && gser->send_break) in gs_break_ctl()
840 status = gser->send_break(gser, duration); in gs_break_ctl()
841 spin_unlock_irq(&port->port_lock); in gs_break_ctl()
858 /*-------------------------------------------------------------------------*/
866 struct gs_console *cons = req->context; in gs_console_complete_out()
868 switch (req->status) { in gs_console_complete_out()
871 __func__, ep->name, req->status); in gs_console_complete_out()
875 spin_lock(&cons->lock); in gs_console_complete_out()
876 req->length = 0; in gs_console_complete_out()
877 schedule_work(&cons->work); in gs_console_complete_out()
878 spin_unlock(&cons->lock); in gs_console_complete_out()
880 case -ECONNRESET: in gs_console_complete_out()
881 case -ESHUTDOWN: in gs_console_complete_out()
883 pr_vdebug("%s: %s shutdown\n", __func__, ep->name); in gs_console_complete_out()
890 struct usb_request *req = cons->req; in __gs_console_push()
897 if (req->length) in __gs_console_push()
900 ep = cons->console.data; in __gs_console_push()
901 size = kfifo_out(&cons->buf, req->buf, ep->maxpacket); in __gs_console_push()
905 if (cons->missed && ep->maxpacket >= 64) { in __gs_console_push()
909 len = sprintf(buf, "\n[missed %zu bytes]\n", cons->missed); in __gs_console_push()
910 kfifo_in(&cons->buf, buf, len); in __gs_console_push()
911 cons->missed = 0; in __gs_console_push()
914 req->length = size; in __gs_console_push()
916 req->length = 0; in __gs_console_push()
923 spin_lock_irq(&cons->lock); in gs_console_work()
927 spin_unlock_irq(&cons->lock); in gs_console_work()
937 spin_lock_irqsave(&cons->lock, flags); in gs_console_write()
939 n = kfifo_in(&cons->buf, buf, count); in gs_console_write()
941 cons->missed += count - n; in gs_console_write()
943 if (cons->req && !cons->req->length) in gs_console_write()
944 schedule_work(&cons->work); in gs_console_write()
946 spin_unlock_irqrestore(&cons->lock, flags); in gs_console_write()
951 *index = co->index; in gs_console_device()
957 struct gs_console *cons = port->console; in gs_console_connect()
964 ep = port->port_usb->in; in gs_console_connect()
965 req = gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC); in gs_console_connect()
967 return -ENOMEM; in gs_console_connect()
968 req->complete = gs_console_complete_out; in gs_console_connect()
969 req->context = cons; in gs_console_connect()
970 req->length = 0; in gs_console_connect()
972 spin_lock(&cons->lock); in gs_console_connect()
973 cons->req = req; in gs_console_connect()
974 cons->console.data = ep; in gs_console_connect()
975 spin_unlock(&cons->lock); in gs_console_connect()
977 pr_debug("ttyGS%d: console connected!\n", port->port_num); in gs_console_connect()
979 schedule_work(&cons->work); in gs_console_connect()
986 struct gs_console *cons = port->console; in gs_console_disconnect()
993 spin_lock(&cons->lock); in gs_console_disconnect()
995 req = cons->req; in gs_console_disconnect()
996 ep = cons->console.data; in gs_console_disconnect()
997 cons->req = NULL; in gs_console_disconnect()
999 spin_unlock(&cons->lock); in gs_console_disconnect()
1013 if (port->console) in gs_console_init()
1016 cons = kzalloc(sizeof(*port->console), GFP_KERNEL); in gs_console_init()
1018 return -ENOMEM; in gs_console_init()
1020 strcpy(cons->console.name, "ttyGS"); in gs_console_init()
1021 cons->console.write = gs_console_write; in gs_console_init()
1022 cons->console.device = gs_console_device; in gs_console_init()
1023 cons->console.flags = CON_PRINTBUFFER; in gs_console_init()
1024 cons->console.index = port->port_num; in gs_console_init()
1026 INIT_WORK(&cons->work, gs_console_work); in gs_console_init()
1027 spin_lock_init(&cons->lock); in gs_console_init()
1029 err = kfifo_alloc(&cons->buf, GS_CONSOLE_BUF_SIZE, GFP_KERNEL); in gs_console_init()
1031 pr_err("ttyGS%d: allocate console buffer failed\n", port->port_num); in gs_console_init()
1036 port->console = cons; in gs_console_init()
1037 register_console(&cons->console); in gs_console_init()
1039 spin_lock_irq(&port->port_lock); in gs_console_init()
1040 if (port->port_usb) in gs_console_init()
1042 spin_unlock_irq(&port->port_lock); in gs_console_init()
1049 struct gs_console *cons = port->console; in gs_console_exit()
1054 unregister_console(&cons->console); in gs_console_exit()
1056 spin_lock_irq(&port->port_lock); in gs_console_exit()
1057 if (cons->req) in gs_console_exit()
1059 spin_unlock_irq(&port->port_lock); in gs_console_exit()
1061 cancel_work_sync(&cons->work); in gs_console_exit()
1062 kfifo_free(&cons->buf); in gs_console_exit()
1064 port->console = NULL; in gs_console_exit()
1077 mutex_lock(&ports[port_num].lock); in gserial_set_console()
1078 port = ports[port_num].port; in gserial_set_console()
1081 ret = -ENXIO; in gserial_set_console()
1082 goto out; in gserial_set_console()
1089 out: in gserial_set_console()
1090 mutex_unlock(&ports[port_num].lock); in gserial_set_console()
1101 mutex_lock(&ports[port_num].lock); in gserial_get_console()
1102 port = ports[port_num].port; in gserial_get_console()
1105 ret = -ENXIO; in gserial_get_console()
1107 ret = sprintf(page, "%u\n", !!port->console); in gserial_get_console()
1109 mutex_unlock(&ports[port_num].lock); in gserial_get_console()
1128 return -ENOSYS; in gs_console_init()
1143 mutex_lock(&ports[port_num].lock); in gs_port_alloc()
1144 if (ports[port_num].port) { in gs_port_alloc()
1145 ret = -EBUSY; in gs_port_alloc()
1146 goto out; in gs_port_alloc()
1151 ret = -ENOMEM; in gs_port_alloc()
1152 goto out; in gs_port_alloc()
1155 tty_port_init(&port->port); in gs_port_alloc()
1156 spin_lock_init(&port->port_lock); in gs_port_alloc()
1157 init_waitqueue_head(&port->drain_wait); in gs_port_alloc()
1158 init_waitqueue_head(&port->close_wait); in gs_port_alloc()
1160 INIT_DELAYED_WORK(&port->push, gs_rx_push); in gs_port_alloc()
1162 INIT_LIST_HEAD(&port->read_pool); in gs_port_alloc()
1163 INIT_LIST_HEAD(&port->read_queue); in gs_port_alloc()
1164 INIT_LIST_HEAD(&port->write_pool); in gs_port_alloc()
1166 port->port_num = port_num; in gs_port_alloc()
1167 port->port_line_coding = *coding; in gs_port_alloc()
1169 ports[port_num].port = port; in gs_port_alloc()
1170 out: in gs_port_alloc()
1171 mutex_unlock(&ports[port_num].lock); in gs_port_alloc()
1179 spin_lock_irq(&port->port_lock); in gs_closed()
1180 cond = port->port.count == 0; in gs_closed()
1181 spin_unlock_irq(&port->port_lock); in gs_closed()
1188 cancel_delayed_work_sync(&port->push); in gserial_free_port()
1190 wait_event(port->close_wait, gs_closed(port)); in gserial_free_port()
1191 WARN_ON(port->port_usb != NULL); in gserial_free_port()
1192 tty_port_destroy(&port->port); in gserial_free_port()
1200 mutex_lock(&ports[port_num].lock); in gserial_free_line()
1201 if (!ports[port_num].port) { in gserial_free_line()
1202 mutex_unlock(&ports[port_num].lock); in gserial_free_line()
1205 port = ports[port_num].port; in gserial_free_line()
1207 ports[port_num].port = NULL; in gserial_free_line()
1208 mutex_unlock(&ports[port_num].lock); in gserial_free_line()
1230 if (ret == -EBUSY) in gserial_alloc_line_no_console()
1241 port = ports[port_num].port; in gserial_alloc_line_no_console()
1242 tty_dev = tty_port_register_device(&port->port, in gserial_alloc_line_no_console()
1249 mutex_lock(&ports[port_num].lock); in gserial_alloc_line_no_console()
1250 ports[port_num].port = NULL; in gserial_alloc_line_no_console()
1251 mutex_unlock(&ports[port_num].lock); in gserial_alloc_line_no_console()
1266 gs_console_init(ports[*line_num].port); in gserial_alloc_line()
1273 * gserial_connect - notify TTY I/O glue that USB link is active
1286 * before calling this, as well as the appropriate (speed-specific)
1291 * On success, ep->driver_data will be overwritten.
1300 return -ENXIO; in gserial_connect()
1302 port = ports[port_num].port; in gserial_connect()
1305 return -EINVAL; in gserial_connect()
1307 if (port->port_usb) { in gserial_connect()
1309 return -EBUSY; in gserial_connect()
1313 status = usb_ep_enable(gser->in); in gserial_connect()
1316 gser->in->driver_data = port; in gserial_connect()
1318 status = usb_ep_enable(gser->out); in gserial_connect()
1321 gser->out->driver_data = port; in gserial_connect()
1324 spin_lock_irqsave(&port->port_lock, flags); in gserial_connect()
1325 gser->ioport = port; in gserial_connect()
1326 port->port_usb = gser; in gserial_connect()
1331 gser->port_line_coding = port->port_line_coding; in gserial_connect()
1338 if (port->port.count) { in gserial_connect()
1339 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num); in gserial_connect()
1341 if (gser->connect) in gserial_connect()
1342 gser->connect(gser); in gserial_connect()
1344 if (gser->disconnect) in gserial_connect()
1345 gser->disconnect(gser); in gserial_connect()
1349 spin_unlock_irqrestore(&port->port_lock, flags); in gserial_connect()
1354 usb_ep_disable(gser->in); in gserial_connect()
1359 * gserial_disconnect - notify TTY I/O glue that USB link is inactive
1371 struct gs_port *port = gser->ioport; in gserial_disconnect()
1378 spin_lock_irqsave(&port->port_lock, flags); in gserial_disconnect()
1383 port->port_line_coding = gser->port_line_coding; in gserial_disconnect()
1385 port->port_usb = NULL; in gserial_disconnect()
1386 gser->ioport = NULL; in gserial_disconnect()
1387 if (port->port.count > 0) { in gserial_disconnect()
1388 wake_up_interruptible(&port->drain_wait); in gserial_disconnect()
1389 if (port->port.tty) in gserial_disconnect()
1390 tty_hangup(port->port.tty); in gserial_disconnect()
1392 port->suspended = false; in gserial_disconnect()
1393 spin_unlock_irqrestore(&port->port_lock, flags); in gserial_disconnect()
1396 usb_ep_disable(gser->out); in gserial_disconnect()
1397 usb_ep_disable(gser->in); in gserial_disconnect()
1400 spin_lock_irqsave(&port->port_lock, flags); in gserial_disconnect()
1401 if (port->port.count == 0) in gserial_disconnect()
1402 kfifo_free(&port->port_write_buf); in gserial_disconnect()
1403 gs_free_requests(gser->out, &port->read_pool, NULL); in gserial_disconnect()
1404 gs_free_requests(gser->out, &port->read_queue, NULL); in gserial_disconnect()
1405 gs_free_requests(gser->in, &port->write_pool, NULL); in gserial_disconnect()
1407 port->read_allocated = port->read_started = in gserial_disconnect()
1408 port->write_allocated = port->write_started = 0; in gserial_disconnect()
1410 spin_unlock_irqrestore(&port->port_lock, flags); in gserial_disconnect()
1416 struct gs_port *port = gser->ioport; in gserial_suspend()
1419 spin_lock_irqsave(&port->port_lock, flags); in gserial_suspend()
1420 port->suspended = true; in gserial_suspend()
1421 spin_unlock_irqrestore(&port->port_lock, flags); in gserial_suspend()
1427 struct gs_port *port = gser->ioport; in gserial_resume()
1430 spin_lock_irqsave(&port->port_lock, flags); in gserial_resume()
1431 port->suspended = false; in gserial_resume()
1432 if (!port->start_delayed) { in gserial_resume()
1433 spin_unlock_irqrestore(&port->port_lock, flags); in gserial_resume()
1437 pr_debug("delayed start ttyGS%d\n", port->port_num); in gserial_resume()
1439 if (gser->connect) in gserial_resume()
1440 gser->connect(gser); in gserial_resume()
1441 port->start_delayed = false; in gserial_resume()
1442 spin_unlock_irqrestore(&port->port_lock, flags); in gserial_resume()
1457 driver->driver_name = "g_serial"; in userial_init()
1458 driver->name = "ttyGS"; in userial_init()
1461 driver->type = TTY_DRIVER_TYPE_SERIAL; in userial_init()
1462 driver->subtype = SERIAL_TYPE_NORMAL; in userial_init()
1463 driver->init_termios = tty_std_termios; in userial_init()
1465 /* 9600-8-N-1 ... matches defaults expected by "usbser.sys" on in userial_init()
1466 * MS-Windows. Otherwise, most of these flags shouldn't affect in userial_init()
1469 driver->init_termios.c_cflag = in userial_init()
1471 driver->init_termios.c_ispeed = 9600; in userial_init()
1472 driver->init_termios.c_ospeed = 9600; in userial_init()
1476 mutex_init(&ports[i].lock); in userial_init()