Lines Matching refs:hvcsd
296 static int hvcs_get_pi(struct hvcs_struct *hvcsd);
299 static void hvcs_partner_free(struct hvcs_struct *hvcsd);
317 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_partner_vtys_show() local
321 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_partner_vtys_show()
322 retval = sprintf(buf, "%X\n", hvcsd->p_unit_address); in hvcs_partner_vtys_show()
323 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_partner_vtys_show()
331 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_partner_clcs_show() local
335 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_partner_clcs_show()
336 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]); in hvcs_partner_clcs_show()
337 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_partner_clcs_show()
356 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_current_vty_show() local
360 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_current_vty_show()
361 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]); in hvcs_current_vty_show()
362 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_current_vty_show()
373 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_vterm_state_store() local
380 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_vterm_state_store()
382 if (hvcsd->port.count > 0) { in hvcs_vterm_state_store()
383 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_store()
389 if (hvcsd->connected == 0) { in hvcs_vterm_state_store()
390 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_store()
396 hvcs_partner_free(hvcsd); in hvcs_vterm_state_store()
399 hvcsd->vdev->unit_address, in hvcs_vterm_state_store()
400 hvcsd->p_unit_address, in hvcs_vterm_state_store()
401 (uint32_t)hvcsd->p_partition_ID); in hvcs_vterm_state_store()
403 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_store()
410 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_vterm_state_show() local
414 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_vterm_state_show()
415 retval = sprintf(buf, "%d\n", hvcsd->connected); in hvcs_vterm_state_show()
416 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_show()
425 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_index_show() local
429 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_index_show()
430 retval = sprintf(buf, "%d\n", hvcsd->index); in hvcs_index_show()
431 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_index_show()
487 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_unthrottle() local
490 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_unthrottle()
491 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_unthrottle()
492 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_unthrottle()
498 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_throttle() local
501 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_throttle()
502 vio_disable_interrupts(hvcsd->vdev); in hvcs_throttle()
503 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_throttle()
513 struct hvcs_struct *hvcsd = dev_instance; in hvcs_handle_interrupt() local
515 spin_lock(&hvcsd->lock); in hvcs_handle_interrupt()
516 vio_disable_interrupts(hvcsd->vdev); in hvcs_handle_interrupt()
517 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_handle_interrupt()
518 spin_unlock(&hvcsd->lock); in hvcs_handle_interrupt()
525 static void hvcs_try_write(struct hvcs_struct *hvcsd) in hvcs_try_write() argument
527 uint32_t unit_address = hvcsd->vdev->unit_address; in hvcs_try_write()
528 struct tty_struct *tty = hvcsd->port.tty; in hvcs_try_write()
531 if (hvcsd->todo_mask & HVCS_TRY_WRITE) { in hvcs_try_write()
534 &hvcsd->buffer[0], in hvcs_try_write()
535 hvcsd->chars_in_buffer ); in hvcs_try_write()
537 hvcsd->chars_in_buffer = 0; in hvcs_try_write()
539 hvcsd->todo_mask &= ~(HVCS_TRY_WRITE); in hvcs_try_write()
555 static int hvcs_io(struct hvcs_struct *hvcsd) in hvcs_io() argument
563 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_io()
565 unit_address = hvcsd->vdev->unit_address; in hvcs_io()
566 tty = hvcsd->port.tty; in hvcs_io()
568 hvcs_try_write(hvcsd); in hvcs_io()
571 hvcsd->todo_mask &= ~(HVCS_READ_MASK); in hvcs_io()
573 } else if (!(hvcsd->todo_mask & (HVCS_READ_MASK))) in hvcs_io()
577 hvcsd->todo_mask &= ~(HVCS_READ_MASK); in hvcs_io()
579 if (tty_buffer_request_room(&hvcsd->port, HVCS_BUFF_LEN) >= HVCS_BUFF_LEN) { in hvcs_io()
583 tty_insert_flip_string(&hvcsd->port, buf, got); in hvcs_io()
588 hvcsd->todo_mask |= HVCS_QUICK_READ; in hvcs_io()
590 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_io()
593 tty_flip_buffer_push(&hvcsd->port); in hvcs_io()
596 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_io()
597 vio_enable_interrupts(hvcsd->vdev); in hvcs_io()
598 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_io()
601 return hvcsd->todo_mask; in hvcs_io()
604 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_io()
605 return hvcsd->todo_mask; in hvcs_io()
610 struct hvcs_struct *hvcsd; in khvcsd() local
621 list_for_each_entry(hvcsd, &hvcs_structs, next) { in khvcsd()
622 hvcs_todo_mask |= hvcs_io(hvcsd); in khvcsd()
666 struct hvcs_struct *hvcsd = container_of(p, struct hvcs_struct, port); in hvcs_destruct_port() local
671 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_destruct_port()
673 comp = hvcsd->destroyed; in hvcs_destruct_port()
675 list_del(&(hvcsd->next)); in hvcs_destruct_port()
677 if (hvcsd->connected == 1) { in hvcs_destruct_port()
678 hvcs_partner_free(hvcsd); in hvcs_destruct_port()
681 hvcsd->vdev->unit_address, in hvcs_destruct_port()
682 hvcsd->p_unit_address, in hvcs_destruct_port()
683 (uint32_t)hvcsd->p_partition_ID); in hvcs_destruct_port()
686 hvcsd->vdev->unit_address); in hvcs_destruct_port()
688 hvcsd->vdev = NULL; in hvcs_destruct_port()
690 hvcsd->p_unit_address = 0; in hvcs_destruct_port()
691 hvcsd->p_partition_ID = 0; in hvcs_destruct_port()
692 hvcsd->destroyed = NULL; in hvcs_destruct_port()
693 hvcs_return_index(hvcsd->index); in hvcs_destruct_port()
694 memset(&hvcsd->p_location_code[0], 0x00, HVCS_CLC_LENGTH + 1); in hvcs_destruct_port()
696 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_destruct_port()
699 kfree(hvcsd); in hvcs_destruct_port()
730 struct hvcs_struct *hvcsd; in hvcs_probe() local
751 hvcsd = kzalloc(sizeof(*hvcsd), GFP_KERNEL); in hvcs_probe()
752 if (!hvcsd) in hvcs_probe()
755 tty_port_init(&hvcsd->port); in hvcs_probe()
756 hvcsd->port.ops = &hvcs_port_ops; in hvcs_probe()
757 spin_lock_init(&hvcsd->lock); in hvcs_probe()
759 hvcsd->vdev = dev; in hvcs_probe()
760 dev_set_drvdata(&dev->dev, hvcsd); in hvcs_probe()
762 hvcsd->index = index; in hvcs_probe()
765 hvcsd->chars_in_buffer = 0; in hvcs_probe()
766 hvcsd->todo_mask = 0; in hvcs_probe()
767 hvcsd->connected = 0; in hvcs_probe()
773 if (hvcs_get_pi(hvcsd)) { in hvcs_probe()
776 hvcsd->vdev->unit_address); in hvcs_probe()
785 list_add_tail(&(hvcsd->next), &hvcs_structs); in hvcs_probe()
799 struct hvcs_struct *hvcsd = dev_get_drvdata(&dev->dev); in hvcs_remove() local
806 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_remove()
808 hvcsd->destroyed = ∁ in hvcs_remove()
809 tty = tty_port_tty_get(&hvcsd->port); in hvcs_remove()
811 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_remove()
822 tty_port_put(&hvcsd->port); in hvcs_remove()
840 static void hvcs_set_pi(struct hvcs_partner_info *pi, struct hvcs_struct *hvcsd) in hvcs_set_pi() argument
842 hvcsd->p_unit_address = pi->unit_address; in hvcs_set_pi()
843 hvcsd->p_partition_ID = pi->partition_ID; in hvcs_set_pi()
846 strscpy(hvcsd->p_location_code, pi->location_code, in hvcs_set_pi()
847 sizeof(hvcsd->p_location_code)); in hvcs_set_pi()
863 static int hvcs_get_pi(struct hvcs_struct *hvcsd) in hvcs_get_pi() argument
866 uint32_t unit_address = hvcsd->vdev->unit_address; in hvcs_get_pi()
884 hvcsd->p_unit_address = 0; in hvcs_get_pi()
885 hvcsd->p_partition_ID = 0; in hvcs_get_pi()
888 hvcs_set_pi(pi, hvcsd); in hvcs_get_pi()
900 struct hvcs_struct *hvcsd; in hvcs_rescan_devices_list() local
905 list_for_each_entry(hvcsd, &hvcs_structs, next) { in hvcs_rescan_devices_list()
906 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_rescan_devices_list()
907 hvcs_get_pi(hvcsd); in hvcs_rescan_devices_list()
908 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_rescan_devices_list()
921 static int hvcs_has_pi(struct hvcs_struct *hvcsd) in hvcs_has_pi() argument
923 if ((!hvcsd->p_unit_address) || (!hvcsd->p_partition_ID)) in hvcs_has_pi()
934 static int hvcs_partner_connect(struct hvcs_struct *hvcsd) in hvcs_partner_connect() argument
937 unsigned int unit_address = hvcsd->vdev->unit_address; in hvcs_partner_connect()
947 hvcsd->p_partition_ID, in hvcs_partner_connect()
948 hvcsd->p_unit_address); in hvcs_partner_connect()
950 hvcsd->connected = 1; in hvcs_partner_connect()
959 if (hvcs_get_pi(hvcsd)) in hvcs_partner_connect()
962 if (!hvcs_has_pi(hvcsd)) in hvcs_partner_connect()
966 hvcsd->p_partition_ID, in hvcs_partner_connect()
967 hvcsd->p_unit_address); in hvcs_partner_connect()
969 hvcsd->connected = 1; in hvcs_partner_connect()
985 static void hvcs_partner_free(struct hvcs_struct *hvcsd) in hvcs_partner_free() argument
989 retval = hvcs_free_connection(hvcsd->vdev->unit_address); in hvcs_partner_free()
991 hvcsd->connected = 0; in hvcs_partner_free()
995 static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address, in hvcs_enable_device() argument
1005 rc = request_irq(irq, &hvcs_handle_interrupt, 0, "ibmhvcs", hvcsd); in hvcs_enable_device()
1016 free_irq(irq, hvcsd); in hvcs_enable_device()
1022 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_enable_device()
1023 hvcs_partner_free(hvcsd); in hvcs_enable_device()
1024 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_enable_device()
1039 struct hvcs_struct *hvcsd; in hvcs_get_by_index() local
1043 list_for_each_entry(hvcsd, &hvcs_structs, next) { in hvcs_get_by_index()
1044 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_get_by_index()
1045 if (hvcsd->index == index) { in hvcs_get_by_index()
1046 tty_port_get(&hvcsd->port); in hvcs_get_by_index()
1047 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_get_by_index()
1049 return hvcsd; in hvcs_get_by_index()
1051 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_get_by_index()
1060 struct hvcs_struct *hvcsd; in hvcs_install() local
1070 hvcsd = hvcs_get_by_index(tty->index); in hvcs_install()
1071 if (!hvcsd) { in hvcs_install()
1077 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_install()
1079 if (hvcsd->connected == 0) { in hvcs_install()
1080 retval = hvcs_partner_connect(hvcsd); in hvcs_install()
1082 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1088 hvcsd->port.count = 0; in hvcs_install()
1089 hvcsd->port.tty = tty; in hvcs_install()
1090 tty->driver_data = hvcsd; in hvcs_install()
1092 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN); in hvcs_install()
1098 irq = hvcsd->vdev->irq; in hvcs_install()
1099 vdev = hvcsd->vdev; in hvcs_install()
1100 unit_address = hvcsd->vdev->unit_address; in hvcs_install()
1102 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_install()
1103 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1109 retval = hvcs_enable_device(hvcsd, unit_address, irq, vdev); in hvcs_install()
1115 retval = tty_port_install(&hvcsd->port, driver, tty); in hvcs_install()
1121 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_install()
1122 vio_disable_interrupts(hvcsd->vdev); in hvcs_install()
1123 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1124 free_irq(irq, hvcsd); in hvcs_install()
1126 tty_port_put(&hvcsd->port); in hvcs_install()
1137 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_open() local
1140 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_open()
1141 hvcsd->port.count++; in hvcs_open()
1142 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_open()
1143 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_open()
1148 hvcsd->vdev->unit_address ); in hvcs_open()
1155 struct hvcs_struct *hvcsd; in hvcs_close() local
1174 hvcsd = tty->driver_data; in hvcs_close()
1176 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_close()
1177 if (hvcsd->port.count == 0) { in hvcs_close()
1178 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_close()
1180 } else if (--hvcsd->port.count == 0) { in hvcs_close()
1182 vio_disable_interrupts(hvcsd->vdev); in hvcs_close()
1189 hvcsd->port.tty = NULL; in hvcs_close()
1191 irq = hvcsd->vdev->irq; in hvcs_close()
1192 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_close()
1196 free_irq(irq, hvcsd); in hvcs_close()
1198 } else if (hvcsd->port.count < 0) { in hvcs_close()
1200 hvcsd->vdev->unit_address, hvcsd->port.count); in hvcs_close()
1203 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_close()
1208 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_cleanup() local
1217 tty_port_put(&hvcsd->port); in hvcs_cleanup()
1222 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_hangup() local
1226 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_hangup()
1233 vio_disable_interrupts(hvcsd->vdev); in hvcs_hangup()
1235 hvcsd->todo_mask = 0; in hvcs_hangup()
1236 hvcsd->port.tty = NULL; in hvcs_hangup()
1237 hvcsd->port.count = 0; in hvcs_hangup()
1241 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN); in hvcs_hangup()
1242 hvcsd->chars_in_buffer = 0; in hvcs_hangup()
1244 irq = hvcsd->vdev->irq; in hvcs_hangup()
1246 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_hangup()
1248 free_irq(irq, hvcsd); in hvcs_hangup()
1260 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_write() local
1272 if (!hvcsd) in hvcs_write()
1284 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_write()
1292 if (hvcsd->port.count <= 0) { in hvcs_write()
1293 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_write()
1297 unit_address = hvcsd->vdev->unit_address; in hvcs_write()
1301 (HVCS_BUFF_LEN - hvcsd->chars_in_buffer)); in hvcs_write()
1309 memcpy(&hvcsd->buffer[hvcsd->chars_in_buffer], in hvcs_write()
1313 hvcsd->chars_in_buffer += tosend; in hvcs_write()
1322 if (!(hvcsd->todo_mask & HVCS_TRY_WRITE)) in hvcs_write()
1325 &hvcsd->buffer[0], in hvcs_write()
1326 hvcsd->chars_in_buffer); in hvcs_write()
1336 hvcsd->todo_mask |= HVCS_TRY_WRITE; in hvcs_write()
1341 hvcsd->chars_in_buffer = 0; in hvcs_write()
1350 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_write()
1365 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_write_room() local
1367 if (!hvcsd || hvcsd->port.count <= 0) in hvcs_write_room()
1370 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer; in hvcs_write_room()
1375 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_chars_in_buffer() local
1377 return hvcsd->chars_in_buffer; in hvcs_chars_in_buffer()