Add a set of usb commands to the usbutils defines for mcp2210 comms, and use the same command name for send and receive.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
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 {