diff options
author | INSUN PYO <insun.pyo@samsung.com> | 2020-03-23 19:46:18 +0900 |
---|---|---|
committer | Hyotaek Shim <hyotaek.shim@samsung.com> | 2020-03-25 03:41:38 +0000 |
commit | 24cd219f7051a45d7c198fd34b12d441efc8e32c (patch) | |
tree | f805241d6b2bf226b7314addd4c6b9e1d1f08a03 | |
parent | 1f71e203308af848415d3424f25641209c8cea07 (diff) | |
download | libdevice-node-24cd219f7051a45d7c198fd34b12d441efc8e32c.tar.gz libdevice-node-24cd219f7051a45d7c198fd34b12d441efc8e32c.tar.bz2 libdevice-node-24cd219f7051a45d7c198fd34b12d441efc8e32c.zip |
Fixed configfs not supporting multi-configuration
One usb function can be used in multiple config in configfs.
So when you create a usb function, you have to check if it exists.
Change-Id: I8f16fe4c542b277c12022d1c96d8ccb0aee32237
(cherry picked from commit 632729260576e9e7a81a18f8ef7dc9f51fe8c184)
-rw-r--r-- | hw/usb_cfs_client_common.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/hw/usb_cfs_client_common.c b/hw/usb_cfs_client_common.c index 029988b..0a1990b 100644 --- a/hw/usb_cfs_client_common.c +++ b/hw/usb_cfs_client_common.c @@ -425,20 +425,23 @@ static int cfs_set_gadget_config(struct cfs_client *cfs_client, int config_id, s instance[sizeof(instance) - 1] = '\0'; } - ret = usbg_create_function(cfs_client->gadget, function_type, instance, NULL, &function); - if (ret) - return ret; - - /* Setting rndis mac address. This should be done at this point, - * since the node host_addr changes to read only after the function - * is added to config. */ - if (usbg_get_function_type(function) == USBG_F_RNDIS) - (void)cfs_set_rndis_mac_addr(cfs_client->gadget, function); /* A random value is used if fails */ - - if (usbg_get_function_type(function) == USBG_F_FFS) { - ret = cfs_prep_ffs_service(usb_func, function); + function = usbg_get_function(cfs_client->gadget, function_type, instance); + if (!function) { + ret = usbg_create_function(cfs_client->gadget, function_type, instance, NULL, &function); if (ret) return ret; + + /* Setting rndis mac address. This should be done at this point, + * since the node host_addr changes to read only after the function + * is added to config. */ + if (usbg_get_function_type(function) == USBG_F_RNDIS) + (void)cfs_set_rndis_mac_addr(cfs_client->gadget, function); /* A random value is used if fails */ + + if (usbg_get_function_type(function) == USBG_F_FFS) { + ret = cfs_prep_ffs_service(usb_func, function); + if (ret) + return ret; + } } ret = usbg_add_config_function(config, NULL, function); |