usb: Move ffs services cleanup to hw_cfs_gadget_close 94/191294/1 submit/tizen/20181015.121248
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Mon, 15 Oct 2018 11:35:21 +0000 (13:35 +0200)
committerPaweł Szewczyk <p.szewczyk@samsung.com>
Mon, 15 Oct 2018 11:35:21 +0000 (13:35 +0200)
Change-Id: I1fc61542b8228ff038b64ee1df3cd5b6c3947a1c
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
hw/usb_cfs_client_common.c

index 0fd191230f36c035030d37911f9c475eb266d648..8069f4dc27fde703d15662177ec1db25a152e269 100644 (file)
@@ -836,8 +836,6 @@ static int cfs_enable(struct usb_client *usb)
 static int cfs_disable(struct usb_client *usb)
 {
        struct cfs_client *cfs_client;
-       usbg_function *func;
-       int ret;
 
        if (!usb)
                return -EINVAL;
@@ -845,29 +843,6 @@ static int cfs_disable(struct usb_client *usb)
        cfs_client = container_of(usb, struct cfs_client,
                                  client);
 
-       usbg_for_each_function(func, cfs_client->gadget) {
-               char *name = (char *)usbg_get_function_type_str(
-                                           usbg_get_function_type(func));
-               char *instance = (char *)usbg_get_function_instance(func);
-               struct usb_function *usb_func;
-
-               ret = cfs_find_func(name, instance);
-               if (ret < 0)
-                       continue;
-
-               usb_func = _available_funcs[ret];
-               if (usb_func->function_group ==
-                   USB_FUNCTION_GROUP_WITH_SERVICE) {
-                       struct usb_function_with_service *fws;
-
-                       fws = container_of(usb_func,
-                                          struct usb_function_with_service,
-                                          func);
-                       systemd_stop_socket(fws->service);
-                       systemd_stop_service(fws->service);
-               }
-       }
-
        return usbg_disable_gadget(cfs_client->gadget);
 }
 
@@ -926,6 +901,8 @@ EXPORT
 int hw_cfs_gadget_close(struct hw_common *common)
 {
        struct cfs_client *cfs_client;
+       usbg_function *func;
+       int ret;
 
        if (!common)
                return -EINVAL;
@@ -933,6 +910,29 @@ int hw_cfs_gadget_close(struct hw_common *common)
        cfs_client = container_of(common, struct cfs_client,
                                  client.common);
 
+       usbg_for_each_function(func, cfs_client->gadget) {
+               char *name = (char *)usbg_get_function_type_str(
+                                           usbg_get_function_type(func));
+               char *instance = (char *)usbg_get_function_instance(func);
+               struct usb_function *usb_func;
+
+               ret = cfs_find_func(name, instance);
+               if (ret < 0)
+                       continue;
+
+               usb_func = _available_funcs[ret];
+               if (usb_func->function_group ==
+                   USB_FUNCTION_GROUP_WITH_SERVICE) {
+                       struct usb_function_with_service *fws;
+
+                       fws = container_of(usb_func,
+                                          struct usb_function_with_service,
+                                          func);
+                       systemd_stop_socket(fws->service);
+                       systemd_stop_service(fws->service);
+               }
+       }
+
        /*
         * For now we don't check for errors
         * but we should somehow handle them