From: INSUN PYO Date: Mon, 23 Mar 2020 10:46:18 +0000 (+0900) Subject: Fixed configfs not supporting multi-configuration X-Git-Tag: submit/tizen_5.5/20200326.053433~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24cd219f7051a45d7c198fd34b12d441efc8e32c;p=platform%2Fcore%2Fsystem%2Flibdevice-node.git 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) --- 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);