Remove is_emulator() on usb 83/225683/3
authorINSUN PYO <insun.pyo@samsung.com>
Mon, 24 Feb 2020 03:10:01 +0000 (12:10 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 24 Feb 2020 11:05:49 +0000 (11:05 +0000)
Deviced only uses three functions in usb_client hal: disable, enable and reconfigure_gadget.
If emulator's usb_client hal provides these three functions as dummy,
deviced can be used on both the emulator and target as a single code.

Change-Id: Ie2f32403e9767f65d4166ab8be6c83b68891b452

src/usb/usb.c

index 2d52bf2..b551378 100644 (file)
@@ -274,12 +274,10 @@ static int usb_enable(unsigned int mode)
        if (usb_state_get_current_mode() != USB_FUNCTION_NONE)
                usb_state_update_state(USB_CONNECTED, USB_FUNCTION_NONE);
 
-       if (!is_emulator()) {
-               ret = usb_config_enable();
-               if (ret < 0) {
-                       _E("Failed to enable usb config: %d", ret);
-                       return ret;
-               }
+       ret = usb_config_enable();
+       if (ret < 0) {
+               _E("Failed to enable usb config: %d", ret);
+               return ret;
        }
 
        usb_state_update_state(USB_CONNECTED, mode);
@@ -301,11 +299,9 @@ static int usb_disable(void)
                        usb_state_update_state(USB_DISCONNECTED, USB_FUNCTION_NONE);
        }
 
-       if (!is_emulator()) {
-               ret = usb_config_disable();
-               if (ret != 0)
-                       _E("Failed to disable usb config: %d", ret);
-       }
+       ret = usb_config_disable();
+       if (ret != 0)
+               _E("Failed to disable usb config: %d", ret);
 
        if (disp_plgn.pm_unlock_internal)
                disp_plgn.pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE);
@@ -326,12 +322,10 @@ int usb_change_mode(unsigned mode)
                }
        }
 
-       if (!is_emulator()) {
-               ret = usb_change_gadget(mode);
-               if (ret < 0) {
-                       _E("Failed to change gadget: %d", ret);
-                       mode = usb_state_get_selected_mode();
-               }
+       ret = usb_change_gadget(mode);
+       if (ret < 0) {
+               _E("Failed to change gadget: %d", ret);
+               mode = usb_state_get_selected_mode();
        }
 
        (void)usb_state_set_selected_mode(mode);
@@ -435,21 +429,19 @@ static void usb_init(void *data)
 
        usb_state_retrieve_selected_mode();
 
-       if (!is_emulator()) {
-               ret = usb_probe();
-               if (ret < 0) {
-                       _E("USB client cannot be used: %d", ret);
-                       return;
-               }
+       ret = usb_probe();
+       if (ret < 0) {
+               _E("USB client cannot be used: %d", ret);
+               return;
+       }
 
-               ret = usb_config_init();
-               if (ret < 0)
-                       _E("Failed to initialize usb configuation.");
+       ret = usb_config_init();
+       if (ret < 0)
+               _E("Failed to initialize usb configuation.");
 
-               ret = register_udev_uevent_control(&uh);
-               if (ret < 0)
-                       _E("Failed to register udev event(%d)", ret);
-       }
+       ret = register_udev_uevent_control(&uh);
+       if (ret < 0)
+               _E("Failed to register udev event(%d)", ret);
 
        ret = usb_dbus_init();
        if (ret < 0)
@@ -465,11 +457,9 @@ static void usb_exit(void *data)
        remove_usb_tethering_handler();
        usb_state_update_state(USB_DISCONNECTED, USB_FUNCTION_NONE);
 
-       if (!is_emulator()) {
-               unregister_udev_uevent_control(&uh);
-               usb_config_deinit();
-               usb_release();
-       }
+       unregister_udev_uevent_control(&uh);
+       usb_config_deinit();
+       usb_release();
 }
 
 struct extcon_ops extcon_usb_ops = {