Lines Matching refs:hp
102 struct hvc_struct *hp; in hvc_get_by_index() local
107 list_for_each_entry(hp, &hvc_structs, next) { in hvc_get_by_index()
108 spin_lock_irqsave(&hp->lock, flags); in hvc_get_by_index()
109 if (hp->index == index) { in hvc_get_by_index()
110 tty_port_get(&hp->port); in hvc_get_by_index()
111 spin_unlock_irqrestore(&hp->lock, flags); in hvc_get_by_index()
113 return hp; in hvc_get_by_index()
115 spin_unlock_irqrestore(&hp->lock, flags); in hvc_get_by_index()
117 hp = NULL; in hvc_get_by_index()
120 return hp; in hvc_get_by_index()
234 struct hvc_struct *hp = container_of(port, struct hvc_struct, port); in hvc_port_destruct() local
239 spin_lock_irqsave(&hp->lock, flags); in hvc_port_destruct()
240 list_del(&(hp->next)); in hvc_port_destruct()
241 spin_unlock_irqrestore(&hp->lock, flags); in hvc_port_destruct()
245 kfree(hp); in hvc_port_destruct()
270 struct hvc_struct *hp; in hvc_instantiate() local
279 hp = hvc_get_by_index(index); in hvc_instantiate()
280 if (hp) { in hvc_instantiate()
281 tty_port_put(&hp->port); in hvc_instantiate()
314 struct hvc_struct *hp; in hvc_install() local
318 if (!(hp = hvc_get_by_index(tty->index))) in hvc_install()
321 tty->driver_data = hp; in hvc_install()
323 rc = tty_port_install(&hp->port, driver, tty); in hvc_install()
325 tty_port_put(&hp->port); in hvc_install()
335 struct hvc_struct *hp = tty->driver_data; in hvc_open() local
339 spin_lock_irqsave(&hp->port.lock, flags); in hvc_open()
341 if (hp->port.count++ > 0) { in hvc_open()
342 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_open()
346 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_open()
348 tty_port_tty_set(&hp->port, tty); in hvc_open()
350 if (hp->ops->notifier_add) in hvc_open()
351 rc = hp->ops->notifier_add(hp, hp->data); in hvc_open()
360 tty_port_tty_set(&hp->port, NULL); in hvc_open()
362 tty_port_put(&hp->port); in hvc_open()
373 struct hvc_struct *hp; in hvc_close() local
387 hp = tty->driver_data; in hvc_close()
389 spin_lock_irqsave(&hp->port.lock, flags); in hvc_close()
391 if (--hp->port.count == 0) { in hvc_close()
392 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_close()
394 tty_port_tty_set(&hp->port, NULL); in hvc_close()
396 if (hp->ops->notifier_del) in hvc_close()
397 hp->ops->notifier_del(hp, hp->data); in hvc_close()
400 cancel_work_sync(&hp->tty_resize); in hvc_close()
409 if (hp->port.count < 0) in hvc_close()
411 hp->vtermno, hp->port.count); in hvc_close()
412 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_close()
418 struct hvc_struct *hp = tty->driver_data; in hvc_cleanup() local
420 tty_port_put(&hp->port); in hvc_cleanup()
425 struct hvc_struct *hp = tty->driver_data; in hvc_hangup() local
428 if (!hp) in hvc_hangup()
432 cancel_work_sync(&hp->tty_resize); in hvc_hangup()
434 spin_lock_irqsave(&hp->port.lock, flags); in hvc_hangup()
441 if (hp->port.count <= 0) { in hvc_hangup()
442 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_hangup()
446 hp->port.count = 0; in hvc_hangup()
447 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_hangup()
448 tty_port_tty_set(&hp->port, NULL); in hvc_hangup()
450 hp->n_outbuf = 0; in hvc_hangup()
452 if (hp->ops->notifier_hangup) in hvc_hangup()
453 hp->ops->notifier_hangup(hp, hp->data); in hvc_hangup()
460 static int hvc_push(struct hvc_struct *hp) in hvc_push() argument
464 n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf); in hvc_push()
467 hp->do_wakeup = 1; in hvc_push()
472 hp->n_outbuf = 0; in hvc_push()
474 hp->n_outbuf -= n; in hvc_push()
475 if (hp->n_outbuf > 0) in hvc_push()
476 memmove(hp->outbuf, hp->outbuf + n, hp->n_outbuf); in hvc_push()
478 hp->do_wakeup = 1; in hvc_push()
485 struct hvc_struct *hp = tty->driver_data; in hvc_write() local
490 if (!hp) in hvc_write()
494 if (hp->port.count <= 0) in hvc_write()
497 spin_lock_irqsave(&hp->lock, flags); in hvc_write()
500 if (hp->n_outbuf > 0) in hvc_write()
501 hvc_push(hp); in hvc_write()
503 while (count > 0 && (rsize = hp->outbuf_size - hp->n_outbuf) > 0) { in hvc_write()
506 memcpy(hp->outbuf + hp->n_outbuf, buf, rsize); in hvc_write()
509 hp->n_outbuf += rsize; in hvc_write()
511 hvc_push(hp); in hvc_write()
513 spin_unlock_irqrestore(&hp->lock, flags); in hvc_write()
518 if (hp->n_outbuf) in hvc_write()
535 struct hvc_struct *hp; in hvc_set_winsz() local
540 hp = container_of(work, struct hvc_struct, tty_resize); in hvc_set_winsz()
542 tty = tty_port_tty_get(&hp->port); in hvc_set_winsz()
546 spin_lock_irqsave(&hp->lock, hvc_flags); in hvc_set_winsz()
547 ws = hp->ws; in hvc_set_winsz()
548 spin_unlock_irqrestore(&hp->lock, hvc_flags); in hvc_set_winsz()
561 struct hvc_struct *hp = tty->driver_data; in hvc_write_room() local
563 if (!hp) in hvc_write_room()
566 return hp->outbuf_size - hp->n_outbuf; in hvc_write_room()
571 struct hvc_struct *hp = tty->driver_data; in hvc_chars_in_buffer() local
573 if (!hp) in hvc_chars_in_buffer()
575 return hp->n_outbuf; in hvc_chars_in_buffer()
593 int hvc_poll(struct hvc_struct *hp) in hvc_poll() argument
602 spin_lock_irqsave(&hp->lock, flags); in hvc_poll()
605 if (hp->n_outbuf > 0) in hvc_poll()
606 written_total = hvc_push(hp); in hvc_poll()
609 if (hp->n_outbuf > 0) { in hvc_poll()
616 tty = tty_port_tty_get(&hp->port); in hvc_poll()
627 if (!hp->irq_requested) in hvc_poll()
632 int count = tty_buffer_request_room(&hp->port, N_INBUF); in hvc_poll()
640 n = hp->ops->get_chars(hp->vtermno, buf, count); in hvc_poll()
644 spin_unlock_irqrestore(&hp->lock, flags); in hvc_poll()
646 spin_lock_irqsave(&hp->lock, flags); in hvc_poll()
659 if (hp->index == hvc_console.index) { in hvc_poll()
675 tty_insert_flip_char(&hp->port, buf[i], 0); in hvc_poll()
682 if (hp->do_wakeup) { in hvc_poll()
683 hp->do_wakeup = 0; in hvc_poll()
687 spin_unlock_irqrestore(&hp->lock, flags); in hvc_poll()
694 tty_flip_buffer_push(&hp->port); in hvc_poll()
712 void __hvc_resize(struct hvc_struct *hp, struct winsize ws) in __hvc_resize() argument
714 hp->ws = ws; in __hvc_resize()
715 schedule_work(&hp->tty_resize); in __hvc_resize()
727 struct hvc_struct *hp; in khvcd() local
737 list_for_each_entry(hp, &hvc_structs, next) { in khvcd()
738 poll_mask |= hvc_poll(hp); in khvcd()
764 struct hvc_struct *hp = tty->driver_data; in hvc_tiocmget() local
766 if (!hp || !hp->ops->tiocmget) in hvc_tiocmget()
768 return hp->ops->tiocmget(hp); in hvc_tiocmget()
774 struct hvc_struct *hp = tty->driver_data; in hvc_tiocmset() local
776 if (!hp || !hp->ops->tiocmset) in hvc_tiocmset()
778 return hp->ops->tiocmset(hp, set, clear); in hvc_tiocmset()
790 struct hvc_struct *hp = tty->driver_data; in hvc_poll_get_char() local
794 n = hp->ops->get_chars(hp->vtermno, &ch, 1); in hvc_poll_get_char()
805 struct hvc_struct *hp = tty->driver_data; in hvc_poll_put_char() local
809 n = hp->ops->put_chars(hp->vtermno, &ch, 1); in hvc_poll_put_char()
841 struct hvc_struct *hp; in hvc_alloc() local
851 hp = kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size, in hvc_alloc()
853 if (!hp) in hvc_alloc()
856 hp->vtermno = vtermno; in hvc_alloc()
857 hp->data = data; in hvc_alloc()
858 hp->ops = ops; in hvc_alloc()
859 hp->outbuf_size = outbuf_size; in hvc_alloc()
860 hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))]; in hvc_alloc()
862 tty_port_init(&hp->port); in hvc_alloc()
863 hp->port.ops = &hvc_port_ops; in hvc_alloc()
865 INIT_WORK(&hp->tty_resize, hvc_set_winsz); in hvc_alloc()
866 spin_lock_init(&hp->lock); in hvc_alloc()
874 if (vtermnos[i] == hp->vtermno && in hvc_alloc()
875 cons_ops[i] == hp->ops) in hvc_alloc()
882 hp->index = i; in hvc_alloc()
886 list_add_tail(&(hp->next), &hvc_structs); in hvc_alloc()
892 return hp; in hvc_alloc()
896 int hvc_remove(struct hvc_struct *hp) in hvc_remove() argument
901 tty = tty_port_tty_get(&hp->port); in hvc_remove()
903 spin_lock_irqsave(&hp->lock, flags); in hvc_remove()
904 if (hp->index < MAX_NR_HVC_CONSOLES) { in hvc_remove()
906 vtermnos[hp->index] = -1; in hvc_remove()
907 cons_ops[hp->index] = NULL; in hvc_remove()
913 spin_unlock_irqrestore(&hp->lock, flags); in hvc_remove()
921 tty_port_put(&hp->port); in hvc_remove()