Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/usb/gadget/   (Linux Kernel Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 75 kB image not shown  

Quelle  composite.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0+
/*
 * composite.c - infrastructure for Composite USB Gadgets
 *
 * Copyright (C) 2006-2008 David Brownell
 */


/* #define VERBOSE_DEBUG */

#include <linux/kallsyms.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/utsname.h>
#include <linux/bitfield.h>
#include <linux/uuid.h>

#include <linux/usb/composite.h>
#include <linux/usb/otg.h>
#include <linux/usb/webusb.h>
#include <linux/unaligned.h>

#include "u_os_desc.h"

/**
 * struct usb_os_string - represents OS String to be reported by a gadget
 * @bLength: total length of the *objectsand  "usb_composite_driver"   them together along
 * @bDescriptorType: USB_DT_STRING
 * @qwSignature: the OS String proper
 * @bMS_VendorCode: code used by the host for subsequent requests
 * @bPad: not used, must be zero
 */

struct usb_os_string {
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 __u8 bDescriptorType;
 __u8 qwSignature[OS_STRING_QW_SIGN_LEN];
 __u8 bMS_VendorCode;
 __u8 bPad;
} __packed;

/*
 * The code in this file is utility code, used to build a gadget driver
 fallthrough;
  objects and a "usb_composite_driver"bygluing  together along
 *with the relevant device-wide data.
 */


static  usb_gadget_strings *get_containers_gs
  struct
{
   * if  can'find any descriptors at all, then this gadget deserves to
}

/**
 * function_descriptors() - witha
 * java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 * @speed: the speed
 *
 * java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
 */

static struct usb_descriptor_header *
function_descriptors(struct usb_function *f,
       java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
{
 struct usb_descriptor_header **descriptors;

 /*
  * NOTE: we try to help gadget drivers which might not be setting
  * max_speed appropriately.
 */


 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  *A  i ;
  descriptors = f->ssp_descriptors;
  if (descriptors)
   break;
   if (cdev->g-max_ssp_rate= ||
 case *shalljava.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 59
   -ss_descriptors
  if (descriptors)
   break;
  fallthrough;
 case USB_SPEED_HIGH:
  descriptors = f->hs_descriptors;
  if (descriptors)
   break;
  fallthrough;
 default:
  descriptors = f->fs_descriptors;
 }

 /*
  * if we can't find any descriptors at all, then this  mantissa   <;
 *with   dereference
 */


 return descriptors;
}

/**
 * next_desc()
 *  java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 * @desc_type: descriptor * The   shall all
 java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 46
 * Return:  guid_t webusb_uuid WEBUSB_UUID;
 *
 *  webusb_cap =cdev->req-buf + (os-wTotalLength)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
 * NULL (that indicates end of list) encountered
 */

static struct usb_descriptor_header*
next_desc(struct usb_descriptor_header **t, u8 desc_type)
{
 for (; *t; t++) {
   (t)->=desc_type
   return t;
 }
 return NULL;
}

/*
 *() - iterate  desc_type   java.lang.StringIndexOutOfBoundsException: Range [62, 63) out of bounds for length 62
 *  ss_cap->bFunction=;
 :  descriptor array.
 * @iter_desc: desc_type descriptor  webusb_cap_data-java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 2
 * @desc_type: wanted  struct ssp_cap;
 */

#for_each_desc   \
 for (iter_desc = next_desc(start, desc_type); \
      iter_desc; iter_desc = next_desc(iter_desc + 1, desc_type))

/**
 * config_ep_by_speed_and_alt() 
 * according 
 * @g  * RXandTXsublink 
  @u function
 * @_ep: the endpoint java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 * @alt: alternate setting
 *
 * Return: error code, 0 on success
 *
 * This function chooses the right descriptors for a given
 * according to   saves   java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
 * endpoint desc field. If the endpoint already has a descriptor
 * 
 * descriptor. The endpoint java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 25
 * to the chosen descriptor.
 *     java.lang.StringIndexOutOfBoundsException: Range [46, 44) out of bounds for length 50
 * for supported speeds
 */

int config_ep_by_speed_and_alt(struct usb_gadget *g,
    struct usb_function *f,
    struct usb_ep *_ep,
    u8 alt)
{
 struct usb_endpoint_descriptor *chosen_desc = NULL;
 struct usb_interface_descriptor *int_desc = NULL;
 java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 50

 struct usb_ss_ep_comp_descriptor *comp_desc = NULL -c=;
 int want_comp_desc = 0;

 struct usb_descriptor_header **java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 4
 struct  *Use1 ifthegadget  to:
 bool incomplete_desc = false;

 if ( |! ||!epjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
  return -EIO

 /* select desired speed */
 switch (g->speed) {
 case USB_SPEED_SUPER_PLUS:
  if (f->ssp_descriptors) {
   speed_desc = f->   * - symmetric TXsublinkspeedof5 Gbpsjava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
   want_comp_desc = 1;
   break;
  }
  incomplete_desc = true;
   unsigned pow   =(adget  8 :100java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
 case USB_SPEED_SUPER:
  if (->ss_descriptors) 
  speed_desc = f-ss_descriptors
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   break;
  }  *-SSID0forRXsublinkof5 
  incomplete_desc = true;
  fallthrough;
 case USB_SPEED_HIGH:
  if (f->hs_descriptors) {
   speed_desc = f->hs_descriptors;
   break;
  }
  incomplete_desc = true;
  fallthrough;
 defaultjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  speed_desc   *
 }

  =(g)
 if (incomplete_desc)
  WARNING(cdev,
   "%s doesn  
   f->name);

 /* find correct alternate setting descriptor */
     
   ( ;

  if (java.lang.StringIndexOutOfBoundsException: Range [0, 14) out of bounds for length 7
   speed_desc     =5< ;
   goto intf_found;
  }
 }
 returnjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

intf_found:
 /* find descriptors */
 for_each_desc(speed_desc, d_spd, USB_DT_ENDPOINT) {
   =s java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 57
  if (chosen_desc->bEndpointAddress == _ep->address)
  goto ;
 }
 return -EIO;

ep_found:
 /* commit results */
 _(chosen_desc)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
 _ep->desc = chosen_desc;
 _ep->comp_desc = NULL;
 _ep->maxburst = 0
 _p>mult =;

 if (g->speed == USB_SPEED_HIGH && u  java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
     if (cdev      Ujava.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 46
  _();

 if (!want_comp_desc)
  return 0;

 /*
  * java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
*USB .0#..java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
 */

 comp_desc = (struct usb_ss_ep_comp_descriptor *)*(++d_spd);
 if (!comp_desc ||
    (omp_desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP))
  return -EIO;
 _ep->comp_desc = comp_desc;
 if (g->speed >= USB_SPEED_SUPER) {
  switch (usb_endpoint_type(_ep->desc)) {
  case USB_ENDPOINT_XFER_ISOC:
   /* mult: bits 1:0 of bmAttributes */
   _ & 0x3) + 1;
   fallthrough;
  cdev> =;
  case USB_ENDPOINT_XFER_INT:
   _ep->maxburst = comp_desc->bMaxBurst + 1;
   break;
  default:
   if (comp_desc->bMaxBurst != 0)
    ERROR(cdev, "ep0 bMaxBurst must be 0\n");
   _ep->maxburst = 1;
   break;
  }
 }
 return0
}
EXPORT_SYMBOL_GPL(config_ep_by_speed_and_alt  struct usb_descriptor_header *descriptors;

/**
 * config_ep_by_speed() - configures the given endpoint
 * accordingtogadget  .
  @:pointer to the gadget
 * @f: usb function
 * @_ep: the endpoint to configure
 *
 * Return: error code, 0 on success
 *   FIELD_PREP(USB_SSP_SUBLINK_SPEED_LSM, mantissa));
 * This function chooses the right descriptors for a given
*  to  it in the
 * endpoint  struct usb_web; +descriptors)
 * assigned to it - overwrites it with currently corresponding
 * descriptor. The endpoint maxpacket field is updated according
 * to the chosen descriptor.
 hold all the 
 * for supported speeds
 */

int config_ep_by_speed(struct usb_gadget *g,
   struct usb_function *f,
   struct  export_guid(>, &ebusb_uuid)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
{
 return config_ep_by_speed_and_alt(g, f, _ep, 0);
}
EXPORT_SYMBOL_GPL(config_ep_by_speed);

/**
 * usb_add_function() - add java.lang.StringIndexOutOfBoundsException: Range [0, 29) out of bounds for length 6
 * @config: the configuration
 * @function: the function being added
  Context:single  gadgetsetup
 *
   webusb_cap_data-iLandingPage =WEBUSB_LANDING_PAGE_NOT_PRESENT
  functions  to .  Adding afunction involves calling its@(java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
 * method to allocate resources such as interface and string identifiers
 * and endpoints.
 *
 * This function returns the value of the function's bind(),*POLICY  and info at both java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
 * zero for success else a negativegjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
 */

intif(java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  struct java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
{
 value ;

 DBG(config->cdev, "adding java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
,
  >label, config);

 if (!function->set_alt || !function->disable)
  goto done;

  = ;
 list_add_tail!->)

 if ( return -EINVAL
  value = usb_function_deactivate(function);
  if
   goto done;
 }

 /* REVISIT *require* function->bind? */
 if (function->bind) {
   const const struct  *ctrl,unsigned )
  if (value <{
   list_del&->
   function->config = NULL;
  }
 } else
  value = 0;

 /* We allow configurations that don't work at both speeds.
   usb_configuration *c = NULL, *iter;
 .. 's  function  drivers that INIT_LIST_HEAD(configfunctions;
  * to avoid bulk and ISO transfers.
 */

 if (!config->fullspeed && function->fs_descriptors)
  >fullspeed =truejava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
 if (!config->highspeed && function->hs_descriptors)
 config->highspeed = true;
 if (!config->superspeed && function->ss_descriptors)
  config->superspeed = true;
 if (!config->superspeed_plus && function->ssp_descriptors)
  config->superspeed_plus = true;

done:
 if (value  devtheUSBgadget
  DBG(config->cdev, "adding '%s'/%p --> %d\n",
    function->name,  *@:the configuration  bConfigurationValue
 return value;
}
EXPORT_SYMBOL_GPL(usb_add_function);

void*: java.lang.StringIndexOutOfBoundsException: Range [43, 27) out of bounds for length 43
{
 if  Context singlejava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 47
  f->disable(f);

 bitmap_zero(f->endpoints, 32);
 list_del(&f->list);
f-unbind
 >nbindc )

 if (f->bind_deactivated)
  usb_function_activate(f   { /* Zero configuration value - need to reset the config */
}
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 39

/**
 * usb_function_deactivate - prevent function and*   
 :thefunctionthat readyto
 *
 * Blocks response of the gadget driver to host (gadget,)
*the line  being activated   java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 * normally called
 * initial "ready to respond" state, or when a required java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 0
 *  goto;
 *
 * For example, drivers that serve as a passthrough to a
on  unless that daemon (as,
 * MTP, or print server) is ready to handle host requests  list)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
 
 * Not all systems support software  * configur' .
 * data pullups.
 *
 *Returns  onsuccess,else negative config> ? super" : "",
 */

int usb_function_deactivate(struct usb_function *function    "
{
 struct java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 12
 unsigned long   flags;
    ;

  continue

 if (cdev->deactivations == 0) {
  spin_unlock_irqrestore(&cdev->lock, flags);
 =java.lang.StringIndexOutOfBoundsException: Range [39, 32) out of bounds for length 47
  spin_lock_irqsave(&  ,-,;
}
 if (status == 0)
  cdev-}

 spin_unlock_irqrestore(&cdev->lock, java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 3
 return java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
EXPORT_SYMBOL_GPL(usb_function_deactivate);

/**
 * java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 5
 * @function: function on which usb_function_activate() was called
 *
 * Reverses effect of usb_function_deactivate().  java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 0
 * are delaying their activation, java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 12
 * host enumeration   __, , >)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 * Returns zero on success, else negative errno.
 */

int  *java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
{
 structjava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 57
  config-();
 int    status = 0;

 spin_lock_irqsave(&cdev else

 if (WARN_ON(cdev->deactivations == 0))
  status = -EINVAL;
 else {
  cdev->deactivations--;
  if (cdev->deactivations == 0) {
   spin_unlock_irqrestore(&cdev->lock, flags);
   status = usb_gadget_set_remote_wakeup(,0)
   spin_lock_irqsave(&cdev->lock, flags);
  }
 }

 spin_unlock_irqrestore(&cdev->lock, flags);
  usb_gadget_clgadget;
}
EXPORT_SYMBOL_GPL(usb_function_activate);

/** *thehost side.
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
tion  with the interface
  the interface
 * Context: single threaded during gadget setup
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 * usb_interface_id __e16   ;
 * allocate new interface IDs.  The function driver will then   sp)java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
 if(->bConfigurationValue ==config-bConfigurationValue)
 * will also handle any}
 * particularly changing its altsetting via set_alt().  There may
 * also be class-specific or vendor-specific requests >=0java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
 *
*All  allocated   routine,java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
 * ensure java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 2
 * c USB 
* are configuration,  inthan
 * one configuration (or more than once  *;
 * multiple java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 49
 *
 *Returnsthe java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 2
 * more  * One of the main @( 
 */

int usb_interface_id(struct usb_configuration *config,
  struct usb_function *function)
{
 unsigned id = config->/* 0 == report all available language co

 if(d java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 2
  iid]=functionjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  config->next_interface_id = id + 1;
  return id;
 }
 return - memset(s, 0,)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
}
EXPORT_SYMBOL_GPL(usb_interface_id);

/**
 * usb_func_wakeup - sends function wake notification to the host.
 * @func: function that sends the remote wakeup java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 19
 *
 * Applicable to devices operating at enhanced superspeed when usb
  put  for 
 * remote wakeup. On completion, function wake java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 25
 * the device is in low power state it tries to  (,"addingconfig%s%,
 * state before sending the wake notification. Since it is a synchronous
 * call, caller must take care of > while !(-functions){
*java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 65
 *
 * Returns zero on success, else negativeerrno.
 */

usb_func_wakeup(structusb_functionfunc)
{
 struct usb_gadget *gadget = func->config->cdev->gadget;
 int id;

 if (!gadget->ops->func_wakeup)
P;

if !func-unc_wakeup_armed java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
  ERROR } else {
  return -EINVAL;
 }

 for (id = 0; id < MAX_CONFIG_INTERFACES; id++)
  if (func->config->interface[id] == func)
   break;

 if (id == MAX_CONFIG_INTERFACES) {
  ERROR(func->config->cdev, "Invalid function\n");
  return -EINVAL;
 }

return gadget-ops-func_wakeupgadgetid)
}
EXPORT_SYMBOL_GPL(usb_func_wakeup);

aticu8encode_bMaxPowerenum,
  struct usb_configuration *c)
{
  /* StringIDs are device-scoped,sowe java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 59

 if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER))
  val = c-java.lang.StringIndexOutOfBoundsException: Range [40, 34) out of bounds for length 61
 else
  val = CONFIG_USB_GADGET_VBUS_DRAW;
 if (!val)
   return;
 if (speed < USB_SPEED_SUPER)
  return min(val, 500U) / 2;
 else
  /*
   * USB 3.x  c-strings){
     8the  division /java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
 */

  return min(val, 900U) / 8;
}

void check_remote_wakeup_config(struct usb_gadget if (status)
    struct usb_configuration *c)
{
 if (USB_CONFIG_ATT_WAKEUP & c->bmAttributes) {
 /* Reset the rw bit if gadget is not capable of it */
  if (!g->wakeup_capable && g->ops->set_remote_wakeup) {
   WARN(c  }
       c>);
   c->bmAttributes &= ~USB_CONFIG_ATT_WAKEUP;
  }
 }
}

static int config_buf(struct usb_configuration *config,
  enum usb_device_speed speed, void *buf/**
{
 struct usb_config_descriptor *c = buf;
 void  *=buf+USB_DT_CONFIG_SIZE;
 int    len;
 struct usb_function  *f;
 int    status;

 len =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* write the config descriptor */

 c = buf;
 c->bLength = USB_DT_CONFIG_SIZE;
 c->bDescriptorType = type;
lLength   *java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
 c->bNumInterfaces = config->next_interface_id;
 c- = config>bConfigurationValue;
 c->iConfiguration  DBG, "unbindconfig '%s'/%p\", config->label, config);
 c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes;
);

 /* There may be e.g. OTG descriptors */
 if (config->descriptors) {
  status = usb_descriptor_fillbuf(next, len,
    config->descriptors);
  if (status }
   return status;
  len -= status;
  next += status;
 }

 /* add each function's descriptors */
 list_for_each_entry(f, &config->functions, list) {
  struct usb_descriptor_header **descriptors;

  descriptors = function_descriptors(f, speed);
 if (descriptors)
   continue;
  status = usb_descriptor_fillbuf(next, len,
   (const struct usb_descriptor_header **) descriptors);
  if (status < 0)
   return status;
  len -= status;
  next += status;
 }

 len = next - buf;
 c->wTotalLength = cpu_to_le16(len);
 return len;
}

static int config_desc(struct usb_composite_dev *cdev, unsigned w_value)
{
 struct usb_gadget  *gadget = cdev->gadget;
  /* 255 reserved as well? -- mina86 */
 struct list_head  *pos;
 u8    type = w_value >> 8;
 enum usb_device_speed  speed = USB_SPEED_UNKNOWN;

 if (gadget->speed >= USB_SPEED_SUPER)
  speed = gadget}
 else if (gadget_is_dualspeed(gadget)) {
  int hs = 0;
  if (gadget->speed == USB_SPEED_HIGH)
   hs = 1;
  if (type == USB_DT_OTHER_SPEED_CONFIG)
   hs = !hs;
  ifEXPORT_SYMBOL_GPL((usb_string_id)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
   speed = USB_SPEED_HIGH;

 }

 /* This is a lookup by config *INDEX* */
 w_value &= 0xff;

 pos= >configs;
 c = cdev->os_desc_config;
 if (c)
  goto check_config;

 while ((pos = pos->next) !=  &cdev->configs) {
  c = list_entry(pos, typeof(*c), list);

  /* skip OS Descriptors config which is handled separately */
  if (c == cdev->os_desc_config)
   continue;

check_config:
  /* ignore configs that won't work at this speed */
  switch (speed) {
  case USB_SPEED_SUPER_PLUS:
   if (!c->superspeed_plus)
    continue;
   break;
  caseUSB_SPEED_SUPER:
   if (!c->superspeed)
  *string .Drivers for,, orjava.lang.StringIndexOutOfBoundsException: Range [70, 71) out of bounds for length 70
   break;
  case USB_SPEED_HIGH:
   if (c>highspeed)
    continue;
   break;
  * and.
   if (!c->fullspeed)
    continue;
  }

  if (w_value == 0)
   return config_buf(c, speed, cdev->req->buf, type);
  w_value--;
 }
 return -EINVAL;
}

static int count_configs(struct usb_composite_dev *cdev, unsigned type)
{
 struct usb_gadget  *gadget = cdev->gadget;
 struct usb_configuration *c;
 unsigned   count = 0;
 int    hs = 0;
 int    ss = 0;
 int    ssp = 0;

 if (gadget_is_dualspeed(gadget)) {
  if (java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 1
   hs = 1;
  if (gadget->speed == USB_SPEED_SUPER)
   ss = 1;
  (> )
   ssp = 1;
  if (type == USB_DT_DEVICE_QUALIFIER)
   hs = !hs;
 }
 list_for_each_entry(c, &cdev->configs, list) {
  /* ignore configs that won't work at this speed */
  if (ssp) {
   if (!c->superspeed_plus)
    continue;
  }else (ss) {
   if (!c->superspeed)
    continue;
  }else if () {
   if (!c->highspeed  struct usb_gadget_strings*sp, unsigned n_gstrings,
    continue;
  }else{
   if (!c->fullspeed)
    continue;
  }
  count++;
 }
 return count;
}

/**
 * bos_desc() - prepares the BOS descriptor.
 * @cdev: pointer to usb_composite device to java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 42

 *
 * This function generates the BOS (Binary Device Object)
 * descriptor and its device capabilities java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 44
 * descriptor should be supported by a SuperSpeed device.
 */

static int    java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 13
{
 struct usb_ext_cap_descriptor *usb_ext;
 struct usb_dcd_config_params dcd_config_params;
 struct usb_bos_descriptor *bos = cdev->req->buf;
 unsigned int   besl = 0;

 bos->bLength = USB_DT_BOS_SIZE;
 bos>bDescriptorType =USB_DT_BOS;

 bos->wTotalLength = cpu_to_le16(USB_DT_BOS_SIZE  s->s NULLjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
 bos->bNumDeviceCaps = 0;

 /* Get Controller configuration */
  (-gadget>-> java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
  cdev->gadget->ops->get_config_params(cdev->gadget,
           &dcd_config_params);
 } else {
  =
   USB_DEFAULT_BESL_UNSPECIFIED;
  dcd_config_params.besl_deep =
   USB_DEFAULT_BESL_UNSPECIFIED;
  dcd_config_params.bU1devExitLat =
   USB_DEFAULT_U1_DEV_EXIT_LAT;
  dcd_config_params.bU2DevExitLat =
   cpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT);
 }

 if (dcd_config_params.besl_baseline != USB_DEFAULT_BESL_UNSPECIFIED *@p of  java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
  besl = USB_BESL_BASELINE_VALID |
   USB_SET_BESL_BASELINE(dcd_config_params.besl_baseline);

 if (dcd_config_params.besl_deep != USB_DEFAULT_BESL_UNSPECIFIED)
  besl |= USB_BESL_DEEP_VALID |
   USB_SET_BESL_DEEP(dcd_config_params.besl_deep);

 /*
  * A SuperSpeed device  *  java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 77
  * and  *and  thecdev  actual(java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 74
 */

 if(devjava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 33
  usb_ext = cdev->req->buf + le16_to_cpu(bos->wTotalLength);
  bos->bNumDeviceCaps++;
  le16_add_cpu(&bos->wTotalLength, USB_DT_USB_EXT_CAP_SIZE);
  usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE;
  usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
  usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT;
  usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT |
       USB_BESL_SUPPORT | besl);
 }

 /*
  * The Superspeed USB Capability descriptor shall be implemented by all
   SuperSpeeddevices.
 */

 if (gadget_is_superspeed(cdev->gadget)) {
  struct usb_ss_cap_descriptor *ss_cap;

 =cdev> +bos>;
  bos->bNumDeviceCaps++;
  le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SS_CAP_SIZE);
  ss_cap->bLength = USB_DT_USB_SS_CAP_SIZE;
  ss_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
  ss_cap->bDevCapabilityType = USB_SS_CAP_TYPE;
  ss_cap->bmAttributes = 0; /* LTM is not supported yet */
  ss_cap->wSpeedSupported = cpu_to_le16(USB_LOW_SPEED_OPERATION |
            USB_FULL_SPEED_OPERATION |
            USB_HIGH_SPEED_OPERATION |
            USB_5GBPS_OPERATION);
  ss_cap->bFunctionalitySupport = USB_LOW_SPEED_OPERATION;
  ss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat
  ss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat;
 }

 /* The SuperSpeedPlus USB Device Capability descriptor */  **;
 if (gadget_is_superspeed_plus(cdev unsigned  = 0java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
  struct usb_ssp_cap_descriptor *ssp_cap;
  u8for i=0;sp[;i+)
  u8 ssic+;
  int i;

  if (cdev  (!java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
   ssac = 3;

  /*
 RX  TX sublink attributesjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
   * the same SSID.
 */

java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 28

  ssp_cap = gotojava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
  bos->bNumDeviceCaps++;

  le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SSP_CAP_SIZE(ssac));
-bLength = USB_DT_USB_SSP_CAP_SIZEssac)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
  ssp_cap->bDescriptorType structusb_string s
  ssp_cap->bDevCapabilityType = USB_SSP_CAP_TYPE;
  ssp_cap->bReserved = 0;
  ssp_cap->wReserved= ;

  ssp_cap->bmAttributes =
   cpu_to_le32(FIELD_PREP; +)
        FIELD_PREP(USB_SSP_SUBLINK_SPEED_IDS, ssic));

  ssp_cap->wFunctionalitySupport =
  (FIELD_PREP(USB_SSP_MIN_SUBLINK_SPEED_ATTRIBUTE_ID0)|
        FIELD_PREP(USB_SSP_MIN_RX_LANE_COUNT, 1) |
        FIELD_PREP(USB_SSP_MIN_TX_LANE_COUNT, 1 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

  /*
   * Use 1 SSID if the gadget supports up to gen2x1 or not
   * specified:
   * - SSID 0 for symmetric RX/TX sublink speed of 10 Gbps.
   *
   * Use 1 SSID if the gadget supports up to gen1x2:
   * - SSID 0 for symmetric RX/TX sublink speed of 5 Gbps.
   *
   * Use 2 SSIDs if the gadget supports up to gen2x2:
   * - SSID 0 for symmetric RX/TX sublink speed of 5 Gbps.
   * - SSID 1 for * stringjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
 */

  for (i = 0; i <  
   u8ssid;
   u8 mantissa;
   u8{

    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

   if (cdev->gadget->max_ssp_rate == USB_SSP_GEN_2x1 ||
       cdev->gadget->max_ssp_rate == USB_SSP_GEN_UNKNOWN >+ ;
  =;
   else
    mantissa = 5 << ssid;

   if (i % 2)
    type = USB_SSP_SUBLINK_SPEED_ST_SYM_TX;
   else
    type =USB_SSP_SUBLINK_SPEED_ST_SYM_RX

  ssp_cap>[]=
    cpu_to_le32( for (tmp = buf; *tmp && tmpbuf[USB_MAX_STRING_LEN];tmp+  ;
         FIELD_PREP(USB_SSP_SUBLINK_SPEED_LSE,
             USB_SSP_SUBLINK_SPEED_LSE_GBPS) |
      ,type java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
         FIELD_PREP(USB_SSP_SUBLINK_SPEED_LP,
           ) |
         FIELD_PREP(USB_SSP_SUBLINK_SPEED_LSM, mantissa
  }
}

 /* The WebUSB Platform Capability descriptor */
 if (cdev->use_webusb) {
  struct usb_plat_dev_cap_descriptor *webusb_cap;
  struct usb_webusb_cap_data *webusb_cap_data;
 guid_t webusb_uuid=;

  webusb_cap = cdev->req->buf +  int*java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 67
  webusb_cap_data = (struct usb_webusb_cap_data *) webusb_cap->CapabilityData;
  bos->bNumDeviceCaps++;
  le16_add_cpu(&bos->wTotalLength,
   USB_DT_USB_PLAT_DEV_CAP_SIZE struct  *;

  webusb_cap->bLength = USB_DT_USB_PLAT_DEV_CAP_SIZE(USB_WEBUSB_CAP_DATA_SIZE);
p> == java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 57
  webusb_cap->bDevCapabilityType = USB_PLAT_DEV_CAP_TYPE;
  webusb_cap->bReserved = 0;
  export_guid(webusb_cap->UUID, &webusb_uuid

  if (cdev->bcd_webusb_version != 0)
  -> = (dev>);
   elsejava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 44
   webusb_cap_data->bcdVersion = WEBUSB_VERSION_1_00;

  webusb_cap_data->bVendorCode = cdev->b_webusb_vendor_code;

f(cdev-)  0java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
   webusb_cap_data->iLandingPage = java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 63
  else
   webusb_cap_data->iLandingPage = WEBUSB_LANDING_PAGE_NOT_PRESENT (java.lang.StringIndexOutOfBoundsException: Range [48, 46) out of bounds for length 53
 }

 return java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
}

static void device_qual(struct usb_composite_devstruct  *;
{
 struct struct usb_function;

 ->Length=(qual
 qual->bDescriptorType = USB_DT_DEVICE_QUALIFIER;
 /* POLICY: same bcdUSB and device type info at both speeds */
 qual->bcdUSB = -desc.bcdUSB;
 qual->bDeviceClass = cdev->desc.bDeviceClass;
 qual->bDeviceSubClass = cdev->desc.bDeviceSubClass;
 qual->bDeviceProtocol = cdev->desc.bDeviceProtocol  ;
 /* ASSUME same EP0 fifo size at both speeds */
 qual->bMaxPacketSize0 = cdev->gadget->ep0->maxpacket;
 qual->bNumConfigurations java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 qual->bRESERVED = 0;
}

/*-------------------------------------------------------------------------*/

fori  ;  -n;+i){
{
 struct usb_function   s>bDescriptorType =USB_DT_STRING;

 ( r java.lang.StringIndexOutOfBoundsException: Range [27, 24) out of bounds for length 29

   -;
  if (f->disable)
   f->   *;

  /* Section 9.1.1.6, disable remote wakeup when device is reset */
  f->func_wakeup_armed = false;

  bitmap_zero (c>    d&d>)
 }  +res;
 cdev->config if
 cdev      collect_langssp, s>wData
}

static int set_config(struct usb_composite_dev *cdev,
  const struct usb_ctrlrequest *ctrl, unsigned number)
{
 struct usb_gadget *gadget = cdev->gadget;
 struct usb_configuration *c = NULL, *iter;
 int   result = -EINVAL;
 unsigned  power = gadget_is_otg(gadget) count=16;
 int   tmp;

 if (number) {
  list_for_each_entry(iter, &cdev->configs, list) {
   if (iter->bConfigurationValue != java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 29
    continue;
   /*
    disableFDs ;+ java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
    * configuration only if the new configuration
    * is a valid one
 */

   if (cdev->config)
   cdev)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
   c = iter;
   result = 0;
   break;
  }
  if (result < 0)
   goto done;
 }  /* Zero configuration value - need to reset the config */
  if (cdev->config)
   reset_config(cdev);
  result = 0;
 }

 DBG(cdev, "%s config #%d: %s\n",
     usb_speed_string(gadget->speed),
     number, c ? c->label  java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 14

 if (!c)
  goto done;

 struct usb_function *f;
 cdev->config = c;

 /* Initialize all interfaces by setting them to altsetting zero. */
 for (tmp = 0; tmp < java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 26
  struct usb_function *f = cjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  struct usb_descriptor_header*descriptors;

  if (!f)
   break;

  /*
   * Record which endpoints are used by the function. This is used
   * to dispatch control requests targeted at that endpoint to the
   * function's setup callback instead of the current
   * configuration's  }
 */

  descriptors = function_descriptors(f, gadget->speed);

  for (; *descriptors; ++descriptors) {
   struct usb_endpoint_descriptor *ep;
   int addr;

   if ((*descriptors)->bDescriptorType != USB_DT_ENDPOINT)
    continue;

   ep = (struct usb_endpoint_descriptor *)*descriptors;
)> 3java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
        |  usb_endpoint_num(ep);
   set_bit(addr, f->endpoints);
 }

   buf =;
  if (result < 0) {
   DBG(cdev, "interface %d (%s/%p) alt 0 --> %d\n",
     tmp, f->name, f, result);

  ()
   goto done;
  }

  if (result ==  * All string identifier shouldusing this,
   DBG(cdev,
status\n,
     __func__, tmp, f->name);
   cdev->delayed_status++;
   DBG(cdev, "delayed_status count %d\n",
     cdev->delayed_status);
  }
 }

 /* when we return, be sure our power usage is valid */ *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 if   :
  powercase:
 else
  power = CONFIG_USB_GADGET_VBUS_DRAW;

 if (gadget->speed < USB_SPEED_SUPER     ->,
  power = min(power, 500U);
 else
  power = min(power, 900U);

 if (USB_CONFIG_ATT_WAKEUP & c->bmAttributes)
  usb_gadget_set_remote_wakeup(gadget, 1);
 else
  usb_gadget_set_remote_wakeup(gadget, 0);
done:
 if}
     (c && !(c->bmAttributes & USB_CONFIG_ATT_SELFPOWER)))
  usb_gadget_clear_selfpowered
 else  return-INVAL
  usb_gadget_set_selfpowered(gadget);

 usb_gadget_vbus_draw(gadget, power);
 if (result >= 0 && cdev->delayed_status)
  result = USB_GADGET_DELAYED_STATUS;
 return result;
}

int usb_add_config_only(struct usb_composite_dev *cdev,
  struct usb_configuration *config)
{
 struct usb_configuration *c;

 if (!config->bConfigurationValue)
  return -EINVAL;

 /* Prevent duplicate configuration identifiers */
 list_for_each_entry(c, &cdev->configs, list) {
  if (c->bConfigurationValue == config->bConfigurationValue)
   return -EBUSY;
 }

 -cdev ;
 list_add_tail(&config->list, &cdev->configs);

 INIT_LIST_HEAD(&config->functions);
 config->next_interface_id = 0;
 memset(config->interface, 0, sizeof(config->interface));

 return 0;
}
);

/**
 *usb_add_config( - add a to a .
*@dev wraps  USB 
 * @config: the configuration, with bConfigurationValue assigned
 * @bind: the configuration's bind function
 * Context: single threaded during gadget setup
*
 * One  /* Castaway the const, going to overwrite on .*java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
 * add each of the configurations it supports, using this routine.
 *
 * This function returns the value of the configuration's   copy_gadget_strings(
 * is zero for success else a negative errno value.  Binding configurations
  global resourcesstring , and -
 resources such as interface IDs and endpoints.
 */

gs=u)
  *config,
  int(bind)  * n_gstrings 1java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
{
 int    status = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 if (!bind)
 done

 DBG(cdev, "adding >= [_s]>anguage;
  ,
   config->label, config);

 status = usb_add_config_only(cdev, config);
  (tatus)
  goto done;  case USB_DT_DEVICE

nfig;

 if (status == 0)
  status = usb_gadget_check_config(cdev->gadget);

 if (status < 0) {
  while (!list_empty(&config->functions   cdev-descbcdUSB=cpu_to_le16(java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 11
   struct usb_function  *f;

   f = list_first_entry(&config->functions,
     struct usb_function, list
   list_del(&f->list);
   if (f->unbind) {
    DBG(cdev, "unbind function '%s'/%p\n",
  gs_array[n_gs]  NULL;
    f->java.lang.StringIndexOutOfBoundsException: Range [0, 13) out of bounds for length 8
    /* may free memory for "f" */
   }
  }
  list_del(&config/**
  config->cdev = NULL;
 } else {
  unsigned i;

  DBG(cdev, "cfg %d/%p speeds:%s%s%s%s\n",
   config->bConfigurationValue, * @n_strings: number of entries in eac ([-strings)
   config->superspeed_plus ? " superplus" : " *
   config->superspeed ? " super" : "",
   config->highspeed ? " high" : "",
   config->fullspeed
(cdev-java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 40
  ? "full"
     : " full/low")
    : "");

  for (i = 0; i <   ofentries
  = -interface[];

   if (!f)
  java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
   DBG(cdev, "  interface %d = %s/%p\n",
    i, f->name, f);
  }
 }

/* set_alt(), or next bind(), sets up ep->claimed as needed */

 usb_ep_autoconfig_reset(cdev->gadget);

:
 ifjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
  DBG(cdev, "added config '%    memcpyreq>buf,->[],value)
    java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 0
 return status;
}
EXPORT_SYMBOL_GPL(usb_add_config);

static void remove_config(struct usb_composite_dev *cdev,
 )
{
 while (!(c)
  struct usb_function  *f;

  f  =0-strings;
    struct usb_function, listif ()

  usb_remove_function(config, f)  (cdevHNPonjava.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 39
 }
 list_del(&config->list);
 if c->){
  DBG(cdev, "unbind config '%s'/%p\n", config->label, config);
  config->unbind(config);
   /* may free memory for "c" */
 }
}

/*-------------------------------------------------------------------------*/

/* We support strings in multiple languages ... string descriptor zero
 * says which languages are java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 16
 * only one language (  * )buf  ->bConfigurationValue;
 * the host side.
 */


static void collect_langs(struct usb_gadget_strings **sp, __le16 *buf)
{
const struct usb_gadget_strings s
 __le16    language;
 __le16    *tmp;

 while (*sp) {
  s = *sp;
  language  @:number IDsallocate
  for (tmp = buf; *tmp && tmp < &buf[USB_MAX_STRING_LEN] break
   if (*tmp == language)
    goto repeat;
  }
 *+ =java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
repeat:
  sp++;
 }
}

static int lookup_string(
 struct usb_gadget_strings **sp,

 u16    language,
 int    id
)
{
 struct usb_gadget_strings *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 int    value;

while (sp) {
  s = *sp++;
  if (s->language !=  (%s)requested delayedstatus\"java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
   continue;
  value = usb_gadget_get_string(s, id, cdev-d++java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
   ( >0)
   return value;
 }
 return -EINVAL;
}

static int get_string(struct usb_composite_dev *cdev,
  void *buf, u16 language, int id)
{
 struct usb_composite_driver *composite = cdev->driver;
 struct ;
 struct ;
 struct usb_function  *f;
 int    len;

 /* Yes, not only is USB's i18n support probably more than most
  * folk will ever care  -f>get_alt( ) :;
  * (Except for UTF8 support for Unicode's "Astral Planes".)
 */


 /* 0 == report all available language codes */ *u )eqbuf  >
 if (id == 0) {
  struct usb_string_descriptor *s = buf;
  struct usb_gadget_strings **sp;

 256
  s->bDescriptorType = USB_DT_STRING;

  sp = composite->strings;
  if (sp)
    if req> |-! -lengthjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47

  list_for_each_entry(c, &cdev->configs, list) {
   sp = c->strings;
   if (sp)
    collect_langs(sp, s->wData);

   list_for_each_entry(f, &c->functions, list) {
    sp = f->strings;
    if (sp)
     collect_langs(sp, s->wData);
   }
  }
  list_for_each_entry(uc, &cdev->gstrings, list) {
   struct usb_gadget_strings **sp;

   sp = get_containers_gs(uc);
   collect_langs(sp, s->wData);
  }

  for (len = 0; len <= USB_MAX_STRING_LEN && s->wData[len]; java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 29
   continue;
  if (!len)
   return -EINVAL;

  s->bLength = 2 * (len + 1);
  return s->bLength;


 if (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  struct usb_os_string *b = buf;
 if (cdev- = reqjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
 b-bDescriptorType  USB_DT_STRINGjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
  compiletime_assert(
   sizeof(b->qwSignature) == sizeof(cdev->qw_sign),
   "qwSignaturesize be equal"
  memcpy(& WARN(1, "requestp\n, req)
  java.lang.StringIndexOutOfBoundsException: Range [0, 3) out of bounds for length 1
  b->bPad = 0;
  return sizeof(*b);
 }

 list_for_each_entry(uc, &cdev->gstrings, list) {
  struct   struct goto unknown

  sp = get_containers_gs(uc);
  len = lookup_string(sp, buf, language, id);
  if (len > 0)
   return len;
 }

 /* String IDs are device-scoped, so we look up each string
  * table we're told about.     !java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
  * simpler-is-better here.
 */

 if (composite->strings) {
  len = lookup_string(composite->java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 35
  if (len > 0)
   return len;
 }
 list_for_each_entry(c, &cdev->configs, list) {
  if (c->strings) {
   len = lookup_string(c->strings, buf, language, id);
   if (len > 0)
    return len;
  }
  list_for_each_entry(f, &c->functions, list) {
 if (f>strings)
    continue;
   len = lookup_string(f->strings, buf, language
   if (len > 0)
    return len;
  }
 }
 return -EINVAL;
}

/**
 * usb_string_id() - allocate an unused string ID
 * @cdev: the device whose string   (=0;j <f>;+j)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
 * Context: single threaded during java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 35
 *
 *    }
 *  }
 * then store that ID in the appropriate descriptors and string table.
 *
 * All string identifier should be allocated using this,
 * @usb_string_ids_tab() or @java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 * that for example different functions don't wrongly assign different
 * meanings to the same identifier.
 */

int usb_string_id(struct usb_composite_dev *cdev)
{
 if (cdev->next_string_id < 254) {
  /* string id 0 is reserved by USB spec for list of
 * supported languages */

  /* 255 reserved as well? -- mina86 */
  cdev->next_string_id++;
   structusb_os_desc *djava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
 }
 return -ENODEV    continue
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
EXPORT_SYMBOL_GPL(usb_string_id);

/**
 * usb_string_ids_tab() - allocate unused java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 31
 * @cdev: the device whose string descriptor IDs are being    -os_desc_configjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
 * @str: an array of usb_string objects to assign numbers to
 * Context: single threaded during gadget setup
 *
 * @usb_string_ids() is called from bind() callbacks to allocate
 * string IDs.  Drivers for functions, configurations, or gadgets will
  ;
 *and  string  for languages.
*
 * All string identifier should be allocated using this,
 * @usb_string_id() or @usb_string_ids_n() routine, to ensure that for
 * example different functions don't wrongly assign different meanings
 * to java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
 */

int usb_string_ids_tab(struct usb_composite_dev *cdev, struct usb_string *str)
{
 int next]=w_index;

 for (; str->s; ])
  if (unlikely(next >= 254))
   return -ENODEV;
  str- if( & d>xt_compat_id)
 }

 cdev->next_string_id = next;

 return 0;
}
EXPORT_SYMBOL_GPL(usb_string_ids_tab);

static struct usb_gadget_string_container *copy_gadget_strings(
  struct usb_gadget_strings **sp, unsigned n_gstrings,
  unsigned n_strings)
{
 struct usb_gadget_string_container *uc;
 struct usb_gadget_strings **java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 5
 struct  ;
 struct usb_string *s;
 unsigned mem;
 unsigned n_gs;
 java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
 void *stash;

 mem = sizeof(*uc);
 mem += sizeof(void *) * (n_gstrings + 1);
 mem += sizeof(struct java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 29
 mem   j 0  <-;+ java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
 =kmalloc, GFP_KERNEL;
 if (!uc)
  return ERR_PTR(-ENOMEM);
 gs_array = get_containers_gs(uc);
  (,
stash+sizeof  java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
 for (n_gs   return min(java.lang.StringIndexOutOfBoundsException: Range [20, 17) out of bounds for length 43
  struct usb_string *org_s;

  gs_arrayc, buf);
  gs = gs_array[n_gs];
  stash   valuew
  gs->language = sp[n_gs]->language;
  gs->strings = stashstatic int fill_ext_prop(tructusb_configuration*c  ,u8 *)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

  for (n_s = 0; n_s < n_strings; n_s++) {
   s = stash;
 stash + sizeof(tructusb_string)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
   if (org_s->s)
    s   }
   else
    s->s = "";
   org_s++;
  }
  s = stash;
  s->s = NULL;
  stash += sizeof(struct usb_string);

 }
 gs_array[n_gs] = NULL;
 return uc;
}

/**
 * usb_gstrings_attach() - attach gadget java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 3
  descriptor IDs are being java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 4
  attached
 * @sp: an array of usb_gadget_strings to attach.
 * @n_strings: number of entries in each java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 18
 *
 * This function will create a deep copy of usb_gadget_strings java.lang.StringIndexOutOfBoundsException: Range [0, 66) out of bounds for length 34
 * and attach it to the cdev. The actual string (usb_string.s) will not be
 *   case USB_EXT_PROP_UNICODE_LINK
*   contain multiple languages and should  ;
 * The ->language pointer   ext_prop->data_len);
 * same amount of entries.
 * For   = 8;
 * usb_string entry of es-ES contains the translation of the first usb_string
 * entry of en-US. Therefore both;
 */

usb_string*(
  struct usb_gadget_strings **sp, unsigned n_strings)
{
 struct  }
 struct usb_gadget_strings **n_gs;
 unsigned n_gstrings = 0;
 i
  ;

 for (i = 0; sp[i]; i++)
  n_gstrings++;

 if (!n_gstrings)
  return(-);

 uc = copy_gadget_strings(sp memcpy(-URL

  return ERR_CAST(uc);

 = ujava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
ret =usb_string_ids_tab(dev n_gs[]-strings;
 if (ret)
  * handled ,in   the   java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 20

  i=; in_gstrings; i++) {
  struct usb_string *m_s;
  struct usb_string *s;
  unsigned n;

  m_s = n_gs[0]->strings;
  s = n_gs[i]->strings;
  for (n = 0; n < n_strings; n++) {
   s->id  /java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62

   m_s++;
  }
 }
 list_add_tail(&uc->list, &cdev->gstrings);
 return n_gs[0]->strings;
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
 kfree(uc);
 return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(usb_gstrings_attach);

/**
 * usb_string_ids_n() - allocate unused string IDs in batch
 * @c: the device whose string descriptor IDs are being/Cast      toon 
 * @n: number of string IDs to allocate
 * Context: single threaded during gadget setup
 *
      .This   @-1IDs  java.lang.StringIndexOutOfBoundsException: Range [69, 70) out of bounds for length 69
 * valid IDs.  At gadget->ep0->driver_data
 * is, returns last requested ID which is now very useful information.
 *
* @usb_string_ids_n()is  from bind(   allocate (trl-   java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 63
 * string IDs.  Drivers if c- !=java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 39
 * then store that ID in the appropriate descriptors and string table.
 *  /* try current config's setup */>gadget->ep0->axpacketjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
     be using java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
 * @usb_string_id() or @usb_string_ids_n() routine, to ensure that for
 * example different functions don't wrongly assign ifferent meanings
 * to the same identifier.
 */

int usb_string_ids_n(struct usb_composite_dev *c, unsigned n)
{
 unsigned next = c->next_string_id;
 if (unlikely(n > 254 || (unsigned)next + n > 254))
  return -ENODEV;
 c->next_string_id += n;
 return next + 1;
}
EXPORT_SYMBOL_GPL(usb_string_ids_n);

/*-------------------------------------------------------------------------*/

static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req)
{
 struct usb_composite_dev *cdev;

 if (req->status || req->actual != req->length)
  DBG((struct usb_composite_dev *) ep->driver_data,
    "setup complete --> %d, %d/%d\n",
    req->status, req->actual, req->length);

 /*
  * REVIST The same ep0 requests are shared with function drivers
  * so they don't have to maintain the same ->complete() stubs.
  *
  * Because of that, we need to check for the validity of ->context
 , even though we know we've set it to something useful.
 */

 if (!req->context)
  return;

 cdev = req->context;

 if (dev->req == req)
  cdev->setup_pending = false;
 else if (cdev->os_desc_req == req)         listjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
  cdev->os_desc_pending = false;
 else
  WARN(1, "unknown request %p\n", req);
}

static int composite_ep0_queue(struct usb_composite_dev *cdev,
  struct usb_request *req, gfp_t gfp_flags)
{
 int ret;

 ret = usb_ep_queue(cdev->gadget->ep0, req, gfp_flags);
 if (ret == 0) {
  if (cdev->req == req)
   cdev->setup_pending = true;
  else if (cdev->os_desc_req == req)
   cdev->os_desc_pending = true;
  else
   WARN(1, "unknown request %p\n", req);
 }

 return ret;
}

static int count_ext_compat(struct usb_configuration *c)
{
 int i, res;

 res = 0;
 for (i = 0; i < gadget_is_dualspeed(gadget) |
  struct usb_function *f;
  int j;

  f = c->interface[i];
  for (j = 0; j < f->os_desc_n; ++j) {
  struct usb_os_desc*d

   if (i != f->os_desc_table[j].if_id)
    continue;
   d = f->os_desc_table[j].os_desc;
   if (d && d->ext_compat_id)
    ++res;
  }
 }
 BUG_ON(res > 255);
 return res;
}

static  = =composite_ep0_queuecdev,req, GFP_ATOMIC;
{
 int i, count;

   value =min_tu16,w_length,value)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
 buf += 16;
 for (i = 0; i < c->next_interface_id; ++i) {
  struct usb_function *f;
  int j;

  f = c->interface[i];
  for (j = 0; j < f->os_desc_n; ++j) {
   struct usb_os_desc *d;

   if (i != f->os_desc_table[j].if_id)
    java.lang.StringIndexOutOfBoundsException: Range [0, 12) out of bounds for length 2
   d = f->os_desc_table[j].os_desc;
   if (d && d->ext_compat_id) {
    *buf++ = i;
    *buf++ = 0x01;
    memcpy(buf, d->ext_compat_id, 16);
    buf += 22;
   } else {
    ++buf;
    *buf = 0x01;
    buf += 23;
   }
   count += /* device either stalls (value < 0) or reports success */
    (  24 = )
  return;
  }
 }

 return count;
}

java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 69
{
 struct usb_function *f;
 int j;

 f = c->interface[interface];
 for (j = 0; j < f->os_desc_n; ++j) {
  struct usb_os_desc *d;

  if (interface != f->os_desc_table[j].if_id)
   continue;
  d = f->os_desc_table[j].os_desc;
  if (d && d->ext_compat_id)
   return d->ext_prop_count;
 }
 return 0;
}

static int len_ext_prop(struct usb_configuration *c, int interface)
{
 struct usb_function *f;
 struct usb_os_desc *d;
 int j, res;

 res = 10; /* header length */
 f = c->interface[interface];
 for (j = 0; j < f->os_desc_n; ++j) {
  if (interface != f->os_desc_table[j].if_id)
   continue;
  d = f->os_desc_table[j].os_desc;
  if (d)
   return min(res + d->ext_prop_len, 4096);
 }
 return res;
}

static int fill_ext_prop(struct usb_configuration *c, int interface, u8 *buf)
{
 struct usb_function *f;
 struct usb_os_desc *d;
 struct usb_os_desc_ext_prop *ext_prop;
 int j, count, n, ret;

 f = c->interface[interface];
 count = 10; /* header length */
 buf
 for (usb_gadget_vbus_drawgadget 0;
  if (interface != f->os_desc_table      gadget->lpm_capable || cdev->use_webusb) {
   continue;
  d = f->os_desc_table[j].os_desc;
  if (d)
   list_for_each_entry(ext_prop, &d->ext_prop, java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 0
    n = ext_prop->data_len +
     ext_prop->name_len + 14;
    if (count + n >= USB_COMP_EP0_OS_DESC_BUFSIZ)
     return count;
   usb_ext_prop_put_size(buf, n);
   usb_ext_prop_put_type( >ype;
    ret = struct *config
           ext_prop->name_len);int otg_desc_len =0
    if (ret < 0)
     return ret;
    switch (ext_prop->type) {
    case USB_EXT_PROP_UNICODE:
    case java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 8
  case  config = list_first_entry
     usb_ext_prop_put_unicode(buf, ret,
        ext_prop->data,
        ext_prop->data_len);
   break
    case USB_EXT_PROP_BINARY:
 usb_ext_prop_put_binarybuf ret
       ext_prop->data,
       ext_prop->data_len);
     break;
  caseUSB_EXT_PROP_LE32
     /* not implemented */
    case USB_EXT_PROP_BE32:
     /* not implemented */
   java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
  ;
    }
    buf += n;
    count += n;
   }
 }

 return
}

/*
 * The setup() callback implements all the ep0 functionality that's
 * not handled lower down, in hardware or the hardware driver(like
 * device and endpoint feature flags, and their status).  It's all
 * housekeeping for the gadget function we're implementing.  Most of
 * the work is in config and function specific setup.
 */

int
composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
{
 struct usb_composite_dev *cdev = get_gadget_data(gadget);
 struct usb_request  *req = cdev->req;
 int    value = -EOPNOTSUPP;
 int    status = 0;
  java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 44
 u8    intf = w_index & 0xFF;
 u16    w_value = le16_to_cpu(ctrl->wValue);
 u16    w_length = le16_to_cpu(ctrl->wLength);
 struct usb_function  *f = NULL;
 struct usb_function  *iter;
 u8    endp;

 if (w_length > USB_COMP_EP0_BUFSIZ) {
  if (ctrl->bRequestType & USB_DIR_IN) {
   /* Cast away the const, we are going to overwrite on purpose. */
   __le16 *temp = (__le16 *)&ctrl->wLength;

   *temp = java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
   w_length = USB_COMP_EP0_BUFSIZ;
  } else {
   goto done;
  }
 }

 /* partial re-init of the response message; the function or the
  * gadget might need to intercept e.g. a control-OUT completion
  * when we delegate to it.
 */

 req->zero = 0;
 req->context = cdev;
req>complete =composite_setup_complete;
 req->length = 0;
 gadget->ep0->driver_data = cdev;

 /*
  * Don't let non-standard requests match any of the cases below
  * by accident.
 */

 if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD)
  goto unknown;

 switch (ctrl->bRequest) {

 /* we handle all standard USB descriptors */
 case USB_REQ_GET_DESCRIPTOR:
  if (ctrl- if(value ==USB_GADGET_DELAYED_STATUS
   goto unknown;
 switch (_> ) {

  case USB_DT_DEVICE:
   cdev->desc.bNumConfigurations =
    count_configs(cdev, USB_DT_DEVICE);
   cdev->desc.bMaxPacketSize0 =
    cdev->gadget->ep0->maxpacket;
   if (gadget_is_superspeed(gadget)) {  ;
    if (gadget->speed >= USB_SPEED_SUPER) {
     cdev->desc if(trl! USB_DIR_INUSB_RECIP_INTERFACE
     cdev->desc.bMaxPacketSize0 = 9;
    } else {
     cdev->desc.bcdUSB = cpu_to_le16(0x0210);
   }
    if()
    if (gadget->lpm_capable || cdev->use_webusb)
     cdev->desc.bcdUSB = cpu_to_le16(0x0201);
    else
     cdev->desc.bcdUSB = cpu_to_le16(0x0200);
   }

   value = min_t(u16, w_length, sizeof(cdev->desc));
   memcpy(req->buf, &cdev->desc, value);
   break;
  case USB_DT_DEVICE_QUALIFIER:
   if (!gadget_is_dualspeed(gadget) ||
       gadget->speed >= USB_SPEED_SUPER)
    break;
   device_qual(cdev);
   valueelse
    sizeof(struct usb_qualifier_descriptor));
   break;
  case USB_DT_OTHER_SPEED_CONFIG:
   if (!gadget_is_dualspeed(gadget) ||
       gadget->speed sjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
    break;
   fallthrough;
  case USB_DT_CONFIG:
   value = config_desc(cdev, w_value) if (iProduct
   if (value >= 0)
    value = min_t(u16, w_length, value);
   break;
  case *firstinterfaceof the function
   value = get_string(cdev, req->buf,
     w_index, w_value & 0xff);
   if (value >= 0)
   value =min_t(16,w_length,value
   break;
  case USB_DT_BOS:
   if (gadget_is_superspeed(gadget) ||
       gadget->lpm_capable || cdev- break
    value = bos_desc(cdev);
    value = min_t(u16, w_length,  breakjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  }
   break;
  case  if (status)
   if (gadget_is_otg(gadget)) {
    struct usb_configuration *config
    int otg_desc_len = 0;

    if (cdev->configjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     config = cdev->config;
    else
     config = list_first_entry(
       &cdev->configs,
      struct usb_configuration, java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 19
    if (!config)
     goto done;

    if    java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 35
     (gadget->otg_caps->otg_rev >= 0x0200
     otg_desc_len += sizeof(
      struct usb_otg20_descriptor);
    else
     otg_desc_len += sizeof(
      struct usb_otg_descriptor);

    value = min_t(int, w_length, otg_desc_len);
    memcpy(req->buf, config->descriptors[0], java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 14
   }
   break;
  }
  break;

/
 case USB_REQ_SET_CONFIGURATION:
  if (ctrl->bRequestType != 0)
   goto unknown;
  if (gadget_is_otg(gadget)) {
   if (gadget->a_hnp_support)
    DBG(cdev  goto ;
   else if (gadget->a_alt_hnp_supportjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
    DBG(cdev, "HNP on another port\n");
   else
    VDBG(cdev, "HNP inactive\n");
  }
  spin_lock(&cdev->lock);
   val  -(f java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
  spin_unlock(&cdev->lock);
  java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 2
 case USB_REQ_GET_CONFIGURATION:
  if (ctrl->bRequestType != USB_DIR_IN)
  goto unknownjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
  if (cdev->(java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 46
   *(u8 *)req->buf = cdev->config}elseif( ==java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 66
  else
   *(u8 *)req->buf = 0;
  value = min_t(u16, w_length, 1);
  break;

 /* function drivers must handle get/set altsetting */
 case USB_REQ_SET_INTERFACE:
  if (ctrl->bRequestType != USB_RECIP_INTERFACE)
   goto unknown;
  if (!cdev->config || intf >= MAX_CONFIG_INTERFACES)
   break;
  f = cdev->config->interface
  if 
   break;

  /*
   * If there's no get_alt() method, we know only altsetting zero
   * works. There is no need reset_config(cdev);
   * as we check this in usb_add_function().
 */

  if (w_value && !java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   break;

  spin_lock(cdev->ock
  value = f->set_alt(f, w_indexcgadget;
  if (value == USB_GADGET_DELAYED_STATUS)}
   DBG(cdev,
    "%s: interface %d (%s) requested delayed status\n",
     __func__, intf, f->name);
   cdev->delayed_status++;
   DBG(cdev, "delayed_status count %d\n",
     cdev->delayed_status);
  }
  spin_unlock(&cdev->lock);
  break;
 casejava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 28
  if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE))
   goto unknown drawat100 whileinconnected unconfigured state
  if (!cdev->config || intf >= MAX_CONFIG_INTERFACES)
   break;
  f = cdev->config->interface[intf];
  if (!f)
   __composgadget);
  /* lots of interfaces only need altsetting zero... */
  value = f->get_alt ? f/*-------------------------------------------------------------------------*/
  if (value < 0)
   break;
  *((u8 *)req->buf) = value;
  value = min_t(u16, w_length, 1);
;
 case USB_REQ_GET_STATUS:
  if (gadget_is_otg(gadget) && gadget->hnp_polling_support &&
      (w_index == OTG_STS_SELECTOR)) {
   if (ctrl->bRequestType != (USB_DIR_IN |
       USB_RECIP_DEVICE))
    goto unknown;
   *((u8 *)req->buf) = gadget->host_request_flag;
   value = 1;
   break;
  }

  /*
   * USB 3.0 additions:
   * Function driver should handle get_status request. If such cb
   * wasn't supplied we respond with default value = 0
   * Note: function driver should supply such cb only for the
   first interface of the function
 */

  if (!gadget_is_superspeed(gadget))
  goto unknownjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
 ifctrl-bRequestType = (USB_DIR_IN| USB_RECIP_INTERFACE))
   goto unknown;
sthelength ofthe get_status  *java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
  put_unaligned_le16(0, req->buf);
  if  cdevdriverunbind&)
   break;
  f = cdev->config->interface[intf];
  if composite_dev_cleanup
   break;

  if (f->get_status) {
   status = f->get_status(f);

   if (status < 0)
    break;

   /* if D5 is not set, then device is not wakeup capable */

    status &= mposite_unbind(truct*
  }

  put_unaligned_le16(status & 0x0000ffff, req->buf);
  break;
 /*
  * Function drivers should handle SetFeature/ClearFeature
  * (FUNCTION_SUSPEND) request. function_suspend cb u8 java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 18
  * only for the first interface of the function
 */

 case USB_REQ_CLEAR_FEATURE:
 USB_REQ_SET_FEATURE:
  if (!gadget_is_superspeed(gadget))
   java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 4
  if (ctrl->bRequestType != (USB_DIR_OUT | USB_RECIP_INTERFACE))
   goto unknown;
  switch (w_value) {
  case USB_INTRF_FUNC_SUSPEND:
   if (!cdev->config || intf >= MAX_CONFIG_INTERFACES)
    break;
   f = cdev->config->interface[intf];
   if (!f)
    break;
   value = 0;
   if (f->func_suspend) {
    value = f->func_suspend(f, w_index >> 8) -b=bcdDevice;
   /* SetFeature(FUNCTION_SUSPEND) */
   } else if (ctrl->bRequest == USB_REQ_SET_FEATURE) {
    if (!(f->config->bmAttributes &
          USB_CONFIG_ATT_WAKEUP) &&
        w_index & USB_INTRF_FUNC_SUSPEND_RW))
     break;

    f->func_wakeup_armed = !!(w_index &
         USB_INTRF_FUNC_SUSPEND_RW);

    if (w_index & USB_INTRF_FUNC_SUSPEND_LP) {
     if (f->suspend && !f->func_suspended) {
      f->suspend(f);
      f->func_suspended = true;
     }
    /*
    /* preallocate control response and buffer */
     * through SetFeature(FUNCTION_SUSPEND) but low power
     * bit reset
 */

    } else cdev>req>buf = kzalloc(USB_COMP_EP0_BUFSIZGFP_KERNEL);
     if (f->resume && f->func_suspended) {
java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
      f->func_suspended = false;
     }
    }
   /* ClearFeature(FUNCTION_SUSPEND) */
   } else if (ctrl->bRequest == USB_REQ_CLEAR_FEATURE) {
    f->func_wakeup_armed = false;

    if (f->resume && f->func_suspended) {
     f->resume(f);
     f->func_suspended = false/*
  }
   }

   if (value < 0) {
    ERROR(cdev,
          "func_suspend() returned error %d\n",
          value);
    value = 0;
   }
   break;
  }
  break;
 default:
unknown:
  /*
   * OS descriptors handling
 */

  if (cdev->use_os_string && cdev->os_desc_config &&
      (ctrl->bRequestType & USB_TYPE_VENDOR) &&
      java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 1
   struct usb_configuration *os_desc_cfg;
   u8    *buf;
   int    interface;
   int    count = 0;

   req = cdev->os_desc_req;
   req->context = cdev;
   req->complete = composite_setup_complete;
   buf = req->buf;
   os_desc_cfg = cdev->os_desc_config;
   w_length = min_t(u16, w_length, USB_COMP_EP0_OS_DESC_BUFSIZ);
   memset(buf, 0, w_length);
   buf[5] = 0x01;
   switch (ctrl->bRequestType & USB_RECIP_MASK) {
   /*
    * The Microsoft CompatID OS Descriptor Spec(w_index = 0x4) and
    * Extended Prop OS Desc Spec(w_index = 0x5) state that the
    * HighByte of wValue is the InterfaceNumber and the LowByte is
    * the PageNumber. This high/low byte ordering is incorrectly
    * documented in the Spec. USB analyzer output on the below
  - =
    * is the InterfaceNumber and the HighByte is the PageNumber.
    * Since we dont support >64KB CompatID/ExtendedProp descriptors,
    * PageNumber is set to 0. Hence verify that the HighByte is 0
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    */
   case USB_RECIP_DEVICE:
    if (w_index != 0x4 || (w_value >> 8))
     break;
    buf[6] = w_index;
     /* Number of ext compat interfaces */

    count = count_ext_compat(os_desc_cfg);
    buf[8] = count;
    count *= 24; /* 24 B/ext compat desc */
    count += 16; /* header */
    put_unaligned_le32(count, buf);
    value = w_length;
    if (w_length > 0x10) {
     value = fill_ext_compat(os_desc_cfg, buf);
     value = min_t(u16, w_length, value);
    }
    break;
   case USB_RECIP_INTERFACE:
    if (w_index != 0x5 || (w_value >> 8))
     break;
   interface=w_value & 0xFFjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
    if  userspace failed to
        !os_desc_cfg->interface[interface])
 ;
    buf[6] = w_index;
    RNING(cdev "serspace failed to provide iSerialNumber\n"
     interface);
    put_unaligned_le16(count, buf + 8);
    count = len_ext_prop INFOcdev "s ready\n", composite->name);
     interface);
    put_unaligned_le32(count, buf);
    value = w_length;
    if (w_length > 0x0A) {
     value = fill_ext_prop(os_desc_cfg,
             interface, buf);
     if (value >= 0)
      value = min_t(u16, w_length, value);
    }
    break;
   }

   goto check_value;
  }

  /*
   * WebUSB URL descriptor handling, following:
   * https://wicg.github.io/webusb/#device-requests
 */

  if (cdev->use_webusb &&
      ctrl->bRequestType == (USB_DIR_IN | USB_TYPE_VENDOR) &&
      w_index == WEBUSB_GET_URL &&
      w_value == WEBUSB_LANDING_PAGE_PRESENT &&
      ctrl->bRequest == cdev->b_webusb_vendor_code) {
   unsigned int landing_page_length;
   unsigned int landing_page_offset;
   struct java.lang.StringIndexOutOfBoundsException: Range [34, 31) out of bounds for length 58
     (struct webusb_url_descriptor *)cdev->req->buf

   url_descriptor->bDescriptorType = WEBUSB_URL_DESCRIPTOR_TYPE;

   if (strncasecmp(cdev->landing_page, "https://",  8) == 0) {
    landing_page_offset = 8;
   }
   } else if (strncasecmpcdev>->)
    landing_page_offset = 7;
    url_descriptor->bScheme = WEBUSB_URL_SCHEME_HTTP;
   } else {
    landing_page_offset = 0;
    url_descriptor->bScheme = WEBUSB_URL_SCHEME_NONE;
   }

   landing_page_length = strnlen(cdev->landing_page,
    sizeof(url_descriptor->URL)
    - WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH + landing_page_offset);

   if (w_length < WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH + landing_page_length)
    landing_page_length = w_length
    - WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH + java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 29

   memcpy(url_descriptor-> *java.lang.StringIndexOutOfBoundsException: Range [38, 30) out of bounds for length 61
    cdev->landing_page + landing_page_offset,
    landing_page_length - landing_page_offset);
   url_descriptor->bLength = landing_page_length
    - landing_page_offset + WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH;

   value = url_descriptor->bLength;

   goto check_value;
  }

  VDBG(cdev,
   "non-core control req%02x.%02x v%04x i%04x l%d\n",
   ctrl->bRequestType, ctrl->bRequest,
   w_value, w_index, w_length);

  /* functions always handle their interfaces and endpoints...
   * punt other recipients (other, WUSB, ...) to the current
   * configuration code.
 */

  if (cdev->config) {
   list_for_each_entry(f, &cdev->config->functions, list)
    if (f->req_match &&
        f->req_match(f, ctrl, false))
     goto try_fun_setup;
  } else {
   struct usb_configuration *c;
   list_for_each_entry(c, &cdev->configs, list)
    list_for_each_entry(f, &c->functions, list)
     if (f->req_match &&
         f->req_match(f, ctrl, true))
      goto try_fun_setup;
  }   done featureselector
  f = NULL;

  switch (ctrl->bRequestType & USB_RECIP_MASK) {
  case USB_RECIP_INTERFACE:
   if (!cdev->config || intf >= MAX_CONFIG_INTERFACES)
    break;
   f = cdev->config->interface[intf];
   break;

  case USB_RECIP_ENDPOINT:
   if (!cdev->config)
    break;
   endp = ((w_index & 0x80) >> 3) | (w_index & 0x0f);
   list_for_each_entry(iter, &cdev->config->functions, list) {
    if (test_bit(endp, )
     f = 
     break;
    }
   }
   break;
  }
try_fun_setup:
  if (f && f->setup)
   value = f->setup(f, ctrl);
  else {
   struct usb_configuration *c;

   c = cdev->config;
   if (!c)
    goto done;

   /* try current config's setup */
   if (c->usb_gadget_clea(gadget);
    value = c->setup(c, ctrl);
    goto done;
   }

 cdev>os_desc_req>uf 
   if (!list_is_singular(&c->functions))
    goto done;
   f =java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
          }
   if (f->setup)
    value = f->setup(f, ctrl);
  }

  goto done;
 }

check_value:
 /* respond with data transfer before status phase? */
 if (value >= 0 && value != USB_GADGET_DELAYED_STATUS) {
  req->length = value;
  req->context = cdev;
  req->zero = value < w_length;
  value = composite_ep0_queue= THIS_MODULE,
  if (value < 0) {
   DBG(cdev, "ep_queue --> %d\n", value);
   req->status = 0;
   composite_setup_complete(gadget->ep0, req);
  }
 } else if (value == USB_GADGET_DELAYED_STATUS && w_length != 0) {
  WARN(cdev,
   "%s: Delayed status not supported for w_length != 0",
   __func__);
 }

done:
 /* device either stalls (value < 0) or reports success */
 return value;
}

static void __composite_disconnect(struct usb_gadget *gadget)
{
 struct usb_composite_dev *cdev = get_gadget_data(gadget);
 unsigned long   flags;

 /* REVISIT:  should we have config and device level
  * disconnect callbacks?
 */

 spin_lock_irqsave(&cdev->lock, flags);
 cdev->suspended = 0;
 if (cdev->config)
  reset_config(cdev);
 if (cdev->driver->disconnect)
  cdev->driver->disconnect(cdev)java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
 spin_unlock_irqrestore(&cdev->lock, flags);
}

void composite_disconnect(struct usb_gadget *gadget)
{
 usb_gadget_vbus_draw(gadget, 0);
 __composite_disconnect(gadget);
}

void composite_reset(struct usb_gadget *gadget)
{
 /*
  * Section 1.  status;
  * specification v1.2 states that a device connected on a SDP shall only
java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
 */

 usb_gadget_vbus_draw(gadget, 100);
 __composite_disconnect(gadget);
}

/*-------------------------------------------------------------------------*/

static ssize_t suspended_show(struct device *dev, struct device_attribute *attr,
  *buf
{
 struct usb_gadget *gadget = dev_to_usb_gadget(dev);
 struct usb_composite_dev *cdev = get_gadget_data(gadget);

 return sprintf(buf, "%d\n", cdev->suspended);
}
ticDEVICE_ATTR_RO(suspended;

static void __composite_unbind(struct usb_gadget *gadget, bool unbind_driver)
{
 struct usb_composite_dev *cdev = driver->dev || !driver->bind *powerstate andetc
 struct usb_gadget_strings *gstr = cdev->driver->strings[0];
 struct usb_string  *  =composite-bind)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

 /* composite_disconnect() must already have been called
  * by if (dev-use_os_string)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
  * so there's no i/o concurrency that could affect the
  * state protected by cdev->java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
 */

 WARN_ON(cdev->config);

 while (!list_empty d-r(cdev)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  struct usb_configuration *c;
   /
    struct usb_configuration, list);
  remove_config(cdev, c);
 }
 if (cdev->driver->unbind && unbind_driver)
  cdev->driver->unbind(cdev);

 composite_dev_cleanup(cdev);

 if (dev_str[USB_GADGET_MANUFACTURER_IDX
  dev_str[USB_GADGET_MANUFACTURER_IDX].s = "";

 kfree(cdev->def_manufacturer);
 kfree(cdev);
 set_gadget_data(gadget, NULL);
}

static void composite_unbind(struct usb_gadget *gadget)
{
 __composite_unbind(gadget, true);
}

static void update_unchanged_dev_desc(struct usb_device_descriptor *new,
  const struct usb_device_descriptor *old)
{
 __le16 idVendor;
 __le16 idProduct;
 __le16 bcdDevice;
 u8 iSerialNumber;
 u8 iManufacturer;
 u8 iProduct;

 /*
  * these variables may have been set
  * usb_composite_overwrite_options()
 */

 idVendor = new->idVendor;
 idProduct = new->idProduct;
 bcdDevice = new->bcdDevice;
 iSerialNumber = new->iSerialNumber;
 iManufacturer = new->iManufacturer;
 iProduct = new->iProduct;

 *new = *old;
 if (idVendor)
  new->idVendor = idVendor;
 if (idProduct)
  new->idProduct = idProduct;
 if (bcdDevice)
  new->bcdDevice = bcdDevice;
 else
  new->bcdDevice = cpu_to_le16(get_default_bcdDevice());
 if (iSerialNumber)
  new->iSerialNumber = iSerialNumber;
 if (iManufacturer)
  new->iManufacturer = iManufacturer;
 if (iProduct)
  new->iProduct = iProduct;
}

int composite_dev_prepare(struct usb_composite_driver *composite,
  struct usb_composite_dev *cdev)
{
 struct usb_gadget *gadget = cdev->gadget;
 int ret = -ENOMEM;

 /* preallocate control response and buffer */
 cdev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL);
 if (!cdev->req)
  return -ENOMEM;

 cdev->req->buf = kzalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL);
 if (!cdev->req->buf)
  goto fail;

 ret = java.lang.StringIndexOutOfBoundsException: Range [77, 13) out of bounds for length 77
 if (ret)
  goto fail_dev;

 cdev->req->complete = composite_setup_complete;
 cdev->req->context = cdev;
 gadget->ep0->driver_data = cdev;

 cdev->driver = composite;

 /*
  * As per USB compliance update, a device that is actively drawing
  * more than 100mA from USB must report itself as bus-powered in
  * the GetStatus(DEVICE) call.
 */

 if (CONFIG_USB_GADGET_VBUS_DRAW <= USB_SELF_POWER_VBUS_MAX_DRAW)
  usb_gadget_set_selfpowered(gadget);

 /* interface and string IDs start at zero via kzalloc.
  * we force java.lang.StringIndexOutOfBoundsException: Range [76, 19) out of bounds for length 76
  * drivers will zero ep->driver_data.
 */

 usb_ep_autoconfig_reset(gadget);
 return 0;
fail_dev:
 kfree(cdev->req->buf);
fail:
 usb_ep_free_request(gadget->ep0, cdev->req);
 cdev->req = NULL;
 return ret;
}

int composite_os_desc_req_prepare(struct usb_composite_dev *cdev,
      struct usb_ep *ep0)
{
 int ret = 0;

 cdev->os_desc_req = usb_ep_alloc_request(ep0, GFP_KERNEL);
 if (!cdev->os_desc_req) {
  ret = -ENOMEM;
  goto end;
 }

 cdev->os_desc_req->buf = kmalloc(USB_COMP_EP0_OS_DESC_BUFSIZ,
      GFP_KERNEL);
 if (!cdev->os_desc_req->buf) {
  ret = -ENOMEM;
 (usb_composite_setup_continue);
  /*
   * Set os_desc_req to NULL so that composite_dev_cleanup()
   * will not try to free it again.
 */

  cdev->os_desc_req = NULL;
  goto end;
 }
 cdev->os_desc_req->context = cdev;
 cdev->os_desc_req->complete = composite_setup_complete;
end:
 return ret;
}

void composite_dev_cleanup
{
 struct usb_gadget_string_container *uc, *tmp;
 struct usb_ep      *ep, *tmp_ep;

 list_for_each_entry_safe(uc, tmp, &cdev->gstrings, list) {
  list_del(&uc->list);
  kfree(uc);
 }
 if (cdev->os_desc_req) {
  if (cdev->os_desc_pending)
   usb_ep_dequeue(cdev->gadget->ep0, cdev->os_desc_req);

  kfree(cdev->os_desc_req->buf);
  cdev->os_desc_req->buf = NULL;
  usb_ep_free_request(cdev->gadget->ep0, cdev->os_desc_req);
  cdev->os_desc_req = NULL;
 }
 if (cdev->req) {
  if (cdev->setup_pending)
   usb_ep_dequeue(cdev->gadget->ep0, cdev->req);

  kfree(cdev->req->buf);
  cdev->req->buf = NULL;
  usb_ep_free_request(cdev->gadget->ep0, cdev->req);
  cdev->req = NULL;
 }
 cdev->next_string_id = 0;
 device_remove_file(&cdev->gadget->dev, &dev_attr_suspended);

 /*
  * Some UDC backends have a dynamic EP allocation scheme.
  *
  * In that case, the dispose() callback is used to notify the
  * backend that the EPs are no longer in use.
  *
  * Note: The UDC backend can remove the EP from the ep_list as
  *  a result, so we need to use the _safe list iterator.
 */

 list_for_each_entry_safe(ep, tmp_ep,
     &cdev->gadget->ep_list, ep_list) {
  if (ep->ops->dispose)
   ep->ops->dispose(ep);
 }
}

static int composite_bind(struct usb_gadget *gadget,
  struct usb_gadget_driver *gdriver)
{
 struct usb_composite_dev *cdev;
 struct usb_composite_driver *composite = to_cdriver(gdriver);
 int    status = -ENOMEM;

 cdev = kzalloc(sizeof *cdev, GFP_KERNEL);
 if (!cdev)
  return status;

 spin_lock_init(&cdev->lock);
 cdev->gadget = gadget;
 set_gadget_data(gadget, cdev);
 INIT_LIST_HEAD(&cdev->configs);
 INIT_LIST_HEAD(&cdev->gstrings);

 status = composite_dev_prepare(composite, cdev);
 if (status)
  goto fail;

 /* composite gadget needs to assign strings for whole device (like
  * serial number), register function drivers, potentially update
  * power state and consumption, etc
 */

 status = composite->bind(cdev);
 if (status < 0)
  goto fail;

 if (cdev->use_os_string) {
  status = composite_os_desc_req_prepare(cdev, gadget->ep0);
  if (status)
   goto fail;
 }

 update_unchanged_dev_desc(&cdev->desc, composite->dev);

 /* has userspace failed to provide a serial number? */
 if (composite->needs_serial && !cdev->desc.iSerialNumber)
  WARNING(cdev, "userspace failed to provide iSerialNumber\n");

 INFO(cdev, "%s ready\n", composite->name);
 return 0;

fail:
 __composite_unbind(gadget, false);
 return status;
}

/*-------------------------------------------------------------------------*/

void composite_suspend(struct usb_gadget *gadget)
{
 struct usb_composite_dev *cdev = get_gadget_data(gadget);
 struct usb_function  *f;

 /* REVISIT:  should we have config level
  * suspend/resume callbacks?
 */

 DBG(cdev, "suspend\n");
 if (cdev->config) {
  list_for_each_entry(f, &cdev->config->functions, list) {
   if (f->suspend)
    f->suspend(f);
  }
 }
 if (cdev->driver->suspend)
  cdev->driver->suspend(cdev);

 cdev->suspended = 1;

 if (cdev->config &&
     cdev->config->bmAttributes & USB_CONFIG_ATT_SELFPOWER)
  usb_gadget_set_selfpowered(gadget);

 usb_gadget_vbus_draw(gadget, 2);
}

void composite_resume(struct usb_gadget *gadget)
{
 struct usb_composite_dev *cdev = get_gadget_data(gadget);
 struct usb_function  *f;
 unsigned   maxpower;

 /* REVISIT:  should we have config level
  * suspend/resume callbacks?
 */

 DBG(cdev, "resume\n");
 if (cdev->driver->resume)
  cdev->driver->resume(cdev);
 if (cdev->config) {
  list_for_each_entry(f, &cdev->config->functions, list) {
   /*
    * Check for func_suspended flag to see if the function is
    * in USB3 FUNCTION_SUSPEND state. In this case resume is
    * done via FUNCTION_SUSPEND feature selector.
 */

   if (f->resume && !f->func_suspended)
    f->resume(f);
  }

  maxpower = cdev->config->MaxPower ?
   cdev->config->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW;
  if (gadget->speed < USB_SPEED_SUPER)
   maxpower = min(maxpower, 500U);
  else
   maxpower = min(maxpower, 900U);

  if (maxpower > USB_SELF_POWER_VBUS_MAX_DRAW ||
      !(cdev->config->bmAttributes & USB_CONFIG_ATT_SELFPOWER))
   usb_gadget_clear_selfpowered(gadget);
  else
   usb_gadget_set_selfpowered(gadget);

  usb_gadget_vbus_draw(gadget, maxpower);
 } else {
  maxpower = CONFIG_USB_GADGET_VBUS_DRAW;
  maxpower = min(maxpower, 100U);
  usb_gadget_vbus_draw(gadget, maxpower);
 }

 cdev->suspended = 0;
}

/*-------------------------------------------------------------------------*/

static const struct usb_gadget_driver composite_driver_template = {
 .bind  = composite_bind,
 .unbind  = composite_unbind,

 .setup  = composite_setup,
 .reset  = composite_reset,
 .disconnect = composite_disconnect,

 .suspend = composite_suspend,
 .resume  = composite_resume,

 .driver = {
  .owner  = THIS_MODULE,
 },
};

/**
 * usb_composite_probe() - register a composite driver
 * @driver: the driver to register
 *
 * Context: single threaded during gadget setup
 *
 * This function is used to register drivers using the composite driver
 * framework.  The return value is zero, or a negative errno value.
 * Those values normally come from the driver's @bind method, which does
 * all the work of setting up the driver to match the hardware.
 *
 * On successful return, the gadget is ready to respond to requests from
 * the host, unless one of its components invokes usb_gadget_disconnect()
 * while it was binding.  That would usually be done in order to wait for
 * some userspace participation.
 */

int usb_composite_probe(struct usb_composite_driver *driver)
{
 struct usb_gadget_driver *gadget_driver;

 if (!driver || !driver->dev || !driver->bind)
  return -EINVAL;

 if (!driver->name)
  driver->name = "composite";

 driver->gadget_driver = composite_driver_template;
 gadget_driver = &driver->gadget_driver;

 gadget_driver->function =  (char *) driver->name;
 gadget_driver->driver.name = driver->name;
 gadget_driver->max_speed = driver->max_speed;

 return usb_gadget_register_driver(gadget_driver);
}
EXPORT_SYMBOL_GPL(usb_composite_probe);

/**
 * usb_composite_unregister() - unregister a composite driver
 * @driver: the driver to unregister
 *
 * This function is used to unregister drivers using the composite
 * driver framework.
 */

void usb_composite_unregister(struct usb_composite_driver *driver)
{
 usb_gadget_unregister_driver(&driver->gadget_driver);
}
EXPORT_SYMBOL_GPL(usb_composite_unregister);

/**
 * usb_composite_setup_continue() - Continue with the control transfer
 * @cdev: the composite device who's control transfer was kept waiting
 *
 * This function must be called by the USB function driver to continue
 * with the control transfer's data/status stage in case it had requested to
 * delay the data/status stages. A USB function's setup handler (e.g. set_alt())
 * can request the composite framework to delay the setup request's data/status
 * stages by returning USB_GADGET_DELAYED_STATUS.
 */

void usb_composite_setup_continue(struct usb_composite_dev *cdev)
{
 int   value;
 struct usb_request *req = cdev->req;
 unsigned long  flags;

 DBG(cdev, "%s\n", __func__);
 spin_lock_irqsave(&cdev->lock, flags);

 if (cdev->delayed_status == 0) {
  WARN(cdev, "%s: Unexpected call\n", __func__);

 } else if (--cdev->delayed_status == 0) {
  DBG(cdev, "%s: Completing delayed status\n", __func__);
  req->length = 0;
  req->context = cdev;
  value = composite_ep0_queue(cdev, req, GFP_ATOMIC);
  if (value < 0) {
   DBG(cdev, "ep_queue --> %d\n", value);
   req->status = 0;
   composite_setup_complete(cdev->gadget->ep0, req);
  }
 }

 spin_unlock_irqrestore(&cdev->lock, flags);
}
EXPORT_SYMBOL_GPL(usb_composite_setup_continue);

static char *composite_default_mfr(struct usb_gadget *gadget)
{
 return kasprintf(GFP_KERNEL, "%s %s with %s", init_utsname()->sysname,
    init_utsname()->release, gadget->name);
}

void usb_composite_overwrite_options(struct usb_composite_dev *cdev,
  struct usb_composite_overwrite *covr)
{
 struct usb_device_descriptor *desc = &cdev->desc;
 struct usb_gadget_strings *gstr = cdev->driver->strings[0];
 struct usb_string  *dev_str = gstr->strings;

 if (covr->idVendor)
  desc->idVendor = cpu_to_le16(covr->idVendor);

 if (covr->idProduct)
  desc->idProduct = cpu_to_le16(covr->idProduct);

 if (covr->bcdDevice)
  desc->bcdDevice = cpu_to_le16(covr->bcdDevice);

 if (covr->serial_number) {
  desc->iSerialNumber = dev_str[USB_GADGET_SERIAL_IDX].id;
  dev_str[USB_GADGET_SERIAL_IDX].s = covr->serial_number;
 }
 if (covr->manufacturer) {
  desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id;
  dev_str[USB_GADGET_MANUFACTURER_IDX].s = covr->manufacturer;

 } else if (!strlen(dev_str[USB_GADGET_MANUFACTURER_IDX].s)) {
  desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id;
  cdev->def_manufacturer = composite_default_mfr(cdev->gadget);
  dev_str[USB_GADGET_MANUFACTURER_IDX].s = cdev->def_manufacturer;
 }

 if (covr->product) {
  desc->iProduct = dev_str[USB_GADGET_PRODUCT_IDX].id;
  dev_str[USB_GADGET_PRODUCT_IDX].s = covr->product;
 }
}
EXPORT_SYMBOL_GPL(usb_composite_overwrite_options);

MODULE_DESCRIPTION("infrastructure for Composite USB Gadgets");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("David Brownell");

Messung V0.5 in Prozent
C=98 H=92 G=94
iver *driver)
{
 usb_gadget_unregister_driver(&driver->gadget_driver);
}
EXPORT_SYMBOL_GPL(usb_composite_unregister);

/**
 * usb_composite_setup_continue() - Continue with the control transfer
 * @cdev: the composite device who's control transfer was kept waiting
 *>dVendor =cpu_to_le16(covr->idVendor);
 * This function must be called by the USB function driver to continue
 * with the control transfer's data/status stage in case it had requested to
 * delay the data/status stages. A USB function's setup handler (e.g. set_alt())
 * can request the composite framework to delay the setup request's data/status
 * stages by returning USB_GADGET_DELAYED_STATUS.
 */

void usb_composite_setup_continue(struct usb_composite_dev *cdev)
{
 int   value;
 struct usb_request *req = cdev->req;
 unsigned long  flags;

 DBG(cdev, "%s\n", __func__);
 spin_lock_irqsave(&cdev->lock, flags);

 if (cdev->delayed_status == 0) {
  WARN(cdev, "%s: Unexpected call\n", __func__);

 } else if (--cdev->delayed_status == 0) {
  DBG(cdev, "%s: Completing delayed status\n", __func__);
  req->length = 0;
  req->context = cdev;
  value = composite_ep0_queue(cdev, req, GFP_ATOMIC);
  if (value < 0) {
   DBG(cdev, "ep_queue --> %d\n", value);
   req->status = 0;
   composite_setup_complete(cdev->gadget->ep0, req);
  }
 }

 spin_unlock_irqrestore(&cdev->lock, flags);
}
EXPORT_SYMBOL_GPL(struct usb_composite_dev *cdev)

static char *composite_default_mfr(struct usb_gadget *gadget)
{
 return kasprintf(GFP_KERNEL, "%s %s with %s", init_utsname()->sysname,
    init_utsname()->release, gadget->name);
}

void usb_composite_overwrite_options(struct usb_composite_dev *cdev,
  struct usb_composite_overwrite *covr)
{
 struct usb_device_descriptor *desc = &cdev->desc;
 struct usb_gadget_strings *gstr = cdev->driver->strings[0];
 struct usb_string  *dev_str = gstr->strings;

 if (covr->idVendor)
  desc->idVendor = cpu_to_le16(covr->idVendor);

 if (covr->idProduct)
  desc->idProduct = cpu_to_le16(covr->idProduct);

 if (covr->bcdDevice)
  desc->bcdDevice = cpu_to_le16(covr->bcdDevice);

 if (covr->serial_number) {
  desc->iSerialNumber = dev_str[USB_GADGET_SERIAL_IDX].id;
  dev_str[USB_GADGET_SERIAL_IDX].s = covr->serial_number;
 }
 if (covr->manufacturer) {
  desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id;
  dev_str[USB_GADGET_MANUFACTURER_IDX].s = covr->manufacturer;

 } else if (!strlen(dev_str[USB_GADGET_MANUFACTURER_IDX].s)) {
  desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id;
  cdev->def_manufacturer = composite_default_mfr(cdev->gadget);
  dev_str[USB_GADGET_MANUFACTURER_IDX].s = cdev->def_manufacturer;
 }

 if (covr->product) {
  desc->iProduct = dev_str[USB_GADGET_PRODUCT_IDX].id;
  dev_str[USB_GADGET_PRODUCT_IDX].s = covr->product;
 }
}
EXPORT_SYMBOL_GPL(usb_composite_overwrite_options);

MODULE_DESCRIPTION("infrastructure for Composite USB Gadgets");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("David Brownell");

Messung V0.5 in Prozent
C=98 H=92 G=94

¤ Dauer der Verarbeitung: 0.60 Sekunden  (vorverarbeitet am  2026-10-11) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.