diff options
author | INSUN PYO <insun.pyo@samsung.com> | 2020-01-22 15:44:05 +0900 |
---|---|---|
committer | INSUN PYO <insun.pyo@samsung.com> | 2020-01-22 23:39:13 +0000 |
commit | 2cac3dee59d0bfe6649b2e908c0e4c64b875037e (patch) | |
tree | a775df987c6a4ab8e188c9517242a1ebc0824930 /hw/usb_cfs_client_common.c | |
parent | fc3750ffd68a709dc3a733b446ebe8b208284a22 (diff) | |
download | libdevice-node-2cac3dee59d0bfe6649b2e908c0e4c64b875037e.tar.gz libdevice-node-2cac3dee59d0bfe6649b2e908c0e4c64b875037e.tar.bz2 libdevice-node-2cac3dee59d0bfe6649b2e908c0e4c64b875037e.zip |
Refactoring usb gadget headersubmit/tizen_5.5/20200122.234617accepted/tizen/5.5/unified/20200128.034023
Merge "struct usb_function_witch_service" into "struct usb_function".
Change-Id: I9ed616f7e5933594093e9a027dd7d56cf1b016c8
(cherry picked from commit c76e213a9ecef080b7dc3ae92105969e9d531deb)
Diffstat (limited to 'hw/usb_cfs_client_common.c')
-rw-r--r-- | hw/usb_cfs_client_common.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/hw/usb_cfs_client_common.c b/hw/usb_cfs_client_common.c index b3ddee2..8f8c69f 100644 --- a/hw/usb_cfs_client_common.c +++ b/hw/usb_cfs_client_common.c @@ -612,6 +612,8 @@ static int cfs_prep_ffs_service(const char *name, const char *instance, int ret; /* TODO: Add some good error handling */ + if (!socket_name) + return -EINVAL; left = sizeof(buf); pos = buf; @@ -735,17 +737,14 @@ static int cfs_set_gadget_config(struct cfs_client *cfs_client, 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); - ret = cfs_prep_ffs_service(usb_func->name, - usb_func->instance, - instance, - fws->service); - if (ret) - return ret; + if (usb_func->service) { + ret = cfs_prep_ffs_service(usb_func->name, + usb_func->instance, + instance, + usb_func->service); + if (ret) + return ret; + } } } @@ -837,7 +836,6 @@ static int cfs_enable(struct usb_client *usb) int ret; struct usb_gadget *gadget; struct cfs_client *cfs_client; - struct usb_function_with_service *fws; if (!usb) return -EINVAL; @@ -857,8 +855,8 @@ static int cfs_enable(struct usb_client *usb) if (gadget->funcs[i]->function_group != USB_FUNCTION_GROUP_WITH_POST_SERVICE) continue; - fws = container_of(gadget->funcs[i], struct usb_function_with_service, func); - (void)systemd_start_unit_wait_started(fws->service, ".service", -1); + if (gadget->funcs[i]->service) + (void)systemd_start_unit_wait_started(gadget->funcs[i]->service, ".service", -1); } cfs_free_gadget(gadget); @@ -872,7 +870,6 @@ static int cfs_disable(struct usb_client *usb) int ret; struct usb_gadget *gadget; struct cfs_client *cfs_client; - struct usb_function_with_service *fws; if (!usb) return -EINVAL; @@ -885,8 +882,8 @@ static int cfs_disable(struct usb_client *usb) if (gadget->funcs[i]->function_group != USB_FUNCTION_GROUP_WITH_POST_SERVICE) continue; - fws = container_of(gadget->funcs[i], struct usb_function_with_service, func); - (void)systemd_stop_unit_wait_stopped(fws->service, ".service", -1); + if (gadget->funcs[i]->service) + (void)systemd_stop_unit_wait_stopped(gadget->funcs[i]->service, ".service", -1); } cfs_free_gadget(gadget); @@ -970,15 +967,11 @@ int hw_cfs_gadget_close(struct hw_common *common) 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_unit_wait_stopped(fws->service, ".socket", -1); - systemd_stop_unit_wait_stopped(fws->service, ".service", -1); + if (usb_func->function_group == USB_FUNCTION_GROUP_WITH_SERVICE) { + if (usb_func->service) { + systemd_stop_unit_wait_stopped(usb_func->service, ".socket", -1); + systemd_stop_unit_wait_stopped(usb_func->service, ".service", -1); + } } } |