Lines Matching refs:hvcsd
302 static int hvcs_has_pi(struct hvcs_struct *hvcsd);
304 struct hvcs_struct *hvcsd);
305 static int hvcs_get_pi(struct hvcs_struct *hvcsd);
308 static int hvcs_partner_connect(struct hvcs_struct *hvcsd);
309 static void hvcs_partner_free(struct hvcs_struct *hvcsd);
311 static int hvcs_enable_device(struct hvcs_struct *hvcsd,
339 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_partner_vtys_show() local
343 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_partner_vtys_show()
344 retval = sprintf(buf, "%X\n", hvcsd->p_unit_address); in hvcs_partner_vtys_show()
345 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_partner_vtys_show()
353 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_partner_clcs_show() local
357 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_partner_clcs_show()
358 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]); in hvcs_partner_clcs_show()
359 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_partner_clcs_show()
378 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_current_vty_show() local
382 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_current_vty_show()
383 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]); in hvcs_current_vty_show()
384 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_current_vty_show()
395 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_vterm_state_store() local
402 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_vterm_state_store()
404 if (hvcsd->port.count > 0) { in hvcs_vterm_state_store()
405 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_store()
411 if (hvcsd->connected == 0) { in hvcs_vterm_state_store()
412 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_store()
418 hvcs_partner_free(hvcsd); in hvcs_vterm_state_store()
421 hvcsd->vdev->unit_address, in hvcs_vterm_state_store()
422 hvcsd->p_unit_address, in hvcs_vterm_state_store()
423 (uint32_t)hvcsd->p_partition_ID); in hvcs_vterm_state_store()
425 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_store()
432 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_vterm_state_show() local
436 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_vterm_state_show()
437 retval = sprintf(buf, "%d\n", hvcsd->connected); in hvcs_vterm_state_show()
438 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_vterm_state_show()
447 struct hvcs_struct *hvcsd = from_vio_dev(viod); in hvcs_index_show() local
451 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_index_show()
452 retval = sprintf(buf, "%d\n", hvcsd->index); in hvcs_index_show()
453 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_index_show()
504 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_unthrottle() local
507 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_unthrottle()
508 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_unthrottle()
509 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_unthrottle()
515 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_throttle() local
518 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_throttle()
519 vio_disable_interrupts(hvcsd->vdev); in hvcs_throttle()
520 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_throttle()
530 struct hvcs_struct *hvcsd = dev_instance; in hvcs_handle_interrupt() local
532 spin_lock(&hvcsd->lock); in hvcs_handle_interrupt()
533 vio_disable_interrupts(hvcsd->vdev); in hvcs_handle_interrupt()
534 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_handle_interrupt()
535 spin_unlock(&hvcsd->lock); in hvcs_handle_interrupt()
542 static void hvcs_try_write(struct hvcs_struct *hvcsd) in hvcs_try_write() argument
544 uint32_t unit_address = hvcsd->vdev->unit_address; in hvcs_try_write()
545 struct tty_struct *tty = hvcsd->port.tty; in hvcs_try_write()
548 if (hvcsd->todo_mask & HVCS_TRY_WRITE) { in hvcs_try_write()
551 &hvcsd->buffer[0], in hvcs_try_write()
552 hvcsd->chars_in_buffer ); in hvcs_try_write()
554 hvcsd->chars_in_buffer = 0; in hvcs_try_write()
556 hvcsd->todo_mask &= ~(HVCS_TRY_WRITE); in hvcs_try_write()
572 static int hvcs_io(struct hvcs_struct *hvcsd) in hvcs_io() argument
580 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_io()
582 unit_address = hvcsd->vdev->unit_address; in hvcs_io()
583 tty = hvcsd->port.tty; in hvcs_io()
585 hvcs_try_write(hvcsd); in hvcs_io()
588 hvcsd->todo_mask &= ~(HVCS_READ_MASK); in hvcs_io()
590 } else if (!(hvcsd->todo_mask & (HVCS_READ_MASK))) in hvcs_io()
594 hvcsd->todo_mask &= ~(HVCS_READ_MASK); in hvcs_io()
596 if (tty_buffer_request_room(&hvcsd->port, HVCS_BUFF_LEN) >= HVCS_BUFF_LEN) { in hvcs_io()
600 tty_insert_flip_string(&hvcsd->port, buf, got); in hvcs_io()
605 hvcsd->todo_mask |= HVCS_QUICK_READ; in hvcs_io()
607 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_io()
610 tty_flip_buffer_push(&hvcsd->port); in hvcs_io()
614 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_io()
615 vio_enable_interrupts(hvcsd->vdev); in hvcs_io()
616 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_io()
619 return hvcsd->todo_mask; in hvcs_io()
622 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_io()
623 return hvcsd->todo_mask; in hvcs_io()
628 struct hvcs_struct *hvcsd; in khvcsd() local
639 list_for_each_entry(hvcsd, &hvcs_structs, next) { in khvcsd()
640 hvcs_todo_mask |= hvcs_io(hvcsd); in khvcsd()
684 struct hvcs_struct *hvcsd = container_of(p, struct hvcs_struct, port); in hvcs_destruct_port() local
689 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_destruct_port()
692 list_del(&(hvcsd->next)); in hvcs_destruct_port()
694 if (hvcsd->connected == 1) { in hvcs_destruct_port()
695 hvcs_partner_free(hvcsd); in hvcs_destruct_port()
698 hvcsd->vdev->unit_address, in hvcs_destruct_port()
699 hvcsd->p_unit_address, in hvcs_destruct_port()
700 (uint32_t)hvcsd->p_partition_ID); in hvcs_destruct_port()
703 hvcsd->vdev->unit_address); in hvcs_destruct_port()
705 vdev = hvcsd->vdev; in hvcs_destruct_port()
706 hvcsd->vdev = NULL; in hvcs_destruct_port()
708 hvcsd->p_unit_address = 0; in hvcs_destruct_port()
709 hvcsd->p_partition_ID = 0; in hvcs_destruct_port()
710 hvcs_return_index(hvcsd->index); in hvcs_destruct_port()
711 memset(&hvcsd->p_location_code[0], 0x00, HVCS_CLC_LENGTH + 1); in hvcs_destruct_port()
713 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_destruct_port()
718 kfree(hvcsd); in hvcs_destruct_port()
747 struct hvcs_struct *hvcsd; in hvcs_probe() local
769 hvcsd = kzalloc(sizeof(*hvcsd), GFP_KERNEL); in hvcs_probe()
770 if (!hvcsd) in hvcs_probe()
773 tty_port_init(&hvcsd->port); in hvcs_probe()
774 hvcsd->port.ops = &hvcs_port_ops; in hvcs_probe()
775 spin_lock_init(&hvcsd->lock); in hvcs_probe()
777 hvcsd->vdev = dev; in hvcs_probe()
778 dev_set_drvdata(&dev->dev, hvcsd); in hvcs_probe()
780 hvcsd->index = index; in hvcs_probe()
783 hvcsd->chars_in_buffer = 0; in hvcs_probe()
784 hvcsd->todo_mask = 0; in hvcs_probe()
785 hvcsd->connected = 0; in hvcs_probe()
791 if (hvcs_get_pi(hvcsd)) { in hvcs_probe()
794 hvcsd->vdev->unit_address); in hvcs_probe()
803 list_add_tail(&(hvcsd->next), &hvcs_structs); in hvcs_probe()
809 hvcsd->vdev->unit_address); in hvcs_probe()
824 struct hvcs_struct *hvcsd = dev_get_drvdata(&dev->dev); in hvcs_remove() local
828 if (!hvcsd) in hvcs_remove()
833 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_remove()
835 tty = hvcsd->port.tty; in hvcs_remove()
837 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_remove()
843 tty_port_put(&hvcsd->port); in hvcs_remove()
866 static void hvcs_set_pi(struct hvcs_partner_info *pi, struct hvcs_struct *hvcsd) in hvcs_set_pi() argument
868 hvcsd->p_unit_address = pi->unit_address; in hvcs_set_pi()
869 hvcsd->p_partition_ID = pi->partition_ID; in hvcs_set_pi()
872 strlcpy(hvcsd->p_location_code, pi->location_code, in hvcs_set_pi()
873 sizeof(hvcsd->p_location_code)); in hvcs_set_pi()
889 static int hvcs_get_pi(struct hvcs_struct *hvcsd) in hvcs_get_pi() argument
892 uint32_t unit_address = hvcsd->vdev->unit_address; in hvcs_get_pi()
910 hvcsd->p_unit_address = 0; in hvcs_get_pi()
911 hvcsd->p_partition_ID = 0; in hvcs_get_pi()
914 hvcs_set_pi(pi, hvcsd); in hvcs_get_pi()
926 struct hvcs_struct *hvcsd; in hvcs_rescan_devices_list() local
931 list_for_each_entry(hvcsd, &hvcs_structs, next) { in hvcs_rescan_devices_list()
932 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_rescan_devices_list()
933 hvcs_get_pi(hvcsd); in hvcs_rescan_devices_list()
934 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_rescan_devices_list()
947 static int hvcs_has_pi(struct hvcs_struct *hvcsd) in hvcs_has_pi() argument
949 if ((!hvcsd->p_unit_address) || (!hvcsd->p_partition_ID)) in hvcs_has_pi()
960 static int hvcs_partner_connect(struct hvcs_struct *hvcsd) in hvcs_partner_connect() argument
963 unsigned int unit_address = hvcsd->vdev->unit_address; in hvcs_partner_connect()
973 hvcsd->p_partition_ID, in hvcs_partner_connect()
974 hvcsd->p_unit_address); in hvcs_partner_connect()
976 hvcsd->connected = 1; in hvcs_partner_connect()
985 if (hvcs_get_pi(hvcsd)) in hvcs_partner_connect()
988 if (!hvcs_has_pi(hvcsd)) in hvcs_partner_connect()
992 hvcsd->p_partition_ID, in hvcs_partner_connect()
993 hvcsd->p_unit_address); in hvcs_partner_connect()
995 hvcsd->connected = 1; in hvcs_partner_connect()
1011 static void hvcs_partner_free(struct hvcs_struct *hvcsd) in hvcs_partner_free() argument
1015 retval = hvcs_free_connection(hvcsd->vdev->unit_address); in hvcs_partner_free()
1017 hvcsd->connected = 0; in hvcs_partner_free()
1021 static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address, in hvcs_enable_device() argument
1031 rc = request_irq(irq, &hvcs_handle_interrupt, 0, "ibmhvcs", hvcsd); in hvcs_enable_device()
1042 free_irq(irq, hvcsd); in hvcs_enable_device()
1048 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_enable_device()
1049 hvcs_partner_free(hvcsd); in hvcs_enable_device()
1050 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_enable_device()
1065 struct hvcs_struct *hvcsd; in hvcs_get_by_index() local
1069 list_for_each_entry(hvcsd, &hvcs_structs, next) { in hvcs_get_by_index()
1070 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_get_by_index()
1071 if (hvcsd->index == index) { in hvcs_get_by_index()
1072 tty_port_get(&hvcsd->port); in hvcs_get_by_index()
1073 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_get_by_index()
1075 return hvcsd; in hvcs_get_by_index()
1077 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_get_by_index()
1086 struct hvcs_struct *hvcsd; in hvcs_install() local
1096 hvcsd = hvcs_get_by_index(tty->index); in hvcs_install()
1097 if (!hvcsd) { in hvcs_install()
1103 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_install()
1105 if (hvcsd->connected == 0) { in hvcs_install()
1106 retval = hvcs_partner_connect(hvcsd); in hvcs_install()
1108 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1114 hvcsd->port.count = 0; in hvcs_install()
1115 hvcsd->port.tty = tty; in hvcs_install()
1116 tty->driver_data = hvcsd; in hvcs_install()
1118 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN); in hvcs_install()
1124 irq = hvcsd->vdev->irq; in hvcs_install()
1125 vdev = hvcsd->vdev; in hvcs_install()
1126 unit_address = hvcsd->vdev->unit_address; in hvcs_install()
1128 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_install()
1129 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1135 retval = hvcs_enable_device(hvcsd, unit_address, irq, vdev); in hvcs_install()
1141 retval = tty_port_install(&hvcsd->port, driver, tty); in hvcs_install()
1147 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_install()
1148 vio_disable_interrupts(hvcsd->vdev); in hvcs_install()
1149 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_install()
1150 free_irq(irq, hvcsd); in hvcs_install()
1152 tty_port_put(&hvcsd->port); in hvcs_install()
1163 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_open() local
1166 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_open()
1167 hvcsd->port.count++; in hvcs_open()
1168 hvcsd->todo_mask |= HVCS_SCHED_READ; in hvcs_open()
1169 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_open()
1174 hvcsd->vdev->unit_address ); in hvcs_open()
1181 struct hvcs_struct *hvcsd; in hvcs_close() local
1200 hvcsd = tty->driver_data; in hvcs_close()
1202 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_close()
1203 if (--hvcsd->port.count == 0) { in hvcs_close()
1205 vio_disable_interrupts(hvcsd->vdev); in hvcs_close()
1212 hvcsd->port.tty = NULL; in hvcs_close()
1214 irq = hvcsd->vdev->irq; in hvcs_close()
1215 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_close()
1219 free_irq(irq, hvcsd); in hvcs_close()
1221 } else if (hvcsd->port.count < 0) { in hvcs_close()
1223 hvcsd->vdev->unit_address, hvcsd->port.count); in hvcs_close()
1226 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_close()
1231 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_cleanup() local
1240 tty_port_put(&hvcsd->port); in hvcs_cleanup()
1245 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_hangup() local
1250 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_hangup()
1252 temp_open_count = hvcsd->port.count; in hvcs_hangup()
1259 vio_disable_interrupts(hvcsd->vdev); in hvcs_hangup()
1261 hvcsd->todo_mask = 0; in hvcs_hangup()
1265 hvcsd->port.tty = NULL; in hvcs_hangup()
1267 hvcsd->port.count = 0; in hvcs_hangup()
1271 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN); in hvcs_hangup()
1272 hvcsd->chars_in_buffer = 0; in hvcs_hangup()
1274 irq = hvcsd->vdev->irq; in hvcs_hangup()
1276 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_hangup()
1278 free_irq(irq, hvcsd); in hvcs_hangup()
1292 tty_port_put(&hvcsd->port); in hvcs_hangup()
1306 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_write() local
1318 if (!hvcsd) in hvcs_write()
1330 spin_lock_irqsave(&hvcsd->lock, flags); in hvcs_write()
1338 if (hvcsd->port.count <= 0) { in hvcs_write()
1339 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_write()
1343 unit_address = hvcsd->vdev->unit_address; in hvcs_write()
1346 tosend = min(count, (HVCS_BUFF_LEN - hvcsd->chars_in_buffer)); in hvcs_write()
1354 memcpy(&hvcsd->buffer[hvcsd->chars_in_buffer], in hvcs_write()
1358 hvcsd->chars_in_buffer += tosend; in hvcs_write()
1367 if (!(hvcsd->todo_mask & HVCS_TRY_WRITE)) in hvcs_write()
1370 &hvcsd->buffer[0], in hvcs_write()
1371 hvcsd->chars_in_buffer); in hvcs_write()
1381 hvcsd->todo_mask |= HVCS_TRY_WRITE; in hvcs_write()
1386 hvcsd->chars_in_buffer = 0; in hvcs_write()
1395 spin_unlock_irqrestore(&hvcsd->lock, flags); in hvcs_write()
1410 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_write_room() local
1412 if (!hvcsd || hvcsd->port.count <= 0) in hvcs_write_room()
1415 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer; in hvcs_write_room()
1420 struct hvcs_struct *hvcsd = tty->driver_data; in hvcs_chars_in_buffer() local
1422 return hvcsd->chars_in_buffer; in hvcs_chars_in_buffer()