[PATCH 29/29] USB: serial: f81534: clean up port bulk-out setup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Setup each port to use the first bulk-out endpoint in calc_num_ports so
that core allocates the corresponding port resources for us.

Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>
---
 drivers/usb/serial/f81534.c | 62 ++++++++-------------------------------------
 1 file changed, 11 insertions(+), 51 deletions(-)

diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c
index 365e3acd6c6c..3d616a2a9f96 100644
--- a/drivers/usb/serial/f81534.c
+++ b/drivers/usb/serial/f81534.c
@@ -687,6 +687,17 @@ static int f81534_calc_num_ports(struct usb_serial *serial,
 		num_port = 4;		/* Nothing found, oldest version IC */
 	}
 
+	/*
+	 * Setup bulk-out endpoint multiplexing. All ports share the same
+	 * bulk-out endpoint.
+	 */
+	BUILD_BUG_ON(ARRAY_SIZE(epds->bulk_out) < F81534_NUM_PORT);
+
+	for (i = 1; i < num_port; ++i)
+		epds->bulk_out[i] = epds->bulk_out[0];
+
+	epds->num_bulk_out = num_port;
+
 	return num_port;
 }
 
@@ -1078,53 +1089,6 @@ static void f81534_write_usb_callback(struct urb *urb)
 	}
 }
 
-static int f81534_setup_ports(struct usb_serial *serial)
-{
-	struct usb_serial_port *port;
-	u8 port0_out_address;
-	int buffer_size;
-	size_t i;
-
-	/*
-	 * In our system architecture, we had 2 or 4 serial ports,
-	 * but only get 1 set of bulk in/out endpoints.
-	 *
-	 * The usb-serial subsystem will generate port 0 data,
-	 * but port 1/2/3 will not. It's will generate write URB and buffer
-	 * by following code and use the port0 read URB for read operation.
-	 */
-	for (i = 1; i < serial->num_ports; ++i) {
-		port0_out_address = serial->port[0]->bulk_out_endpointAddress;
-		buffer_size = serial->port[0]->bulk_out_size;
-		port = serial->port[i];
-
-		if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL))
-			return -ENOMEM;
-
-		port->bulk_out_size = buffer_size;
-		port->bulk_out_endpointAddress = port0_out_address;
-
-		port->write_urbs[0] = usb_alloc_urb(0, GFP_KERNEL);
-		if (!port->write_urbs[0])
-			return -ENOMEM;
-
-		port->bulk_out_buffers[0] = kzalloc(buffer_size, GFP_KERNEL);
-		if (!port->bulk_out_buffers[0])
-			return -ENOMEM;
-
-		usb_fill_bulk_urb(port->write_urbs[0], serial->dev,
-				usb_sndbulkpipe(serial->dev,
-					port0_out_address),
-				port->bulk_out_buffers[0], buffer_size,
-				serial->type->write_bulk_callback, port);
-
-		port->write_urb = port->write_urbs[0];
-		port->bulk_out_buffer = port->bulk_out_buffers[0];
-	}
-
-	return 0;
-}
-
 static int f81534_attach(struct usb_serial *serial)
 {
 	struct f81534_serial_private *serial_priv;
@@ -1141,10 +1105,6 @@ static int f81534_attach(struct usb_serial *serial)
 
 	mutex_init(&serial_priv->urb_mutex);
 
-	status = f81534_setup_ports(serial);
-	if (status)
-		return status;
-
 	/* Check had custom setting */
 	status = f81534_find_config_idx(serial, &serial_priv->setting_idx);
 	if (status) {
-- 
2.12.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux