[PATCH 2/4] staging: comedi: vmk80xx: simplify vmk80xx_reset_device()

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

 



vmk80xx_reset_device() is called during initialization of a Velleman
K8055 (aka VM110) to send a reset command to the hardware.  The current
function is a bit long-winded and doesn't set the TRANS_OUT_BUSY flag to
prevent re-use of the transmit buffer while the URB is in progress.

Rewrite the function to use vmk80xx_write_packet() to send the command.

Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
---
 drivers/staging/comedi/drivers/vmk80xx.c | 44 +++++++-------------------------
 1 file changed, 9 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c
index 0a74e6c..51859b8 100644
--- a/drivers/staging/comedi/drivers/vmk80xx.c
+++ b/drivers/staging/comedi/drivers/vmk80xx.c
@@ -277,41 +277,6 @@ static void vmk80xx_read_eeprom(struct vmk80xx_private *devpriv, int flag)
 		strncpy(devpriv->fw.ic6_vers, rx + 25, 24);
 }
 
-static int vmk80xx_reset_device(struct vmk80xx_private *devpriv)
-{
-	struct usb_device *usb = devpriv->usb;
-	unsigned char *tx_buf = devpriv->usb_tx_buf;
-	struct urb *urb;
-	unsigned int tx_pipe;
-	int ival;
-	size_t size;
-
-	urb = usb_alloc_urb(0, GFP_KERNEL);
-	if (!urb)
-		return -ENOMEM;
-
-	tx_pipe = usb_sndintpipe(usb, 0x01);
-
-	ival = devpriv->ep_tx->bInterval;
-	size = le16_to_cpu(devpriv->ep_tx->wMaxPacketSize);
-
-	tx_buf[0] = VMK8055_CMD_RST;
-	tx_buf[1] = 0x00;
-	tx_buf[2] = 0x00;
-	tx_buf[3] = 0x00;
-	tx_buf[4] = 0x00;
-	tx_buf[5] = 0x00;
-	tx_buf[6] = 0x00;
-	tx_buf[7] = 0x00;
-
-	usb_fill_int_urb(urb, usb, tx_pipe, tx_buf, size,
-			 vmk80xx_tx_callback, devpriv, ival);
-
-	usb_anchor_urb(urb, &devpriv->tx_anchor);
-
-	return usb_submit_urb(urb, GFP_KERNEL);
-}
-
 static void vmk80xx_build_int_urb(struct urb *urb, int flag)
 {
 	struct vmk80xx_private *devpriv = urb->context;
@@ -468,6 +433,15 @@ exit:
 	return retval;
 }
 
+static int vmk80xx_reset_device(struct vmk80xx_private *devpriv)
+{
+	size_t size;
+
+	size = le16_to_cpu(devpriv->ep_tx->wMaxPacketSize);
+	memset(devpriv->usb_tx_buf, 0, size);
+	return vmk80xx_write_packet(devpriv, VMK8055_CMD_RST);
+}
+
 #define DIR_IN  1
 #define DIR_OUT 2
 
-- 
1.8.1.2

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux