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
672 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_destruct_port()
674 comp = hvcsd->destroyed; in hvcs_destruct_port()
676 list_del(&(hvcsd->next)); in hvcs_destruct_port()
678 if (hvcsd->connected == 1) { in hvcs_destruct_port()
679 hvcs_partner_free(hvcsd); in hvcs_destruct_port()
682 hvcsd->vdev->unit_address, in hvcs_destruct_port()
683 hvcsd->p_unit_address, in hvcs_destruct_port()
684 (uint32_t)hvcsd->p_partition_ID); in hvcs_destruct_port()
687 hvcsd->vdev->unit_address); in hvcs_destruct_port()
689 vdev = hvcsd->vdev; in hvcs_destruct_port()
690 hvcsd->vdev = NULL; in hvcs_destruct_port()
692 hvcsd->p_unit_address = 0; in hvcs_destruct_port()
693 hvcsd->p_partition_ID = 0; in hvcs_destruct_port()
694 hvcsd->destroyed = NULL; in hvcs_destruct_port()
695 hvcs_return_index(hvcsd->index); in hvcs_destruct_port()
696 memset(&hvcsd->p_location_code[0], 0x00, HVCS_CLC_LENGTH + 1); in hvcs_destruct_port()
698 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_destruct_port()
701 kfree(hvcsd); in hvcs_destruct_port()
732 struct hvcs_struct *hvcsd; in hvcs_probe() local
753 hvcsd = kzalloc(sizeof(*hvcsd), GFP_KERNEL); in hvcs_probe()
754 if (!hvcsd) in hvcs_probe()
757 tty_port_init(&hvcsd->port); in hvcs_probe()
758 hvcsd->port.ops = &hvcs_port_ops; in hvcs_probe()
759 spin_lock_init(&hvcsd->lock); in hvcs_probe()
761 hvcsd->vdev = dev; in hvcs_probe()
762 dev_set_drvdata(&dev->dev, hvcsd); in hvcs_probe()
764 hvcsd->index = index; in hvcs_probe()
767 hvcsd->chars_in_buffer = 0; in hvcs_probe()
768 hvcsd->todo_mask = 0; in hvcs_probe()
769 hvcsd->connected = 0; in hvcs_probe()
775 if (hvcs_get_pi(hvcsd)) { in hvcs_probe()
778 hvcsd->vdev->unit_address); in hvcs_probe()
787 list_add_tail(&(hvcsd->next), &hvcs_structs); in hvcs_probe()
801 struct hvcs_struct *hvcsd = dev_get_drvdata(&dev->dev); in hvcs_remove() local
808 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_remove()
810 hvcsd->destroyed = ∁ in hvcs_remove()
811 tty = tty_port_tty_get(&hvcsd->port); in hvcs_remove()
813 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_remove()
824 tty_port_put(&hvcsd->port); in hvcs_remove()
842 static void hvcs_set_pi(struct hvcs_partner_info *pi, struct hvcs_struct *hvcsd) in hvcs_set_pi() argument
844 hvcsd->p_unit_address = pi->unit_address; in hvcs_set_pi()
845 hvcsd->p_partition_ID = pi->partition_ID; in hvcs_set_pi()
848 strscpy(hvcsd->p_location_code, pi->location_code, in hvcs_set_pi()
849 sizeof(hvcsd->p_location_code)); in hvcs_set_pi()
865 static int hvcs_get_pi(struct hvcs_struct *hvcsd) in hvcs_get_pi() argument
868 uint32_t unit_address = hvcsd->vdev->unit_address; in hvcs_get_pi()
886 hvcsd->p_unit_address = 0; in hvcs_get_pi()
887 hvcsd->p_partition_ID = 0; in hvcs_get_pi()
890 hvcs_set_pi(pi, hvcsd); in hvcs_get_pi()
902 struct hvcs_struct *hvcsd; in hvcs_rescan_devices_list() local
907 list_for_each_entry(hvcsd, &hvcs_structs, next) { in hvcs_rescan_devices_list()
908 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_rescan_devices_list()
909 hvcs_get_pi(hvcsd); in hvcs_rescan_devices_list()
910 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_rescan_devices_list()
923 static int hvcs_has_pi(struct hvcs_struct *hvcsd) in hvcs_has_pi() argument
925 if ((!hvcsd->p_unit_address) || (!hvcsd->p_partition_ID)) in hvcs_has_pi()
936 static int hvcs_partner_connect(struct hvcs_struct *hvcsd) in hvcs_partner_connect() argument
939 unsigned int unit_address = hvcsd->vdev->unit_address; in hvcs_partner_connect()
949 hvcsd->p_partition_ID, in hvcs_partner_connect()
950 hvcsd->p_unit_address); in hvcs_partner_connect()
952 hvcsd->connected = 1; in hvcs_partner_connect()
961 if (hvcs_get_pi(hvcsd)) in hvcs_partner_connect()
964 if (!hvcs_has_pi(hvcsd)) in hvcs_partner_connect()
968 hvcsd->p_partition_ID, in hvcs_partner_connect()
969 hvcsd->p_unit_address); in hvcs_partner_connect()
971 hvcsd->connected = 1; in hvcs_partner_connect()
987 static void hvcs_partner_free(struct hvcs_struct *hvcsd) in hvcs_partner_free() argument
991 retval = hvcs_free_connection(hvcsd->vdev->unit_address); in hvcs_partner_free()
993 hvcsd->connected = 0; in hvcs_partner_free()
997 static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address, in hvcs_enable_device() argument
1007 rc = request_irq(irq, &hvcs_handle_interrupt, 0, "ibmhvcs", hvcsd); in hvcs_enable_device()
1018 free_irq(irq, hvcsd); in hvcs_enable_device()
1024 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_enable_device()
1025 hvcs_partner_free(hvcsd); in hvcs_enable_device()
1026 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_enable_device()
1041 struct hvcs_struct *hvcsd; in hvcs_get_by_index() local
1045 list_for_each_entry(hvcsd, &hvcs_structs, next) { in hvcs_get_by_index()
1046 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_get_by_index()
1047 if (hvcsd->index == index) { in hvcs_get_by_index()
1048 tty_port_get(&hvcsd->port); in hvcs_get_by_index()
1049 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_get_by_index()
1051 return hvcsd; in hvcs_get_by_index()
1053 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_get_by_index()
1062 struct hvcs_struct *hvcsd; in hvcs_install() local
1072 hvcsd = hvcs_get_by_index(tty->index); in hvcs_install()
1073 if (!hvcsd) { in hvcs_install()
1079 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_install()
1081 if (hvcsd->connected == 0) { in hvcs_install()
1082 retval = hvcs_partner_connect(hvcsd); in hvcs_install()
1084 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1090 hvcsd->port.count = 0; in hvcs_install()
1091 hvcsd->port.tty = tty; in hvcs_install()
1092 tty->driver_data = hvcsd; in hvcs_install()
1094 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN); in hvcs_install()
1100 irq = hvcsd->vdev->irq; in hvcs_install()
1101 vdev = hvcsd->vdev; in hvcs_install()
1102 unit_address = hvcsd->vdev->unit_address; in hvcs_install()
1104 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_install()
1105 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1111 retval = hvcs_enable_device(hvcsd, unit_address, irq, vdev); in hvcs_install()
1117 retval = tty_port_install(&hvcsd->port, driver, tty); in hvcs_install()
1123 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_install()
1124 vio_disable_interrupts(hvcsd->vdev); in hvcs_install()
1125 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1126 free_irq(irq, hvcsd); in hvcs_install()
1128 tty_port_put(&hvcsd->port); in hvcs_install()
1139 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_open() local
1142 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_open()
1143 hvcsd->port.count++; in hvcs_open()
1144 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_open()
1145 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_open()
1150 hvcsd->vdev->unit_address ); in hvcs_open()
1157 struct hvcs_struct *hvcsd; in hvcs_close() local
1176 hvcsd = tty->driver_data; in hvcs_close()
1178 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_close()
1179 if (hvcsd->port.count == 0) { in hvcs_close()
1180 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_close()
1182 } else if (--hvcsd->port.count == 0) { in hvcs_close()
1184 vio_disable_interrupts(hvcsd->vdev); in hvcs_close()
1191 hvcsd->port.tty = NULL; in hvcs_close()
1193 irq = hvcsd->vdev->irq; in hvcs_close()
1194 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_close()
1198 free_irq(irq, hvcsd); in hvcs_close()
1200 } else if (hvcsd->port.count < 0) { in hvcs_close()
1202 hvcsd->vdev->unit_address, hvcsd->port.count); in hvcs_close()
1205 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_close()
1210 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_cleanup() local
1219 tty_port_put(&hvcsd->port); in hvcs_cleanup()
1224 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_hangup() local
1228 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_hangup()
1235 vio_disable_interrupts(hvcsd->vdev); in hvcs_hangup()
1237 hvcsd->todo_mask = 0; in hvcs_hangup()
1238 hvcsd->port.tty = NULL; in hvcs_hangup()
1239 hvcsd->port.count = 0; in hvcs_hangup()
1243 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN); in hvcs_hangup()
1244 hvcsd->chars_in_buffer = 0; in hvcs_hangup()
1246 irq = hvcsd->vdev->irq; in hvcs_hangup()
1248 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_hangup()
1250 free_irq(irq, hvcsd); in hvcs_hangup()
1262 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_write() local
1274 if (!hvcsd) in hvcs_write()
1286 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_write()
1294 if (hvcsd->port.count <= 0) { in hvcs_write()
1295 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_write()
1299 unit_address = hvcsd->vdev->unit_address; in hvcs_write()
1303 (HVCS_BUFF_LEN - hvcsd->chars_in_buffer)); in hvcs_write()
1311 memcpy(&hvcsd->buffer[hvcsd->chars_in_buffer], in hvcs_write()
1315 hvcsd->chars_in_buffer += tosend; in hvcs_write()
1324 if (!(hvcsd->todo_mask & HVCS_TRY_WRITE)) in hvcs_write()
1327 &hvcsd->buffer[0], in hvcs_write()
1328 hvcsd->chars_in_buffer); in hvcs_write()
1338 hvcsd->todo_mask |= HVCS_TRY_WRITE; in hvcs_write()
1343 hvcsd->chars_in_buffer = 0; in hvcs_write()
1352 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_write()
1367 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_write_room() local
1369 if (!hvcsd || hvcsd->port.count <= 0) in hvcs_write_room()
1372 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer; in hvcs_write_room()
1377 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_chars_in_buffer() local
1379 return hvcsd->chars_in_buffer; in hvcs_chars_in_buffer()