[PATCH v5 02/10] USB: io_ti: Add timeout parameter to ti_vsend_sync()

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

 



From: "Peter E. Berger" <pberger@xxxxxxxxxxx>

Instead of having ti_vsend_sync() decide when to use non-default timeouts,
make "timeout" a parameter and leave the decision to the caller.

Signed-off-by: Peter E. Berger <pberger@xxxxxxxxxxx>
---
 drivers/usb/serial/io_ti.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 3206a6f..75f08c3 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -210,6 +210,10 @@ static int edge_create_sysfs_attrs(struct usb_serial_port *port);
 static int edge_remove_sysfs_attrs(struct usb_serial_port *port);
 
 
+/* Timeouts in msecs: firmware downloads take longer */
+#define TI_VSEND_TIMEOUT_DEFAULT 1000
+#define TI_VSEND_TIMEOUT_FW_DOWNLOAD 10000
+
 static int ti_vread_sync(struct usb_device *dev, __u8 request,
 				__u16 value, __u16 index, u8 *data, int size)
 {
@@ -228,14 +232,11 @@ static int ti_vread_sync(struct usb_device *dev, __u8 request,
 	return 0;
 }
 
-static int ti_vsend_sync(struct usb_device *dev, __u8 request,
+static int ti_vsend_sync(struct usb_device *dev, __u8 request, int timeout,
 				__u16 value, __u16 index, u8 *data, int size)
 {
 	int status;
-	int timeout = 1000;	/* Timeout in msecs */
 
-	if (request == UMPC_COPY_DNLD_TO_I2C)	/* Downloads take longer */
-		timeout = 10000;
 	status = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request,
 			(USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT),
 			value, index, data, size, timeout);
@@ -253,7 +254,8 @@ static int send_cmd(struct usb_device *dev, __u8 command,
 				__u8 moduleid, __u16 value, u8 *data,
 				int size)
 {
-	return ti_vsend_sync(dev, command, value, moduleid, data, size);
+	return ti_vsend_sync(dev, command, TI_VSEND_TIMEOUT_DEFAULT,
+			value, moduleid, data, size);
 }
 
 /* clear tx/rx buffers and fifo in TI UMP */
@@ -382,8 +384,8 @@ static int write_boot_mem(struct edgeport_serial *serial,
 
 	for (i = 0; i < length; ++i) {
 		status = ti_vsend_sync(serial->serial->dev,
-				UMPC_MEMORY_WRITE, buffer[i],
-				(__u16)(i + start_address), NULL, 0);
+				UMPC_MEMORY_WRITE, TI_VSEND_TIMEOUT_DEFAULT,
+				buffer[i], (__u16)(i + start_address), NULL, 0);
 		if (status)
 			return status;
 	}
@@ -425,8 +427,8 @@ static int write_i2c_mem(struct edgeport_serial *serial,
 	 */
 	be_start_address = swab16((u16)start_address);
 	status = ti_vsend_sync(serial->serial->dev,
-				UMPC_MEMORY_WRITE, (__u16)address_type,
-				be_start_address,
+				UMPC_MEMORY_WRITE, TI_VSEND_TIMEOUT_DEFAULT,
+				(__u16)address_type, be_start_address,
 				buffer,	write_length);
 	if (status) {
 		dev_dbg(dev, "%s - ERROR %d\n", __func__, status);
@@ -456,7 +458,8 @@ static int write_i2c_mem(struct edgeport_serial *serial,
 		 *       order regardless of host byte order.
 		 */
 		be_start_address = swab16((u16)start_address);
-		status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE,
+		status = ti_vsend_sync(serial->serial->dev,
+				UMPC_MEMORY_WRITE, TI_VSEND_TIMEOUT_DEFAULT,
 				(__u16)address_type,
 				be_start_address,
 				buffer, write_length);
@@ -1132,6 +1135,7 @@ static int download_fw(struct edgeport_serial *serial)
 				/* Reset UMP -- Back to BOOT MODE */
 				status = ti_vsend_sync(serial->serial->dev,
 						UMPC_HARDWARE_RESET,
+						TI_VSEND_TIMEOUT_DEFAULT,
 						0, 0, NULL, 0);
 
 				dev_dbg(dev, "%s - HARDWARE RESET return %d\n", __func__, status);
@@ -1232,7 +1236,9 @@ static int download_fw(struct edgeport_serial *serial)
 
 			/* Tell firmware to copy download image into I2C */
 			status = ti_vsend_sync(serial->serial->dev,
-					UMPC_COPY_DNLD_TO_I2C, 0, 0, NULL, 0);
+					UMPC_COPY_DNLD_TO_I2C,
+					TI_VSEND_TIMEOUT_FW_DOWNLOAD,
+					0, 0, NULL, 0);
 
 		  	dev_dbg(dev, "%s - Update complete 0x%x\n", __func__, status);
 			if (status) {
-- 
1.8.3.1

--
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