Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 354639
b: refs/heads/master
c: 78f46f0
h: refs/heads/master
i:
  354637: 0cd049e
  354635: 468d180
  354631: b32b0e5
  354623: ef70e29
v: v3
  • Loading branch information
Sebastian Andrzej Siewior authored and Felipe Balbi committed Jan 21, 2013
1 parent c6bc6eb commit e600ee8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 45 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: eeae54075ce3491968e9282cbb44f6a06b306b66
refs/heads/master: 78f46f09a80a39fe646fe415a21435f2a05df6c2
44 changes: 6 additions & 38 deletions trunk/drivers/usb/gadget/f_loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ loopback_bind(struct usb_configuration *c, struct usb_function *f)
return id;
loopback_intf.bInterfaceNumber = id;

id = usb_string_id(cdev);
if (id < 0)
return id;
strings_loopback[0].id = id;
loopback_intf.iInterface = id;

/* allocate endpoints */

loop->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_loop_source_desc);
Expand Down Expand Up @@ -388,41 +394,3 @@ static int __init loopback_bind_config(struct usb_configuration *c)
kfree(loop);
return status;
}

static struct usb_configuration loopback_driver = {
.label = "loopback",
.strings = loopback_strings,
.bConfigurationValue = 2,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
/* .iConfiguration = DYNAMIC */
};

/**
* loopback_add - add a loopback testing configuration to a device
* @cdev: the device to support the loopback configuration
*/
int __init loopback_add(struct usb_composite_dev *cdev, bool autoresume)
{
int id;

/* allocate string ID(s) */
id = usb_string_id(cdev);
if (id < 0)
return id;
strings_loopback[0].id = id;

loopback_intf.iInterface = id;
loopback_driver.iConfiguration = id;

/* support autoresume for remote wakeup testing */
if (autoresume)
loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;

/* support OTG systems */
if (gadget_is_otg(cdev->gadget)) {
loopback_driver.descriptors = otg_desc;
loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}

return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
}
3 changes: 0 additions & 3 deletions trunk/drivers/usb/gadget/g_zero.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,4 @@ void disable_endpoints(struct usb_composite_dev *cdev,
struct usb_ep *in, struct usb_ep *out,
struct usb_ep *iso_in, struct usb_ep *iso_out);

/* configuration-specific linkup */
int loopback_add(struct usb_composite_dev *cdev, bool autoresume);

#endif /* __G_ZERO_H */
24 changes: 21 additions & 3 deletions trunk/drivers/usb/gadget/zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,14 @@ const struct usb_descriptor_header *otg_desc[] = {
static char serial[] = "0123456789.0123456789.0123456789";

#define USB_GZERO_SS_DESC (USB_GADGET_FIRST_AVAIL_IDX + 0)
#define USB_GZERO_LB_DESC (USB_GADGET_FIRST_AVAIL_IDX + 1)

static struct usb_string strings_dev[] = {
[USB_GADGET_MANUFACTURER_IDX].s = "",
[USB_GADGET_PRODUCT_IDX].s = longname,
[USB_GADGET_SERIAL_IDX].s = serial,
[USB_GZERO_SS_DESC].s = "source and sink data",
[USB_GZERO_LB_DESC].s = "loop input to output",
{ } /* end of list */
};

Expand Down Expand Up @@ -254,6 +256,14 @@ static void zero_resume(struct usb_composite_dev *cdev)

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

static struct usb_configuration loopback_driver = {
.label = "loopback",
.strings = loopback_strings,
.bConfigurationValue = 2,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
/* .iConfiguration = DYNAMIC */
};

static struct usb_configuration sourcesink_driver = {
.label = "source/sink",
.strings = sourcesink_strings,
Expand Down Expand Up @@ -281,29 +291,37 @@ static int __init zero_bind(struct usb_composite_dev *cdev)
setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev);

sourcesink_driver.iConfiguration = strings_dev[USB_GZERO_SS_DESC].id;
loopback_driver.iConfiguration = strings_dev[USB_GZERO_LB_DESC].id;

/* support autoresume for remote wakeup testing */
sourcesink_driver.bmAttributes &= ~USB_CONFIG_ATT_WAKEUP;
loopback_driver.bmAttributes &= ~USB_CONFIG_ATT_WAKEUP;
sourcesink_driver.descriptors = NULL;
if (autoresume)
loopback_driver.descriptors = NULL;
if (autoresume) {
sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}

/* support OTG systems */
if (gadget_is_otg(cdev->gadget)) {
sourcesink_driver.descriptors = otg_desc;
sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
loopback_driver.descriptors = otg_desc;
loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}

/* Register primary, then secondary configuration. Note that
* SH3 only allows one config...
*/
if (loopdefault) {
loopback_add(cdev, autoresume != 0);
usb_add_config(cdev, &loopback_driver, loopback_bind_config);
usb_add_config(cdev, &sourcesink_driver,
sourcesink_bind_config);
} else {
usb_add_config(cdev, &sourcesink_driver,
sourcesink_bind_config);
loopback_add(cdev, autoresume != 0);
usb_add_config(cdev, &loopback_driver, loopback_bind_config);
}

usb_composite_overwrite_options(cdev, &coverwrite);
Expand Down

0 comments on commit e600ee8

Please sign in to comment.