usb-host-test: ignore failure module load/unload when it is built-in 13/209713/2 accepted/tizen/unified/20190711.062844 submit/tizen/20190710.072253
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 9 Jul 2019 09:23:59 +0000 (18:23 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Wed, 10 Jul 2019 07:22:10 +0000 (16:22 +0900)
Even though dummy_hcd and usb_f_fs are kernel built-in module,
module load failure blocks usb-host-test. Just ignore the failure
of module load/unload when it is built-in.

Change-Id: I3bd7084cf2ce4b5806d272662ecd16f7b97cc11c
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
src/usb-host-test/usb-host-test.c

index fc687da..5ba6d91 100644 (file)
@@ -32,6 +32,8 @@
 #include "core/devices.h"
 #include "core/list.h"
 
+#define SYS_DUMMY_HCD_PATH "/sys/module/dummy_hcd"
+#define SYS_USB_FFS_PATH "/sys/kernel/config/usb_gadget/hal-gadget/functions/ffs.sdb.default"
 #define FFS_PATH "/run/usb-host-test-ffs"
 #define GADGET_SCHEME_PATH "/etc/deviced/usb-host-test/test_gadget.gs"
 #define FFS_INSTANCE_NAME "usb-host-test"
@@ -338,8 +340,7 @@ static void service_stopped_handler(GDBusConnection  *conn,
 
                ret = unload_module("dummy_hcd");
                if (ret < 0) {
-                       _E("Error unloading module: %d", ret);
-                       goto out1;
+                       _I("Unable to unload module: %d", ret);
                }
 
                if (using_legacy) {
@@ -351,8 +352,7 @@ static void service_stopped_handler(GDBusConnection  *conn,
                } else {
                        ret = unload_module("usb_f_fs");
                        if (ret < 0) {
-                               _E("Error unloading module: %d", ret);
-                               goto out;
+                               _I("Unable to unload module: %d", ret);
                        }
                }
 
@@ -378,8 +378,11 @@ int start()
 
        ret = load_module("dummy_hcd", NULL);
        if (ret < 0) {
-               _E("Error loading module: %d", ret);
-               return ret;
+               /* if dummy_hcd is built-in, then just ignore */
+               if (stat(SYS_DUMMY_HCD_PATH, &st) < 0) {
+                       _E("Error loading module: %d", ret);
+                       return ret;
+               }
        }
 
        /* If you need to setup vid, pid or other data use module parameters */
@@ -398,8 +401,11 @@ int start()
 
                ret = load_module("usb_f_fs", NULL);
                if (ret < 0) {
-                       _E("Error loading module: %d", ret);
-                       return ret;
+                       /* if usb_f_fs is already used, then just ignore */
+                       if (stat(SYS_USB_FFS_PATH, &st) < 0) {
+                               _E("Error loading module: %d", ret);
+                               return ret;
+                       }
                }
 
                ret = load_gadget();