Lines Matching full: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()
327 struct hvc_struct *hp; in hvc_install() local
331 hp = hvc_get_by_index(tty->index); in hvc_install()
332 if (!hp) in hvc_install()
335 tty->driver_data = hp; in hvc_install()
337 rc = tty_port_install(&hp->port, driver, tty); in hvc_install()
339 tty_port_put(&hp->port); in hvc_install()
349 struct hvc_struct *hp = tty->driver_data; in hvc_open() local
353 spin_lock_irqsave(&hp->port.lock, flags); in hvc_open()
355 if (hp->port.count++ > 0) { in hvc_open()
356 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_open()
360 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_open()
362 tty_port_tty_set(&hp->port, tty); in hvc_open()
364 if (hp->ops->notifier_add) in hvc_open()
365 rc = hp->ops->notifier_add(hp, hp->data); in hvc_open()
378 if (hp->ops->dtr_rts) in hvc_open()
379 hp->ops->dtr_rts(hp, true); in hvc_open()
380 tty_port_set_initialized(&hp->port, true); in hvc_open()
391 struct hvc_struct *hp = tty->driver_data; in hvc_close() local
397 spin_lock_irqsave(&hp->port.lock, flags); in hvc_close()
399 if (--hp->port.count == 0) { in hvc_close()
400 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_close()
402 tty_port_tty_set(&hp->port, NULL); in hvc_close()
404 if (!tty_port_initialized(&hp->port)) in hvc_close()
408 if (hp->ops->dtr_rts) in hvc_close()
409 hp->ops->dtr_rts(hp, false); in hvc_close()
411 if (hp->ops->notifier_del) in hvc_close()
412 hp->ops->notifier_del(hp, hp->data); in hvc_close()
415 cancel_work_sync(&hp->tty_resize); in hvc_close()
423 tty_port_set_initialized(&hp->port, false); in hvc_close()
425 if (hp->port.count < 0) in hvc_close()
427 hp->vtermno, hp->port.count); in hvc_close()
428 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_close()
434 struct hvc_struct *hp = tty->driver_data; in hvc_cleanup() local
436 tty_port_put(&hp->port); in hvc_cleanup()
441 struct hvc_struct *hp = tty->driver_data; in hvc_hangup() local
444 if (!hp) in hvc_hangup()
448 cancel_work_sync(&hp->tty_resize); in hvc_hangup()
450 spin_lock_irqsave(&hp->port.lock, flags); in hvc_hangup()
457 if (hp->port.count <= 0) { in hvc_hangup()
458 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_hangup()
462 hp->port.count = 0; in hvc_hangup()
463 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_hangup()
464 tty_port_tty_set(&hp->port, NULL); in hvc_hangup()
466 hp->n_outbuf = 0; in hvc_hangup()
468 if (hp->ops->notifier_hangup) in hvc_hangup()
469 hp->ops->notifier_hangup(hp, hp->data); in hvc_hangup()
474 * on a blocked hypervisor. Call this function with hp->lock held.
476 static int hvc_push(struct hvc_struct *hp) in hvc_push() argument
480 n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf); in hvc_push()
483 hp->do_wakeup = 1; in hvc_push()
488 hp->n_outbuf = 0; in hvc_push()
490 hp->n_outbuf -= n; in hvc_push()
491 if (hp->n_outbuf > 0) in hvc_push()
492 memmove(hp->outbuf, hp->outbuf + n, hp->n_outbuf); in hvc_push()
494 hp->do_wakeup = 1; in hvc_push()
501 struct hvc_struct *hp = tty->driver_data; in hvc_write() local
506 if (!hp) in hvc_write()
510 if (hp->port.count <= 0) in hvc_write()
516 spin_lock_irqsave(&hp->lock, flags); in hvc_write()
518 rsize = hp->outbuf_size - hp->n_outbuf; in hvc_write()
523 memcpy(hp->outbuf + hp->n_outbuf, buf, rsize); in hvc_write()
526 hp->n_outbuf += rsize; in hvc_write()
530 if (hp->n_outbuf > 0) in hvc_write()
531 ret = hvc_push(hp); in hvc_write()
533 spin_unlock_irqrestore(&hp->lock, flags); in hvc_write()
539 if (hp->n_outbuf > 0) in hvc_write()
540 hvc_flush(hp); in hvc_write()
548 if (hp->n_outbuf) in hvc_write()
561 * Locking: hp->lock
565 struct hvc_struct *hp; in hvc_set_winsz() local
570 hp = container_of(work, struct hvc_struct, tty_resize); in hvc_set_winsz()
572 tty = tty_port_tty_get(&hp->port); in hvc_set_winsz()
576 spin_lock_irqsave(&hp->lock, hvc_flags); in hvc_set_winsz()
577 ws = hp->ws; in hvc_set_winsz()
578 spin_unlock_irqrestore(&hp->lock, hvc_flags); in hvc_set_winsz()
591 struct hvc_struct *hp = tty->driver_data; in hvc_write_room() local
593 if (!hp) in hvc_write_room()
596 return hp->outbuf_size - hp->n_outbuf; in hvc_write_room()
601 struct hvc_struct *hp = tty->driver_data; in hvc_chars_in_buffer() local
603 if (!hp) in hvc_chars_in_buffer()
605 return hp->n_outbuf; in hvc_chars_in_buffer()
632 static int __hvc_poll(struct hvc_struct *hp, bool may_sleep) in __hvc_poll() argument
641 spin_lock_irqsave(&hp->lock, flags); in __hvc_poll()
644 if (hp->n_outbuf > 0) in __hvc_poll()
645 written_total = hvc_push(hp); in __hvc_poll()
648 if (hp->n_outbuf > 0) { in __hvc_poll()
655 spin_unlock_irqrestore(&hp->lock, flags); in __hvc_poll()
657 spin_lock_irqsave(&hp->lock, flags); in __hvc_poll()
661 tty = tty_port_tty_get(&hp->port); in __hvc_poll()
672 if (!hp->irq_requested) in __hvc_poll()
677 count = tty_buffer_request_room(&hp->port, N_INBUF); in __hvc_poll()
685 n = hp->ops->get_chars(hp->vtermno, buf, count); in __hvc_poll()
689 spin_unlock_irqrestore(&hp->lock, flags); in __hvc_poll()
691 spin_lock_irqsave(&hp->lock, flags); in __hvc_poll()
705 if (hp->index == hvc_console.index) { in __hvc_poll()
721 tty_insert_flip_char(&hp->port, buf[i], 0); in __hvc_poll()
727 spin_unlock_irqrestore(&hp->lock, flags); in __hvc_poll()
729 spin_lock_irqsave(&hp->lock, flags); in __hvc_poll()
743 if (hp->do_wakeup) { in __hvc_poll()
744 hp->do_wakeup = 0; in __hvc_poll()
748 spin_unlock_irqrestore(&hp->lock, flags); in __hvc_poll()
755 tty_flip_buffer_push(&hp->port); in __hvc_poll()
762 int hvc_poll(struct hvc_struct *hp) in hvc_poll() argument
764 return __hvc_poll(hp, false); in hvc_poll()
770 * @hp: HVC console pointer
773 * Stores the specified window size information in the hvc structure of @hp.
776 * Locking: Locking free; the function MUST be called holding hp->lock
778 void __hvc_resize(struct hvc_struct *hp, struct winsize ws) in __hvc_resize() argument
780 hp->ws = ws; in __hvc_resize()
781 schedule_work(&hp->tty_resize); in __hvc_resize()
793 struct hvc_struct *hp; in khvcd() local
803 list_for_each_entry(hp, &hvc_structs, next) { in khvcd()
804 poll_mask |= __hvc_poll(hp, true); in khvcd()
838 struct hvc_struct *hp = tty->driver_data; in hvc_tiocmget() local
840 if (!hp || !hp->ops->tiocmget) in hvc_tiocmget()
842 return hp->ops->tiocmget(hp); in hvc_tiocmget()
848 struct hvc_struct *hp = tty->driver_data; in hvc_tiocmset() local
850 if (!hp || !hp->ops->tiocmset) in hvc_tiocmset()
852 return hp->ops->tiocmset(hp, set, clear); in hvc_tiocmset()
864 struct hvc_struct *hp = tty->driver_data; in hvc_poll_get_char() local
868 n = hp->ops->get_chars(hp->vtermno, &ch, 1); in hvc_poll_get_char()
879 struct hvc_struct *hp = tty->driver_data; in hvc_poll_put_char() local
883 n = hp->ops->put_chars(hp->vtermno, &ch, 1); in hvc_poll_put_char()
915 struct hvc_struct *hp; in hvc_alloc() local
925 hp = kzalloc(struct_size(hp, outbuf, outbuf_size), GFP_KERNEL); in hvc_alloc()
926 if (!hp) in hvc_alloc()
929 hp->vtermno = vtermno; in hvc_alloc()
930 hp->data = data; in hvc_alloc()
931 hp->ops = ops; in hvc_alloc()
932 hp->outbuf_size = outbuf_size; in hvc_alloc()
934 tty_port_init(&hp->port); in hvc_alloc()
935 hp->port.ops = &hvc_port_ops; in hvc_alloc()
937 INIT_WORK(&hp->tty_resize, hvc_set_winsz); in hvc_alloc()
938 spin_lock_init(&hp->lock); in hvc_alloc()
946 if (vtermnos[i] == hp->vtermno && in hvc_alloc()
947 cons_ops[i] == hp->ops) in hvc_alloc()
961 hp->index = i; in hvc_alloc()
967 list_add_tail(&(hp->next), &hvc_structs); in hvc_alloc()
973 return hp; in hvc_alloc()
977 void hvc_remove(struct hvc_struct *hp) in hvc_remove() argument
982 tty = tty_port_tty_get(&hp->port); in hvc_remove()
985 spin_lock_irqsave(&hp->lock, flags); in hvc_remove()
986 if (hp->index < MAX_NR_HVC_CONSOLES) { in hvc_remove()
987 vtermnos[hp->index] = -1; in hvc_remove()
988 cons_ops[hp->index] = NULL; in hvc_remove()
991 /* Don't whack hp->irq because tty_hangup() will need to free the irq. */ in hvc_remove()
993 spin_unlock_irqrestore(&hp->lock, flags); in hvc_remove()
1002 tty_port_put(&hp->port); in hvc_remove()