Lines Matching defs:hp

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