summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINSUN PYO <insun.pyo@samsung.com>2020-03-25 11:52:33 (GMT)
committerHyotaek Shim <hyotaek.shim@samsung.com>2020-03-26 04:54:15 (GMT)
commit71ad3e609b84ecdcd5d005fb871b915662c43916 (patch)
tree9c7ba9752f7ce641dfac22e7b535512fec467456
parentb13cd53ed4983e17f7d11c5e153a428a2b821cd3 (diff)
downloadlibdevice-node-71ad3e609b84ecdcd5d005fb871b915662c43916.zip
libdevice-node-71ad3e609b84ecdcd5d005fb871b915662c43916.tar.gz
libdevice-node-71ad3e609b84ecdcd5d005fb871b915662c43916.tar.bz2
The usb gadget's config uses only one string information. So instead of dynamically creating string information, only use one fixed. Change-Id: Ie7e5bb198a429c8ac766002711f6add47d06fa1e (cherry picked from commit f4221a979f17129610293fed809d7fd822d59f54)
-rw-r--r--hw/usb_cfs_client_common.c4
-rw-r--r--hw/usb_client_common.c3
-rw-r--r--hw/usb_gadget.h2
-rw-r--r--hw/usb_gadget_common.c22
4 files changed, 7 insertions, 24 deletions
diff --git a/hw/usb_cfs_client_common.c b/hw/usb_cfs_client_common.c
index db6b781..e9d4135 100644
--- a/hw/usb_cfs_client_common.c
+++ b/hw/usb_cfs_client_common.c
@@ -400,8 +400,8 @@ static int cfs_set_gadget_config(struct cfs_client *cfs_client, int config_id, s
if (ret)
return ret;
- for (i = 0; usb_config->strs && usb_config->strs[i].lang_code; ++i) {
- ret = usbg_set_config_string(config, usb_config->strs[i].lang_code, usb_config->strs[i].config_str);
+ if (usb_config->strs.config_str) {
+ ret = usbg_set_config_string(config, usb_config->strs.lang_code, usb_config->strs.config_str);
if (ret)
return ret;
}
diff --git a/hw/usb_client_common.c b/hw/usb_client_common.c
index f0e4e1f..3020cda 100644
--- a/hw/usb_client_common.c
+++ b/hw/usb_client_common.c
@@ -92,9 +92,6 @@ static bool legacy_is_gadget_supported(struct usb_client *usb,
for (j = 0; gadget->configs[j]; ++j) {
struct usb_configuration *config = gadget->configs[j];
- if (config->strs && config->strs[0].lang_code)
- return false;
-
if (!config->funcs)
return false;
diff --git a/hw/usb_gadget.h b/hw/usb_gadget.h
index 95ad859..4dd3be9 100644
--- a/hw/usb_gadget.h
+++ b/hw/usb_gadget.h
@@ -103,7 +103,7 @@ struct usb_configuration_strings {
struct usb_configuration {
struct usb_configuration_attributes attrs;
- struct usb_configuration_strings *strs;
+ struct usb_configuration_strings strs;
struct usb_function **funcs;
};
diff --git a/hw/usb_gadget_common.c b/hw/usb_gadget_common.c
index 17393ec..c27d065 100644
--- a/hw/usb_gadget_common.c
+++ b/hw/usb_gadget_common.c
@@ -34,17 +34,10 @@ static struct usb_function *_available_funcs[];
static void simple_cleanup_config(struct usb_configuration *config)
{
- int i;
-
if (!config)
return;
- if (config->strs) {
- for (i = 0; config->strs[i].lang_code; ++i)
- free(config->strs[i].config_str);
-
- free(config->strs);
- }
+ free(config->strs.config_str);
if (config->funcs)
free(config->funcs);
@@ -82,23 +75,16 @@ static int alloc_default_config(struct usb_configuration **_config)
config = calloc(1, sizeof(*config));
if (!config)
- goto out;
-
- config->strs = calloc(1, sizeof(*config->strs));
- if (!config->strs)
- goto free_config;
+ return -ENOMEM;
config->attrs.bmAttributs = DEFAULT_BMATTRIBUTES;
config->attrs.MaxPower = DEFAULT_MAX_POWER;
+ /* TODO. Here is where to set the string used in config of configfs */
+
*_config = config;
return 0;
-
-free_config:
- free(config);
-out:
- return -ENOMEM;
}
static int get_device_serial(char **out)