usbip: usbip_host_common: Use new error codes to return request status
authorShuah Khan <shuahkh@osg.samsung.com>
Wed, 7 Mar 2018 20:42:25 +0000 (13:42 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 Mar 2018 17:17:08 +0000 (09:17 -0800)
Currently ST_OK and ST_NA are the only values used to communicate
status of a request from a client. Use new error codes to clearly
indicate what failed. For example, when client sends request to
import a device that isn't export-able, send ST_DEV_BUSY to the client.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/usb/usbip/libsrc/usbip_host_common.c

index 6ff7b601f854562090b348097963554113e3fb75..dc93fadbee96355d5cc81ecb600c60948ecd67be 100644 (file)
@@ -234,14 +234,17 @@ int usbip_export_device(struct usbip_exported_device *edev, int sockfd)
                switch (edev->status) {
                case SDEV_ST_ERROR:
                        dbg("status SDEV_ST_ERROR");
+                       ret = ST_DEV_ERR;
                        break;
                case SDEV_ST_USED:
                        dbg("status SDEV_ST_USED");
+                       ret = ST_DEV_BUSY;
                        break;
                default:
                        dbg("status unknown: 0x%x", edev->status);
+                       ret = -1;
                }
-               return -1;
+               return ret;
        }
 
        /* only the first interface is true */