drivers/usbdev/gadget/composite_desc.c
int16_t composite_mkcfgdesc(struct composite_dev_s *priv, uint8_t *buf)
{
  struct usb_config_descriptor *config_desc;
  uint8_t *buf_tmp = buf;
  int16_t len;
  int16_t total = 0;
  int16_t config_len;
  int i;

  /* Copy all contained interface descriptors into the buffer too */

  for (i = 0; i < priv->ndevices; i++)
    {
      len = priv->device[i].compdesc.mkconfdesc(buf_tmp, &priv->device[i].compdesc.devinfo);
      if (len <= 0)
        {
          return -1;
        }
      total   += len;
      buf_tmp += len;
    }

  if (priv->ndevices > 1)
    {
      config_len = total;
      total      = composite_mkcfgdesc_sub(buf, config_len);
      if (total < 0)
        {
          return -1;
        }

      config_len  = total;
      config_desc = (struct usb_config_descriptor *)buf;
      USETW(config_desc->wTotalLength, config_len);
      config_desc->bNumInterface = priv->ninterfaces;
    }

  return total;
}
/****************************************************************************
 * Name: composite_mkcfgdesc
 *
 * Description:
 *   Construct the configuration descriptor
 *
 ****************************************************************************/
composite_mkcfgdesc
Description:
Construct the configuration descriptor
composite_mkcfgdesc Description : Construct the configuration descriptor
int16_t composite_mkcfgdesc(struct composite_dev_s *priv, uint8_t *buf)
{
  struct usb_config_descriptor *config_desc;
  uint8_t *buf_tmp = buf;
  int16_t len;
  int16_t total = 0;
  int16_t config_len;
  int i;
  for (i = 0; i < priv->ndevices; i++)
    {
      len = priv->device[i].compdesc.mkconfdesc(buf_tmp, &priv->device[i].compdesc.devinfo);
      if (len <= 0)
        {
          return -1;
        }
      total   += len;
      buf_tmp += len;
    }
  if (priv->ndevices > 1)
    {
      config_len = total;
      total      = composite_mkcfgdesc_sub(buf, config_len);
      if (total < 0)
        {
          return -1;
        }
      config_len  = total;
      config_desc = (struct usb_config_descriptor *)buf;
      USETW(config_desc->wTotalLength, config_len);
      config_desc->bNumInterface = priv->ninterfaces;
    }
  return total;
}
int16_t composite_mkcfgdesc ( struct composite_dev_s * priv , uint8_t * buf ) { struct usb_config_descriptor * config_desc ; uint8_t * buf_tmp = buf ; int16_t len ; int16_t total = 0 ; int16_t config_len ; int i ; for ( i = 0 ; i < priv -> ndevices ; i ++ ) { len = priv -> device [ i ] . compdesc . mkconfdesc ( buf_tmp , & priv -> device [ i ] . compdesc . devinfo ) ; if ( len <= 0 ) { return -1 ; } total += len ; buf_tmp += len ; } if ( priv -> ndevices > 1 ) { config_len = total ; total = composite_mkcfgdesc_sub ( buf , config_len ) ; if ( total < 0 ) { return -1 ; } config_len = total ; config_desc = ( struct usb_config_descriptor * ) buf ; USETW ( config_desc -> wTotalLength , config_len ) ; config_desc -> bNumInterface = priv -> ninterfaces ; } return total ; }
Name: composite_mkcfgdesc
 Description:
   Construct the configuration descriptor
Name : composite_mkcfgdesc Description : Construct the configuration descriptor
/* Copy all contained interface descriptors into the buffer too */