/* We only start I/O when something is connected to both sides of this port. If nothing is listening on the host side, we may be pointlessly filling up our TX buffers and FIFO.  */
static int gs_start_io(struct gs_port *port)
/* We only start I/O when something is connected to both sides of this port. If nothing is listening on the host side, we may be pointlessly filling up our TX buffers and FIFO.  */
static int gs_start_io(struct gs_port *port)
{
	struct list_head	*head = &port->read_pool;
	struct usb_ep		*ep = port->port_usb->out;
	int			status;
	unsigned		started;
	status = gs_alloc_requests(ep, head, gs_read_complete);
	if (status)
		return status;
	status = gs_alloc_requests(port->port_usb->in, &port->write_pool,
			gs_write_complete);
	if (status) {
		gs_free_requests(ep, head);
		return status;
	}
	port->n_read = 0;
	started = gs_start_rx(port);
	if (started) {
		tty_wakeup(port->port_tty);
	} else {
		gs_free_requests(ep, head);
		gs_free_requests(port->port_usb->in, &port->write_pool);
		status = -EIO;
	}
	return status;
}