Commit ecabf237 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] USB: Add OTG support to g_file_storage

This patch adds minimal USB On-The-Go support (mainly just an extra
descriptor) to the File-Storage Gadget.  The changes were based on the
additions made to the Gadget Zero driver.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 0aa13ba4
......@@ -248,7 +248,7 @@
#define DRIVER_DESC "File-backed Storage Gadget"
#define DRIVER_NAME "g_file_storage"
#define DRIVER_VERSION "28 July 2004"
#define DRIVER_VERSION "31 August 2004"
static const char longname[] = DRIVER_DESC;
static const char shortname[] = DRIVER_NAME;
......@@ -866,6 +866,14 @@ config_desc = {
.bMaxPower = 1, // self-powered
};
static struct usb_otg_descriptor
otg_desc = {
.bLength = sizeof(otg_desc),
.bDescriptorType = USB_DT_OTG,
.bmAttributes = USB_OTG_SRP,
};
/* There is only one interface. */
static struct usb_interface_descriptor
......@@ -914,6 +922,7 @@ fs_intr_in_desc = {
};
static const struct usb_descriptor_header *fs_function[] = {
(struct usb_descriptor_header *) &otg_desc,
(struct usb_descriptor_header *) &intf_desc,
(struct usb_descriptor_header *) &fs_bulk_in_desc,
(struct usb_descriptor_header *) &fs_bulk_out_desc,
......@@ -976,6 +985,7 @@ hs_intr_in_desc = {
};
static const struct usb_descriptor_header *hs_function[] = {
(struct usb_descriptor_header *) &otg_desc,
(struct usb_descriptor_header *) &intf_desc,
(struct usb_descriptor_header *) &hs_bulk_in_desc,
(struct usb_descriptor_header *) &hs_bulk_out_desc,
......@@ -1018,9 +1028,10 @@ static struct usb_gadget_strings stringtab = {
* and with code managing interfaces and their altsettings. They must
* also handle different speeds and other-speed requests.
*/
static int populate_config_buf(enum usb_device_speed speed,
static int populate_config_buf(struct usb_gadget *gadget,
u8 *buf, u8 type, unsigned index)
{
enum usb_device_speed speed = gadget->speed;
int len;
const struct usb_descriptor_header **function;
......@@ -1036,6 +1047,10 @@ static int populate_config_buf(enum usb_device_speed speed,
#endif
function = fs_function;
/* for now, don't advertise srp-only devices */
if (!gadget->is_otg)
function++;
len = usb_gadget_config_buf(&config_desc, buf, EP0_BUFSIZE, function);
((struct usb_config_descriptor *) buf)->bDescriptorType = type;
return len;
......@@ -1366,7 +1381,7 @@ static int standard_setup_req(struct fsg_dev *fsg,
#ifdef CONFIG_USB_GADGET_DUALSPEED
get_config:
#endif
value = populate_config_buf(fsg->gadget->speed,
value = populate_config_buf(fsg->gadget,
req->buf,
ctrl->wValue >> 8,
ctrl->wValue & 0xff);
......@@ -3896,6 +3911,11 @@ static int __init fsg_bind(struct usb_gadget *gadget)
hs_intr_in_desc.bEndpointAddress = fs_intr_in_desc.bEndpointAddress;
#endif
if (gadget->is_otg) {
otg_desc.bmAttributes |= USB_OTG_HNP,
config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
rc = -ENOMEM;
/* Allocate the request and buffer for endpoint 0 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment