Lines Matching refs:hp
92 struct hvc_struct *hp; in hvc_get_by_index() local
97 list_for_each_entry(hp, &hvc_structs, next) { in hvc_get_by_index()
98 spin_lock_irqsave(&hp->lock, flags); in hvc_get_by_index()
99 if (hp->index == index) { in hvc_get_by_index()
100 tty_port_get(&hp->port); in hvc_get_by_index()
101 spin_unlock_irqrestore(&hp->lock, flags); in hvc_get_by_index()
103 return hp; in hvc_get_by_index()
105 spin_unlock_irqrestore(&hp->lock, flags); in hvc_get_by_index()
107 hp = NULL; in hvc_get_by_index()
110 return hp; in hvc_get_by_index()
131 static int hvc_flush(struct hvc_struct *hp) in hvc_flush() argument
133 return __hvc_flush(hp->ops, hp->vtermno, true); in hvc_flush()
251 struct hvc_struct *hp = container_of(port, struct hvc_struct, port); in hvc_port_destruct() local
256 spin_lock_irqsave(&hp->lock, flags); in hvc_port_destruct()
257 list_del(&(hp->next)); in hvc_port_destruct()
258 spin_unlock_irqrestore(&hp->lock, flags); in hvc_port_destruct()
262 kfree(hp); in hvc_port_destruct()
287 struct hvc_struct *hp; in hvc_instantiate() local
296 hp = hvc_get_by_index(index); in hvc_instantiate()
297 if (hp) { in hvc_instantiate()
298 tty_port_put(&hp->port); in hvc_instantiate()
331 struct hvc_struct *hp; in hvc_install() local
335 hp = hvc_get_by_index(tty->index); in hvc_install()
336 if (!hp) in hvc_install()
339 tty->driver_data = hp; in hvc_install()
341 rc = tty_port_install(&hp->port, driver, tty); in hvc_install()
343 tty_port_put(&hp->port); in hvc_install()
353 struct hvc_struct *hp = tty->driver_data; in hvc_open() local
357 spin_lock_irqsave(&hp->port.lock, flags); in hvc_open()
359 if (hp->port.count++ > 0) { in hvc_open()
360 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_open()
364 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_open()
366 tty_port_tty_set(&hp->port, tty); in hvc_open()
368 if (hp->ops->notifier_add) in hvc_open()
369 rc = hp->ops->notifier_add(hp, hp->data); in hvc_open()
378 tty_port_tty_set(&hp->port, NULL); in hvc_open()
380 tty_port_put(&hp->port); in hvc_open()
385 if (hp->ops->dtr_rts) in hvc_open()
386 hp->ops->dtr_rts(hp, 1); in hvc_open()
396 struct hvc_struct *hp; in hvc_close() local
410 hp = tty->driver_data; in hvc_close()
412 spin_lock_irqsave(&hp->port.lock, flags); in hvc_close()
414 if (--hp->port.count == 0) { in hvc_close()
415 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_close()
417 tty_port_tty_set(&hp->port, NULL); in hvc_close()
420 if (hp->ops->dtr_rts) in hvc_close()
421 hp->ops->dtr_rts(hp, 0); in hvc_close()
423 if (hp->ops->notifier_del) in hvc_close()
424 hp->ops->notifier_del(hp, hp->data); in hvc_close()
427 cancel_work_sync(&hp->tty_resize); in hvc_close()
436 if (hp->port.count < 0) in hvc_close()
438 hp->vtermno, hp->port.count); in hvc_close()
439 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_close()
445 struct hvc_struct *hp = tty->driver_data; in hvc_cleanup() local
447 tty_port_put(&hp->port); in hvc_cleanup()
452 struct hvc_struct *hp = tty->driver_data; in hvc_hangup() local
455 if (!hp) in hvc_hangup()
459 cancel_work_sync(&hp->tty_resize); in hvc_hangup()
461 spin_lock_irqsave(&hp->port.lock, flags); in hvc_hangup()
468 if (hp->port.count <= 0) { in hvc_hangup()
469 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_hangup()
473 hp->port.count = 0; in hvc_hangup()
474 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_hangup()
475 tty_port_tty_set(&hp->port, NULL); in hvc_hangup()
477 hp->n_outbuf = 0; in hvc_hangup()
479 if (hp->ops->notifier_hangup) in hvc_hangup()
480 hp->ops->notifier_hangup(hp, hp->data); in hvc_hangup()
487 static int hvc_push(struct hvc_struct *hp) in hvc_push() argument
491 n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf); in hvc_push()
494 hp->do_wakeup = 1; in hvc_push()
499 hp->n_outbuf = 0; in hvc_push()
501 hp->n_outbuf -= n; in hvc_push()
502 if (hp->n_outbuf > 0) in hvc_push()
503 memmove(hp->outbuf, hp->outbuf + n, hp->n_outbuf); in hvc_push()
505 hp->do_wakeup = 1; in hvc_push()
512 struct hvc_struct *hp = tty->driver_data; in hvc_write() local
517 if (!hp) in hvc_write()
521 if (hp->port.count <= 0) in hvc_write()
527 spin_lock_irqsave(&hp->lock, flags); in hvc_write()
529 rsize = hp->outbuf_size - hp->n_outbuf; in hvc_write()
534 memcpy(hp->outbuf + hp->n_outbuf, buf, rsize); in hvc_write()
537 hp->n_outbuf += rsize; in hvc_write()
541 if (hp->n_outbuf > 0) in hvc_write()
542 ret = hvc_push(hp); in hvc_write()
544 spin_unlock_irqrestore(&hp->lock, flags); in hvc_write()
550 if (hp->n_outbuf > 0) in hvc_write()
551 hvc_flush(hp); in hvc_write()
559 if (hp->n_outbuf) in hvc_write()
576 struct hvc_struct *hp; in hvc_set_winsz() local
581 hp = container_of(work, struct hvc_struct, tty_resize); in hvc_set_winsz()
583 tty = tty_port_tty_get(&hp->port); in hvc_set_winsz()
587 spin_lock_irqsave(&hp->lock, hvc_flags); in hvc_set_winsz()
588 ws = hp->ws; in hvc_set_winsz()
589 spin_unlock_irqrestore(&hp->lock, hvc_flags); in hvc_set_winsz()
602 struct hvc_struct *hp = tty->driver_data; in hvc_write_room() local
604 if (!hp) in hvc_write_room()
607 return hp->outbuf_size - hp->n_outbuf; in hvc_write_room()
612 struct hvc_struct *hp = tty->driver_data; in hvc_chars_in_buffer() local
614 if (!hp) in hvc_chars_in_buffer()
616 return hp->n_outbuf; in hvc_chars_in_buffer()
643 static int __hvc_poll(struct hvc_struct *hp, bool may_sleep) in __hvc_poll() argument
652 spin_lock_irqsave(&hp->lock, flags); in __hvc_poll()
655 if (hp->n_outbuf > 0) in __hvc_poll()
656 written_total = hvc_push(hp); in __hvc_poll()
659 if (hp->n_outbuf > 0) { in __hvc_poll()
666 spin_unlock_irqrestore(&hp->lock, flags); in __hvc_poll()
668 spin_lock_irqsave(&hp->lock, flags); in __hvc_poll()
672 tty = tty_port_tty_get(&hp->port); in __hvc_poll()
683 if (!hp->irq_requested) in __hvc_poll()
688 count = tty_buffer_request_room(&hp->port, N_INBUF); in __hvc_poll()
696 n = hp->ops->get_chars(hp->vtermno, buf, count); in __hvc_poll()
700 spin_unlock_irqrestore(&hp->lock, flags); in __hvc_poll()
702 spin_lock_irqsave(&hp->lock, flags); in __hvc_poll()
716 if (hp->index == hvc_console.index) { in __hvc_poll()
732 tty_insert_flip_char(&hp->port, buf[i], 0); in __hvc_poll()
738 spin_unlock_irqrestore(&hp->lock, flags); in __hvc_poll()
740 spin_lock_irqsave(&hp->lock, flags); in __hvc_poll()
754 if (hp->do_wakeup) { in __hvc_poll()
755 hp->do_wakeup = 0; in __hvc_poll()
759 spin_unlock_irqrestore(&hp->lock, flags); in __hvc_poll()
766 tty_flip_buffer_push(&hp->port); in __hvc_poll()
773 int hvc_poll(struct hvc_struct *hp) in hvc_poll() argument
775 return __hvc_poll(hp, false); in hvc_poll()
789 void __hvc_resize(struct hvc_struct *hp, struct winsize ws) in __hvc_resize() argument
791 hp->ws = ws; in __hvc_resize()
792 schedule_work(&hp->tty_resize); in __hvc_resize()
804 struct hvc_struct *hp; in khvcd() local
814 list_for_each_entry(hp, &hvc_structs, next) { in khvcd()
815 poll_mask |= __hvc_poll(hp, true); in khvcd()
849 struct hvc_struct *hp = tty->driver_data; in hvc_tiocmget() local
851 if (!hp || !hp->ops->tiocmget) in hvc_tiocmget()
853 return hp->ops->tiocmget(hp); in hvc_tiocmget()
859 struct hvc_struct *hp = tty->driver_data; in hvc_tiocmset() local
861 if (!hp || !hp->ops->tiocmset) in hvc_tiocmset()
863 return hp->ops->tiocmset(hp, set, clear); in hvc_tiocmset()
875 struct hvc_struct *hp = tty->driver_data; in hvc_poll_get_char() local
879 n = hp->ops->get_chars(hp->vtermno, &ch, 1); in hvc_poll_get_char()
890 struct hvc_struct *hp = tty->driver_data; in hvc_poll_put_char() local
894 n = hp->ops->put_chars(hp->vtermno, &ch, 1); in hvc_poll_put_char()
926 struct hvc_struct *hp; in hvc_alloc() local
936 hp = kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size, in hvc_alloc()
938 if (!hp) in hvc_alloc()
941 hp->vtermno = vtermno; in hvc_alloc()
942 hp->data = data; in hvc_alloc()
943 hp->ops = ops; in hvc_alloc()
944 hp->outbuf_size = outbuf_size; in hvc_alloc()
945 hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))]; in hvc_alloc()
947 tty_port_init(&hp->port); in hvc_alloc()
948 hp->port.ops = &hvc_port_ops; in hvc_alloc()
950 INIT_WORK(&hp->tty_resize, hvc_set_winsz); in hvc_alloc()
951 spin_lock_init(&hp->lock); in hvc_alloc()
959 if (vtermnos[i] == hp->vtermno && in hvc_alloc()
960 cons_ops[i] == hp->ops) in hvc_alloc()
967 hp->index = i; in hvc_alloc()
971 list_add_tail(&(hp->next), &hvc_structs); in hvc_alloc()
977 return hp; in hvc_alloc()
981 int hvc_remove(struct hvc_struct *hp) in hvc_remove() argument
986 tty = tty_port_tty_get(&hp->port); in hvc_remove()
989 spin_lock_irqsave(&hp->lock, flags); in hvc_remove()
990 if (hp->index < MAX_NR_HVC_CONSOLES) { in hvc_remove()
991 vtermnos[hp->index] = -1; in hvc_remove()
992 cons_ops[hp->index] = NULL; in hvc_remove()
997 spin_unlock_irqrestore(&hp->lock, flags); in hvc_remove()
1006 tty_port_put(&hp->port); in hvc_remove()