- /****************************** Configurations ******************************/
- static
int __init do_config(struct usb_configuration *c) - {
- struct hidg_func_node *e;
- int func = 0, status = 0;
- if (gadget_is_otg(c->cdev->gadget)) {
- c->descriptors = otg_desc;
- c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
- }
- list_for_each_entry(e, &hidg_func_list, node) {
- status = hidg_bind_config(c, e->func, func++);
- if (status)
- break;
- }
- return status;
- }
- static
struct usb_configuration config_driver = { - .label = "HID Gadget",
- .bind = do_config,
- .bConfigurationValue = 1,
- /* .iConfiguration = DYNAMIC */
- .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
- };
- /****************************** Gadget Bind ******************************/
- static
int __init hid_bind(struct usb_composite_dev *cdev) - {
- struct usb_gadget *gadget = cdev->gadget;
- struct list_head *tmp;
- int status, gcnum, funcs = 0;
- list_for_each(tmp, &hidg_func_list)
- funcs++;
- if (!funcs)
- return -ENODEV;
- /* set up HID */
- printk("=============bind\n");
- status = ghid_setup(cdev->gadget, funcs);
- if (status < 0)
- return status;
- gcnum = usb_gadget_controller_number(gadget);
- if (gcnum >= 0)
- device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum);
- else
- device_desc.bcdDevice = cpu_to_le16(0x0300 | 0x0099);
- /* Allocate string descriptor numbers ... note that string
- * contents can be overridden by the composite_dev glue.
- */
- /* device descriptor strings: manufacturer, product */
- snprintf(manufacturer, sizeof manufacturer, "%s %s with %s",
- init_utsname()->sysname, init_utsname()->release,
- gadget->name);
- status = usb_string_id(cdev);
- if (status < 0)
- return status;
- strings_dev[STRING_MANUFACTURER_IDX].id = status;
- device_desc.iManufacturer = status;
- status = usb_string_id(cdev);
- if (status < 0)
- return status;
- strings_dev[STRING_PRODUCT_IDX].id = status;
- device_desc.iProduct = status;
- /* register our configuration */
- status = usb_add_config(cdev, &config_driver);
- if (status < 0)
- return status;
- dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n");
- return 0;
- }
|