char name[128];
int remain_after_disable; /* do not stop the service on disabling usb-gadget function */
};
-static GList *service_config_list;
static char board_serial[128] = "01234TEST";
return NULL;
}
+static struct usb_function *find_usb_function_by_service_name(const char *service)
+{
+ int i;
+
+ if(!service || !service[0])
+ return NULL;
+
+ for (i = 0; available_funcs[i]; ++i)
+ if (!strcmp(service, available_funcs[i]->service))
+ return available_funcs[i];
+
+ return NULL;
+}
+
static void simple_cleanup_config(struct usb_configuration *config)
{
if (!config)
{
if (MATCH(result->section, "SystemdUnit")) {
struct service_config svc = { 0, };
- void *entry = NULL;
+ struct usb_function *func;
g_list_foreach(result->props, parse_property_systemd_unit, &svc);
- entry = malloc(sizeof(struct service_config));
- if (!entry) {
- _E("Failed to alloc service config");
- return 0;
+ func = find_usb_function_by_service_name(svc.name);
+ if (func) {
+ _I("usb-gadget service config: name=%s, remain_after_disable=%d",
+ svc.name, svc.remain_after_disable);
+ func->remain_after_disable = svc.remain_after_disable;
}
-
- _I("usb-gadget service config: name=%s, remain_after_disable=%d",
- svc.name, svc.remain_after_disable);
- service_config_list = g_list_prepend(service_config_list, memcpy(entry, &svc, sizeof(svc)));
-
} else if (MATCH(result->section, "Attribute")) {
struct usb_gadget_config gc = { 0, };
void *entry = NULL;