/* * Tty port functions */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include void tty_port_init(struct tty_port *port) { memset(port, 0, sizeof(*port)); init_waitqueue_head(&port->open_wait); init_waitqueue_head(&port->close_wait); mutex_init(&port->mutex); port->close_delay = (50 * HZ) / 100; port->closing_wait = (3000 * HZ) / 100; } EXPORT_SYMBOL(tty_port_init); int tty_port_alloc_xmit_buf(struct tty_port *port) { /* We may sleep in get_zeroed_page() */ mutex_lock(&port->mutex); if (port->xmit_buf == NULL) port->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); mutex_unlock(&port->mutex); if (port->xmit_buf == NULL) return -ENOMEM; return 0; } EXPORT_SYMBOL(tty_port_alloc_xmit_buf); void tty_port_free_xmit_buf(struct tty_port *port) { mutex_lock(&port->mutex); if (port->xmit_buf != NULL) { free_page((unsigned long)port->xmit_buf); port->xmit_buf = NULL; } mutex_unlock(&port->mutex); } EXPORT_SYMBOL(tty_port_free_xmit_buf);