Lines Matching refs:port

28 dbc_kfifo_to_req(struct dbc_port *port, char *packet)  in dbc_kfifo_to_req()  argument
32 len = kfifo_len(&port->port.xmit_fifo); in dbc_kfifo_to_req()
39 if (port->tx_boundary) in dbc_kfifo_to_req()
40 len = min(port->tx_boundary, len); in dbc_kfifo_to_req()
42 len = kfifo_out(&port->port.xmit_fifo, packet, len); in dbc_kfifo_to_req()
44 if (port->tx_boundary) in dbc_kfifo_to_req()
45 port->tx_boundary -= len; in dbc_kfifo_to_req()
50 static int dbc_start_tx(struct dbc_port *port) in dbc_start_tx() argument
51 __releases(&port->port_lock) in dbc_start_tx()
52 __acquires(&port->port_lock) in dbc_start_tx()
58 struct list_head *pool = &port->write_pool; in dbc_start_tx()
62 len = dbc_kfifo_to_req(port, req->buf); in dbc_start_tx()
70 spin_unlock(&port->port_lock); in dbc_start_tx()
72 spin_lock(&port->port_lock); in dbc_start_tx()
80 if (do_tty_wake && port->port.tty) in dbc_start_tx()
81 tty_wakeup(port->port.tty); in dbc_start_tx()
86 static void dbc_start_rx(struct dbc_port *port) in dbc_start_rx() argument
87 __releases(&port->port_lock) in dbc_start_rx()
88 __acquires(&port->port_lock) in dbc_start_rx()
92 struct list_head *pool = &port->read_pool; in dbc_start_rx()
95 if (!port->port.tty) in dbc_start_rx()
102 spin_unlock(&port->port_lock); in dbc_start_rx()
104 spin_lock(&port->port_lock); in dbc_start_rx()
117 struct dbc_port *port = dbc_to_port(dbc); in dbc_read_complete() local
119 spin_lock_irqsave(&port->port_lock, flags); in dbc_read_complete()
120 list_add_tail(&req->list_pool, &port->read_queue); in dbc_read_complete()
121 tasklet_schedule(&port->push); in dbc_read_complete()
122 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_read_complete()
128 struct dbc_port *port = dbc_to_port(dbc); in dbc_write_complete() local
130 spin_lock_irqsave(&port->port_lock, flags); in dbc_write_complete()
131 list_add(&req->list_pool, &port->write_pool); in dbc_write_complete()
134 dbc_start_tx(port); in dbc_write_complete()
143 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_write_complete()
193 struct dbc_port *port; in dbc_tty_install() local
196 port = idr_find(&dbc_tty_minors, tty->index); in dbc_tty_install()
199 if (!port) in dbc_tty_install()
202 tty->driver_data = port; in dbc_tty_install()
204 return tty_port_install(&port->port, driver, tty); in dbc_tty_install()
209 struct dbc_port *port = tty->driver_data; in dbc_tty_open() local
211 return tty_port_open(&port->port, tty, file); in dbc_tty_open()
216 struct dbc_port *port = tty->driver_data; in dbc_tty_close() local
218 tty_port_close(&port->port, tty, file); in dbc_tty_close()
224 struct dbc_port *port = tty->driver_data; in dbc_tty_write() local
228 spin_lock_irqsave(&port->port_lock, flags); in dbc_tty_write()
235 if (port->tx_boundary) { in dbc_tty_write()
236 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_write()
241 written = kfifo_in(&port->port.xmit_fifo, buf, count); in dbc_tty_write()
244 port->tx_boundary = kfifo_len(&port->port.xmit_fifo); in dbc_tty_write()
246 dbc_start_tx(port); in dbc_tty_write()
249 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_write()
256 struct dbc_port *port = tty->driver_data; in dbc_tty_put_char() local
260 spin_lock_irqsave(&port->port_lock, flags); in dbc_tty_put_char()
261 status = kfifo_put(&port->port.xmit_fifo, ch); in dbc_tty_put_char()
262 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_put_char()
269 struct dbc_port *port = tty->driver_data; in dbc_tty_flush_chars() local
272 spin_lock_irqsave(&port->port_lock, flags); in dbc_tty_flush_chars()
273 dbc_start_tx(port); in dbc_tty_flush_chars()
274 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_flush_chars()
279 struct dbc_port *port = tty->driver_data; in dbc_tty_write_room() local
283 spin_lock_irqsave(&port->port_lock, flags); in dbc_tty_write_room()
284 room = kfifo_avail(&port->port.xmit_fifo); in dbc_tty_write_room()
286 if (port->tx_boundary) in dbc_tty_write_room()
289 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_write_room()
296 struct dbc_port *port = tty->driver_data; in dbc_tty_chars_in_buffer() local
300 spin_lock_irqsave(&port->port_lock, flags); in dbc_tty_chars_in_buffer()
301 chars = kfifo_len(&port->port.xmit_fifo); in dbc_tty_chars_in_buffer()
302 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_chars_in_buffer()
309 struct dbc_port *port = tty->driver_data; in dbc_tty_unthrottle() local
312 spin_lock_irqsave(&port->port_lock, flags); in dbc_tty_unthrottle()
313 tasklet_schedule(&port->push); in dbc_tty_unthrottle()
314 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_unthrottle()
336 struct dbc_port *port = from_tasklet(port, t, push); in dbc_rx_push() local
337 struct list_head *queue = &port->read_queue; in dbc_rx_push()
339 spin_lock_irqsave(&port->port_lock, flags); in dbc_rx_push()
340 tty = port->port.tty; in dbc_rx_push()
364 n = port->n_read; in dbc_rx_push()
370 count = tty_insert_flip_string(&port->port, packet, in dbc_rx_push()
375 port->n_read += count; in dbc_rx_push()
378 port->n_read = 0; in dbc_rx_push()
381 list_move_tail(&req->list_pool, &port->read_pool); in dbc_rx_push()
385 tty_flip_buffer_push(&port->port); in dbc_rx_push()
390 tasklet_schedule(&port->push); in dbc_rx_push()
397 dbc_start_rx(port); in dbc_rx_push()
399 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_rx_push()
405 struct dbc_port *port = container_of(_port, struct dbc_port, port); in dbc_port_activate() local
407 spin_lock_irqsave(&port->port_lock, flags); in dbc_port_activate()
408 dbc_start_rx(port); in dbc_port_activate()
409 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_port_activate()
419 xhci_dbc_tty_init_port(struct xhci_dbc *dbc, struct dbc_port *port) in xhci_dbc_tty_init_port() argument
421 tty_port_init(&port->port); in xhci_dbc_tty_init_port()
422 spin_lock_init(&port->port_lock); in xhci_dbc_tty_init_port()
423 tasklet_setup(&port->push, dbc_rx_push); in xhci_dbc_tty_init_port()
424 INIT_LIST_HEAD(&port->read_pool); in xhci_dbc_tty_init_port()
425 INIT_LIST_HEAD(&port->read_queue); in xhci_dbc_tty_init_port()
426 INIT_LIST_HEAD(&port->write_pool); in xhci_dbc_tty_init_port()
428 port->port.ops = &dbc_port_ops; in xhci_dbc_tty_init_port()
429 port->n_read = 0; in xhci_dbc_tty_init_port()
433 xhci_dbc_tty_exit_port(struct dbc_port *port) in xhci_dbc_tty_exit_port() argument
435 tasklet_kill(&port->push); in xhci_dbc_tty_exit_port()
436 tty_port_destroy(&port->port); in xhci_dbc_tty_exit_port()
443 struct dbc_port *port = dbc_to_port(dbc); in xhci_dbc_tty_register_device() local
445 if (port->registered) in xhci_dbc_tty_register_device()
448 xhci_dbc_tty_init_port(dbc, port); in xhci_dbc_tty_register_device()
451 port->minor = idr_alloc(&dbc_tty_minors, port, 0, 64, GFP_KERNEL); in xhci_dbc_tty_register_device()
454 if (port->minor < 0) { in xhci_dbc_tty_register_device()
455 ret = port->minor; in xhci_dbc_tty_register_device()
459 ret = kfifo_alloc(&port->port.xmit_fifo, DBC_WRITE_BUF_SIZE, in xhci_dbc_tty_register_device()
464 ret = xhci_dbc_alloc_requests(dbc, BULK_IN, &port->read_pool, in xhci_dbc_tty_register_device()
469 ret = xhci_dbc_alloc_requests(dbc, BULK_OUT, &port->write_pool, in xhci_dbc_tty_register_device()
474 tty_dev = tty_port_register_device(&port->port, in xhci_dbc_tty_register_device()
475 dbc_tty_driver, port->minor, NULL); in xhci_dbc_tty_register_device()
481 port->registered = true; in xhci_dbc_tty_register_device()
486 xhci_dbc_free_requests(&port->read_pool); in xhci_dbc_tty_register_device()
487 xhci_dbc_free_requests(&port->write_pool); in xhci_dbc_tty_register_device()
489 kfifo_free(&port->port.xmit_fifo); in xhci_dbc_tty_register_device()
491 idr_remove(&dbc_tty_minors, port->minor); in xhci_dbc_tty_register_device()
493 xhci_dbc_tty_exit_port(port); in xhci_dbc_tty_register_device()
502 struct dbc_port *port = dbc_to_port(dbc); in xhci_dbc_tty_unregister_device() local
504 if (!port->registered) in xhci_dbc_tty_unregister_device()
506 tty_unregister_device(dbc_tty_driver, port->minor); in xhci_dbc_tty_unregister_device()
507 xhci_dbc_tty_exit_port(port); in xhci_dbc_tty_unregister_device()
508 port->registered = false; in xhci_dbc_tty_unregister_device()
511 idr_remove(&dbc_tty_minors, port->minor); in xhci_dbc_tty_unregister_device()
514 kfifo_free(&port->port.xmit_fifo); in xhci_dbc_tty_unregister_device()
515 xhci_dbc_free_requests(&port->read_pool); in xhci_dbc_tty_unregister_device()
516 xhci_dbc_free_requests(&port->read_queue); in xhci_dbc_tty_unregister_device()
517 xhci_dbc_free_requests(&port->write_pool); in xhci_dbc_tty_unregister_device()
528 struct dbc_port *port; in xhci_dbc_tty_probe() local
534 port = kzalloc(sizeof(*port), GFP_KERNEL); in xhci_dbc_tty_probe()
535 if (!port) in xhci_dbc_tty_probe()
545 dbc->priv = port; in xhci_dbc_tty_probe()
552 kfree(port); in xhci_dbc_tty_probe()
563 struct dbc_port *port = dbc_to_port(dbc); in xhci_dbc_tty_remove() local
566 kfree(port); in xhci_dbc_tty_remove()