summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyotaek Shim <hyotaek.shim@samsung.com>2020-03-20 01:50:48 (GMT)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>2020-03-20 01:50:48 (GMT)
commit09e540970141dd6551c900b59e680f27e0b1ee41 (patch)
tree8cb44f5274969fbe3e978db907e23acbf44ba46e
parent8a8e28cfb44dadc830b8e0931c96ec1d9818b53c (diff)
parentf03caba1dffef266dc744d8d7372202d6c00dd78 (diff)
downloadlibdevice-node-09e540970141dd6551c900b59e680f27e0b1ee41.zip
libdevice-node-09e540970141dd6551c900b59e680f27e0b1ee41.tar.gz
libdevice-node-09e540970141dd6551c900b59e680f27e0b1ee41.tar.bz2
Merge "Remove unnecessary functions to clone/fee usb_function" into tizen_5.5
-rw-r--r--hw/usb_gadget.h3
-rw-r--r--hw/usb_gadget_common.c61
2 files changed, 2 insertions, 62 deletions
diff --git a/hw/usb_gadget.h b/hw/usb_gadget.h
index 02ec7ed..fd0e2fd 100644
--- a/hw/usb_gadget.h
+++ b/hw/usb_gadget.h
@@ -80,9 +80,6 @@ struct usb_function {
const char *service;
void (*handler)(int enable);
-
- int (*clone)(struct usb_function *func, struct usb_function **_clone);
- void (*free_func)(struct usb_function *func);
};
struct usb_configuration_attributes {
diff --git a/hw/usb_gadget_common.c b/hw/usb_gadget_common.c
index c8eddc4..179bb4c 100644
--- a/hw/usb_gadget_common.c
+++ b/hw/usb_gadget_common.c
@@ -61,10 +61,6 @@ static void simple_cleanup_config(struct usb_configuration *config)
free(config->strs);
}
- /*
- * Each function will be free later,
- * for now we cleanup only pointers.
- */
if (config->funcs)
free(config->funcs);
@@ -94,12 +90,8 @@ static void simple_cleanup_gadget(struct usb_gadget *gadget)
free(gadget->configs);
}
- if (gadget->funcs) {
- for (i = 0; gadget->funcs[i]; ++i)
- gadget->funcs[i]->free_func(gadget->funcs[i]);
-
+ if (gadget->funcs)
free(gadget->funcs);
- }
free(gadget);
}
@@ -330,10 +322,7 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id,
if (!(gadget_id->function_mask & func_id))
continue;
- ret = _available_funcs[i]->clone(_available_funcs[i],
- gadget->funcs + idx);
- if (ret)
- goto free_functions;
+ gadget->funcs[idx] = _available_funcs[i];
++idx;
}
@@ -362,7 +351,6 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id,
return 0;
free_configs:
-free_functions:
free_gadget:
simple_cleanup_gadget(gadget);
out:
@@ -377,49 +365,6 @@ void rndis_handler(int enable)
(void)systemd_stop_unit_wait_stopped("rndis.service", NULL, -1);
}
-static void free_simple_func(struct usb_function *func)
-{
- if (func) {
- free((void *)func->name);
- free((void *)func->instance);
- free((void *)func->service);
- free(func);
- }
-}
-
-static int clone_simple_func(struct usb_function *func,
- struct usb_function **clone)
-{
- struct usb_function *other;
-
- if (!func || !clone)
- return -EINVAL;
-
- other = (struct usb_function *)calloc(1, sizeof(struct usb_function));
- if (!other)
- return -ENOMEM;
-
- *other = *func;
-
- other->name = strdup(func->name);
- other->instance = strdup(func->instance);
- if (!other->name || !other->instance)
- goto out_nomem;
-
- if (func->service) {
- other->service = strdup(func->service);
- if (!other->service)
- goto out_nomem;
- }
-
- *clone = other;
- return 0;
-
-out_nomem:
- free_simple_func(other);
- return -ENOMEM;
-}
-
#define DEFINE_USB_FUNCTION(_id, _name, _is_functionfs, _service, _handler) \
static struct usb_function _##_name##_function = { \
.id = _id, \
@@ -428,8 +373,6 @@ out_nomem:
.is_functionfs = _is_functionfs, \
.service = _service, \
.handler = _handler, \
- .clone = clone_simple_func, \
- .free_func = free_simple_func, \
}
DEFINE_USB_FUNCTION(USB_FUNCTION_MTP, mtp, 1, "mtp-responder", NULL);