Lines Matching +full:console +full:- +full:size

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)
26 #include <linux/console.h>
65 * gserial <---> gs_port ... links will be null when the USB link is
68 * gserial->ioport == usb_ep->driver_data ... gs_port
69 * gs_port->port_usb ... gserial
71 * gs_port <---> tty_struct ... links will be null when the TTY file
73 * gserial->port_tty ... tty_struct
74 * tty_struct->driver_data ... gserial
85 /* Prevents race conditions while accessing gser->ioport */
88 /* console info */
90 struct console console; member
108 struct gs_console *console; member
131 struct usb_cdc_line_coding port_line_coding; /* 8-N-1 etc */
155 /*-------------------------------------------------------------------------*/
173 req->length = len; in gs_alloc_req()
174 req->buf = kmalloc(len, kmalloc_flags); in gs_alloc_req()
175 if (req->buf == NULL) { in gs_alloc_req()
192 kfree(req->buf); in gs_free_req()
201 * buffer and the size is returned. If there is no data to
207 gs_send_packet(struct gs_port *port, char *packet, unsigned size) in gs_send_packet() argument
211 len = kfifo_len(&port->port_write_buf); in gs_send_packet()
212 if (len < size) in gs_send_packet()
213 size = len; in gs_send_packet()
214 if (size != 0) in gs_send_packet()
215 size = kfifo_out(&port->port_write_buf, packet, size); in gs_send_packet()
216 return size; in gs_send_packet()
228 * Context: caller owns port_lock; port_usb is non-null.
232 __releases(&port->port_lock) in gs_start_tx()
233 __acquires(&port->port_lock) in gs_start_tx()
236 struct list_head *pool = &port->write_pool; in gs_start_tx()
241 if (!port->port_usb) in gs_start_tx()
244 in = port->port_usb->in; in gs_start_tx()
246 while (!port->write_busy && !list_empty(pool)) { in gs_start_tx()
250 if (port->write_started >= QUEUE_SIZE) in gs_start_tx()
253 req = list_entry(pool->next, struct usb_request, list); in gs_start_tx()
254 len = gs_send_packet(port, req->buf, in->maxpacket); in gs_start_tx()
256 wake_up_interruptible(&port->drain_wait); in gs_start_tx()
261 req->length = len; in gs_start_tx()
262 list_del(&req->list); in gs_start_tx()
263 req->zero = kfifo_is_empty(&port->port_write_buf); in gs_start_tx()
265 pr_vdebug("ttyGS%d: tx len=%d, %3ph ...\n", port->port_num, len, req->buf); in gs_start_tx()
272 * the TTY closed (dev->ioport->port_tty is NULL). in gs_start_tx()
274 port->write_busy = true; in gs_start_tx()
275 spin_unlock(&port->port_lock); in gs_start_tx()
277 spin_lock(&port->port_lock); in gs_start_tx()
278 port->write_busy = false; in gs_start_tx()
282 __func__, "queue", in->name, status); in gs_start_tx()
283 list_add(&req->list, pool); in gs_start_tx()
287 port->write_started++; in gs_start_tx()
290 if (!port->port_usb) in gs_start_tx()
294 if (do_tty_wake && port->port.tty) in gs_start_tx()
295 tty_wakeup(port->port.tty); in gs_start_tx()
304 __releases(&port->port_lock) in gs_start_rx()
305 __acquires(&port->port_lock) in gs_start_rx()
308 struct list_head *pool = &port->read_pool; in gs_start_rx()
309 struct usb_ep *out = port->port_usb->out; in gs_start_rx()
317 tty = port->port.tty; in gs_start_rx()
321 if (port->read_started >= QUEUE_SIZE) in gs_start_rx()
324 req = list_entry(pool->next, struct usb_request, list); in gs_start_rx()
325 list_del(&req->list); in gs_start_rx()
326 req->length = out->maxpacket; in gs_start_rx()
331 spin_unlock(&port->port_lock); in gs_start_rx()
333 spin_lock(&port->port_lock); in gs_start_rx()
337 __func__, "queue", out->name, status); in gs_start_rx()
338 list_add(&req->list, pool); in gs_start_rx()
341 port->read_started++; in gs_start_rx()
344 if (!port->port_usb) in gs_start_rx()
347 return port->read_started; in gs_start_rx()
365 struct list_head *queue = &port->read_queue; in gs_rx_push()
370 spin_lock_irq(&port->port_lock); in gs_rx_push()
371 tty = port->port.tty; in gs_rx_push()
381 switch (req->status) { in gs_rx_push()
382 case -ESHUTDOWN: in gs_rx_push()
384 pr_vdebug("ttyGS%d: shutdown\n", port->port_num); in gs_rx_push()
390 port->port_num, req->status); in gs_rx_push()
398 if (req->actual && tty) { in gs_rx_push()
399 char *packet = req->buf; in gs_rx_push()
400 unsigned size = req->actual; in gs_rx_push() local
405 n = port->n_read; in gs_rx_push()
408 size -= n; in gs_rx_push()
411 count = tty_insert_flip_string(&port->port, packet, in gs_rx_push()
412 size); in gs_rx_push()
415 if (count != size) { in gs_rx_push()
417 port->n_read += count; in gs_rx_push()
419 port->port_num, count, req->actual); in gs_rx_push()
422 port->n_read = 0; in gs_rx_push()
425 list_move(&req->list, &port->read_pool); in gs_rx_push()
426 port->read_started--; in gs_rx_push()
433 tty_flip_buffer_push(&port->port); in gs_rx_push()
440 * We may leave non-empty queue only when there is a tty, and in gs_rx_push()
444 schedule_delayed_work(&port->push, 1); in gs_rx_push()
447 if (!disconnect && port->port_usb) in gs_rx_push()
450 spin_unlock_irq(&port->port_lock); in gs_rx_push()
455 struct gs_port *port = ep->driver_data; in gs_read_complete()
458 spin_lock(&port->port_lock); in gs_read_complete()
459 list_add_tail(&req->list, &port->read_queue); in gs_read_complete()
460 schedule_delayed_work(&port->push, 0); in gs_read_complete()
461 spin_unlock(&port->port_lock); in gs_read_complete()
466 struct gs_port *port = ep->driver_data; in gs_write_complete()
468 spin_lock(&port->port_lock); in gs_write_complete()
469 list_add(&req->list, &port->write_pool); in gs_write_complete()
470 port->write_started--; in gs_write_complete()
472 switch (req->status) { in gs_write_complete()
476 __func__, ep->name, req->status); in gs_write_complete()
483 case -ESHUTDOWN: in gs_write_complete()
485 pr_vdebug("%s: %s shutdown\n", __func__, ep->name); in gs_write_complete()
489 spin_unlock(&port->port_lock); in gs_write_complete()
498 req = list_entry(head->next, struct usb_request, list); in gs_free_requests()
499 list_del(&req->list); in gs_free_requests()
502 (*allocated)--; in gs_free_requests()
512 int n = allocated ? QUEUE_SIZE - *allocated : QUEUE_SIZE; in gs_alloc_requests()
514 /* Pre-allocate up to QUEUE_SIZE transfers, but if we can't in gs_alloc_requests()
519 req = gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC); in gs_alloc_requests()
521 return list_empty(head) ? -ENOMEM : 0; in gs_alloc_requests()
522 req->complete = fn; in gs_alloc_requests()
523 list_add_tail(&req->list, head); in gs_alloc_requests()
531 * gs_start_io - start USB I/O streams
533 * Context: holding port_lock; port_tty and port_usb are non-null
541 struct list_head *head = &port->read_pool; in gs_start_io()
546 if (!port->port_usb || !port->port.tty) in gs_start_io()
547 return -EIO; in gs_start_io()
555 ep = port->port_usb->out; in gs_start_io()
557 &port->read_allocated); in gs_start_io()
561 status = gs_alloc_requests(port->port_usb->in, &port->write_pool, in gs_start_io()
562 gs_write_complete, &port->write_allocated); in gs_start_io()
564 gs_free_requests(ep, head, &port->read_allocated); in gs_start_io()
569 port->n_read = 0; in gs_start_io()
576 tty_wakeup(port->port.tty); in gs_start_io()
578 gs_free_requests(ep, head, &port->read_allocated); in gs_start_io()
579 gs_free_requests(port->port_usb->in, &port->write_pool, in gs_start_io()
580 &port->write_allocated); in gs_start_io()
581 status = -EIO; in gs_start_io()
587 /*-------------------------------------------------------------------------*/
598 int port_num = tty->index; in gs_open()
605 status = -ENODEV; in gs_open()
609 spin_lock_irq(&port->port_lock); in gs_open()
612 if (!kfifo_initialized(&port->port_write_buf)) { in gs_open()
614 spin_unlock_irq(&port->port_lock); in gs_open()
621 status = kfifo_alloc(&port->port_write_buf, in gs_open()
629 spin_lock_irq(&port->port_lock); in gs_open()
633 if (port->port.count++) in gs_open()
636 tty->driver_data = port; in gs_open()
637 port->port.tty = tty; in gs_open()
640 if (port->port_usb) { in gs_open()
642 if (!port->suspended) { in gs_open()
643 struct gserial *gser = port->port_usb; in gs_open()
645 pr_debug("gs_open: start ttyGS%d\n", port->port_num); in gs_open()
648 if (gser->connect) in gs_open()
649 gser->connect(gser); in gs_open()
651 pr_debug("delay start of ttyGS%d\n", port->port_num); in gs_open()
652 port->start_delayed = true; in gs_open()
656 pr_debug("gs_open: ttyGS%d (%p,%p)\n", port->port_num, tty, file); in gs_open()
659 spin_unlock_irq(&port->port_lock); in gs_open()
670 spin_lock_irq(&p->port_lock); in gs_close_flush_done()
671 cond = p->port_usb == NULL || !kfifo_len(&p->port_write_buf) || in gs_close_flush_done()
672 p->port.count > 1; in gs_close_flush_done()
673 spin_unlock_irq(&p->port_lock); in gs_close_flush_done()
680 struct gs_port *port = tty->driver_data; in gs_close()
683 spin_lock_irq(&port->port_lock); in gs_close()
685 if (port->port.count != 1) { in gs_close()
687 if (port->port.count == 0) in gs_close()
690 --port->port.count; in gs_close()
694 pr_debug("gs_close: ttyGS%d (%p,%p) ...\n", port->port_num, tty, file); in gs_close()
696 gser = port->port_usb; in gs_close()
697 if (gser && !port->suspended && gser->disconnect) in gs_close()
698 gser->disconnect(gser); in gs_close()
703 if (kfifo_len(&port->port_write_buf) > 0 && gser) { in gs_close()
704 spin_unlock_irq(&port->port_lock); in gs_close()
705 wait_event_interruptible_timeout(port->drain_wait, in gs_close()
708 spin_lock_irq(&port->port_lock); in gs_close()
710 if (port->port.count != 1) in gs_close()
713 gser = port->port_usb; in gs_close()
718 * let the push async work fire again until we're re-opened. in gs_close()
721 kfifo_free(&port->port_write_buf); in gs_close()
723 kfifo_reset(&port->port_write_buf); in gs_close()
725 port->start_delayed = false; in gs_close()
726 port->port.count = 0; in gs_close()
727 port->port.tty = NULL; in gs_close()
730 port->port_num, tty, file); in gs_close()
732 wake_up(&port->close_wait); in gs_close()
734 spin_unlock_irq(&port->port_lock); in gs_close()
739 struct gs_port *port = tty->driver_data; in gs_write()
743 port->port_num, tty, count); in gs_write()
745 spin_lock_irqsave(&port->port_lock, flags); in gs_write()
747 count = kfifo_in(&port->port_write_buf, buf, count); in gs_write()
749 if (port->port_usb) in gs_write()
751 spin_unlock_irqrestore(&port->port_lock, flags); in gs_write()
758 struct gs_port *port = tty->driver_data; in gs_put_char()
763 port->port_num, tty, ch, __builtin_return_address(0)); in gs_put_char()
765 spin_lock_irqsave(&port->port_lock, flags); in gs_put_char()
766 status = kfifo_put(&port->port_write_buf, ch); in gs_put_char()
767 spin_unlock_irqrestore(&port->port_lock, flags); in gs_put_char()
774 struct gs_port *port = tty->driver_data; in gs_flush_chars()
777 pr_vdebug("gs_flush_chars: (%d,%p)\n", port->port_num, tty); in gs_flush_chars()
779 spin_lock_irqsave(&port->port_lock, flags); in gs_flush_chars()
780 if (port->port_usb) in gs_flush_chars()
782 spin_unlock_irqrestore(&port->port_lock, flags); in gs_flush_chars()
787 struct gs_port *port = tty->driver_data; in gs_write_room()
791 spin_lock_irqsave(&port->port_lock, flags); in gs_write_room()
792 if (port->port_usb) in gs_write_room()
793 room = kfifo_avail(&port->port_write_buf); in gs_write_room()
794 spin_unlock_irqrestore(&port->port_lock, flags); in gs_write_room()
797 port->port_num, tty, room); in gs_write_room()
804 struct gs_port *port = tty->driver_data; in gs_chars_in_buffer()
808 spin_lock_irqsave(&port->port_lock, flags); in gs_chars_in_buffer()
809 chars = kfifo_len(&port->port_write_buf); in gs_chars_in_buffer()
810 spin_unlock_irqrestore(&port->port_lock, flags); in gs_chars_in_buffer()
813 port->port_num, tty, chars); in gs_chars_in_buffer()
821 struct gs_port *port = tty->driver_data; in gs_unthrottle()
824 spin_lock_irqsave(&port->port_lock, flags); in gs_unthrottle()
825 if (port->port_usb) { in gs_unthrottle()
830 pr_vdebug("ttyGS%d: unthrottle\n", port->port_num); in gs_unthrottle()
831 schedule_delayed_work(&port->push, 0); in gs_unthrottle()
833 spin_unlock_irqrestore(&port->port_lock, flags); in gs_unthrottle()
838 struct gs_port *port = tty->driver_data; in gs_break_ctl()
843 port->port_num, duration); in gs_break_ctl()
845 spin_lock_irq(&port->port_lock); in gs_break_ctl()
846 gser = port->port_usb; in gs_break_ctl()
847 if (gser && gser->send_break) in gs_break_ctl()
848 status = gser->send_break(gser, duration); in gs_break_ctl()
849 spin_unlock_irq(&port->port_lock); in gs_break_ctl()
866 /*-------------------------------------------------------------------------*/
874 struct gs_console *cons = req->context; in gs_console_complete_out()
876 switch (req->status) { in gs_console_complete_out()
879 __func__, ep->name, req->status); in gs_console_complete_out()
883 spin_lock(&cons->lock); in gs_console_complete_out()
884 req->length = 0; in gs_console_complete_out()
885 schedule_work(&cons->work); in gs_console_complete_out()
886 spin_unlock(&cons->lock); in gs_console_complete_out()
888 case -ECONNRESET: in gs_console_complete_out()
889 case -ESHUTDOWN: in gs_console_complete_out()
891 pr_vdebug("%s: %s shutdown\n", __func__, ep->name); in gs_console_complete_out()
898 struct usb_request *req = cons->req; in __gs_console_push()
900 size_t size; in __gs_console_push() local
905 if (req->length) in __gs_console_push()
908 ep = cons->console.data; in __gs_console_push()
909 size = kfifo_out(&cons->buf, req->buf, ep->maxpacket); in __gs_console_push()
910 if (!size) in __gs_console_push()
913 if (cons->missed && ep->maxpacket >= 64) { in __gs_console_push()
917 len = sprintf(buf, "\n[missed %zu bytes]\n", cons->missed); in __gs_console_push()
918 kfifo_in(&cons->buf, buf, len); in __gs_console_push()
919 cons->missed = 0; in __gs_console_push()
922 req->length = size; in __gs_console_push()
924 spin_unlock_irq(&cons->lock); in __gs_console_push()
926 req->length = 0; in __gs_console_push()
927 spin_lock_irq(&cons->lock); in __gs_console_push()
934 spin_lock_irq(&cons->lock); in gs_console_work()
938 spin_unlock_irq(&cons->lock); in gs_console_work()
941 static void gs_console_write(struct console *co, in gs_console_write()
944 struct gs_console *cons = container_of(co, struct gs_console, console); in gs_console_write()
948 spin_lock_irqsave(&cons->lock, flags); in gs_console_write()
950 n = kfifo_in(&cons->buf, buf, count); in gs_console_write()
952 cons->missed += count - n; in gs_console_write()
954 if (cons->req && !cons->req->length) in gs_console_write()
955 schedule_work(&cons->work); in gs_console_write()
957 spin_unlock_irqrestore(&cons->lock, flags); in gs_console_write()
960 static struct tty_driver *gs_console_device(struct console *co, int *index) in gs_console_device()
962 *index = co->index; in gs_console_device()
968 struct gs_console *cons = port->console; in gs_console_connect()
975 ep = port->port_usb->in; in gs_console_connect()
976 req = gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC); in gs_console_connect()
978 return -ENOMEM; in gs_console_connect()
979 req->complete = gs_console_complete_out; in gs_console_connect()
980 req->context = cons; in gs_console_connect()
981 req->length = 0; in gs_console_connect()
983 spin_lock(&cons->lock); in gs_console_connect()
984 cons->req = req; in gs_console_connect()
985 cons->console.data = ep; in gs_console_connect()
986 spin_unlock(&cons->lock); in gs_console_connect()
988 pr_debug("ttyGS%d: console connected!\n", port->port_num); in gs_console_connect()
990 schedule_work(&cons->work); in gs_console_connect()
997 struct gs_console *cons = port->console; in gs_console_disconnect()
1004 spin_lock(&cons->lock); in gs_console_disconnect()
1006 req = cons->req; in gs_console_disconnect()
1007 ep = cons->console.data; in gs_console_disconnect()
1008 cons->req = NULL; in gs_console_disconnect()
1010 spin_unlock(&cons->lock); in gs_console_disconnect()
1024 if (port->console) in gs_console_init()
1027 cons = kzalloc(sizeof(*port->console), GFP_KERNEL); in gs_console_init()
1029 return -ENOMEM; in gs_console_init()
1031 strcpy(cons->console.name, "ttyGS"); in gs_console_init()
1032 cons->console.write = gs_console_write; in gs_console_init()
1033 cons->console.device = gs_console_device; in gs_console_init()
1034 cons->console.flags = CON_PRINTBUFFER; in gs_console_init()
1035 cons->console.index = port->port_num; in gs_console_init()
1037 INIT_WORK(&cons->work, gs_console_work); in gs_console_init()
1038 spin_lock_init(&cons->lock); in gs_console_init()
1040 err = kfifo_alloc(&cons->buf, GS_CONSOLE_BUF_SIZE, GFP_KERNEL); in gs_console_init()
1042 pr_err("ttyGS%d: allocate console buffer failed\n", port->port_num); in gs_console_init()
1047 port->console = cons; in gs_console_init()
1048 register_console(&cons->console); in gs_console_init()
1050 spin_lock_irq(&port->port_lock); in gs_console_init()
1051 if (port->port_usb) in gs_console_init()
1053 spin_unlock_irq(&port->port_lock); in gs_console_init()
1060 struct gs_console *cons = port->console; in gs_console_exit()
1065 unregister_console(&cons->console); in gs_console_exit()
1067 spin_lock_irq(&port->port_lock); in gs_console_exit()
1068 if (cons->req) in gs_console_exit()
1070 spin_unlock_irq(&port->port_lock); in gs_console_exit()
1072 cancel_work_sync(&cons->work); in gs_console_exit()
1073 kfifo_free(&cons->buf); in gs_console_exit()
1075 port->console = NULL; in gs_console_exit()
1092 ret = -ENXIO; in gserial_set_console()
1116 ret = -ENXIO; in gserial_get_console()
1118 ret = sprintf(page, "%u\n", !!port->console); in gserial_get_console()
1139 return -ENOSYS; in gs_console_init()
1156 ret = -EBUSY; in gs_port_alloc()
1162 ret = -ENOMEM; in gs_port_alloc()
1166 tty_port_init(&port->port); in gs_port_alloc()
1167 spin_lock_init(&port->port_lock); in gs_port_alloc()
1168 init_waitqueue_head(&port->drain_wait); in gs_port_alloc()
1169 init_waitqueue_head(&port->close_wait); in gs_port_alloc()
1171 INIT_DELAYED_WORK(&port->push, gs_rx_push); in gs_port_alloc()
1173 INIT_LIST_HEAD(&port->read_pool); in gs_port_alloc()
1174 INIT_LIST_HEAD(&port->read_queue); in gs_port_alloc()
1175 INIT_LIST_HEAD(&port->write_pool); in gs_port_alloc()
1177 port->port_num = port_num; in gs_port_alloc()
1178 port->port_line_coding = *coding; in gs_port_alloc()
1190 spin_lock_irq(&port->port_lock); in gs_closed()
1191 cond = port->port.count == 0; in gs_closed()
1192 spin_unlock_irq(&port->port_lock); in gs_closed()
1199 cancel_delayed_work_sync(&port->push); in gserial_free_port()
1201 wait_event(port->close_wait, gs_closed(port)); in gserial_free_port()
1202 WARN_ON(port->port_usb != NULL); in gserial_free_port()
1203 tty_port_destroy(&port->port); in gserial_free_port()
1241 if (ret == -EBUSY) in gserial_alloc_line_no_console()
1253 tty_dev = tty_port_register_device(&port->port, in gserial_alloc_line_no_console()
1284 * gserial_connect - notify TTY I/O glue that USB link is active
1297 * before calling this, as well as the appropriate (speed-specific)
1302 * On success, ep->driver_data will be overwritten.
1311 return -ENXIO; in gserial_connect()
1316 return -EINVAL; in gserial_connect()
1318 if (port->port_usb) { in gserial_connect()
1320 return -EBUSY; in gserial_connect()
1324 status = usb_ep_enable(gser->in); in gserial_connect()
1327 gser->in->driver_data = port; in gserial_connect()
1329 status = usb_ep_enable(gser->out); in gserial_connect()
1332 gser->out->driver_data = port; in gserial_connect()
1335 spin_lock_irqsave(&port->port_lock, flags); in gserial_connect()
1336 gser->ioport = port; in gserial_connect()
1337 port->port_usb = gser; in gserial_connect()
1342 gser->port_line_coding = port->port_line_coding; in gserial_connect()
1349 if (port->port.count) { in gserial_connect()
1350 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num); in gserial_connect()
1352 if (gser->connect) in gserial_connect()
1353 gser->connect(gser); in gserial_connect()
1355 if (gser->disconnect) in gserial_connect()
1356 gser->disconnect(gser); in gserial_connect()
1360 spin_unlock_irqrestore(&port->port_lock, flags); in gserial_connect()
1365 usb_ep_disable(gser->in); in gserial_connect()
1370 * gserial_disconnect - notify TTY I/O glue that USB link is inactive
1382 struct gs_port *port = gser->ioport; in gserial_disconnect()
1391 spin_lock(&port->port_lock); in gserial_disconnect()
1396 port->port_line_coding = gser->port_line_coding; in gserial_disconnect()
1398 port->port_usb = NULL; in gserial_disconnect()
1399 gser->ioport = NULL; in gserial_disconnect()
1400 if (port->port.count > 0) { in gserial_disconnect()
1401 wake_up_interruptible(&port->drain_wait); in gserial_disconnect()
1402 if (port->port.tty) in gserial_disconnect()
1403 tty_hangup(port->port.tty); in gserial_disconnect()
1405 port->suspended = false; in gserial_disconnect()
1406 spin_unlock(&port->port_lock); in gserial_disconnect()
1410 usb_ep_disable(gser->out); in gserial_disconnect()
1411 usb_ep_disable(gser->in); in gserial_disconnect()
1414 spin_lock_irqsave(&port->port_lock, flags); in gserial_disconnect()
1415 if (port->port.count == 0) in gserial_disconnect()
1416 kfifo_free(&port->port_write_buf); in gserial_disconnect()
1417 gs_free_requests(gser->out, &port->read_pool, NULL); in gserial_disconnect()
1418 gs_free_requests(gser->out, &port->read_queue, NULL); in gserial_disconnect()
1419 gs_free_requests(gser->in, &port->write_pool, NULL); in gserial_disconnect()
1421 port->read_allocated = port->read_started = in gserial_disconnect()
1422 port->write_allocated = port->write_started = 0; in gserial_disconnect()
1424 spin_unlock_irqrestore(&port->port_lock, flags); in gserial_disconnect()
1434 port = gser->ioport; in gserial_suspend()
1441 spin_lock(&port->port_lock); in gserial_suspend()
1443 port->suspended = true; in gserial_suspend()
1444 spin_unlock_irqrestore(&port->port_lock, flags); in gserial_suspend()
1454 port = gser->ioport; in gserial_resume()
1461 spin_lock(&port->port_lock); in gserial_resume()
1463 port->suspended = false; in gserial_resume()
1464 if (!port->start_delayed) { in gserial_resume()
1465 spin_unlock_irqrestore(&port->port_lock, flags); in gserial_resume()
1469 pr_debug("delayed start ttyGS%d\n", port->port_num); in gserial_resume()
1471 if (gser->connect) in gserial_resume()
1472 gser->connect(gser); in gserial_resume()
1473 port->start_delayed = false; in gserial_resume()
1474 spin_unlock_irqrestore(&port->port_lock, flags); in gserial_resume()
1489 driver->driver_name = "g_serial"; in userial_init()
1490 driver->name = "ttyGS"; in userial_init()
1493 driver->type = TTY_DRIVER_TYPE_SERIAL; in userial_init()
1494 driver->subtype = SERIAL_TYPE_NORMAL; in userial_init()
1495 driver->init_termios = tty_std_termios; in userial_init()
1497 /* 9600-8-N-1 ... matches defaults expected by "usbser.sys" on in userial_init()
1498 * MS-Windows. Otherwise, most of these flags shouldn't affect in userial_init()
1501 driver->init_termios.c_cflag = in userial_init()
1503 driver->init_termios.c_ispeed = 9600; in userial_init()
1504 driver->init_termios.c_ospeed = 9600; in userial_init()