Skip to contentSkip to conversation

USB: EHCI Debug Port Device Gadget

DISCUSSION Geert Uytterhoeven 1 participant 1 message Aug 12, 2010 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 44 lines · Linux Kernel Mailing List

Gitweb:     http://git.kernel.org/linus/f6c826a90055dd05905982f7a3f60e0bcaa0434e

   USB: EHCI Debug Port Device Gadget

drivers/usb/gadget/dbgp.c new file +34 -0
new file mode 100644
index 0000000..0ed50a2
 
+static int dbgp_setup(struct usb_gadget *gadget,
+                     const struct usb_ctrlrequest *ctrl)
+{
+       struct usb_request *req = dbgp.req;
+       u8 request = ctrl->bRequest;
+       u16 value = le16_to_cpu(ctrl->wValue);
+       u16 length = le16_to_cpu(ctrl->wLength);
+       int err = 0;
+       void *data;
+       u16 len;
+
+       gadget->ep0->driver_data = gadget;
+
+       if (request == USB_REQ_GET_DESCRIPTOR) {
+               switch (value>>8) {
+               case USB_DT_DEVICE:
+                       dev_dbg(&dbgp.gadget->dev, "setup: desc device\n");
+                       len = sizeof device_desc;
+                       data = &device_desc;
+                       break;
+               case USB_DT_DEBUG:
+                       dev_dbg(&dbgp.gadget->dev, "setup: desc debug\n");
+                       len = sizeof dbg_desc;
+                       data = &dbg_desc;
+                       break;
+               default:
+                       goto fail;
+               }
+       } else if (request == USB_REQ_SET_FEATURE &&
+                  value == USB_DEVICE_DEBUG_MODE) {
+               len = 0;
+               data = NULL;
+               dev_dbg(&dbgp.gadget->dev, "setup: feat debug\n");
+#ifdef CONFIG_USB_G_DBGP_PRINTK

drivers/usb/gadget/dbgp.c

Quoted 10 lines
drivers/usb/gadget/dbgp.c new file +10 -0
+               err = dbgp_enable_ep();
+#else
+               err = gserial_connect(dbgp.serial, 0);
+#endif
+               if (err < 0)
+                       goto fail;
+       } else
+               goto fail;
+
+       if (len >= 0) {

warning: comparison is always true due to limited range of data type

len is u16. Perhaps the test was intended to be `(len > 0)'?

Quoted 50 lines

+               req->length = min(length, len);
+               req->zero = len < req->length;
+               if (data && req->length)
+                       memcpy(req->buf, data, req->length);

drivers/usb/gadget/dbgp.c new file +41 -1
+
+               req->complete = dbgp_setup_complete;
+               return usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
+       }
+
+fail:
+       dev_dbg(&dbgp.gadget->dev,
+               "setup: failure req %x v %x\n", request, value);
+       return err;
+}
+
+static struct usb_gadget_driver dbgp_driver = {
+       .function = "dbgp",
+       .speed = USB_SPEED_HIGH,
+       .bind = dbgp_bind,
+       .unbind = dbgp_unbind,
+       .setup = dbgp_setup,
+       .disconnect = dbgp_disconnect,
+       .driver = {
+               .owner = THIS_MODULE,
+               .name = "dbgp"
+       },
+};
+
+static int __init dbgp_init(void)
+{
+       return usb_gadget_register_driver(&dbgp_driver);
+}
+
+static void __exit dbgp_exit(void)
+{
+       usb_gadget_unregister_driver(&dbgp_driver);
+#ifdef CONFIG_USB_G_DBGP_SERIAL
+       gserial_cleanup();
+#endif
+}
+
+MODULE_AUTHOR("Stephane Duverger");
+MODULE_LICENSE("GPL");
+module_init(dbgp_init);
+module_exit(dbgp_exit);
--

To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signature · 11 lines
Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�