• Home
  • Raw
  • Download

Lines Matching full:port

52 /* Microseconds that thread will delay waiting for a vcc port ref */
116 * vcc_table_add() - Add VCC port to the VCC table
117 * @port: pointer to the VCC port
119 * Return: index of the port in the VCC table on success,
122 static int vcc_table_add(struct vcc_port *port) in vcc_table_add() argument
130 vcc_table[i] = port; in vcc_table_add()
143 * vcc_table_remove() - Removes a VCC port from the VCC table
159 * vcc_get() - Gets a reference to VCC port
163 * Return: reference to the VCC port, if found
164 * NULL, if port not found
168 struct vcc_port *port; in vcc_get() local
174 port = vcc_table[index]; in vcc_get()
175 if (!port) { in vcc_get()
181 if (port->excl_locked) { in vcc_get()
186 port->refcnt++; in vcc_get()
188 return port; in vcc_get()
191 if (port->refcnt) { in vcc_get()
201 port->refcnt++; in vcc_get()
202 port->excl_locked = true; in vcc_get()
205 return port; in vcc_get()
209 * vcc_put() - Returns a reference to VCC port
210 * @port: pointer to VCC port
216 static void vcc_put(struct vcc_port *port, bool excl) in vcc_put() argument
220 if (!port) in vcc_put()
226 if (WARN_ON((excl && !port->excl_locked) || in vcc_put()
227 (!excl && port->excl_locked))) in vcc_put()
230 port->refcnt--; in vcc_put()
233 port->excl_locked = false; in vcc_put()
240 * vcc_get_ne() - Get a non-exclusive reference to VCC port
243 * Gets a non-exclusive reference to VCC port, if it's not removed
245 * Return: pointer to the VCC port, if found
246 * NULL, if port not found
250 struct vcc_port *port; in vcc_get_ne() local
252 port = vcc_get(index, false); in vcc_get_ne()
254 if (port && port->removed) { in vcc_get_ne()
255 vcc_put(port, false); in vcc_get_ne()
259 return port; in vcc_get_ne()
262 static void vcc_kick_rx(struct vcc_port *port) in vcc_kick_rx() argument
264 struct vio_driver_state *vio = &port->vio; in vcc_kick_rx()
266 assert_spin_locked(&port->lock); in vcc_kick_rx()
268 if (!timer_pending(&port->rx_timer) && !port->removed) { in vcc_kick_rx()
270 port->rx_timer.expires = (jiffies + 1); in vcc_kick_rx()
271 add_timer(&port->rx_timer); in vcc_kick_rx()
275 static void vcc_kick_tx(struct vcc_port *port) in vcc_kick_tx() argument
277 assert_spin_locked(&port->lock); in vcc_kick_tx()
279 if (!timer_pending(&port->tx_timer) && !port->removed) { in vcc_kick_tx()
280 port->tx_timer.expires = (jiffies + 1); in vcc_kick_tx()
281 add_timer(&port->tx_timer); in vcc_kick_tx()
287 if (WARN_ON(!tty || !tty->port)) in vcc_rx_check()
294 (tty_buffer_request_room(tty->port, VCC_BUFF_LEN) < VCC_BUFF_LEN)) in vcc_rx_check()
304 if (WARN_ON(!tty || !tty->port)) in vcc_rx()
307 len = tty_insert_flip_string(tty->port, buf, size); in vcc_rx()
309 tty_flip_buffer_push(tty->port); in vcc_rx()
314 static int vcc_ldc_read(struct vcc_port *port) in vcc_ldc_read() argument
316 struct vio_driver_state *vio = &port->vio; in vcc_ldc_read()
321 tty = port->tty; in vcc_ldc_read()
331 vcc_kick_rx(port); in vcc_ldc_read()
367 struct vcc_port *port = from_timer(port, t, rx_timer); in vcc_rx_timer() local
372 spin_lock_irqsave(&port->lock, flags); in vcc_rx_timer()
373 port->rx_timer.expires = 0; in vcc_rx_timer()
375 vio = &port->vio; in vcc_rx_timer()
379 if (!port->tty || port->removed) in vcc_rx_timer()
382 rv = vcc_ldc_read(port); in vcc_rx_timer()
387 spin_unlock_irqrestore(&port->lock, flags); in vcc_rx_timer()
388 vcc_put(port, false); in vcc_rx_timer()
393 struct vcc_port *port = from_timer(port, t, tx_timer); in vcc_tx_timer() local
399 spin_lock_irqsave(&port->lock, flags); in vcc_tx_timer()
400 port->tx_timer.expires = 0; in vcc_tx_timer()
402 if (!port->tty || port->removed) in vcc_tx_timer()
405 tosend = min(VCC_BUFF_LEN, port->chars_in_buffer); in vcc_tx_timer()
409 pkt = &port->buffer; in vcc_tx_timer()
412 vccdbgl(port->vio.lp); in vcc_tx_timer()
414 rv = ldc_write(port->vio.lp, pkt, (VIO_TAG_SIZE + tosend)); in vcc_tx_timer()
419 vcc_kick_tx(port); in vcc_tx_timer()
421 struct tty_struct *tty = port->tty; in vcc_tx_timer()
423 port->chars_in_buffer = 0; in vcc_tx_timer()
429 spin_unlock_irqrestore(&port->lock, flags); in vcc_tx_timer()
430 vcc_put(port, false); in vcc_tx_timer()
443 struct vcc_port *port; in vcc_event() local
447 port = arg; in vcc_event()
448 vio = &port->vio; in vcc_event()
450 spin_lock_irqsave(&port->lock, flags); in vcc_event()
459 rv = vcc_ldc_read(port); in vcc_event()
468 spin_unlock_irqrestore(&port->lock, flags); in vcc_event()
489 struct vcc_port *port; in vcc_sysfs_domain_show() local
492 port = dev_get_drvdata(dev); in vcc_sysfs_domain_show()
493 if (!port) in vcc_sysfs_domain_show()
496 rv = scnprintf(buf, PAGE_SIZE, "%s\n", port->domain); in vcc_sysfs_domain_show()
501 static int vcc_send_ctl(struct vcc_port *port, int ctl) in vcc_send_ctl() argument
510 rv = ldc_write(port->vio.lp, &pkt, sizeof(pkt.tag)); in vcc_send_ctl()
521 struct vcc_port *port; in vcc_sysfs_break_store() local
526 port = dev_get_drvdata(dev); in vcc_sysfs_break_store()
527 if (!port) in vcc_sysfs_break_store()
530 spin_lock_irqsave(&port->lock, flags); in vcc_sysfs_break_store()
534 else if (vcc_send_ctl(port, VCC_CTL_BREAK) < 0) in vcc_sysfs_break_store()
535 vcc_kick_tx(port); in vcc_sysfs_break_store()
537 spin_unlock_irqrestore(&port->lock, flags); in vcc_sysfs_break_store()
557 * vcc_probe() - Initialize VCC port
558 * @vdev: Pointer to VIO device of the new VCC port
561 * Initializes a VCC port to receive serial console data from
571 struct vcc_port *port; in vcc_probe() local
585 port = kzalloc(sizeof(struct vcc_port), GFP_KERNEL); in vcc_probe()
586 if (!port) in vcc_probe()
591 rv = vio_driver_init(&port->vio, vdev, VDEV_CONSOLE_CON, vcc_versions, in vcc_probe()
596 port->vio.debug = vcc_dbg_vio; in vcc_probe()
599 rv = vio_ldc_alloc(&port->vio, &vcc_ldc_cfg, port); in vcc_probe()
603 spin_lock_init(&port->lock); in vcc_probe()
605 port->index = vcc_table_add(port); in vcc_probe()
606 if (port->index == -1) { in vcc_probe()
613 dev = tty_register_device(vcc_tty_driver, port->index, &vdev->dev); in vcc_probe()
634 port->domain = kstrdup(domain, GFP_KERNEL); in vcc_probe()
642 timer_setup(&port->rx_timer, vcc_rx_timer, 0); in vcc_probe()
643 timer_setup(&port->tx_timer, vcc_tx_timer, 0); in vcc_probe()
645 dev_set_drvdata(&vdev->dev, port); in vcc_probe()
648 * IRQs until the port is up. in vcc_probe()
651 vio_port_up(&port->vio); in vcc_probe()
657 kfree(port->domain); in vcc_probe()
659 tty_unregister_device(vcc_tty_driver, port->index); in vcc_probe()
661 vcc_table_remove(port->index); in vcc_probe()
663 vio_ldc_free(&port->vio); in vcc_probe()
666 kfree(port); in vcc_probe()
672 * vcc_remove() - Terminate a VCC port
673 * @vdev: Pointer to VIO device of the VCC port
675 * Terminates a VCC port. Sets up the teardown of TTY and
682 struct vcc_port *port = dev_get_drvdata(&vdev->dev); in vcc_remove() local
684 if (!port) in vcc_remove()
687 del_timer_sync(&port->rx_timer); in vcc_remove()
688 del_timer_sync(&port->tx_timer); in vcc_remove()
694 if (port->tty) in vcc_remove()
695 tty_vhangup(port->tty); in vcc_remove()
698 * clients to this port in vcc_remove()
700 port = vcc_get(port->index, true); in vcc_remove()
702 if (WARN_ON(!port)) in vcc_remove()
705 tty_unregister_device(vcc_tty_driver, port->index); in vcc_remove()
707 del_timer_sync(&port->vio.timer); in vcc_remove()
708 vio_ldc_free(&port->vio); in vcc_remove()
711 if (port->tty) { in vcc_remove()
712 port->removed = true; in vcc_remove()
713 vcc_put(port, true); in vcc_remove()
715 vcc_table_remove(port->index); in vcc_remove()
717 kfree(port->vio.name); in vcc_remove()
718 kfree(port->domain); in vcc_remove()
719 kfree(port); in vcc_remove()
727 .type = "vcc-port",
742 struct vcc_port *port; in vcc_open() local
752 port = vcc_get_ne(tty->index); in vcc_open()
753 if (unlikely(!port)) { in vcc_open()
754 pr_err("VCC: open: Failed to find VCC port\n"); in vcc_open()
758 if (unlikely(!port->vio.lp)) { in vcc_open()
760 vcc_put(port, false); in vcc_open()
763 vccdbgl(port->vio.lp); in vcc_open()
765 vcc_put(port, false); in vcc_open()
767 if (unlikely(!tty->port)) { in vcc_open()
768 pr_err("VCC: open: TTY port not found\n"); in vcc_open()
772 if (unlikely(!tty->port->ops)) { in vcc_open()
777 return tty_port_open(tty->port, tty, vcc_file); in vcc_open()
790 if (unlikely(!tty->port)) { in vcc_close()
791 pr_err("VCC: close: TTY port not found\n"); in vcc_close()
795 tty_port_close(tty->port, tty, vcc_file); in vcc_close()
798 static void vcc_ldc_hup(struct vcc_port *port) in vcc_ldc_hup() argument
802 spin_lock_irqsave(&port->lock, flags); in vcc_ldc_hup()
804 if (vcc_send_ctl(port, VCC_CTL_HUP) < 0) in vcc_ldc_hup()
805 vcc_kick_tx(port); in vcc_ldc_hup()
807 spin_unlock_irqrestore(&port->lock, flags); in vcc_ldc_hup()
812 struct vcc_port *port; in vcc_hangup() local
819 port = vcc_get_ne(tty->index); in vcc_hangup()
820 if (unlikely(!port)) { in vcc_hangup()
821 pr_err("VCC: hangup: Failed to find VCC port\n"); in vcc_hangup()
825 if (unlikely(!tty->port)) { in vcc_hangup()
826 pr_err("VCC: hangup: TTY port not found\n"); in vcc_hangup()
827 vcc_put(port, false); in vcc_hangup()
831 vcc_ldc_hup(port); in vcc_hangup()
833 vcc_put(port, false); in vcc_hangup()
835 tty_port_hangup(tty->port); in vcc_hangup()
841 struct vcc_port *port; in vcc_write() local
853 port = vcc_get_ne(tty->index); in vcc_write()
854 if (unlikely(!port)) { in vcc_write()
855 pr_err("VCC: write: Failed to find VCC port"); in vcc_write()
859 spin_lock_irqsave(&port->lock, flags); in vcc_write()
861 pkt = &port->buffer; in vcc_write()
866 tosend = min(count, (VCC_BUFF_LEN - port->chars_in_buffer)); in vcc_write()
871 memcpy(&pkt->data[port->chars_in_buffer], &buf[total_sent], in vcc_write()
873 port->chars_in_buffer += tosend; in vcc_write()
879 vccdbgl(port->vio.lp); in vcc_write()
885 rv = ldc_write(port->vio.lp, pkt, (VIO_TAG_SIZE + tosend)); in vcc_write()
892 vcc_kick_tx(port); in vcc_write()
896 port->chars_in_buffer = 0; in vcc_write()
899 spin_unlock_irqrestore(&port->lock, flags); in vcc_write()
901 vcc_put(port, false); in vcc_write()
910 struct vcc_port *port; in vcc_write_room() local
918 port = vcc_get_ne(tty->index); in vcc_write_room()
919 if (unlikely(!port)) { in vcc_write_room()
920 pr_err("VCC: write_room: Failed to find VCC port\n"); in vcc_write_room()
924 num = VCC_BUFF_LEN - port->chars_in_buffer; in vcc_write_room()
926 vcc_put(port, false); in vcc_write_room()
933 struct vcc_port *port; in vcc_chars_in_buffer() local
941 port = vcc_get_ne(tty->index); in vcc_chars_in_buffer()
942 if (unlikely(!port)) { in vcc_chars_in_buffer()
943 pr_err("VCC: chars_in_buffer: Failed to find VCC port\n"); in vcc_chars_in_buffer()
947 num = port->chars_in_buffer; in vcc_chars_in_buffer()
949 vcc_put(port, false); in vcc_chars_in_buffer()
956 struct vcc_port *port; in vcc_break_ctl() local
964 port = vcc_get_ne(tty->index); in vcc_break_ctl()
965 if (unlikely(!port)) { in vcc_break_ctl()
966 pr_err("VCC: break_ctl: Failed to find VCC port\n"); in vcc_break_ctl()
972 vcc_put(port, false); in vcc_break_ctl()
976 spin_lock_irqsave(&port->lock, flags); in vcc_break_ctl()
978 if (vcc_send_ctl(port, VCC_CTL_BREAK) < 0) in vcc_break_ctl()
979 vcc_kick_tx(port); in vcc_break_ctl()
981 spin_unlock_irqrestore(&port->lock, flags); in vcc_break_ctl()
983 vcc_put(port, false); in vcc_break_ctl()
1012 pr_err("VCC: install: Failed to find VCC port\n"); in vcc_install()
1013 tty->port = NULL; in vcc_install()
1020 tty->port = port_tty; in vcc_install()
1031 struct vcc_port *port; in vcc_cleanup() local
1038 port = vcc_get(tty->index, true); in vcc_cleanup()
1039 if (port) { in vcc_cleanup()
1040 port->tty = NULL; in vcc_cleanup()
1042 if (port->removed) { in vcc_cleanup()
1044 kfree(port->vio.name); in vcc_cleanup()
1045 kfree(port->domain); in vcc_cleanup()
1046 kfree(port); in vcc_cleanup()
1048 vcc_put(port, true); in vcc_cleanup()
1052 tty_port_destroy(tty->port); in vcc_cleanup()
1053 kfree(tty->port); in vcc_cleanup()
1054 tty->port = NULL; in vcc_cleanup()