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 hp = hvc_get_by_index(tty->index); in hvc_install()
323 if (!hp) in hvc_install()
326 tty->driver_data = hp; in hvc_install()
328 rc = tty_port_install(&hp->port, driver, tty); in hvc_install()
330 tty_port_put(&hp->port); in hvc_install()
340 struct hvc_struct *hp = tty->driver_data; in hvc_open() local
344 spin_lock_irqsave(&hp->port.lock, flags); in hvc_open()
346 if (hp->port.count++ > 0) { in hvc_open()
347 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_open()
351 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_open()
353 tty_port_tty_set(&hp->port, tty); in hvc_open()
355 if (hp->ops->notifier_add) in hvc_open()
356 rc = hp->ops->notifier_add(hp, hp->data); in hvc_open()
365 tty_port_tty_set(&hp->port, NULL); in hvc_open()
367 tty_port_put(&hp->port); in hvc_open()
372 if (hp->ops->dtr_rts) in hvc_open()
373 hp->ops->dtr_rts(hp, 1); in hvc_open()
383 struct hvc_struct *hp; in hvc_close() local
397 hp = tty->driver_data; in hvc_close()
399 spin_lock_irqsave(&hp->port.lock, flags); in hvc_close()
401 if (--hp->port.count == 0) { in hvc_close()
402 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_close()
404 tty_port_tty_set(&hp->port, NULL); in hvc_close()
407 if (hp->ops->dtr_rts) in hvc_close()
408 hp->ops->dtr_rts(hp, 0); in hvc_close()
410 if (hp->ops->notifier_del) in hvc_close()
411 hp->ops->notifier_del(hp, hp->data); in hvc_close()
414 cancel_work_sync(&hp->tty_resize); in hvc_close()
423 if (hp->port.count < 0) in hvc_close()
425 hp->vtermno, hp->port.count); in hvc_close()
426 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_close()
432 struct hvc_struct *hp = tty->driver_data; in hvc_cleanup() local
434 tty_port_put(&hp->port); in hvc_cleanup()
439 struct hvc_struct *hp = tty->driver_data; in hvc_hangup() local
442 if (!hp) in hvc_hangup()
446 cancel_work_sync(&hp->tty_resize); in hvc_hangup()
448 spin_lock_irqsave(&hp->port.lock, flags); in hvc_hangup()
455 if (hp->port.count <= 0) { in hvc_hangup()
456 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_hangup()
460 hp->port.count = 0; in hvc_hangup()
461 spin_unlock_irqrestore(&hp->port.lock, flags); in hvc_hangup()
462 tty_port_tty_set(&hp->port, NULL); in hvc_hangup()
464 hp->n_outbuf = 0; in hvc_hangup()
466 if (hp->ops->notifier_hangup) in hvc_hangup()
467 hp->ops->notifier_hangup(hp, hp->data); in hvc_hangup()
474 static int hvc_push(struct hvc_struct *hp) in hvc_push() argument
478 n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf); in hvc_push()
481 hp->do_wakeup = 1; in hvc_push()
486 hp->n_outbuf = 0; in hvc_push()
488 hp->n_outbuf -= n; in hvc_push()
489 if (hp->n_outbuf > 0) in hvc_push()
490 memmove(hp->outbuf, hp->outbuf + n, hp->n_outbuf); in hvc_push()
492 hp->do_wakeup = 1; in hvc_push()
499 struct hvc_struct *hp = tty->driver_data; in hvc_write() local
504 if (!hp) in hvc_write()
508 if (hp->port.count <= 0) in hvc_write()
511 spin_lock_irqsave(&hp->lock, flags); in hvc_write()
514 if (hp->n_outbuf > 0) in hvc_write()
515 hvc_push(hp); in hvc_write()
517 while (count > 0 && (rsize = hp->outbuf_size - hp->n_outbuf) > 0) { in hvc_write()
520 memcpy(hp->outbuf + hp->n_outbuf, buf, rsize); in hvc_write()
523 hp->n_outbuf += rsize; in hvc_write()
525 hvc_push(hp); in hvc_write()
527 spin_unlock_irqrestore(&hp->lock, flags); in hvc_write()
532 if (hp->n_outbuf) in hvc_write()
549 struct hvc_struct *hp; in hvc_set_winsz() local
554 hp = container_of(work, struct hvc_struct, tty_resize); in hvc_set_winsz()
556 tty = tty_port_tty_get(&hp->port); in hvc_set_winsz()
560 spin_lock_irqsave(&hp->lock, hvc_flags); in hvc_set_winsz()
561 ws = hp->ws; in hvc_set_winsz()
562 spin_unlock_irqrestore(&hp->lock, hvc_flags); in hvc_set_winsz()
575 struct hvc_struct *hp = tty->driver_data; in hvc_write_room() local
577 if (!hp) in hvc_write_room()
580 return hp->outbuf_size - hp->n_outbuf; in hvc_write_room()
585 struct hvc_struct *hp = tty->driver_data; in hvc_chars_in_buffer() local
587 if (!hp) in hvc_chars_in_buffer()
589 return hp->n_outbuf; in hvc_chars_in_buffer()
607 int hvc_poll(struct hvc_struct *hp) in hvc_poll() argument
616 spin_lock_irqsave(&hp->lock, flags); in hvc_poll()
619 if (hp->n_outbuf > 0) in hvc_poll()
620 written_total = hvc_push(hp); in hvc_poll()
623 if (hp->n_outbuf > 0) { in hvc_poll()
630 tty = tty_port_tty_get(&hp->port); in hvc_poll()
641 if (!hp->irq_requested) in hvc_poll()
646 int count = tty_buffer_request_room(&hp->port, N_INBUF); in hvc_poll()
654 n = hp->ops->get_chars(hp->vtermno, buf, count); in hvc_poll()
658 spin_unlock_irqrestore(&hp->lock, flags); in hvc_poll()
660 spin_lock_irqsave(&hp->lock, flags); in hvc_poll()
673 if (hp->index == hvc_console.index) { in hvc_poll()
689 tty_insert_flip_char(&hp->port, buf[i], 0); in hvc_poll()
696 if (hp->do_wakeup) { in hvc_poll()
697 hp->do_wakeup = 0; in hvc_poll()
701 spin_unlock_irqrestore(&hp->lock, flags); in hvc_poll()
708 tty_flip_buffer_push(&hp->port); in hvc_poll()
726 void __hvc_resize(struct hvc_struct *hp, struct winsize ws) in __hvc_resize() argument
728 hp->ws = ws; in __hvc_resize()
729 schedule_work(&hp->tty_resize); in __hvc_resize()
741 struct hvc_struct *hp; in khvcd() local
751 list_for_each_entry(hp, &hvc_structs, next) { in khvcd()
752 poll_mask |= hvc_poll(hp); in khvcd()
785 struct hvc_struct *hp = tty->driver_data; in hvc_tiocmget() local
787 if (!hp || !hp->ops->tiocmget) in hvc_tiocmget()
789 return hp->ops->tiocmget(hp); in hvc_tiocmget()
795 struct hvc_struct *hp = tty->driver_data; in hvc_tiocmset() local
797 if (!hp || !hp->ops->tiocmset) in hvc_tiocmset()
799 return hp->ops->tiocmset(hp, set, clear); in hvc_tiocmset()
811 struct hvc_struct *hp = tty->driver_data; in hvc_poll_get_char() local
815 n = hp->ops->get_chars(hp->vtermno, &ch, 1); in hvc_poll_get_char()
826 struct hvc_struct *hp = tty->driver_data; in hvc_poll_put_char() local
830 n = hp->ops->put_chars(hp->vtermno, &ch, 1); in hvc_poll_put_char()
862 struct hvc_struct *hp; in hvc_alloc() local
872 hp = kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size, in hvc_alloc()
874 if (!hp) in hvc_alloc()
877 hp->vtermno = vtermno; in hvc_alloc()
878 hp->data = data; in hvc_alloc()
879 hp->ops = ops; in hvc_alloc()
880 hp->outbuf_size = outbuf_size; in hvc_alloc()
881 hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))]; in hvc_alloc()
883 tty_port_init(&hp->port); in hvc_alloc()
884 hp->port.ops = &hvc_port_ops; in hvc_alloc()
886 INIT_WORK(&hp->tty_resize, hvc_set_winsz); in hvc_alloc()
887 spin_lock_init(&hp->lock); in hvc_alloc()
895 if (vtermnos[i] == hp->vtermno && in hvc_alloc()
896 cons_ops[i] == hp->ops) in hvc_alloc()
903 hp->index = i; in hvc_alloc()
907 list_add_tail(&(hp->next), &hvc_structs); in hvc_alloc()
913 return hp; in hvc_alloc()
917 int hvc_remove(struct hvc_struct *hp) in hvc_remove() argument
922 tty = tty_port_tty_get(&hp->port); in hvc_remove()
924 spin_lock_irqsave(&hp->lock, flags); in hvc_remove()
925 if (hp->index < MAX_NR_HVC_CONSOLES) { in hvc_remove()
927 vtermnos[hp->index] = -1; in hvc_remove()
928 cons_ops[hp->index] = NULL; in hvc_remove()
934 spin_unlock_irqrestore(&hp->lock, flags); in hvc_remove()
942 tty_port_put(&hp->port); in hvc_remove()