• Home
  • Raw
  • Download

Lines Matching refs:port

23 static int tty_port_default_receive_buf(struct tty_port *port,  in tty_port_default_receive_buf()  argument
31 tty = READ_ONCE(port->itty); in tty_port_default_receive_buf()
46 static void tty_port_default_wakeup(struct tty_port *port) in tty_port_default_wakeup() argument
48 struct tty_struct *tty = tty_port_tty_get(port); in tty_port_default_wakeup()
62 void tty_port_init(struct tty_port *port) in tty_port_init() argument
64 memset(port, 0, sizeof(*port)); in tty_port_init()
65 tty_buffer_init(port); in tty_port_init()
66 init_waitqueue_head(&port->open_wait); in tty_port_init()
67 init_waitqueue_head(&port->delta_msr_wait); in tty_port_init()
68 mutex_init(&port->mutex); in tty_port_init()
69 mutex_init(&port->buf_mutex); in tty_port_init()
70 spin_lock_init(&port->lock); in tty_port_init()
71 port->close_delay = (50 * HZ) / 100; in tty_port_init()
72 port->closing_wait = (3000 * HZ) / 100; in tty_port_init()
73 port->client_ops = &tty_port_default_client_ops; in tty_port_init()
74 kref_init(&port->kref); in tty_port_init()
89 void tty_port_link_device(struct tty_port *port, in tty_port_link_device() argument
94 driver->ports[index] = port; in tty_port_link_device()
109 struct device *tty_port_register_device(struct tty_port *port, in tty_port_register_device() argument
113 return tty_port_register_device_attr(port, driver, index, device, NULL, NULL); in tty_port_register_device()
130 struct device *tty_port_register_device_attr(struct tty_port *port, in tty_port_register_device_attr() argument
135 tty_port_link_device(port, driver, index); in tty_port_register_device_attr()
153 struct device *tty_port_register_device_attr_serdev(struct tty_port *port, in tty_port_register_device_attr_serdev() argument
160 tty_port_link_device(port, driver, index); in tty_port_register_device_attr_serdev()
162 dev = serdev_tty_port_register(port, device, driver, index); in tty_port_register_device_attr_serdev()
183 struct device *tty_port_register_device_serdev(struct tty_port *port, in tty_port_register_device_serdev() argument
187 return tty_port_register_device_attr_serdev(port, driver, index, in tty_port_register_device_serdev()
202 void tty_port_unregister_device(struct tty_port *port, in tty_port_unregister_device() argument
207 ret = serdev_tty_port_unregister(port); in tty_port_unregister_device()
215 int tty_port_alloc_xmit_buf(struct tty_port *port) in tty_port_alloc_xmit_buf() argument
218 mutex_lock(&port->buf_mutex); in tty_port_alloc_xmit_buf()
219 if (port->xmit_buf == NULL) in tty_port_alloc_xmit_buf()
220 port->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); in tty_port_alloc_xmit_buf()
221 mutex_unlock(&port->buf_mutex); in tty_port_alloc_xmit_buf()
222 if (port->xmit_buf == NULL) in tty_port_alloc_xmit_buf()
228 void tty_port_free_xmit_buf(struct tty_port *port) in tty_port_free_xmit_buf() argument
230 mutex_lock(&port->buf_mutex); in tty_port_free_xmit_buf()
231 if (port->xmit_buf != NULL) { in tty_port_free_xmit_buf()
232 free_page((unsigned long)port->xmit_buf); in tty_port_free_xmit_buf()
233 port->xmit_buf = NULL; in tty_port_free_xmit_buf()
235 mutex_unlock(&port->buf_mutex); in tty_port_free_xmit_buf()
247 void tty_port_destroy(struct tty_port *port) in tty_port_destroy() argument
249 tty_buffer_cancel_work(port); in tty_port_destroy()
250 tty_buffer_free_all(port); in tty_port_destroy()
256 struct tty_port *port = container_of(kref, struct tty_port, kref); in tty_port_destructor() local
259 if (WARN_ON(port->itty)) in tty_port_destructor()
261 if (port->xmit_buf) in tty_port_destructor()
262 free_page((unsigned long)port->xmit_buf); in tty_port_destructor()
263 tty_port_destroy(port); in tty_port_destructor()
264 if (port->ops && port->ops->destruct) in tty_port_destructor()
265 port->ops->destruct(port); in tty_port_destructor()
267 kfree(port); in tty_port_destructor()
270 void tty_port_put(struct tty_port *port) in tty_port_put() argument
272 if (port) in tty_port_put()
273 kref_put(&port->kref, tty_port_destructor); in tty_port_put()
284 struct tty_struct *tty_port_tty_get(struct tty_port *port) in tty_port_tty_get() argument
289 spin_lock_irqsave(&port->lock, flags); in tty_port_tty_get()
290 tty = tty_kref_get(port->tty); in tty_port_tty_get()
291 spin_unlock_irqrestore(&port->lock, flags); in tty_port_tty_get()
304 void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty) in tty_port_tty_set() argument
308 spin_lock_irqsave(&port->lock, flags); in tty_port_tty_set()
309 tty_kref_put(port->tty); in tty_port_tty_set()
310 port->tty = tty_kref_get(tty); in tty_port_tty_set()
311 spin_unlock_irqrestore(&port->lock, flags); in tty_port_tty_set()
315 static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty) in tty_port_shutdown() argument
317 mutex_lock(&port->mutex); in tty_port_shutdown()
318 if (port->console) in tty_port_shutdown()
321 if (tty_port_initialized(port)) { in tty_port_shutdown()
322 tty_port_set_initialized(port, 0); in tty_port_shutdown()
328 tty_port_lower_dtr_rts(port); in tty_port_shutdown()
330 if (port->ops->shutdown) in tty_port_shutdown()
331 port->ops->shutdown(port); in tty_port_shutdown()
334 mutex_unlock(&port->mutex); in tty_port_shutdown()
346 void tty_port_hangup(struct tty_port *port) in tty_port_hangup() argument
351 spin_lock_irqsave(&port->lock, flags); in tty_port_hangup()
352 port->count = 0; in tty_port_hangup()
353 tty = port->tty; in tty_port_hangup()
356 port->tty = NULL; in tty_port_hangup()
357 spin_unlock_irqrestore(&port->lock, flags); in tty_port_hangup()
358 tty_port_set_active(port, 0); in tty_port_hangup()
359 tty_port_shutdown(port, tty); in tty_port_hangup()
361 wake_up_interruptible(&port->open_wait); in tty_port_hangup()
362 wake_up_interruptible(&port->delta_msr_wait); in tty_port_hangup()
372 void tty_port_tty_hangup(struct tty_port *port, bool check_clocal) in tty_port_tty_hangup() argument
374 struct tty_struct *tty = tty_port_tty_get(port); in tty_port_tty_hangup()
387 void tty_port_tty_wakeup(struct tty_port *port) in tty_port_tty_wakeup() argument
389 port->client_ops->write_wakeup(port); in tty_port_tty_wakeup()
401 int tty_port_carrier_raised(struct tty_port *port) in tty_port_carrier_raised() argument
403 if (port->ops->carrier_raised == NULL) in tty_port_carrier_raised()
405 return port->ops->carrier_raised(port); in tty_port_carrier_raised()
417 void tty_port_raise_dtr_rts(struct tty_port *port) in tty_port_raise_dtr_rts() argument
419 if (port->ops->dtr_rts) in tty_port_raise_dtr_rts()
420 port->ops->dtr_rts(port, 1); in tty_port_raise_dtr_rts()
432 void tty_port_lower_dtr_rts(struct tty_port *port) in tty_port_lower_dtr_rts() argument
434 if (port->ops->dtr_rts) in tty_port_lower_dtr_rts()
435 port->ops->dtr_rts(port, 0); in tty_port_lower_dtr_rts()
463 int tty_port_block_til_ready(struct tty_port *port, in tty_port_block_til_ready() argument
474 tty_port_set_active(port, 1); in tty_port_block_til_ready()
480 tty_port_raise_dtr_rts(port); in tty_port_block_til_ready()
481 tty_port_set_active(port, 1); in tty_port_block_til_ready()
496 spin_lock_irqsave(&port->lock, flags); in tty_port_block_til_ready()
497 port->count--; in tty_port_block_til_ready()
498 port->blocked_open++; in tty_port_block_til_ready()
499 spin_unlock_irqrestore(&port->lock, flags); in tty_port_block_til_ready()
503 if (C_BAUD(tty) && tty_port_initialized(port)) in tty_port_block_til_ready()
504 tty_port_raise_dtr_rts(port); in tty_port_block_til_ready()
506 prepare_to_wait(&port->open_wait, &wait, TASK_INTERRUPTIBLE); in tty_port_block_til_ready()
510 if (tty_hung_up_p(filp) || !tty_port_initialized(port)) { in tty_port_block_til_ready()
511 if (port->flags & ASYNC_HUP_NOTIFY) in tty_port_block_til_ready()
523 if (do_clocal || tty_port_carrier_raised(port)) in tty_port_block_til_ready()
533 finish_wait(&port->open_wait, &wait); in tty_port_block_til_ready()
538 spin_lock_irqsave(&port->lock, flags); in tty_port_block_til_ready()
540 port->count++; in tty_port_block_til_ready()
541 port->blocked_open--; in tty_port_block_til_ready()
542 spin_unlock_irqrestore(&port->lock, flags); in tty_port_block_til_ready()
544 tty_port_set_active(port, 1); in tty_port_block_til_ready()
549 static void tty_port_drain_delay(struct tty_port *port, struct tty_struct *tty) in tty_port_drain_delay() argument
555 timeout = (HZ * 10 * port->drain_delay) / bps; in tty_port_drain_delay()
564 int tty_port_close_start(struct tty_port *port, in tty_port_close_start() argument
572 spin_lock_irqsave(&port->lock, flags); in tty_port_close_start()
573 if (tty->count == 1 && port->count != 1) { in tty_port_close_start()
575 port->count); in tty_port_close_start()
576 port->count = 1; in tty_port_close_start()
578 if (--port->count < 0) { in tty_port_close_start()
580 port->count); in tty_port_close_start()
581 port->count = 0; in tty_port_close_start()
584 if (port->count) { in tty_port_close_start()
585 spin_unlock_irqrestore(&port->lock, flags); in tty_port_close_start()
588 spin_unlock_irqrestore(&port->lock, flags); in tty_port_close_start()
592 if (tty_port_initialized(port)) { in tty_port_close_start()
596 if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) in tty_port_close_start()
597 tty_wait_until_sent(tty, port->closing_wait); in tty_port_close_start()
598 if (port->drain_delay) in tty_port_close_start()
599 tty_port_drain_delay(port, tty); in tty_port_close_start()
610 void tty_port_close_end(struct tty_port *port, struct tty_struct *tty) in tty_port_close_end() argument
617 spin_lock_irqsave(&port->lock, flags); in tty_port_close_end()
619 if (port->blocked_open) { in tty_port_close_end()
620 spin_unlock_irqrestore(&port->lock, flags); in tty_port_close_end()
621 if (port->close_delay) in tty_port_close_end()
622 msleep_interruptible(jiffies_to_msecs(port->close_delay)); in tty_port_close_end()
623 spin_lock_irqsave(&port->lock, flags); in tty_port_close_end()
624 wake_up_interruptible(&port->open_wait); in tty_port_close_end()
626 spin_unlock_irqrestore(&port->lock, flags); in tty_port_close_end()
627 tty_port_set_active(port, 0); in tty_port_close_end()
636 void tty_port_close(struct tty_port *port, struct tty_struct *tty, in tty_port_close() argument
639 if (tty_port_close_start(port, tty, filp) == 0) in tty_port_close()
641 tty_port_shutdown(port, tty); in tty_port_close()
642 if (!port->console) in tty_port_close()
644 tty_port_close_end(port, tty); in tty_port_close()
645 tty_port_tty_set(port, NULL); in tty_port_close()
659 int tty_port_install(struct tty_port *port, struct tty_driver *driver, in tty_port_install() argument
662 tty->port = port; in tty_port_install()
675 int tty_port_open(struct tty_port *port, struct tty_struct *tty, in tty_port_open() argument
678 spin_lock_irq(&port->lock); in tty_port_open()
679 ++port->count; in tty_port_open()
680 spin_unlock_irq(&port->lock); in tty_port_open()
681 tty_port_tty_set(port, tty); in tty_port_open()
689 mutex_lock(&port->mutex); in tty_port_open()
691 if (!tty_port_initialized(port)) { in tty_port_open()
693 if (port->ops->activate) { in tty_port_open()
694 int retval = port->ops->activate(port, tty); in tty_port_open()
697 mutex_unlock(&port->mutex); in tty_port_open()
701 tty_port_set_initialized(port, 1); in tty_port_open()
703 mutex_unlock(&port->mutex); in tty_port_open()
704 return tty_port_block_til_ready(port, tty, filp); in tty_port_open()