Lines Matching full:port
28 dbc_send_packet(struct dbc_port *port, char *packet, unsigned int size) in dbc_send_packet() argument
32 len = kfifo_len(&port->write_fifo); in dbc_send_packet()
36 size = kfifo_out(&port->write_fifo, packet, size); in dbc_send_packet()
40 static int dbc_start_tx(struct dbc_port *port) in dbc_start_tx() argument
41 __releases(&port->port_lock) in dbc_start_tx()
42 __acquires(&port->port_lock) in dbc_start_tx()
48 struct list_head *pool = &port->write_pool; in dbc_start_tx()
52 len = dbc_send_packet(port, req->buf, DBC_MAX_PACKET); in dbc_start_tx()
60 spin_unlock(&port->port_lock); in dbc_start_tx()
62 spin_lock(&port->port_lock); in dbc_start_tx()
70 if (do_tty_wake && port->port.tty) in dbc_start_tx()
71 tty_wakeup(port->port.tty); in dbc_start_tx()
76 static void dbc_start_rx(struct dbc_port *port) in dbc_start_rx() argument
77 __releases(&port->port_lock) in dbc_start_rx()
78 __acquires(&port->port_lock) in dbc_start_rx()
82 struct list_head *pool = &port->read_pool; in dbc_start_rx()
85 if (!port->port.tty) in dbc_start_rx()
92 spin_unlock(&port->port_lock); in dbc_start_rx()
94 spin_lock(&port->port_lock); in dbc_start_rx()
107 struct dbc_port *port = dbc_to_port(dbc); in dbc_read_complete() local
109 spin_lock_irqsave(&port->port_lock, flags); in dbc_read_complete()
110 list_add_tail(&req->list_pool, &port->read_queue); in dbc_read_complete()
111 tasklet_schedule(&port->push); in dbc_read_complete()
112 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_read_complete()
118 struct dbc_port *port = dbc_to_port(dbc); in dbc_write_complete() local
120 spin_lock_irqsave(&port->port_lock, flags); in dbc_write_complete()
121 list_add(&req->list_pool, &port->write_pool); in dbc_write_complete()
124 dbc_start_tx(port); in dbc_write_complete()
133 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_write_complete()
183 struct dbc_port *port; in dbc_tty_install() local
186 port = idr_find(&dbc_tty_minors, tty->index); in dbc_tty_install()
189 if (!port) in dbc_tty_install()
192 tty->driver_data = port; in dbc_tty_install()
194 return tty_port_install(&port->port, driver, tty); in dbc_tty_install()
199 struct dbc_port *port = tty->driver_data; in dbc_tty_open() local
201 return tty_port_open(&port->port, tty, file); in dbc_tty_open()
206 struct dbc_port *port = tty->driver_data; in dbc_tty_close() local
208 tty_port_close(&port->port, tty, file); in dbc_tty_close()
215 struct dbc_port *port = tty->driver_data; in dbc_tty_write() local
218 spin_lock_irqsave(&port->port_lock, flags); in dbc_tty_write()
220 count = kfifo_in(&port->write_fifo, buf, count); in dbc_tty_write()
221 dbc_start_tx(port); in dbc_tty_write()
222 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_write()
229 struct dbc_port *port = tty->driver_data; in dbc_tty_put_char() local
233 spin_lock_irqsave(&port->port_lock, flags); in dbc_tty_put_char()
234 status = kfifo_put(&port->write_fifo, ch); in dbc_tty_put_char()
235 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_put_char()
242 struct dbc_port *port = tty->driver_data; in dbc_tty_flush_chars() local
245 spin_lock_irqsave(&port->port_lock, flags); in dbc_tty_flush_chars()
246 dbc_start_tx(port); in dbc_tty_flush_chars()
247 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_flush_chars()
252 struct dbc_port *port = tty->driver_data; in dbc_tty_write_room() local
256 spin_lock_irqsave(&port->port_lock, flags); in dbc_tty_write_room()
257 room = kfifo_avail(&port->write_fifo); in dbc_tty_write_room()
258 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_write_room()
265 struct dbc_port *port = tty->driver_data; in dbc_tty_chars_in_buffer() local
269 spin_lock_irqsave(&port->port_lock, flags); in dbc_tty_chars_in_buffer()
270 chars = kfifo_len(&port->write_fifo); in dbc_tty_chars_in_buffer()
271 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_chars_in_buffer()
278 struct dbc_port *port = tty->driver_data; in dbc_tty_unthrottle() local
281 spin_lock_irqsave(&port->port_lock, flags); in dbc_tty_unthrottle()
282 tasklet_schedule(&port->push); in dbc_tty_unthrottle()
283 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_tty_unthrottle()
305 struct dbc_port *port = from_tasklet(port, t, push); in dbc_rx_push() local
306 struct list_head *queue = &port->read_queue; in dbc_rx_push()
308 spin_lock_irqsave(&port->port_lock, flags); in dbc_rx_push()
309 tty = port->port.tty; in dbc_rx_push()
333 n = port->n_read; in dbc_rx_push()
339 count = tty_insert_flip_string(&port->port, packet, in dbc_rx_push()
344 port->n_read += count; in dbc_rx_push()
347 port->n_read = 0; in dbc_rx_push()
350 list_move(&req->list_pool, &port->read_pool); in dbc_rx_push()
354 tty_flip_buffer_push(&port->port); in dbc_rx_push()
359 tasklet_schedule(&port->push); in dbc_rx_push()
366 dbc_start_rx(port); in dbc_rx_push()
368 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_rx_push()
374 struct dbc_port *port = container_of(_port, struct dbc_port, port); in dbc_port_activate() local
376 spin_lock_irqsave(&port->port_lock, flags); in dbc_port_activate()
377 dbc_start_rx(port); in dbc_port_activate()
378 spin_unlock_irqrestore(&port->port_lock, flags); in dbc_port_activate()
388 xhci_dbc_tty_init_port(struct xhci_dbc *dbc, struct dbc_port *port) in xhci_dbc_tty_init_port() argument
390 tty_port_init(&port->port); in xhci_dbc_tty_init_port()
391 spin_lock_init(&port->port_lock); in xhci_dbc_tty_init_port()
392 tasklet_setup(&port->push, dbc_rx_push); in xhci_dbc_tty_init_port()
393 INIT_LIST_HEAD(&port->read_pool); in xhci_dbc_tty_init_port()
394 INIT_LIST_HEAD(&port->read_queue); in xhci_dbc_tty_init_port()
395 INIT_LIST_HEAD(&port->write_pool); in xhci_dbc_tty_init_port()
397 port->port.ops = &dbc_port_ops; in xhci_dbc_tty_init_port()
398 port->n_read = 0; in xhci_dbc_tty_init_port()
402 xhci_dbc_tty_exit_port(struct dbc_port *port) in xhci_dbc_tty_exit_port() argument
404 tasklet_kill(&port->push); in xhci_dbc_tty_exit_port()
405 tty_port_destroy(&port->port); in xhci_dbc_tty_exit_port()
412 struct dbc_port *port = dbc_to_port(dbc); in xhci_dbc_tty_register_device() local
414 if (port->registered) in xhci_dbc_tty_register_device()
417 xhci_dbc_tty_init_port(dbc, port); in xhci_dbc_tty_register_device()
420 port->minor = idr_alloc(&dbc_tty_minors, port, 0, 64, GFP_KERNEL); in xhci_dbc_tty_register_device()
423 if (port->minor < 0) { in xhci_dbc_tty_register_device()
424 ret = port->minor; in xhci_dbc_tty_register_device()
428 ret = kfifo_alloc(&port->write_fifo, DBC_WRITE_BUF_SIZE, GFP_KERNEL); in xhci_dbc_tty_register_device()
432 ret = xhci_dbc_alloc_requests(dbc, BULK_IN, &port->read_pool, in xhci_dbc_tty_register_device()
437 ret = xhci_dbc_alloc_requests(dbc, BULK_OUT, &port->write_pool, in xhci_dbc_tty_register_device()
442 tty_dev = tty_port_register_device(&port->port, in xhci_dbc_tty_register_device()
443 dbc_tty_driver, port->minor, NULL); in xhci_dbc_tty_register_device()
449 port->registered = true; in xhci_dbc_tty_register_device()
454 xhci_dbc_free_requests(&port->read_pool); in xhci_dbc_tty_register_device()
455 xhci_dbc_free_requests(&port->write_pool); in xhci_dbc_tty_register_device()
457 kfifo_free(&port->write_fifo); in xhci_dbc_tty_register_device()
459 idr_remove(&dbc_tty_minors, port->minor); in xhci_dbc_tty_register_device()
461 xhci_dbc_tty_exit_port(port); in xhci_dbc_tty_register_device()
463 dev_err(dbc->dev, "can't register tty port, err %d\n", ret); in xhci_dbc_tty_register_device()
470 struct dbc_port *port = dbc_to_port(dbc); in xhci_dbc_tty_unregister_device() local
472 if (!port->registered) in xhci_dbc_tty_unregister_device()
474 tty_unregister_device(dbc_tty_driver, port->minor); in xhci_dbc_tty_unregister_device()
475 xhci_dbc_tty_exit_port(port); in xhci_dbc_tty_unregister_device()
476 port->registered = false; in xhci_dbc_tty_unregister_device()
479 idr_remove(&dbc_tty_minors, port->minor); in xhci_dbc_tty_unregister_device()
482 kfifo_free(&port->write_fifo); in xhci_dbc_tty_unregister_device()
483 xhci_dbc_free_requests(&port->read_pool); in xhci_dbc_tty_unregister_device()
484 xhci_dbc_free_requests(&port->read_queue); in xhci_dbc_tty_unregister_device()
485 xhci_dbc_free_requests(&port->write_pool); in xhci_dbc_tty_unregister_device()
496 struct dbc_port *port; in xhci_dbc_tty_probe() local
502 port = kzalloc(sizeof(*port), GFP_KERNEL); in xhci_dbc_tty_probe()
503 if (!port) in xhci_dbc_tty_probe()
513 dbc->priv = port; in xhci_dbc_tty_probe()
520 kfree(port); in xhci_dbc_tty_probe()
531 struct dbc_port *port = dbc_to_port(dbc); in xhci_dbc_tty_remove() local
534 kfree(port); in xhci_dbc_tty_remove()