• 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()
595 rv = vio_driver_init(&port->vio, vdev, VDEV_CONSOLE_CON, vcc_versions, in vcc_probe()
600 port->vio.debug = vcc_dbg_vio; in vcc_probe()
603 rv = vio_ldc_alloc(&port->vio, &vcc_ldc_cfg, port); in vcc_probe()
607 spin_lock_init(&port->lock); in vcc_probe()
609 port->index = vcc_table_add(port); in vcc_probe()
610 if (port->index == -1) { in vcc_probe()
617 dev = tty_register_device(vcc_tty_driver, port->index, &vdev->dev); in vcc_probe()
638 port->domain = kstrdup(domain, GFP_KERNEL); in vcc_probe()
639 if (!port->domain) { in vcc_probe()
651 timer_setup(&port->rx_timer, vcc_rx_timer, 0); in vcc_probe()
652 timer_setup(&port->tx_timer, vcc_tx_timer, 0); in vcc_probe()
654 dev_set_drvdata(&vdev->dev, port); in vcc_probe()
657 * IRQs until the port is up. in vcc_probe()
660 vio_port_up(&port->vio); in vcc_probe()
666 kfree(port->domain); in vcc_probe()
668 tty_unregister_device(vcc_tty_driver, port->index); in vcc_probe()
670 vcc_table_remove(port->index); in vcc_probe()
672 vio_ldc_free(&port->vio); in vcc_probe()
676 kfree(port); in vcc_probe()
682 * vcc_remove() - Terminate a VCC port
683 * @vdev: Pointer to VIO device of the VCC port
685 * Terminates a VCC port. Sets up the teardown of TTY and
692 struct vcc_port *port = dev_get_drvdata(&vdev->dev); in vcc_remove() local
694 if (!port) in vcc_remove()
697 del_timer_sync(&port->rx_timer); in vcc_remove()
698 del_timer_sync(&port->tx_timer); in vcc_remove()
704 if (port->tty) in vcc_remove()
705 tty_vhangup(port->tty); in vcc_remove()
708 * clients to this port in vcc_remove()
710 port = vcc_get(port->index, true); in vcc_remove()
712 if (WARN_ON(!port)) in vcc_remove()
715 tty_unregister_device(vcc_tty_driver, port->index); in vcc_remove()
717 del_timer_sync(&port->vio.timer); in vcc_remove()
718 vio_ldc_free(&port->vio); in vcc_remove()
721 if (port->tty) { in vcc_remove()
722 port->removed = true; in vcc_remove()
723 vcc_put(port, true); in vcc_remove()
725 vcc_table_remove(port->index); in vcc_remove()
727 kfree(port->vio.name); in vcc_remove()
728 kfree(port->domain); in vcc_remove()
729 kfree(port); in vcc_remove()
737 .type = "vcc-port",
752 struct vcc_port *port; in vcc_open() local
762 port = vcc_get_ne(tty->index); in vcc_open()
763 if (unlikely(!port)) { in vcc_open()
764 pr_err("VCC: open: Failed to find VCC port\n"); in vcc_open()
768 if (unlikely(!port->vio.lp)) { in vcc_open()
770 vcc_put(port, false); in vcc_open()
773 vccdbgl(port->vio.lp); in vcc_open()
775 vcc_put(port, false); in vcc_open()
777 if (unlikely(!tty->port)) { in vcc_open()
778 pr_err("VCC: open: TTY port not found\n"); in vcc_open()
782 if (unlikely(!tty->port->ops)) { in vcc_open()
787 return tty_port_open(tty->port, tty, vcc_file); in vcc_open()
800 if (unlikely(!tty->port)) { in vcc_close()
801 pr_err("VCC: close: TTY port not found\n"); in vcc_close()
805 tty_port_close(tty->port, tty, vcc_file); in vcc_close()
808 static void vcc_ldc_hup(struct vcc_port *port) in vcc_ldc_hup() argument
812 spin_lock_irqsave(&port->lock, flags); in vcc_ldc_hup()
814 if (vcc_send_ctl(port, VCC_CTL_HUP) < 0) in vcc_ldc_hup()
815 vcc_kick_tx(port); in vcc_ldc_hup()
817 spin_unlock_irqrestore(&port->lock, flags); in vcc_ldc_hup()
822 struct vcc_port *port; in vcc_hangup() local
829 port = vcc_get_ne(tty->index); in vcc_hangup()
830 if (unlikely(!port)) { in vcc_hangup()
831 pr_err("VCC: hangup: Failed to find VCC port\n"); in vcc_hangup()
835 if (unlikely(!tty->port)) { in vcc_hangup()
836 pr_err("VCC: hangup: TTY port not found\n"); in vcc_hangup()
837 vcc_put(port, false); in vcc_hangup()
841 vcc_ldc_hup(port); in vcc_hangup()
843 vcc_put(port, false); in vcc_hangup()
845 tty_port_hangup(tty->port); in vcc_hangup()
851 struct vcc_port *port; in vcc_write() local
863 port = vcc_get_ne(tty->index); in vcc_write()
864 if (unlikely(!port)) { in vcc_write()
865 pr_err("VCC: write: Failed to find VCC port"); in vcc_write()
869 spin_lock_irqsave(&port->lock, flags); in vcc_write()
871 pkt = &port->buffer; in vcc_write()
876 tosend = min(count, (VCC_BUFF_LEN - port->chars_in_buffer)); in vcc_write()
881 memcpy(&pkt->data[port->chars_in_buffer], &buf[total_sent], in vcc_write()
883 port->chars_in_buffer += tosend; in vcc_write()
889 vccdbgl(port->vio.lp); in vcc_write()
895 rv = ldc_write(port->vio.lp, pkt, (VIO_TAG_SIZE + tosend)); in vcc_write()
902 vcc_kick_tx(port); in vcc_write()
906 port->chars_in_buffer = 0; in vcc_write()
909 spin_unlock_irqrestore(&port->lock, flags); in vcc_write()
911 vcc_put(port, false); in vcc_write()
920 struct vcc_port *port; in vcc_write_room() local
928 port = vcc_get_ne(tty->index); in vcc_write_room()
929 if (unlikely(!port)) { in vcc_write_room()
930 pr_err("VCC: write_room: Failed to find VCC port\n"); in vcc_write_room()
934 num = VCC_BUFF_LEN - port->chars_in_buffer; in vcc_write_room()
936 vcc_put(port, false); in vcc_write_room()
943 struct vcc_port *port; in vcc_chars_in_buffer() local
951 port = vcc_get_ne(tty->index); in vcc_chars_in_buffer()
952 if (unlikely(!port)) { in vcc_chars_in_buffer()
953 pr_err("VCC: chars_in_buffer: Failed to find VCC port\n"); in vcc_chars_in_buffer()
957 num = port->chars_in_buffer; in vcc_chars_in_buffer()
959 vcc_put(port, false); in vcc_chars_in_buffer()
966 struct vcc_port *port; in vcc_break_ctl() local
974 port = vcc_get_ne(tty->index); in vcc_break_ctl()
975 if (unlikely(!port)) { in vcc_break_ctl()
976 pr_err("VCC: break_ctl: Failed to find VCC port\n"); in vcc_break_ctl()
982 vcc_put(port, false); in vcc_break_ctl()
986 spin_lock_irqsave(&port->lock, flags); in vcc_break_ctl()
988 if (vcc_send_ctl(port, VCC_CTL_BREAK) < 0) in vcc_break_ctl()
989 vcc_kick_tx(port); in vcc_break_ctl()
991 spin_unlock_irqrestore(&port->lock, flags); in vcc_break_ctl()
993 vcc_put(port, false); in vcc_break_ctl()
1022 pr_err("VCC: install: Failed to find VCC port\n"); in vcc_install()
1023 tty->port = NULL; in vcc_install()
1030 tty->port = port_tty; in vcc_install()
1041 struct vcc_port *port; in vcc_cleanup() local
1048 port = vcc_get(tty->index, true); in vcc_cleanup()
1049 if (port) { in vcc_cleanup()
1050 port->tty = NULL; in vcc_cleanup()
1052 if (port->removed) { in vcc_cleanup()
1054 kfree(port->vio.name); in vcc_cleanup()
1055 kfree(port->domain); in vcc_cleanup()
1056 kfree(port); in vcc_cleanup()
1058 vcc_put(port, true); in vcc_cleanup()
1062 tty_port_destroy(tty->port); in vcc_cleanup()
1063 kfree(tty->port); in vcc_cleanup()
1064 tty->port = NULL; in vcc_cleanup()