summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINSUN PYO <insun.pyo@samsung.com>2018-03-14 15:43:10 +0900
committerINSUN PYO <insun.pyo@samsung.com>2018-03-14 16:20:58 +0900
commit35171555725ea09c7ef09df8747075e8976a7540 (patch)
treeebf9e0848db05f18a29520f7aecec3a9a3011049
parent5cf333c64f2e739a59748de7cf079e5e071f5498 (diff)
downloaddevice-manager-plugin-odroid-35171555725ea09c7ef09df8747075e8976a7540.tar.gz
device-manager-plugin-odroid-35171555725ea09c7ef09df8747075e8976a7540.tar.bz2
device-manager-plugin-odroid-35171555725ea09c7ef09df8747075e8976a7540.zip
Signed-off-by: INSUN PYO <insun.pyo@samsung.com> Change-Id: Ibbc64b534e2cf560b61c080299f6fc26b6009700
-rw-r--r--hw/usb_client/usb_client.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/hw/usb_client/usb_client.c b/hw/usb_client/usb_client.c
index 824e562..bfc2d20 100644
--- a/hw/usb_client/usb_client.c
+++ b/hw/usb_client/usb_client.c
@@ -332,7 +332,7 @@ static int legacy_get_current_gadget(struct usb_client *usb,
struct usb_gadget_strings *strs;
struct usb_configuration **configs;
struct usb_function **funcs;
- int i;
+ int i, j;
int ret = -ENOMEM;
gadget = zalloc(sizeof(*gadget));
@@ -373,6 +373,13 @@ static int legacy_get_current_gadget(struct usb_client *usb,
if (ret)
goto free_config_1;
+ i = 0;
+ for (j = 0; configs[0] && configs[0]->funcs[j]; i++, j++)
+ gadget->funcs[i] = configs[0]->funcs[j];
+
+ for (j = 0; configs[1] && configs[1]->funcs[j]; i++, j++)
+ gadget->funcs[i] = configs[1]->funcs[j];
+
*_gadget = gadget;
return 0;
@@ -601,31 +608,24 @@ static int legacy_enable(struct usb_client *usb)
goto disable_gadget;
for (i = 0; gadget->funcs[i]; ++i) {
- if (gadget->funcs[i]->function_group !=
- USB_FUNCTION_GROUP_WITH_SERVICE)
+ if (gadget->funcs[i]->function_group != USB_FUNCTION_GROUP_WITH_SERVICE)
continue;
- fws = container_of(gadget->funcs[i],
- struct usb_function_with_service, func);
+ fws = container_of(gadget->funcs[i], struct usb_function_with_service, func);
ret = systemd_start_service(fws->service);
if (ret < 0)
- goto stop_services;
+ _E("start service failed: %s", fws->service);
}
+ // TODO. free gadget
+ // legacy_free_gadget(gadget);
return 0;
-stop_services:
- while (--i >= 0) {
- if (gadget->funcs[i]->function_group !=
- USB_FUNCTION_GROUP_WITH_SERVICE)
- continue;
-
- fws = container_of(gadget->funcs[i],
- struct usb_function_with_service, func);
- systemd_stop_service(fws->service);
- }
disable_gadget:
sys_set_str(LEGACY_ENABLE_PATH, LEGACY_DISABLE);
+
+ // TODO. free gadget
+ // legacy_free_gadget(gadget);
return ret;
}
@@ -647,9 +647,11 @@ static int legacy_disable(struct usb_client *usb)
fws = container_of(gadget->funcs[i], struct usb_function_with_service, func);
ret = systemd_stop_service(fws->service);
if (ret < 0)
- return ret;
+ _E("stop service failed: %s", fws->service);
}
+ // TODO. free gadget
+ // legacy_free_gadget(gadget);
return sys_set_str(LEGACY_ENABLE_PATH, LEGACY_DISABLE);
}