Lines Matching refs:hvcsd

317 static int hvcs_has_pi(struct hvcs_struct *hvcsd);
319 struct hvcs_struct *hvcsd);
320 static int hvcs_get_pi(struct hvcs_struct *hvcsd);
323 static int hvcs_partner_connect(struct hvcs_struct *hvcsd);
324 static void hvcs_partner_free(struct hvcs_struct *hvcsd);
326 static int hvcs_enable_device(struct hvcs_struct *hvcsd,
354 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_partner_vtys_show() local
358 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_partner_vtys_show()
359 retval = sprintf(buf, "%X\n", hvcsd->p_unit_address); in hvcs_partner_vtys_show()
360 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_partner_vtys_show()
368 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_partner_clcs_show() local
372 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_partner_clcs_show()
373 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]); in hvcs_partner_clcs_show()
374 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_partner_clcs_show()
393 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_current_vty_show() local
397 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_current_vty_show()
398 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]); in hvcs_current_vty_show()
399 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_current_vty_show()
410 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_vterm_state_store() local
417 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_vterm_state_store()
419 if (hvcsd->port.count > 0) { in hvcs_vterm_state_store()
420 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_store()
426 if (hvcsd->connected == 0) { in hvcs_vterm_state_store()
427 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_store()
433 hvcs_partner_free(hvcsd); in hvcs_vterm_state_store()
436 hvcsd->vdev->unit_address, in hvcs_vterm_state_store()
437 hvcsd->p_unit_address, in hvcs_vterm_state_store()
438 (uint32_t)hvcsd->p_partition_ID); in hvcs_vterm_state_store()
440 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_store()
447 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_vterm_state_show() local
451 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_vterm_state_show()
452 retval = sprintf(buf, "%d\n", hvcsd->connected); in hvcs_vterm_state_show()
453 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_show()
462 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_index_show() local
466 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_index_show()
467 retval = sprintf(buf, "%d\n", hvcsd->index); in hvcs_index_show()
468 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_index_show()
520 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_unthrottle() local
523 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_unthrottle()
524 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_unthrottle()
525 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_unthrottle()
531 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_throttle() local
534 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_throttle()
535 vio_disable_interrupts(hvcsd->vdev); in hvcs_throttle()
536 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_throttle()
546 struct hvcs_struct *hvcsd = dev_instance; in hvcs_handle_interrupt() local
548 spin_lock(&hvcsd->lock); in hvcs_handle_interrupt()
549 vio_disable_interrupts(hvcsd->vdev); in hvcs_handle_interrupt()
550 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_handle_interrupt()
551 spin_unlock(&hvcsd->lock); in hvcs_handle_interrupt()
558 static void hvcs_try_write(struct hvcs_struct *hvcsd) in hvcs_try_write() argument
560 uint32_t unit_address = hvcsd->vdev->unit_address; in hvcs_try_write()
561 struct tty_struct *tty = hvcsd->port.tty; in hvcs_try_write()
564 if (hvcsd->todo_mask & HVCS_TRY_WRITE) { in hvcs_try_write()
567 &hvcsd->buffer[0], in hvcs_try_write()
568 hvcsd->chars_in_buffer ); in hvcs_try_write()
570 hvcsd->chars_in_buffer = 0; in hvcs_try_write()
572 hvcsd->todo_mask &= ~(HVCS_TRY_WRITE); in hvcs_try_write()
588 static int hvcs_io(struct hvcs_struct *hvcsd) in hvcs_io() argument
596 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_io()
598 unit_address = hvcsd->vdev->unit_address; in hvcs_io()
599 tty = hvcsd->port.tty; in hvcs_io()
601 hvcs_try_write(hvcsd); in hvcs_io()
604 hvcsd->todo_mask &= ~(HVCS_READ_MASK); in hvcs_io()
606 } else if (!(hvcsd->todo_mask & (HVCS_READ_MASK))) in hvcs_io()
610 hvcsd->todo_mask &= ~(HVCS_READ_MASK); in hvcs_io()
612 if (tty_buffer_request_room(&hvcsd->port, HVCS_BUFF_LEN) >= HVCS_BUFF_LEN) { in hvcs_io()
616 tty_insert_flip_string(&hvcsd->port, buf, got); in hvcs_io()
621 hvcsd->todo_mask |= HVCS_QUICK_READ; in hvcs_io()
623 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_io()
626 tty_flip_buffer_push(&hvcsd->port); in hvcs_io()
630 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_io()
631 vio_enable_interrupts(hvcsd->vdev); in hvcs_io()
632 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_io()
635 return hvcsd->todo_mask; in hvcs_io()
638 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_io()
639 return hvcsd->todo_mask; in hvcs_io()
644 struct hvcs_struct *hvcsd; in khvcsd() local
655 list_for_each_entry(hvcsd, &hvcs_structs, next) { in khvcsd()
656 hvcs_todo_mask |= hvcs_io(hvcsd); in khvcsd()
700 struct hvcs_struct *hvcsd = container_of(p, struct hvcs_struct, port); in hvcs_destruct_port() local
705 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_destruct_port()
708 list_del(&(hvcsd->next)); in hvcs_destruct_port()
710 if (hvcsd->connected == 1) { in hvcs_destruct_port()
711 hvcs_partner_free(hvcsd); in hvcs_destruct_port()
714 hvcsd->vdev->unit_address, in hvcs_destruct_port()
715 hvcsd->p_unit_address, in hvcs_destruct_port()
716 (uint32_t)hvcsd->p_partition_ID); in hvcs_destruct_port()
719 hvcsd->vdev->unit_address); in hvcs_destruct_port()
721 vdev = hvcsd->vdev; in hvcs_destruct_port()
722 hvcsd->vdev = NULL; in hvcs_destruct_port()
724 hvcsd->p_unit_address = 0; in hvcs_destruct_port()
725 hvcsd->p_partition_ID = 0; in hvcs_destruct_port()
726 hvcs_return_index(hvcsd->index); in hvcs_destruct_port()
727 memset(&hvcsd->p_location_code[0], 0x00, HVCS_CLC_LENGTH + 1); in hvcs_destruct_port()
729 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_destruct_port()
734 kfree(hvcsd); in hvcs_destruct_port()
763 struct hvcs_struct *hvcsd; in hvcs_probe() local
785 hvcsd = kzalloc(sizeof(*hvcsd), GFP_KERNEL); in hvcs_probe()
786 if (!hvcsd) in hvcs_probe()
789 tty_port_init(&hvcsd->port); in hvcs_probe()
790 hvcsd->port.ops = &hvcs_port_ops; in hvcs_probe()
791 spin_lock_init(&hvcsd->lock); in hvcs_probe()
793 hvcsd->vdev = dev; in hvcs_probe()
794 dev_set_drvdata(&dev->dev, hvcsd); in hvcs_probe()
796 hvcsd->index = index; in hvcs_probe()
799 hvcsd->chars_in_buffer = 0; in hvcs_probe()
800 hvcsd->todo_mask = 0; in hvcs_probe()
801 hvcsd->connected = 0; in hvcs_probe()
807 if (hvcs_get_pi(hvcsd)) { in hvcs_probe()
810 hvcsd->vdev->unit_address); in hvcs_probe()
819 list_add_tail(&(hvcsd->next), &hvcs_structs); in hvcs_probe()
825 hvcsd->vdev->unit_address); in hvcs_probe()
840 struct hvcs_struct *hvcsd = dev_get_drvdata(&dev->dev); in hvcs_remove() local
844 if (!hvcsd) in hvcs_remove()
849 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_remove()
851 tty = hvcsd->port.tty; in hvcs_remove()
853 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_remove()
859 tty_port_put(&hvcsd->port); in hvcs_remove()
882 static void hvcs_set_pi(struct hvcs_partner_info *pi, struct hvcs_struct *hvcsd) in hvcs_set_pi() argument
884 hvcsd->p_unit_address = pi->unit_address; in hvcs_set_pi()
885 hvcsd->p_partition_ID = pi->partition_ID; in hvcs_set_pi()
888 strlcpy(&hvcsd->p_location_code[0], in hvcs_set_pi()
889 &pi->location_code[0], sizeof(hvcsd->p_location_code)); in hvcs_set_pi()
905 static int hvcs_get_pi(struct hvcs_struct *hvcsd) in hvcs_get_pi() argument
908 uint32_t unit_address = hvcsd->vdev->unit_address; in hvcs_get_pi()
926 hvcsd->p_unit_address = 0; in hvcs_get_pi()
927 hvcsd->p_partition_ID = 0; in hvcs_get_pi()
930 hvcs_set_pi(pi, hvcsd); in hvcs_get_pi()
942 struct hvcs_struct *hvcsd; in hvcs_rescan_devices_list() local
947 list_for_each_entry(hvcsd, &hvcs_structs, next) { in hvcs_rescan_devices_list()
948 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_rescan_devices_list()
949 hvcs_get_pi(hvcsd); in hvcs_rescan_devices_list()
950 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_rescan_devices_list()
963 static int hvcs_has_pi(struct hvcs_struct *hvcsd) in hvcs_has_pi() argument
965 if ((!hvcsd->p_unit_address) || (!hvcsd->p_partition_ID)) in hvcs_has_pi()
976 static int hvcs_partner_connect(struct hvcs_struct *hvcsd) in hvcs_partner_connect() argument
979 unsigned int unit_address = hvcsd->vdev->unit_address; in hvcs_partner_connect()
989 hvcsd->p_partition_ID, in hvcs_partner_connect()
990 hvcsd->p_unit_address); in hvcs_partner_connect()
992 hvcsd->connected = 1; in hvcs_partner_connect()
1001 if (hvcs_get_pi(hvcsd)) in hvcs_partner_connect()
1004 if (!hvcs_has_pi(hvcsd)) in hvcs_partner_connect()
1008 hvcsd->p_partition_ID, in hvcs_partner_connect()
1009 hvcsd->p_unit_address); in hvcs_partner_connect()
1011 hvcsd->connected = 1; in hvcs_partner_connect()
1027 static void hvcs_partner_free(struct hvcs_struct *hvcsd) in hvcs_partner_free() argument
1031 retval = hvcs_free_connection(hvcsd->vdev->unit_address); in hvcs_partner_free()
1033 hvcsd->connected = 0; in hvcs_partner_free()
1037 static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address, in hvcs_enable_device() argument
1047 rc = request_irq(irq, &hvcs_handle_interrupt, 0, "ibmhvcs", hvcsd); in hvcs_enable_device()
1058 free_irq(irq, hvcsd); in hvcs_enable_device()
1064 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_enable_device()
1065 hvcs_partner_free(hvcsd); in hvcs_enable_device()
1066 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_enable_device()
1081 struct hvcs_struct *hvcsd; in hvcs_get_by_index() local
1085 list_for_each_entry(hvcsd, &hvcs_structs, next) { in hvcs_get_by_index()
1086 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_get_by_index()
1087 if (hvcsd->index == index) { in hvcs_get_by_index()
1088 tty_port_get(&hvcsd->port); in hvcs_get_by_index()
1089 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_get_by_index()
1091 return hvcsd; in hvcs_get_by_index()
1093 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_get_by_index()
1102 struct hvcs_struct *hvcsd; in hvcs_install() local
1112 hvcsd = hvcs_get_by_index(tty->index); in hvcs_install()
1113 if (!hvcsd) { in hvcs_install()
1119 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_install()
1121 if (hvcsd->connected == 0) { in hvcs_install()
1122 retval = hvcs_partner_connect(hvcsd); in hvcs_install()
1124 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1130 hvcsd->port.count = 0; in hvcs_install()
1131 hvcsd->port.tty = tty; in hvcs_install()
1132 tty->driver_data = hvcsd; in hvcs_install()
1134 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN); in hvcs_install()
1140 irq = hvcsd->vdev->irq; in hvcs_install()
1141 vdev = hvcsd->vdev; in hvcs_install()
1142 unit_address = hvcsd->vdev->unit_address; in hvcs_install()
1144 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_install()
1145 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1151 retval = hvcs_enable_device(hvcsd, unit_address, irq, vdev); in hvcs_install()
1157 retval = tty_port_install(&hvcsd->port, driver, tty); in hvcs_install()
1163 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_install()
1164 vio_disable_interrupts(hvcsd->vdev); in hvcs_install()
1165 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1166 free_irq(irq, hvcsd); in hvcs_install()
1168 tty_port_put(&hvcsd->port); in hvcs_install()
1179 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_open() local
1182 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_open()
1183 hvcsd->port.count++; in hvcs_open()
1184 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_open()
1185 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_open()
1190 hvcsd->vdev->unit_address ); in hvcs_open()
1197 struct hvcs_struct *hvcsd; in hvcs_close() local
1216 hvcsd = tty->driver_data; in hvcs_close()
1218 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_close()
1219 if (--hvcsd->port.count == 0) { in hvcs_close()
1221 vio_disable_interrupts(hvcsd->vdev); in hvcs_close()
1228 hvcsd->port.tty = NULL; in hvcs_close()
1230 irq = hvcsd->vdev->irq; in hvcs_close()
1231 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_close()
1242 free_irq(irq, hvcsd); in hvcs_close()
1244 } else if (hvcsd->port.count < 0) { in hvcs_close()
1247 hvcsd->vdev->unit_address, hvcsd->port.count); in hvcs_close()
1250 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_close()
1255 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_cleanup() local
1257 tty_port_put(&hvcsd->port); in hvcs_cleanup()
1262 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_hangup() local
1267 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_hangup()
1269 temp_open_count = hvcsd->port.count; in hvcs_hangup()
1276 vio_disable_interrupts(hvcsd->vdev); in hvcs_hangup()
1278 hvcsd->todo_mask = 0; in hvcs_hangup()
1282 hvcsd->port.tty = NULL; in hvcs_hangup()
1284 hvcsd->port.count = 0; in hvcs_hangup()
1288 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN); in hvcs_hangup()
1289 hvcsd->chars_in_buffer = 0; in hvcs_hangup()
1291 irq = hvcsd->vdev->irq; in hvcs_hangup()
1293 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_hangup()
1295 free_irq(irq, hvcsd); in hvcs_hangup()
1309 tty_port_put(&hvcsd->port); in hvcs_hangup()
1323 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_write() local
1335 if (!hvcsd) in hvcs_write()
1347 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_write()
1355 if (hvcsd->port.count <= 0) { in hvcs_write()
1356 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_write()
1360 unit_address = hvcsd->vdev->unit_address; in hvcs_write()
1363 tosend = min(count, (HVCS_BUFF_LEN - hvcsd->chars_in_buffer)); in hvcs_write()
1371 memcpy(&hvcsd->buffer[hvcsd->chars_in_buffer], in hvcs_write()
1375 hvcsd->chars_in_buffer += tosend; in hvcs_write()
1384 if (!(hvcsd->todo_mask & HVCS_TRY_WRITE)) in hvcs_write()
1387 &hvcsd->buffer[0], in hvcs_write()
1388 hvcsd->chars_in_buffer); in hvcs_write()
1398 hvcsd->todo_mask |= HVCS_TRY_WRITE; in hvcs_write()
1403 hvcsd->chars_in_buffer = 0; in hvcs_write()
1412 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_write()
1427 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_write_room() local
1429 if (!hvcsd || hvcsd->port.count <= 0) in hvcs_write_room()
1432 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer; in hvcs_write_room()
1437 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_chars_in_buffer() local
1439 return hvcsd->chars_in_buffer; in hvcs_chars_in_buffer()