Lines Matching refs:hp
106 struct hvc_struct *hp; in hvc_get_by_index() local
111 list_for_each_entry(hp, &hvc_structs, next) { in hvc_get_by_index()
112 spin_lock_irqsave(&hp->lock, flags); in hvc_get_by_index()
113 if (hp->index == index) { in hvc_get_by_index()
114 tty_port_get(&hp->port); in hvc_get_by_index()
115 spin_unlock_irqrestore(&hp->lock, flags); in hvc_get_by_index()
117 return hp; in hvc_get_by_index()
119 spin_unlock_irqrestore(&hp->lock, flags); in hvc_get_by_index()
121 hp = NULL; in hvc_get_by_index()
124 return hp; in hvc_get_by_index()
238 struct hvc_struct *hp = container_of(port, struct hvc_struct, port); in hvc_port_destruct() local
243 spin_lock_irqsave(&hp->lock, flags); in hvc_port_destruct()
244 list_del(&(hp->next)); in hvc_port_destruct()
245 spin_unlock_irqrestore(&hp->lock, flags); in hvc_port_destruct()
249 kfree(hp); in hvc_port_destruct()
274 struct hvc_struct *hp; in hvc_instantiate() local
283 hp = hvc_get_by_index(index); in hvc_instantiate()
284 if (hp) { in hvc_instantiate()
285 tty_port_put(&hp->port); in hvc_instantiate()
318 struct hvc_struct *hp; in hvc_install() local
322 if (!(hp = hvc_get_by_index(tty->index))) in hvc_install()
325 tty->driver_data = hp; in hvc_install()
327 rc = tty_port_install(&hp->port, driver, tty); in hvc_install()
329 tty_port_put(&hp->port); in hvc_install()
339 struct hvc_struct *hp = tty->driver_data; in hvc_open() local
343 spin_lock_irqsave(&hp->port.lock, flags); in hvc_open()
345 if (hp->port.count++ > 0) { in hvc_open()
346 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_open()
350 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_open()
352 tty_port_tty_set(&hp->port, tty); in hvc_open()
354 if (hp->ops->notifier_add) in hvc_open()
355 rc = hp->ops->notifier_add(hp, hp->data); in hvc_open()
364 tty_port_tty_set(&hp->port, NULL); in hvc_open()
366 tty_port_put(&hp->port); in hvc_open()
371 if (hp->ops->dtr_rts) in hvc_open()
372 hp->ops->dtr_rts(hp, 1); in hvc_open()
382 struct hvc_struct *hp; in hvc_close() local
396 hp = tty->driver_data; in hvc_close()
398 spin_lock_irqsave(&hp->port.lock, flags); in hvc_close()
400 if (--hp->port.count == 0) { in hvc_close()
401 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_close()
403 tty_port_tty_set(&hp->port, NULL); in hvc_close()
406 if (hp->ops->dtr_rts) in hvc_close()
407 hp->ops->dtr_rts(hp, 0); in hvc_close()
409 if (hp->ops->notifier_del) in hvc_close()
410 hp->ops->notifier_del(hp, hp->data); in hvc_close()
413 cancel_work_sync(&hp->tty_resize); in hvc_close()
422 if (hp->port.count < 0) in hvc_close()
424 hp->vtermno, hp->port.count); in hvc_close()
425 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_close()
431 struct hvc_struct *hp = tty->driver_data; in hvc_cleanup() local
433 tty_port_put(&hp->port); in hvc_cleanup()
438 struct hvc_struct *hp = tty->driver_data; in hvc_hangup() local
441 if (!hp) in hvc_hangup()
445 cancel_work_sync(&hp->tty_resize); in hvc_hangup()
447 spin_lock_irqsave(&hp->port.lock, flags); in hvc_hangup()
454 if (hp->port.count <= 0) { in hvc_hangup()
455 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_hangup()
459 hp->port.count = 0; in hvc_hangup()
460 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_hangup()
461 tty_port_tty_set(&hp->port, NULL); in hvc_hangup()
463 hp->n_outbuf = 0; in hvc_hangup()
465 if (hp->ops->notifier_hangup) in hvc_hangup()
466 hp->ops->notifier_hangup(hp, hp->data); in hvc_hangup()
473 static int hvc_push(struct hvc_struct *hp) in hvc_push() argument
477 n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf); in hvc_push()
480 hp->do_wakeup = 1; in hvc_push()
485 hp->n_outbuf = 0; in hvc_push()
487 hp->n_outbuf -= n; in hvc_push()
488 if (hp->n_outbuf > 0) in hvc_push()
489 memmove(hp->outbuf, hp->outbuf + n, hp->n_outbuf); in hvc_push()
491 hp->do_wakeup = 1; in hvc_push()
498 struct hvc_struct *hp = tty->driver_data; in hvc_write() local
503 if (!hp) in hvc_write()
507 if (hp->port.count <= 0) in hvc_write()
510 spin_lock_irqsave(&hp->lock, flags); in hvc_write()
513 if (hp->n_outbuf > 0) in hvc_write()
514 hvc_push(hp); in hvc_write()
516 while (count > 0 && (rsize = hp->outbuf_size - hp->n_outbuf) > 0) { in hvc_write()
519 memcpy(hp->outbuf + hp->n_outbuf, buf, rsize); in hvc_write()
522 hp->n_outbuf += rsize; in hvc_write()
524 hvc_push(hp); in hvc_write()
526 spin_unlock_irqrestore(&hp->lock, flags); in hvc_write()
531 if (hp->n_outbuf) in hvc_write()
548 struct hvc_struct *hp; in hvc_set_winsz() local
553 hp = container_of(work, struct hvc_struct, tty_resize); in hvc_set_winsz()
555 tty = tty_port_tty_get(&hp->port); in hvc_set_winsz()
559 spin_lock_irqsave(&hp->lock, hvc_flags); in hvc_set_winsz()
560 ws = hp->ws; in hvc_set_winsz()
561 spin_unlock_irqrestore(&hp->lock, hvc_flags); in hvc_set_winsz()
574 struct hvc_struct *hp = tty->driver_data; in hvc_write_room() local
576 if (!hp) in hvc_write_room()
579 return hp->outbuf_size - hp->n_outbuf; in hvc_write_room()
584 struct hvc_struct *hp = tty->driver_data; in hvc_chars_in_buffer() local
586 if (!hp) in hvc_chars_in_buffer()
588 return hp->n_outbuf; in hvc_chars_in_buffer()
606 int hvc_poll(struct hvc_struct *hp) in hvc_poll() argument
615 spin_lock_irqsave(&hp->lock, flags); in hvc_poll()
618 if (hp->n_outbuf > 0) in hvc_poll()
619 written_total = hvc_push(hp); in hvc_poll()
622 if (hp->n_outbuf > 0) { in hvc_poll()
629 tty = tty_port_tty_get(&hp->port); in hvc_poll()
640 if (!hp->irq_requested) in hvc_poll()
645 int count = tty_buffer_request_room(&hp->port, N_INBUF); in hvc_poll()
653 n = hp->ops->get_chars(hp->vtermno, buf, count); in hvc_poll()
657 spin_unlock_irqrestore(&hp->lock, flags); in hvc_poll()
659 spin_lock_irqsave(&hp->lock, flags); in hvc_poll()
672 if (hp->index == hvc_console.index) { in hvc_poll()
688 tty_insert_flip_char(&hp->port, buf[i], 0); in hvc_poll()
695 if (hp->do_wakeup) { in hvc_poll()
696 hp->do_wakeup = 0; in hvc_poll()
700 spin_unlock_irqrestore(&hp->lock, flags); in hvc_poll()
707 tty_flip_buffer_push(&hp->port); in hvc_poll()
725 void __hvc_resize(struct hvc_struct *hp, struct winsize ws) in __hvc_resize() argument
727 hp->ws = ws; in __hvc_resize()
728 schedule_work(&hp->tty_resize); in __hvc_resize()
740 struct hvc_struct *hp; in khvcd() local
750 list_for_each_entry(hp, &hvc_structs, next) { in khvcd()
751 poll_mask |= hvc_poll(hp); in khvcd()
784 struct hvc_struct *hp = tty->driver_data; in hvc_tiocmget() local
786 if (!hp || !hp->ops->tiocmget) in hvc_tiocmget()
788 return hp->ops->tiocmget(hp); in hvc_tiocmget()
794 struct hvc_struct *hp = tty->driver_data; in hvc_tiocmset() local
796 if (!hp || !hp->ops->tiocmset) in hvc_tiocmset()
798 return hp->ops->tiocmset(hp, set, clear); in hvc_tiocmset()
810 struct hvc_struct *hp = tty->driver_data; in hvc_poll_get_char() local
814 n = hp->ops->get_chars(hp->vtermno, &ch, 1); in hvc_poll_get_char()
825 struct hvc_struct *hp = tty->driver_data; in hvc_poll_put_char() local
829 n = hp->ops->put_chars(hp->vtermno, &ch, 1); in hvc_poll_put_char()
861 struct hvc_struct *hp; in hvc_alloc() local
871 hp = kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size, in hvc_alloc()
873 if (!hp) in hvc_alloc()
876 hp->vtermno = vtermno; in hvc_alloc()
877 hp->data = data; in hvc_alloc()
878 hp->ops = ops; in hvc_alloc()
879 hp->outbuf_size = outbuf_size; in hvc_alloc()
880 hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))]; in hvc_alloc()
882 tty_port_init(&hp->port); in hvc_alloc()
883 hp->port.ops = &hvc_port_ops; in hvc_alloc()
885 INIT_WORK(&hp->tty_resize, hvc_set_winsz); in hvc_alloc()
886 spin_lock_init(&hp->lock); in hvc_alloc()
894 if (vtermnos[i] == hp->vtermno && in hvc_alloc()
895 cons_ops[i] == hp->ops) in hvc_alloc()
902 hp->index = i; in hvc_alloc()
906 list_add_tail(&(hp->next), &hvc_structs); in hvc_alloc()
912 return hp; in hvc_alloc()
916 int hvc_remove(struct hvc_struct *hp) in hvc_remove() argument
921 tty = tty_port_tty_get(&hp->port); in hvc_remove()
923 spin_lock_irqsave(&hp->lock, flags); in hvc_remove()
924 if (hp->index < MAX_NR_HVC_CONSOLES) { in hvc_remove()
926 vtermnos[hp->index] = -1; in hvc_remove()
927 cons_ops[hp->index] = NULL; in hvc_remove()
933 spin_unlock_irqrestore(&hp->lock, flags); in hvc_remove()
941 tty_port_put(&hp->port); in hvc_remove()