Lines Matching refs:hvcsd
304 static int hvcs_has_pi(struct hvcs_struct *hvcsd);
306 struct hvcs_struct *hvcsd);
307 static int hvcs_get_pi(struct hvcs_struct *hvcsd);
310 static int hvcs_partner_connect(struct hvcs_struct *hvcsd);
311 static void hvcs_partner_free(struct hvcs_struct *hvcsd);
313 static int hvcs_enable_device(struct hvcs_struct *hvcsd,
341 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_partner_vtys_show() local
345 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_partner_vtys_show()
346 retval = sprintf(buf, "%X\n", hvcsd->p_unit_address); in hvcs_partner_vtys_show()
347 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_partner_vtys_show()
355 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_partner_clcs_show() local
359 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_partner_clcs_show()
360 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]); in hvcs_partner_clcs_show()
361 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_partner_clcs_show()
380 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_current_vty_show() local
384 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_current_vty_show()
385 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]); in hvcs_current_vty_show()
386 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_current_vty_show()
397 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_vterm_state_store() local
404 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_vterm_state_store()
406 if (hvcsd->port.count > 0) { in hvcs_vterm_state_store()
407 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_store()
413 if (hvcsd->connected == 0) { in hvcs_vterm_state_store()
414 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_store()
420 hvcs_partner_free(hvcsd); in hvcs_vterm_state_store()
423 hvcsd->vdev->unit_address, in hvcs_vterm_state_store()
424 hvcsd->p_unit_address, in hvcs_vterm_state_store()
425 (uint32_t)hvcsd->p_partition_ID); in hvcs_vterm_state_store()
427 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_store()
434 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_vterm_state_show() local
438 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_vterm_state_show()
439 retval = sprintf(buf, "%d\n", hvcsd->connected); in hvcs_vterm_state_show()
440 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_show()
449 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_index_show() local
453 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_index_show()
454 retval = sprintf(buf, "%d\n", hvcsd->index); in hvcs_index_show()
455 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_index_show()
506 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_unthrottle() local
509 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_unthrottle()
510 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_unthrottle()
511 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_unthrottle()
517 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_throttle() local
520 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_throttle()
521 vio_disable_interrupts(hvcsd->vdev); in hvcs_throttle()
522 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_throttle()
532 struct hvcs_struct *hvcsd = dev_instance; in hvcs_handle_interrupt() local
534 spin_lock(&hvcsd->lock); in hvcs_handle_interrupt()
535 vio_disable_interrupts(hvcsd->vdev); in hvcs_handle_interrupt()
536 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_handle_interrupt()
537 spin_unlock(&hvcsd->lock); in hvcs_handle_interrupt()
544 static void hvcs_try_write(struct hvcs_struct *hvcsd) in hvcs_try_write() argument
546 uint32_t unit_address = hvcsd->vdev->unit_address; in hvcs_try_write()
547 struct tty_struct *tty = hvcsd->port.tty; in hvcs_try_write()
550 if (hvcsd->todo_mask & HVCS_TRY_WRITE) { in hvcs_try_write()
553 &hvcsd->buffer[0], in hvcs_try_write()
554 hvcsd->chars_in_buffer ); in hvcs_try_write()
556 hvcsd->chars_in_buffer = 0; in hvcs_try_write()
558 hvcsd->todo_mask &= ~(HVCS_TRY_WRITE); in hvcs_try_write()
574 static int hvcs_io(struct hvcs_struct *hvcsd) in hvcs_io() argument
582 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_io()
584 unit_address = hvcsd->vdev->unit_address; in hvcs_io()
585 tty = hvcsd->port.tty; in hvcs_io()
587 hvcs_try_write(hvcsd); in hvcs_io()
590 hvcsd->todo_mask &= ~(HVCS_READ_MASK); in hvcs_io()
592 } else if (!(hvcsd->todo_mask & (HVCS_READ_MASK))) in hvcs_io()
596 hvcsd->todo_mask &= ~(HVCS_READ_MASK); in hvcs_io()
598 if (tty_buffer_request_room(&hvcsd->port, HVCS_BUFF_LEN) >= HVCS_BUFF_LEN) { in hvcs_io()
602 tty_insert_flip_string(&hvcsd->port, buf, got); in hvcs_io()
607 hvcsd->todo_mask |= HVCS_QUICK_READ; in hvcs_io()
609 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_io()
612 tty_flip_buffer_push(&hvcsd->port); in hvcs_io()
616 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_io()
617 vio_enable_interrupts(hvcsd->vdev); in hvcs_io()
618 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_io()
621 return hvcsd->todo_mask; in hvcs_io()
624 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_io()
625 return hvcsd->todo_mask; in hvcs_io()
630 struct hvcs_struct *hvcsd; in khvcsd() local
641 list_for_each_entry(hvcsd, &hvcs_structs, next) { in khvcsd()
642 hvcs_todo_mask |= hvcs_io(hvcsd); in khvcsd()
686 struct hvcs_struct *hvcsd = container_of(p, struct hvcs_struct, port); in hvcs_destruct_port() local
691 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_destruct_port()
694 list_del(&(hvcsd->next)); in hvcs_destruct_port()
696 if (hvcsd->connected == 1) { in hvcs_destruct_port()
697 hvcs_partner_free(hvcsd); in hvcs_destruct_port()
700 hvcsd->vdev->unit_address, in hvcs_destruct_port()
701 hvcsd->p_unit_address, in hvcs_destruct_port()
702 (uint32_t)hvcsd->p_partition_ID); in hvcs_destruct_port()
705 hvcsd->vdev->unit_address); in hvcs_destruct_port()
707 vdev = hvcsd->vdev; in hvcs_destruct_port()
708 hvcsd->vdev = NULL; in hvcs_destruct_port()
710 hvcsd->p_unit_address = 0; in hvcs_destruct_port()
711 hvcsd->p_partition_ID = 0; in hvcs_destruct_port()
712 hvcs_return_index(hvcsd->index); in hvcs_destruct_port()
713 memset(&hvcsd->p_location_code[0], 0x00, HVCS_CLC_LENGTH + 1); in hvcs_destruct_port()
715 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_destruct_port()
720 kfree(hvcsd); in hvcs_destruct_port()
749 struct hvcs_struct *hvcsd; in hvcs_probe() local
771 hvcsd = kzalloc(sizeof(*hvcsd), GFP_KERNEL); in hvcs_probe()
772 if (!hvcsd) in hvcs_probe()
775 tty_port_init(&hvcsd->port); in hvcs_probe()
776 hvcsd->port.ops = &hvcs_port_ops; in hvcs_probe()
777 spin_lock_init(&hvcsd->lock); in hvcs_probe()
779 hvcsd->vdev = dev; in hvcs_probe()
780 dev_set_drvdata(&dev->dev, hvcsd); in hvcs_probe()
782 hvcsd->index = index; in hvcs_probe()
785 hvcsd->chars_in_buffer = 0; in hvcs_probe()
786 hvcsd->todo_mask = 0; in hvcs_probe()
787 hvcsd->connected = 0; in hvcs_probe()
793 if (hvcs_get_pi(hvcsd)) { in hvcs_probe()
796 hvcsd->vdev->unit_address); in hvcs_probe()
805 list_add_tail(&(hvcsd->next), &hvcs_structs); in hvcs_probe()
811 hvcsd->vdev->unit_address); in hvcs_probe()
826 struct hvcs_struct *hvcsd = dev_get_drvdata(&dev->dev); in hvcs_remove() local
830 if (!hvcsd) in hvcs_remove()
835 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_remove()
837 tty = hvcsd->port.tty; in hvcs_remove()
839 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_remove()
845 tty_port_put(&hvcsd->port); in hvcs_remove()
868 static void hvcs_set_pi(struct hvcs_partner_info *pi, struct hvcs_struct *hvcsd) in hvcs_set_pi() argument
870 hvcsd->p_unit_address = pi->unit_address; in hvcs_set_pi()
871 hvcsd->p_partition_ID = pi->partition_ID; in hvcs_set_pi()
874 strlcpy(hvcsd->p_location_code, pi->location_code, in hvcs_set_pi()
875 sizeof(hvcsd->p_location_code)); in hvcs_set_pi()
891 static int hvcs_get_pi(struct hvcs_struct *hvcsd) in hvcs_get_pi() argument
894 uint32_t unit_address = hvcsd->vdev->unit_address; in hvcs_get_pi()
912 hvcsd->p_unit_address = 0; in hvcs_get_pi()
913 hvcsd->p_partition_ID = 0; in hvcs_get_pi()
916 hvcs_set_pi(pi, hvcsd); in hvcs_get_pi()
928 struct hvcs_struct *hvcsd; in hvcs_rescan_devices_list() local
933 list_for_each_entry(hvcsd, &hvcs_structs, next) { in hvcs_rescan_devices_list()
934 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_rescan_devices_list()
935 hvcs_get_pi(hvcsd); in hvcs_rescan_devices_list()
936 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_rescan_devices_list()
949 static int hvcs_has_pi(struct hvcs_struct *hvcsd) in hvcs_has_pi() argument
951 if ((!hvcsd->p_unit_address) || (!hvcsd->p_partition_ID)) in hvcs_has_pi()
962 static int hvcs_partner_connect(struct hvcs_struct *hvcsd) in hvcs_partner_connect() argument
965 unsigned int unit_address = hvcsd->vdev->unit_address; in hvcs_partner_connect()
975 hvcsd->p_partition_ID, in hvcs_partner_connect()
976 hvcsd->p_unit_address); in hvcs_partner_connect()
978 hvcsd->connected = 1; in hvcs_partner_connect()
987 if (hvcs_get_pi(hvcsd)) in hvcs_partner_connect()
990 if (!hvcs_has_pi(hvcsd)) in hvcs_partner_connect()
994 hvcsd->p_partition_ID, in hvcs_partner_connect()
995 hvcsd->p_unit_address); in hvcs_partner_connect()
997 hvcsd->connected = 1; in hvcs_partner_connect()
1013 static void hvcs_partner_free(struct hvcs_struct *hvcsd) in hvcs_partner_free() argument
1017 retval = hvcs_free_connection(hvcsd->vdev->unit_address); in hvcs_partner_free()
1019 hvcsd->connected = 0; in hvcs_partner_free()
1023 static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address, in hvcs_enable_device() argument
1033 rc = request_irq(irq, &hvcs_handle_interrupt, 0, "ibmhvcs", hvcsd); in hvcs_enable_device()
1044 free_irq(irq, hvcsd); in hvcs_enable_device()
1050 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_enable_device()
1051 hvcs_partner_free(hvcsd); in hvcs_enable_device()
1052 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_enable_device()
1067 struct hvcs_struct *hvcsd; in hvcs_get_by_index() local
1071 list_for_each_entry(hvcsd, &hvcs_structs, next) { in hvcs_get_by_index()
1072 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_get_by_index()
1073 if (hvcsd->index == index) { in hvcs_get_by_index()
1074 tty_port_get(&hvcsd->port); in hvcs_get_by_index()
1075 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_get_by_index()
1077 return hvcsd; in hvcs_get_by_index()
1079 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_get_by_index()
1088 struct hvcs_struct *hvcsd; in hvcs_install() local
1098 hvcsd = hvcs_get_by_index(tty->index); in hvcs_install()
1099 if (!hvcsd) { in hvcs_install()
1105 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_install()
1107 if (hvcsd->connected == 0) { in hvcs_install()
1108 retval = hvcs_partner_connect(hvcsd); in hvcs_install()
1110 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1116 hvcsd->port.count = 0; in hvcs_install()
1117 hvcsd->port.tty = tty; in hvcs_install()
1118 tty->driver_data = hvcsd; in hvcs_install()
1120 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN); in hvcs_install()
1126 irq = hvcsd->vdev->irq; in hvcs_install()
1127 vdev = hvcsd->vdev; in hvcs_install()
1128 unit_address = hvcsd->vdev->unit_address; in hvcs_install()
1130 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_install()
1131 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1137 retval = hvcs_enable_device(hvcsd, unit_address, irq, vdev); in hvcs_install()
1143 retval = tty_port_install(&hvcsd->port, driver, tty); in hvcs_install()
1149 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_install()
1150 vio_disable_interrupts(hvcsd->vdev); in hvcs_install()
1151 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1152 free_irq(irq, hvcsd); in hvcs_install()
1154 tty_port_put(&hvcsd->port); in hvcs_install()
1165 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_open() local
1168 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_open()
1169 hvcsd->port.count++; in hvcs_open()
1170 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_open()
1171 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_open()
1176 hvcsd->vdev->unit_address ); in hvcs_open()
1183 struct hvcs_struct *hvcsd; in hvcs_close() local
1202 hvcsd = tty->driver_data; in hvcs_close()
1204 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_close()
1205 if (--hvcsd->port.count == 0) { in hvcs_close()
1207 vio_disable_interrupts(hvcsd->vdev); in hvcs_close()
1214 hvcsd->port.tty = NULL; in hvcs_close()
1216 irq = hvcsd->vdev->irq; in hvcs_close()
1217 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_close()
1228 free_irq(irq, hvcsd); in hvcs_close()
1230 } else if (hvcsd->port.count < 0) { in hvcs_close()
1232 hvcsd->vdev->unit_address, hvcsd->port.count); in hvcs_close()
1235 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_close()
1240 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_cleanup() local
1242 tty_port_put(&hvcsd->port); in hvcs_cleanup()
1247 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_hangup() local
1252 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_hangup()
1254 temp_open_count = hvcsd->port.count; in hvcs_hangup()
1261 vio_disable_interrupts(hvcsd->vdev); in hvcs_hangup()
1263 hvcsd->todo_mask = 0; in hvcs_hangup()
1267 hvcsd->port.tty = NULL; in hvcs_hangup()
1269 hvcsd->port.count = 0; in hvcs_hangup()
1273 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN); in hvcs_hangup()
1274 hvcsd->chars_in_buffer = 0; in hvcs_hangup()
1276 irq = hvcsd->vdev->irq; in hvcs_hangup()
1278 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_hangup()
1280 free_irq(irq, hvcsd); in hvcs_hangup()
1294 tty_port_put(&hvcsd->port); in hvcs_hangup()
1308 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_write() local
1320 if (!hvcsd) in hvcs_write()
1332 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_write()
1340 if (hvcsd->port.count <= 0) { in hvcs_write()
1341 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_write()
1345 unit_address = hvcsd->vdev->unit_address; in hvcs_write()
1348 tosend = min(count, (HVCS_BUFF_LEN - hvcsd->chars_in_buffer)); in hvcs_write()
1356 memcpy(&hvcsd->buffer[hvcsd->chars_in_buffer], in hvcs_write()
1360 hvcsd->chars_in_buffer += tosend; in hvcs_write()
1369 if (!(hvcsd->todo_mask & HVCS_TRY_WRITE)) in hvcs_write()
1372 &hvcsd->buffer[0], in hvcs_write()
1373 hvcsd->chars_in_buffer); in hvcs_write()
1383 hvcsd->todo_mask |= HVCS_TRY_WRITE; in hvcs_write()
1388 hvcsd->chars_in_buffer = 0; in hvcs_write()
1397 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_write()
1412 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_write_room() local
1414 if (!hvcsd || hvcsd->port.count <= 0) in hvcs_write_room()
1417 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer; in hvcs_write_room()
1422 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_chars_in_buffer() local
1424 return hvcsd->chars_in_buffer; in hvcs_chars_in_buffer()