diff options
author | INSUN PYO <insun.pyo@samsung.com> | 2020-01-03 15:37:29 +0900 |
---|---|---|
committer | INSUN PYO <insun.pyo@samsung.com> | 2020-01-15 10:32:01 +0000 |
commit | 3f40dc3886b914e9a5fcfb51a820788762b0ab14 (patch) | |
tree | 0a816dc75fe40758a93679067b4f514d7b0ce4d9 | |
parent | 03a0bdd3bf53f591f44c4b84451cea3ad96879a9 (diff) | |
download | libdevice-node-3f40dc3886b914e9a5fcfb51a820788762b0ab14.tar.gz libdevice-node-3f40dc3886b914e9a5fcfb51a820788762b0ab14.tar.bz2 libdevice-node-3f40dc3886b914e9a5fcfb51a820788762b0ab14.zip |
Add code to run rndis.service(rndis) and data-route.service(acm) in configfs environmentsubmit/tizen_5.5/20200115.105138accepted/tizen/5.5/unified/20200116.120643
Rndis and acm need their services to complete initialization.
Change-Id: I24381f2e30a4cf1e3051ea4a304d65ad8eb59f50
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
(cherry picked from commit c0fb89192952ca0806c26abddf5daf0e3f3acc30)
-rw-r--r-- | hw/usb_cfs_client_common.c | 52 | ||||
-rw-r--r-- | hw/usb_client_common.c | 7 |
2 files changed, 47 insertions, 12 deletions
diff --git a/hw/usb_cfs_client_common.c b/hw/usb_cfs_client_common.c index f423d22..b3ddee2 100644 --- a/hw/usb_cfs_client_common.c +++ b/hw/usb_cfs_client_common.c @@ -421,8 +421,7 @@ static int cfs_get_current_gadget(struct usb_client *usb, if (!usb) return -EINVAL; - cfs_client = container_of(usb, struct cfs_client, - client); + cfs_client = container_of(usb, struct cfs_client, client); usb_gadget = zalloc(sizeof(*usb_gadget)); if (!usb_gadget) @@ -445,7 +444,6 @@ static int cfs_get_current_gadget(struct usb_client *usb, if (ret) goto free_strs; - n_funcs = cfs_count_functions(cfs_client->gadget); usb_funcs = calloc(n_funcs + 1, sizeof(*usb_funcs)); if (!usb_funcs) @@ -835,27 +833,65 @@ out: static int cfs_enable(struct usb_client *usb) { + int i; + int ret; + struct usb_gadget *gadget; struct cfs_client *cfs_client; + struct usb_function_with_service *fws; if (!usb) return -EINVAL; - cfs_client = container_of(usb, struct cfs_client, - client); + cfs_client = container_of(usb, struct cfs_client, client); + ret = usbg_enable_gadget(cfs_client->gadget, cfs_client->udc); + if (ret) + return ret; + + ret = cfs_get_current_gadget(usb, &gadget); + if (ret) { + usbg_disable_gadget(cfs_client->gadget); + return ret; + } + + for (i = 0; gadget->funcs[i]; ++i) { + if (gadget->funcs[i]->function_group != USB_FUNCTION_GROUP_WITH_POST_SERVICE) + continue; - return usbg_enable_gadget(cfs_client->gadget, cfs_client->udc); + fws = container_of(gadget->funcs[i], struct usb_function_with_service, func); + (void)systemd_start_unit_wait_started(fws->service, ".service", -1); + } + + cfs_free_gadget(gadget); + + return 0; } static int cfs_disable(struct usb_client *usb) { + int i; + int ret; + struct usb_gadget *gadget; struct cfs_client *cfs_client; + struct usb_function_with_service *fws; if (!usb) return -EINVAL; - cfs_client = container_of(usb, struct cfs_client, - client); + ret = cfs_get_current_gadget(usb, &gadget); + if (ret) + return ret; + + for (i = 0; gadget->funcs[i]; ++i) { + 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); + } + + cfs_free_gadget(gadget); + cfs_client = container_of(usb, struct cfs_client, client); return usbg_disable_gadget(cfs_client->gadget); } diff --git a/hw/usb_client_common.c b/hw/usb_client_common.c index 95b815b..dc08bde 100644 --- a/hw/usb_client_common.c +++ b/hw/usb_client_common.c @@ -558,9 +558,8 @@ static int legacy_enable(struct usb_client *usb) if (gadget->funcs[i]->function_group == USB_FUNCTION_GROUP_SIMPLE) continue; - fws = container_of(gadget->funcs[i], - struct usb_function_with_service, func); - systemd_start_unit_wait_started(fws->service, ".service", -1); + fws = container_of(gadget->funcs[i], struct usb_function_with_service, func); + (void)systemd_start_unit_wait_started(fws->service, ".service", -1); } legacy_free_gadget(gadget); @@ -587,7 +586,7 @@ static int legacy_disable(struct usb_client *usb) continue; fws = container_of(gadget->funcs[i], struct usb_function_with_service, func); - systemd_stop_unit_wait_stopped(fws->service, ".service", -1); + (void)systemd_stop_unit_wait_stopped(fws->service, ".service", -1); } ret = sys_set_str(LEGACY_ENABLE_PATH, LEGACY_DISABLE); |