Lines Matching refs:priv
218 static int hvc_iucv_write(struct hvc_iucv_private *priv, in hvc_iucv_write() argument
226 if (priv->iucv_state == IUCV_DISCONN) in hvc_iucv_write()
231 if (priv->iucv_state == IUCV_SEVERED) in hvc_iucv_write()
235 if (list_empty(&priv->tty_inqueue)) in hvc_iucv_write()
239 rb = list_first_entry(&priv->tty_inqueue, struct iucv_tty_buffer, list); in hvc_iucv_write()
249 rc = __iucv_message_receive(priv->path, &rb->msg, 0, in hvc_iucv_write()
283 __hvc_resize(priv->hvc, *((struct winsize *) rb->mbuf->data)); in hvc_iucv_write()
295 *has_more_data = !list_empty(&priv->tty_inqueue); in hvc_iucv_write()
317 struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno); in hvc_iucv_get_chars() local
324 if (!priv) in hvc_iucv_get_chars()
327 spin_lock(&priv->lock); in hvc_iucv_get_chars()
329 written = hvc_iucv_write(priv, buf, count, &has_more_data); in hvc_iucv_get_chars()
330 spin_unlock(&priv->lock); in hvc_iucv_get_chars()
355 static int hvc_iucv_queue(struct hvc_iucv_private *priv, const char *buf, in hvc_iucv_queue() argument
360 if (priv->iucv_state == IUCV_DISCONN) in hvc_iucv_queue()
363 if (priv->iucv_state == IUCV_SEVERED) in hvc_iucv_queue()
366 len = min_t(size_t, count, SNDBUF_SIZE - priv->sndbuf_len); in hvc_iucv_queue()
370 memcpy(priv->sndbuf + priv->sndbuf_len, buf, len); in hvc_iucv_queue()
371 priv->sndbuf_len += len; in hvc_iucv_queue()
373 if (priv->iucv_state == IUCV_CONNECTED) in hvc_iucv_queue()
374 schedule_delayed_work(&priv->sndbuf_work, QUEUE_SNDBUF_DELAY); in hvc_iucv_queue()
388 static int hvc_iucv_send(struct hvc_iucv_private *priv) in hvc_iucv_send() argument
393 if (priv->iucv_state == IUCV_SEVERED) in hvc_iucv_send()
396 if (priv->iucv_state == IUCV_DISCONN) in hvc_iucv_send()
399 if (!priv->sndbuf_len) in hvc_iucv_send()
404 sb = alloc_tty_buffer(priv->sndbuf_len, GFP_ATOMIC); in hvc_iucv_send()
408 memcpy(sb->mbuf->data, priv->sndbuf, priv->sndbuf_len); in hvc_iucv_send()
409 sb->mbuf->datalen = (u16) priv->sndbuf_len; in hvc_iucv_send()
412 list_add_tail(&sb->list, &priv->tty_outqueue); in hvc_iucv_send()
414 rc = __iucv_message_send(priv->path, &sb->msg, 0, 0, in hvc_iucv_send()
422 len = priv->sndbuf_len; in hvc_iucv_send()
423 priv->sndbuf_len = 0; in hvc_iucv_send()
437 struct hvc_iucv_private *priv; in hvc_iucv_sndbuf_work() local
439 priv = container_of(work, struct hvc_iucv_private, sndbuf_work.work); in hvc_iucv_sndbuf_work()
440 if (!priv) in hvc_iucv_sndbuf_work()
443 spin_lock_bh(&priv->lock); in hvc_iucv_sndbuf_work()
444 hvc_iucv_send(priv); in hvc_iucv_sndbuf_work()
445 spin_unlock_bh(&priv->lock); in hvc_iucv_sndbuf_work()
462 struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno); in hvc_iucv_put_chars() local
468 if (!priv) in hvc_iucv_put_chars()
471 spin_lock(&priv->lock); in hvc_iucv_put_chars()
472 queued = hvc_iucv_queue(priv, buf, count); in hvc_iucv_put_chars()
473 spin_unlock(&priv->lock); in hvc_iucv_put_chars()
491 struct hvc_iucv_private *priv; in hvc_iucv_notifier_add() local
493 priv = hvc_iucv_get_private(id); in hvc_iucv_notifier_add()
494 if (!priv) in hvc_iucv_notifier_add()
497 spin_lock_bh(&priv->lock); in hvc_iucv_notifier_add()
498 priv->tty_state = TTY_OPENED; in hvc_iucv_notifier_add()
499 spin_unlock_bh(&priv->lock); in hvc_iucv_notifier_add()
508 static void hvc_iucv_cleanup(struct hvc_iucv_private *priv) in hvc_iucv_cleanup() argument
510 destroy_tty_buffer_list(&priv->tty_outqueue); in hvc_iucv_cleanup()
511 destroy_tty_buffer_list(&priv->tty_inqueue); in hvc_iucv_cleanup()
513 priv->tty_state = TTY_CLOSED; in hvc_iucv_cleanup()
514 priv->iucv_state = IUCV_DISCONN; in hvc_iucv_cleanup()
516 priv->sndbuf_len = 0; in hvc_iucv_cleanup()
523 static inline int tty_outqueue_empty(struct hvc_iucv_private *priv) in tty_outqueue_empty() argument
527 spin_lock_bh(&priv->lock); in tty_outqueue_empty()
528 rc = list_empty(&priv->tty_outqueue); in tty_outqueue_empty()
529 spin_unlock_bh(&priv->lock); in tty_outqueue_empty()
541 static void flush_sndbuf_sync(struct hvc_iucv_private *priv) in flush_sndbuf_sync() argument
545 cancel_delayed_work_sync(&priv->sndbuf_work); in flush_sndbuf_sync()
547 spin_lock_bh(&priv->lock); in flush_sndbuf_sync()
548 hvc_iucv_send(priv); /* force sending buffered data */ in flush_sndbuf_sync()
549 sync_wait = !list_empty(&priv->tty_outqueue); /* anything queued ? */ in flush_sndbuf_sync()
550 spin_unlock_bh(&priv->lock); in flush_sndbuf_sync()
553 wait_event_timeout(priv->sndbuf_waitq, in flush_sndbuf_sync()
554 tty_outqueue_empty(priv), HZ/10); in flush_sndbuf_sync()
589 static void hvc_iucv_hangup(struct hvc_iucv_private *priv) in hvc_iucv_hangup() argument
594 spin_lock(&priv->lock); in hvc_iucv_hangup()
595 if (priv->iucv_state == IUCV_CONNECTED) { in hvc_iucv_hangup()
596 path = priv->path; in hvc_iucv_hangup()
597 priv->path = NULL; in hvc_iucv_hangup()
598 priv->iucv_state = IUCV_SEVERED; in hvc_iucv_hangup()
599 if (priv->tty_state == TTY_CLOSED) in hvc_iucv_hangup()
600 hvc_iucv_cleanup(priv); in hvc_iucv_hangup()
603 if (priv->is_console) { in hvc_iucv_hangup()
604 hvc_iucv_cleanup(priv); in hvc_iucv_hangup()
605 priv->tty_state = TTY_OPENED; in hvc_iucv_hangup()
609 spin_unlock(&priv->lock); in hvc_iucv_hangup()
637 struct hvc_iucv_private *priv; in hvc_iucv_notifier_hangup() local
639 priv = hvc_iucv_get_private(id); in hvc_iucv_notifier_hangup()
640 if (!priv) in hvc_iucv_notifier_hangup()
643 flush_sndbuf_sync(priv); in hvc_iucv_notifier_hangup()
645 spin_lock_bh(&priv->lock); in hvc_iucv_notifier_hangup()
653 priv->tty_state = TTY_CLOSED; in hvc_iucv_notifier_hangup()
655 if (priv->iucv_state == IUCV_SEVERED) in hvc_iucv_notifier_hangup()
656 hvc_iucv_cleanup(priv); in hvc_iucv_notifier_hangup()
657 spin_unlock_bh(&priv->lock); in hvc_iucv_notifier_hangup()
671 struct hvc_iucv_private *priv; in hvc_iucv_dtr_rts() local
680 priv = hvc_iucv_get_private(hp->vtermno); in hvc_iucv_dtr_rts()
681 if (!priv) in hvc_iucv_dtr_rts()
687 flush_sndbuf_sync(priv); in hvc_iucv_dtr_rts()
689 spin_lock_bh(&priv->lock); in hvc_iucv_dtr_rts()
690 path = priv->path; /* save reference to IUCV path */ in hvc_iucv_dtr_rts()
691 priv->path = NULL; in hvc_iucv_dtr_rts()
692 priv->iucv_state = IUCV_DISCONN; in hvc_iucv_dtr_rts()
693 spin_unlock_bh(&priv->lock); in hvc_iucv_dtr_rts()
718 struct hvc_iucv_private *priv; in hvc_iucv_notifier_del() local
720 priv = hvc_iucv_get_private(id); in hvc_iucv_notifier_del()
721 if (!priv) in hvc_iucv_notifier_del()
724 flush_sndbuf_sync(priv); in hvc_iucv_notifier_del()
726 spin_lock_bh(&priv->lock); in hvc_iucv_notifier_del()
727 destroy_tty_buffer_list(&priv->tty_outqueue); in hvc_iucv_notifier_del()
728 destroy_tty_buffer_list(&priv->tty_inqueue); in hvc_iucv_notifier_del()
729 priv->tty_state = TTY_CLOSED; in hvc_iucv_notifier_del()
730 priv->sndbuf_len = 0; in hvc_iucv_notifier_del()
731 spin_unlock_bh(&priv->lock); in hvc_iucv_notifier_del()
788 struct hvc_iucv_private *priv, *tmp; in hvc_iucv_path_pending() local
802 priv = NULL; in hvc_iucv_path_pending()
811 priv = tmp; in hvc_iucv_path_pending()
815 priv = tmp; in hvc_iucv_path_pending()
816 if (priv) in hvc_iucv_path_pending()
819 if (!priv) in hvc_iucv_path_pending()
836 spin_lock(&priv->lock); in hvc_iucv_path_pending()
841 if (priv->iucv_state != IUCV_DISCONN) { in hvc_iucv_path_pending()
852 rc = iucv_path_accept(path, &hvc_iucv_handler, nuser_data, priv); in hvc_iucv_path_pending()
858 priv->path = path; in hvc_iucv_path_pending()
859 priv->iucv_state = IUCV_CONNECTED; in hvc_iucv_path_pending()
862 memcpy(priv->info_path, ipvmid, 8); in hvc_iucv_path_pending()
863 memcpy(priv->info_path + 8, ipuser + 8, 8); in hvc_iucv_path_pending()
866 schedule_delayed_work(&priv->sndbuf_work, 5); in hvc_iucv_path_pending()
869 spin_unlock(&priv->lock); in hvc_iucv_path_pending()
886 struct hvc_iucv_private *priv = path->private; in hvc_iucv_path_severed() local
888 hvc_iucv_hangup(priv); in hvc_iucv_path_severed()
905 struct hvc_iucv_private *priv = path->private; in hvc_iucv_msg_pending() local
914 spin_lock(&priv->lock); in hvc_iucv_msg_pending()
917 if (priv->tty_state == TTY_CLOSED) { in hvc_iucv_msg_pending()
930 list_add_tail(&rb->list, &priv->tty_inqueue); in hvc_iucv_msg_pending()
935 spin_unlock(&priv->lock); in hvc_iucv_msg_pending()
953 struct hvc_iucv_private *priv = path->private; in hvc_iucv_msg_complete() local
957 spin_lock(&priv->lock); in hvc_iucv_msg_complete()
958 list_for_each_entry_safe(ent, next, &priv->tty_outqueue, list) in hvc_iucv_msg_complete()
963 wake_up(&priv->sndbuf_waitq); in hvc_iucv_msg_complete()
964 spin_unlock(&priv->lock); in hvc_iucv_msg_complete()
977 struct hvc_iucv_private *priv = dev_get_drvdata(dev); in hvc_iucv_pm_freeze() local
980 hvc_iucv_hangup(priv); in hvc_iucv_pm_freeze()
1003 struct hvc_iucv_private *priv = dev_get_drvdata(dev); in hvc_iucv_dev_termid_show() local
1006 len = sizeof(priv->srv_name); in hvc_iucv_dev_termid_show()
1007 memcpy(buf, priv->srv_name, len); in hvc_iucv_dev_termid_show()
1017 struct hvc_iucv_private *priv = dev_get_drvdata(dev); in hvc_iucv_dev_state_show() local
1018 return sprintf(buf, "%u:%u\n", priv->iucv_state, priv->tty_state); in hvc_iucv_dev_state_show()
1025 struct hvc_iucv_private *priv = dev_get_drvdata(dev); in hvc_iucv_dev_peer_show() local
1031 spin_lock_bh(&priv->lock); in hvc_iucv_dev_peer_show()
1032 if (priv->iucv_state == IUCV_CONNECTED) { in hvc_iucv_dev_peer_show()
1033 memcpy(vmid, priv->info_path, 8); in hvc_iucv_dev_peer_show()
1034 memcpy(ipuser, priv->info_path + 8, 8); in hvc_iucv_dev_peer_show()
1036 spin_unlock_bh(&priv->lock); in hvc_iucv_dev_peer_show()
1097 struct hvc_iucv_private *priv; in hvc_iucv_alloc() local
1101 priv = kzalloc(sizeof(struct hvc_iucv_private), GFP_KERNEL); in hvc_iucv_alloc()
1102 if (!priv) in hvc_iucv_alloc()
1105 spin_lock_init(&priv->lock); in hvc_iucv_alloc()
1106 INIT_LIST_HEAD(&priv->tty_outqueue); in hvc_iucv_alloc()
1107 INIT_LIST_HEAD(&priv->tty_inqueue); in hvc_iucv_alloc()
1108 INIT_DELAYED_WORK(&priv->sndbuf_work, hvc_iucv_sndbuf_work); in hvc_iucv_alloc()
1109 init_waitqueue_head(&priv->sndbuf_waitq); in hvc_iucv_alloc()
1111 priv->sndbuf = (void *) get_zeroed_page(GFP_KERNEL); in hvc_iucv_alloc()
1112 if (!priv->sndbuf) { in hvc_iucv_alloc()
1113 kfree(priv); in hvc_iucv_alloc()
1118 priv->is_console = is_console; in hvc_iucv_alloc()
1121 priv->hvc = hvc_alloc(HVC_IUCV_MAGIC + id, /* PAGE_SIZE */ in hvc_iucv_alloc()
1123 if (IS_ERR(priv->hvc)) { in hvc_iucv_alloc()
1124 rc = PTR_ERR(priv->hvc); in hvc_iucv_alloc()
1129 priv->hvc->irq_requested = 1; in hvc_iucv_alloc()
1133 memcpy(priv->srv_name, name, 8); in hvc_iucv_alloc()
1134 ASCEBC(priv->srv_name, 8); in hvc_iucv_alloc()
1137 priv->dev = kzalloc(sizeof(*priv->dev), GFP_KERNEL); in hvc_iucv_alloc()
1138 if (!priv->dev) { in hvc_iucv_alloc()
1142 dev_set_name(priv->dev, "hvc_iucv%d", id); in hvc_iucv_alloc()
1143 dev_set_drvdata(priv->dev, priv); in hvc_iucv_alloc()
1144 priv->dev->bus = &iucv_bus; in hvc_iucv_alloc()
1145 priv->dev->parent = iucv_root; in hvc_iucv_alloc()
1146 priv->dev->driver = &hvc_iucv_driver; in hvc_iucv_alloc()
1147 priv->dev->groups = hvc_iucv_dev_attr_groups; in hvc_iucv_alloc()
1148 priv->dev->release = (void (*)(struct device *)) kfree; in hvc_iucv_alloc()
1149 rc = device_register(priv->dev); in hvc_iucv_alloc()
1151 put_device(priv->dev); in hvc_iucv_alloc()
1155 hvc_iucv_table[id] = priv; in hvc_iucv_alloc()
1159 hvc_remove(priv->hvc); in hvc_iucv_alloc()
1161 free_page((unsigned long) priv->sndbuf); in hvc_iucv_alloc()
1162 kfree(priv); in hvc_iucv_alloc()
1170 static void __init hvc_iucv_destroy(struct hvc_iucv_private *priv) in hvc_iucv_destroy() argument
1172 hvc_remove(priv->hvc); in hvc_iucv_destroy()
1173 device_unregister(priv->dev); in hvc_iucv_destroy()
1174 free_page((unsigned long) priv->sndbuf); in hvc_iucv_destroy()
1175 kfree(priv); in hvc_iucv_destroy()