• Home
  • Raw
  • Download

Lines Matching refs:port

22 static int tty_port_default_receive_buf(struct tty_port *port,  in tty_port_default_receive_buf()  argument
30 tty = READ_ONCE(port->itty); in tty_port_default_receive_buf()
45 static void tty_port_default_wakeup(struct tty_port *port) in tty_port_default_wakeup() argument
47 struct tty_struct *tty = tty_port_tty_get(port); in tty_port_default_wakeup()
61 void tty_port_init(struct tty_port *port) in tty_port_init() argument
63 memset(port, 0, sizeof(*port)); in tty_port_init()
64 tty_buffer_init(port); in tty_port_init()
65 init_waitqueue_head(&port->open_wait); in tty_port_init()
66 init_waitqueue_head(&port->delta_msr_wait); in tty_port_init()
67 mutex_init(&port->mutex); in tty_port_init()
68 mutex_init(&port->buf_mutex); in tty_port_init()
69 spin_lock_init(&port->lock); in tty_port_init()
70 port->close_delay = (50 * HZ) / 100; in tty_port_init()
71 port->closing_wait = (3000 * HZ) / 100; in tty_port_init()
72 port->client_ops = &tty_port_default_client_ops; in tty_port_init()
73 kref_init(&port->kref); in tty_port_init()
88 void tty_port_link_device(struct tty_port *port, in tty_port_link_device() argument
93 driver->ports[index] = port; in tty_port_link_device()
108 struct device *tty_port_register_device(struct tty_port *port, in tty_port_register_device() argument
112 return tty_port_register_device_attr(port, driver, index, device, NULL, NULL); in tty_port_register_device()
129 struct device *tty_port_register_device_attr(struct tty_port *port, in tty_port_register_device_attr() argument
134 tty_port_link_device(port, driver, index); in tty_port_register_device_attr()
152 struct device *tty_port_register_device_attr_serdev(struct tty_port *port, in tty_port_register_device_attr_serdev() argument
159 tty_port_link_device(port, driver, index); in tty_port_register_device_attr_serdev()
161 dev = serdev_tty_port_register(port, device, driver, index); in tty_port_register_device_attr_serdev()
182 struct device *tty_port_register_device_serdev(struct tty_port *port, in tty_port_register_device_serdev() argument
186 return tty_port_register_device_attr_serdev(port, driver, index, in tty_port_register_device_serdev()
201 void tty_port_unregister_device(struct tty_port *port, in tty_port_unregister_device() argument
206 ret = serdev_tty_port_unregister(port); in tty_port_unregister_device()
214 int tty_port_alloc_xmit_buf(struct tty_port *port) in tty_port_alloc_xmit_buf() argument
217 mutex_lock(&port->buf_mutex); in tty_port_alloc_xmit_buf()
218 if (port->xmit_buf == NULL) in tty_port_alloc_xmit_buf()
219 port->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); in tty_port_alloc_xmit_buf()
220 mutex_unlock(&port->buf_mutex); in tty_port_alloc_xmit_buf()
221 if (port->xmit_buf == NULL) in tty_port_alloc_xmit_buf()
227 void tty_port_free_xmit_buf(struct tty_port *port) in tty_port_free_xmit_buf() argument
229 mutex_lock(&port->buf_mutex); in tty_port_free_xmit_buf()
230 if (port->xmit_buf != NULL) { in tty_port_free_xmit_buf()
231 free_page((unsigned long)port->xmit_buf); in tty_port_free_xmit_buf()
232 port->xmit_buf = NULL; in tty_port_free_xmit_buf()
234 mutex_unlock(&port->buf_mutex); in tty_port_free_xmit_buf()
246 void tty_port_destroy(struct tty_port *port) in tty_port_destroy() argument
248 tty_buffer_cancel_work(port); in tty_port_destroy()
249 tty_buffer_free_all(port); in tty_port_destroy()
255 struct tty_port *port = container_of(kref, struct tty_port, kref); in tty_port_destructor() local
258 if (WARN_ON(port->itty)) in tty_port_destructor()
260 if (port->xmit_buf) in tty_port_destructor()
261 free_page((unsigned long)port->xmit_buf); in tty_port_destructor()
262 tty_port_destroy(port); in tty_port_destructor()
263 if (port->ops && port->ops->destruct) in tty_port_destructor()
264 port->ops->destruct(port); in tty_port_destructor()
266 kfree(port); in tty_port_destructor()
269 void tty_port_put(struct tty_port *port) in tty_port_put() argument
271 if (port) in tty_port_put()
272 kref_put(&port->kref, tty_port_destructor); in tty_port_put()
283 struct tty_struct *tty_port_tty_get(struct tty_port *port) in tty_port_tty_get() argument
288 spin_lock_irqsave(&port->lock, flags); in tty_port_tty_get()
289 tty = tty_kref_get(port->tty); in tty_port_tty_get()
290 spin_unlock_irqrestore(&port->lock, flags); in tty_port_tty_get()
303 void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty) in tty_port_tty_set() argument
307 spin_lock_irqsave(&port->lock, flags); in tty_port_tty_set()
308 tty_kref_put(port->tty); in tty_port_tty_set()
309 port->tty = tty_kref_get(tty); in tty_port_tty_set()
310 spin_unlock_irqrestore(&port->lock, flags); in tty_port_tty_set()
314 static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty) in tty_port_shutdown() argument
316 mutex_lock(&port->mutex); in tty_port_shutdown()
317 if (port->console) in tty_port_shutdown()
320 if (tty_port_initialized(port)) { in tty_port_shutdown()
321 tty_port_set_initialized(port, 0); in tty_port_shutdown()
327 tty_port_lower_dtr_rts(port); in tty_port_shutdown()
329 if (port->ops->shutdown) in tty_port_shutdown()
330 port->ops->shutdown(port); in tty_port_shutdown()
333 mutex_unlock(&port->mutex); in tty_port_shutdown()
345 void tty_port_hangup(struct tty_port *port) in tty_port_hangup() argument
350 spin_lock_irqsave(&port->lock, flags); in tty_port_hangup()
351 port->count = 0; in tty_port_hangup()
352 tty = port->tty; in tty_port_hangup()
355 port->tty = NULL; in tty_port_hangup()
356 spin_unlock_irqrestore(&port->lock, flags); in tty_port_hangup()
357 tty_port_set_active(port, 0); in tty_port_hangup()
358 tty_port_shutdown(port, tty); in tty_port_hangup()
360 wake_up_interruptible(&port->open_wait); in tty_port_hangup()
361 wake_up_interruptible(&port->delta_msr_wait); in tty_port_hangup()
371 void tty_port_tty_hangup(struct tty_port *port, bool check_clocal) in tty_port_tty_hangup() argument
373 struct tty_struct *tty = tty_port_tty_get(port); in tty_port_tty_hangup()
386 void tty_port_tty_wakeup(struct tty_port *port) in tty_port_tty_wakeup() argument
388 port->client_ops->write_wakeup(port); in tty_port_tty_wakeup()
400 int tty_port_carrier_raised(struct tty_port *port) in tty_port_carrier_raised() argument
402 if (port->ops->carrier_raised == NULL) in tty_port_carrier_raised()
404 return port->ops->carrier_raised(port); in tty_port_carrier_raised()
416 void tty_port_raise_dtr_rts(struct tty_port *port) in tty_port_raise_dtr_rts() argument
418 if (port->ops->dtr_rts) in tty_port_raise_dtr_rts()
419 port->ops->dtr_rts(port, 1); in tty_port_raise_dtr_rts()
431 void tty_port_lower_dtr_rts(struct tty_port *port) in tty_port_lower_dtr_rts() argument
433 if (port->ops->dtr_rts) in tty_port_lower_dtr_rts()
434 port->ops->dtr_rts(port, 0); in tty_port_lower_dtr_rts()
462 int tty_port_block_til_ready(struct tty_port *port, in tty_port_block_til_ready() argument
472 tty_port_set_active(port, 1); in tty_port_block_til_ready()
478 tty_port_raise_dtr_rts(port); in tty_port_block_til_ready()
479 tty_port_set_active(port, 1); in tty_port_block_til_ready()
493 spin_lock_irqsave(&port->lock, flags); in tty_port_block_til_ready()
494 port->count--; in tty_port_block_til_ready()
495 port->blocked_open++; in tty_port_block_til_ready()
496 spin_unlock_irqrestore(&port->lock, flags); in tty_port_block_til_ready()
500 if (C_BAUD(tty) && tty_port_initialized(port)) in tty_port_block_til_ready()
501 tty_port_raise_dtr_rts(port); in tty_port_block_til_ready()
503 prepare_to_wait(&port->open_wait, &wait, TASK_INTERRUPTIBLE); in tty_port_block_til_ready()
506 if (tty_hung_up_p(filp) || !tty_port_initialized(port)) { in tty_port_block_til_ready()
507 if (port->flags & ASYNC_HUP_NOTIFY) in tty_port_block_til_ready()
519 if (do_clocal || tty_port_carrier_raised(port)) in tty_port_block_til_ready()
529 finish_wait(&port->open_wait, &wait); in tty_port_block_til_ready()
533 spin_lock_irqsave(&port->lock, flags); in tty_port_block_til_ready()
535 port->count++; in tty_port_block_til_ready()
536 port->blocked_open--; in tty_port_block_til_ready()
537 spin_unlock_irqrestore(&port->lock, flags); in tty_port_block_til_ready()
539 tty_port_set_active(port, 1); in tty_port_block_til_ready()
544 static void tty_port_drain_delay(struct tty_port *port, struct tty_struct *tty) in tty_port_drain_delay() argument
550 timeout = (HZ * 10 * port->drain_delay) / bps; in tty_port_drain_delay()
559 int tty_port_close_start(struct tty_port *port, in tty_port_close_start() argument
567 spin_lock_irqsave(&port->lock, flags); in tty_port_close_start()
568 if (tty->count == 1 && port->count != 1) { in tty_port_close_start()
570 port->count); in tty_port_close_start()
571 port->count = 1; in tty_port_close_start()
573 if (--port->count < 0) { in tty_port_close_start()
575 port->count); in tty_port_close_start()
576 port->count = 0; in tty_port_close_start()
579 if (port->count) { in tty_port_close_start()
580 spin_unlock_irqrestore(&port->lock, flags); in tty_port_close_start()
583 spin_unlock_irqrestore(&port->lock, flags); in tty_port_close_start()
587 if (tty_port_initialized(port)) { in tty_port_close_start()
591 if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) in tty_port_close_start()
592 tty_wait_until_sent(tty, port->closing_wait); in tty_port_close_start()
593 if (port->drain_delay) in tty_port_close_start()
594 tty_port_drain_delay(port, tty); in tty_port_close_start()
605 void tty_port_close_end(struct tty_port *port, struct tty_struct *tty) in tty_port_close_end() argument
612 spin_lock_irqsave(&port->lock, flags); in tty_port_close_end()
614 if (port->blocked_open) { in tty_port_close_end()
615 spin_unlock_irqrestore(&port->lock, flags); in tty_port_close_end()
616 if (port->close_delay) in tty_port_close_end()
617 msleep_interruptible(jiffies_to_msecs(port->close_delay)); in tty_port_close_end()
618 spin_lock_irqsave(&port->lock, flags); in tty_port_close_end()
619 wake_up_interruptible(&port->open_wait); in tty_port_close_end()
621 spin_unlock_irqrestore(&port->lock, flags); in tty_port_close_end()
622 tty_port_set_active(port, 0); in tty_port_close_end()
631 void tty_port_close(struct tty_port *port, struct tty_struct *tty, in tty_port_close() argument
634 if (tty_port_close_start(port, tty, filp) == 0) in tty_port_close()
636 tty_port_shutdown(port, tty); in tty_port_close()
637 if (!port->console) in tty_port_close()
639 tty_port_close_end(port, tty); in tty_port_close()
640 tty_port_tty_set(port, NULL); in tty_port_close()
654 int tty_port_install(struct tty_port *port, struct tty_driver *driver, in tty_port_install() argument
657 tty->port = port; in tty_port_install()
670 int tty_port_open(struct tty_port *port, struct tty_struct *tty, in tty_port_open() argument
673 spin_lock_irq(&port->lock); in tty_port_open()
674 ++port->count; in tty_port_open()
675 spin_unlock_irq(&port->lock); in tty_port_open()
676 tty_port_tty_set(port, tty); in tty_port_open()
684 mutex_lock(&port->mutex); in tty_port_open()
686 if (!tty_port_initialized(port)) { in tty_port_open()
688 if (port->ops->activate) { in tty_port_open()
689 int retval = port->ops->activate(port, tty); in tty_port_open()
691 mutex_unlock(&port->mutex); in tty_port_open()
695 tty_port_set_initialized(port, 1); in tty_port_open()
697 mutex_unlock(&port->mutex); in tty_port_open()
698 return tty_port_block_til_ready(port, tty, filp); in tty_port_open()