Commit 5015e2580c497d73bd160db7560b7e7093f78269

Con Kolivas 2014-01-03T12:00:23

Add a set of usb commands to the usbutils defines for mcp2210 comms, and use the same command name for send and receive.

diff --git a/mcp2210.c b/mcp2210.c
index 0d4ae5c..d0facc0 100644
--- a/mcp2210.c
+++ b/mcp2210.c
@@ -10,26 +10,25 @@
 #include "usbutils.h"
 #include "mcp2210.h"
 
-bool mcp2210_send_recv(struct cgpu_info *cgpu, char *buf, enum usb_cmds send_cmd,
-		       enum usb_cmds recv_cmd)
+bool mcp2210_send_recv(struct cgpu_info *cgpu, char *buf, enum usb_cmds cmd)
 {
 	int amount, err;
 
 	if (unlikely(cgpu->usbinfo.nodev))
 		return false;
 
-	err = usb_write(cgpu, buf, MCP2210_BUFFER_LENGTH, &amount, send_cmd);
+	err = usb_write(cgpu, buf, MCP2210_BUFFER_LENGTH, &amount, cmd);
 	if (err || amount != MCP2210_BUFFER_LENGTH) {
 		applog(LOG_WARNING, "%s %d: Error %d sending %s sent %d of %d",
-		       cgpu->drv->name, cgpu->device_id, err, usb_cmdname(send_cmd),
+		       cgpu->drv->name, cgpu->device_id, err, usb_cmdname(cmd),
 		       amount, MCP2210_BUFFER_LENGTH);
 		return false;
 	}
 
-	err = usb_read(cgpu, buf, MCP2210_BUFFER_LENGTH, &amount, recv_cmd);
+	err = usb_read(cgpu, buf, MCP2210_BUFFER_LENGTH, &amount, cmd);
 	if (err || amount != MCP2210_BUFFER_LENGTH) {
 		applog(LOG_WARNING, "%s %d: Error %d receiving %s received %d of %d",
-		       cgpu->drv->name, cgpu->device_id, err, usb_cmdname(recv_cmd),
+		       cgpu->drv->name, cgpu->device_id, err, usb_cmdname(cmd),
 		       amount, MCP2210_BUFFER_LENGTH);
 		return false;
 	}
diff --git a/mcp2210.h b/mcp2210.h
index 937a978..e565baf 100644
--- a/mcp2210.h
+++ b/mcp2210.h
@@ -29,6 +29,6 @@
 #define MCP2210_SPI_TRANSFER_ERROR_NA	0xF7	// SPI not available due to external owner
 #define MCP2210_SPI_TRANSFER_ERROR_IP	0xF8	// SPI not available due to transfer in progress
 
-bool mcp2210_send_recv(struct cgpu_info *cgpu, char *buf, enum usb_cmds send_cmd,
-		       enum usb_cmds recv_cmd);
+bool mcp2210_send_recv(struct cgpu_info *cgpu, char *buf, enum usb_cmds cmd);
+
 #endif /* MCP2210_H */
diff --git a/usbutils.h b/usbutils.h
index 84ae2c2..a694f2b 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -386,7 +386,14 @@ struct cg_usb_info {
 	USB_ADD_COMMAND(C_HF_NOTICE, "HFNotice") \
 	USB_ADD_COMMAND(C_HF_GETHEADER, "HFGetHeader") \
 	USB_ADD_COMMAND(C_HF_GETDATA, "HFGetData") \
-	USB_ADD_COMMAND(C_HF_CLEAR_READ, "HFClearRead")
+	USB_ADD_COMMAND(C_HF_CLEAR_READ, "HFClearRead") \
+	USB_ADD_COMMAND(C_MCP_GETGPIOSETTING, "MCPGetGPIOSetting") \
+	USB_ADD_COMMAND(C_MCP_SETGPIOSETTING, "MCPSetGPIOSetting") \
+	USB_ADD_COMMAND(C_MCP_GETGPIOPINVAL, "MCPGetGPIOPinVal") \
+	USB_ADD_COMMAND(C_MCP_SETGPIOPINDIR, "MCPSetGPIOPinDir") \
+	USB_ADD_COMMAND(C_MCP_SETSPISETTING, "MCPSetSPISetting") \
+	USB_ADD_COMMAND(C_MCP_GETSPISETTING, "MCPGetSPISetting") \
+	USB_ADD_COMMAND(C_MCP_SPITRANSFER, "MCPSPITransfer")
 
 /* Create usb_cmds enum from USB_PARSE_COMMANDS macro */
 enum usb_cmds {