• Home
  • Raw
  • Download

Lines Matching refs:port

20 void tty_port_init(struct tty_port *port)  in tty_port_init()  argument
22 memset(port, 0, sizeof(*port)); in tty_port_init()
23 tty_buffer_init(port); in tty_port_init()
24 init_waitqueue_head(&port->open_wait); in tty_port_init()
25 init_waitqueue_head(&port->delta_msr_wait); in tty_port_init()
26 mutex_init(&port->mutex); in tty_port_init()
27 mutex_init(&port->buf_mutex); in tty_port_init()
28 spin_lock_init(&port->lock); in tty_port_init()
29 port->close_delay = (50 * HZ) / 100; in tty_port_init()
30 port->closing_wait = (3000 * HZ) / 100; in tty_port_init()
31 kref_init(&port->kref); in tty_port_init()
46 void tty_port_link_device(struct tty_port *port, in tty_port_link_device() argument
51 driver->ports[index] = port; in tty_port_link_device()
66 struct device *tty_port_register_device(struct tty_port *port, in tty_port_register_device() argument
70 tty_port_link_device(port, driver, index); in tty_port_register_device()
88 struct device *tty_port_register_device_attr(struct tty_port *port, in tty_port_register_device_attr() argument
93 tty_port_link_device(port, driver, index); in tty_port_register_device_attr()
99 int tty_port_alloc_xmit_buf(struct tty_port *port) in tty_port_alloc_xmit_buf() argument
102 mutex_lock(&port->buf_mutex); in tty_port_alloc_xmit_buf()
103 if (port->xmit_buf == NULL) in tty_port_alloc_xmit_buf()
104 port->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); in tty_port_alloc_xmit_buf()
105 mutex_unlock(&port->buf_mutex); in tty_port_alloc_xmit_buf()
106 if (port->xmit_buf == NULL) in tty_port_alloc_xmit_buf()
112 void tty_port_free_xmit_buf(struct tty_port *port) in tty_port_free_xmit_buf() argument
114 mutex_lock(&port->buf_mutex); in tty_port_free_xmit_buf()
115 if (port->xmit_buf != NULL) { in tty_port_free_xmit_buf()
116 free_page((unsigned long)port->xmit_buf); in tty_port_free_xmit_buf()
117 port->xmit_buf = NULL; in tty_port_free_xmit_buf()
119 mutex_unlock(&port->buf_mutex); in tty_port_free_xmit_buf()
131 void tty_port_destroy(struct tty_port *port) in tty_port_destroy() argument
133 tty_buffer_cancel_work(port); in tty_port_destroy()
134 tty_buffer_free_all(port); in tty_port_destroy()
140 struct tty_port *port = container_of(kref, struct tty_port, kref); in tty_port_destructor() local
143 if (WARN_ON(port->itty)) in tty_port_destructor()
145 if (port->xmit_buf) in tty_port_destructor()
146 free_page((unsigned long)port->xmit_buf); in tty_port_destructor()
147 tty_port_destroy(port); in tty_port_destructor()
148 if (port->ops && port->ops->destruct) in tty_port_destructor()
149 port->ops->destruct(port); in tty_port_destructor()
151 kfree(port); in tty_port_destructor()
154 void tty_port_put(struct tty_port *port) in tty_port_put() argument
156 if (port) in tty_port_put()
157 kref_put(&port->kref, tty_port_destructor); in tty_port_put()
169 struct tty_struct *tty_port_tty_get(struct tty_port *port) in tty_port_tty_get() argument
174 spin_lock_irqsave(&port->lock, flags); in tty_port_tty_get()
175 tty = tty_kref_get(port->tty); in tty_port_tty_get()
176 spin_unlock_irqrestore(&port->lock, flags); in tty_port_tty_get()
190 void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty) in tty_port_tty_set() argument
194 spin_lock_irqsave(&port->lock, flags); in tty_port_tty_set()
195 tty_kref_put(port->tty); in tty_port_tty_set()
196 port->tty = tty_kref_get(tty); in tty_port_tty_set()
197 spin_unlock_irqrestore(&port->lock, flags); in tty_port_tty_set()
201 static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty) in tty_port_shutdown() argument
203 mutex_lock(&port->mutex); in tty_port_shutdown()
204 if (port->console) in tty_port_shutdown()
207 if (test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags)) { in tty_port_shutdown()
213 tty_port_lower_dtr_rts(port); in tty_port_shutdown()
215 if (port->ops->shutdown) in tty_port_shutdown()
216 port->ops->shutdown(port); in tty_port_shutdown()
219 mutex_unlock(&port->mutex); in tty_port_shutdown()
232 void tty_port_hangup(struct tty_port *port) in tty_port_hangup() argument
237 spin_lock_irqsave(&port->lock, flags); in tty_port_hangup()
238 port->count = 0; in tty_port_hangup()
239 port->flags &= ~ASYNC_NORMAL_ACTIVE; in tty_port_hangup()
240 tty = port->tty; in tty_port_hangup()
243 port->tty = NULL; in tty_port_hangup()
244 spin_unlock_irqrestore(&port->lock, flags); in tty_port_hangup()
245 tty_port_shutdown(port, tty); in tty_port_hangup()
247 wake_up_interruptible(&port->open_wait); in tty_port_hangup()
248 wake_up_interruptible(&port->delta_msr_wait); in tty_port_hangup()
258 void tty_port_tty_hangup(struct tty_port *port, bool check_clocal) in tty_port_tty_hangup() argument
260 struct tty_struct *tty = tty_port_tty_get(port); in tty_port_tty_hangup()
273 void tty_port_tty_wakeup(struct tty_port *port) in tty_port_tty_wakeup() argument
275 struct tty_struct *tty = tty_port_tty_get(port); in tty_port_tty_wakeup()
293 int tty_port_carrier_raised(struct tty_port *port) in tty_port_carrier_raised() argument
295 if (port->ops->carrier_raised == NULL) in tty_port_carrier_raised()
297 return port->ops->carrier_raised(port); in tty_port_carrier_raised()
310 void tty_port_raise_dtr_rts(struct tty_port *port) in tty_port_raise_dtr_rts() argument
312 if (port->ops->dtr_rts) in tty_port_raise_dtr_rts()
313 port->ops->dtr_rts(port, 1); in tty_port_raise_dtr_rts()
326 void tty_port_lower_dtr_rts(struct tty_port *port) in tty_port_lower_dtr_rts() argument
328 if (port->ops->dtr_rts) in tty_port_lower_dtr_rts()
329 port->ops->dtr_rts(port, 0); in tty_port_lower_dtr_rts()
358 int tty_port_block_til_ready(struct tty_port *port, in tty_port_block_til_ready() argument
368 port->flags |= ASYNC_NORMAL_ACTIVE; in tty_port_block_til_ready()
374 tty_port_raise_dtr_rts(port); in tty_port_block_til_ready()
375 port->flags |= ASYNC_NORMAL_ACTIVE; in tty_port_block_til_ready()
389 spin_lock_irqsave(&port->lock, flags); in tty_port_block_til_ready()
390 port->count--; in tty_port_block_til_ready()
391 port->blocked_open++; in tty_port_block_til_ready()
392 spin_unlock_irqrestore(&port->lock, flags); in tty_port_block_til_ready()
396 if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) in tty_port_block_til_ready()
397 tty_port_raise_dtr_rts(port); in tty_port_block_til_ready()
399 prepare_to_wait(&port->open_wait, &wait, TASK_INTERRUPTIBLE); in tty_port_block_til_ready()
402 if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { in tty_port_block_til_ready()
403 if (port->flags & ASYNC_HUP_NOTIFY) in tty_port_block_til_ready()
415 if (do_clocal || tty_port_carrier_raised(port)) in tty_port_block_til_ready()
425 finish_wait(&port->open_wait, &wait); in tty_port_block_til_ready()
429 spin_lock_irqsave(&port->lock, flags); in tty_port_block_til_ready()
431 port->count++; in tty_port_block_til_ready()
432 port->blocked_open--; in tty_port_block_til_ready()
434 port->flags |= ASYNC_NORMAL_ACTIVE; in tty_port_block_til_ready()
435 spin_unlock_irqrestore(&port->lock, flags); in tty_port_block_til_ready()
440 static void tty_port_drain_delay(struct tty_port *port, struct tty_struct *tty) in tty_port_drain_delay() argument
446 timeout = (HZ * 10 * port->drain_delay) / bps; in tty_port_drain_delay()
455 int tty_port_close_start(struct tty_port *port, in tty_port_close_start() argument
463 spin_lock_irqsave(&port->lock, flags); in tty_port_close_start()
464 if (tty->count == 1 && port->count != 1) { in tty_port_close_start()
467 port->count); in tty_port_close_start()
468 port->count = 1; in tty_port_close_start()
470 if (--port->count < 0) { in tty_port_close_start()
472 port->count); in tty_port_close_start()
473 port->count = 0; in tty_port_close_start()
476 if (port->count) { in tty_port_close_start()
477 spin_unlock_irqrestore(&port->lock, flags); in tty_port_close_start()
480 set_bit(ASYNCB_CLOSING, &port->flags); in tty_port_close_start()
481 spin_unlock_irqrestore(&port->lock, flags); in tty_port_close_start()
485 if (test_bit(ASYNCB_INITIALIZED, &port->flags)) { in tty_port_close_start()
489 if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) in tty_port_close_start()
490 tty_wait_until_sent(tty, port->closing_wait); in tty_port_close_start()
491 if (port->drain_delay) in tty_port_close_start()
492 tty_port_drain_delay(port, tty); in tty_port_close_start()
503 void tty_port_close_end(struct tty_port *port, struct tty_struct *tty) in tty_port_close_end() argument
510 spin_lock_irqsave(&port->lock, flags); in tty_port_close_end()
512 if (port->blocked_open) { in tty_port_close_end()
513 spin_unlock_irqrestore(&port->lock, flags); in tty_port_close_end()
514 if (port->close_delay) { in tty_port_close_end()
516 jiffies_to_msecs(port->close_delay)); in tty_port_close_end()
518 spin_lock_irqsave(&port->lock, flags); in tty_port_close_end()
519 wake_up_interruptible(&port->open_wait); in tty_port_close_end()
521 port->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); in tty_port_close_end()
522 spin_unlock_irqrestore(&port->lock, flags); in tty_port_close_end()
531 void tty_port_close(struct tty_port *port, struct tty_struct *tty, in tty_port_close() argument
534 if (tty_port_close_start(port, tty, filp) == 0) in tty_port_close()
536 tty_port_shutdown(port, tty); in tty_port_close()
538 tty_port_close_end(port, tty); in tty_port_close()
539 tty_port_tty_set(port, NULL); in tty_port_close()
553 int tty_port_install(struct tty_port *port, struct tty_driver *driver, in tty_port_install() argument
556 tty->port = port; in tty_port_install()
569 int tty_port_open(struct tty_port *port, struct tty_struct *tty, in tty_port_open() argument
572 spin_lock_irq(&port->lock); in tty_port_open()
573 ++port->count; in tty_port_open()
574 spin_unlock_irq(&port->lock); in tty_port_open()
575 tty_port_tty_set(port, tty); in tty_port_open()
583 mutex_lock(&port->mutex); in tty_port_open()
585 if (!test_bit(ASYNCB_INITIALIZED, &port->flags)) { in tty_port_open()
587 if (port->ops->activate) { in tty_port_open()
588 int retval = port->ops->activate(port, tty); in tty_port_open()
590 mutex_unlock(&port->mutex); in tty_port_open()
594 set_bit(ASYNCB_INITIALIZED, &port->flags); in tty_port_open()
596 mutex_unlock(&port->mutex); in tty_port_open()
597 return tty_port_block_til_ready(port, tty, filp); in tty_port_open()