summaryrefslogtreecommitdiff
path: root/tools/usb/usbip/libsrc/usbip_common.c
diff options
context:
space:
mode:
authorShuah Khan <shuahkh@osg.samsung.com>2018-03-07 23:42:24 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-03-09 20:17:08 +0300
commitf6bcbf2e24eb10275b6614ccd9cab3e7d93748de (patch)
tree4cb8581885359c7503e6c16144e7561c133820d9 /tools/usb/usbip/libsrc/usbip_common.c
parent8fe8f5821c4ebd1c80099ff0d2b197fd17581a2c (diff)
downloadlinux-f6bcbf2e24eb10275b6614ccd9cab3e7d93748de.tar.xz
usbip: tools: add more error codes for usbip request/reply messages
Currently ST_OK and ST_NA are the only values defined to communicate status of a request from a client. Add more error codes to clearly indicate what failed. For example, when client sends request to import a device that isn't export-able, server can send a specific error code to the client. Existing defines are moved to a common header in libsrc to be included in the libusbip_la-usbip_common.o to be used by all the usbip tools. Supporting interface to print error strings is added to the common lib. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/usb/usbip/libsrc/usbip_common.c')
-rw-r--r--tools/usb/usbip/libsrc/usbip_common.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/usb/usbip/libsrc/usbip_common.c b/tools/usb/usbip/libsrc/usbip_common.c
index 001bb8e8f668..bb424638d75b 100644
--- a/tools/usb/usbip/libsrc/usbip_common.c
+++ b/tools/usb/usbip/libsrc/usbip_common.c
@@ -66,6 +66,29 @@ const char *usbip_speed_string(int num)
return "Unknown Speed";
}
+struct op_common_status_string {
+ int num;
+ char *desc;
+};
+
+static struct op_common_status_string op_common_status_strings[] = {
+ { ST_OK, "Request Completed Successfully" },
+ { ST_NA, "Request Failed" },
+ { ST_DEV_BUSY, "Device busy (exported)" },
+ { ST_DEV_ERR, "Device in error state" },
+ { ST_NODEV, "Device not found" },
+ { ST_ERROR, "Unexpected response" },
+ { 0, NULL}
+};
+
+const char *usbip_op_common_status_string(int status)
+{
+ for (int i = 0; op_common_status_strings[i].desc != NULL; i++)
+ if (op_common_status_strings[i].num == status)
+ return op_common_status_strings[i].desc;
+
+ return "Unknown Op Common Status";
+}
#define DBG_UDEV_INTEGER(name)\
dbg("%-20s = %x", to_string(name), (int) udev->name)