mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-09 20:18:54 -04:00
USB-CDC: Fix coding style issues
Fixes most of checkpatch warnings and errors in USB gadget stack. The most frequently encountered problems are: 1) "(foo*)", "foo * bar", "foo* bar" 2) C99 // comments 3) No spaces before/after/around '?', ':', '=', '==', ',', '&', '(' 4) Spaces before '[' 5) Spaces between function names and '(' 6) Block braces in wrong places 7) Spaces before tabs 8) Macros with complex values not enclosed in parenthesis 9) Multiline comments start just after /* Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
This commit is contained in:
parent
a170f2c797
commit
6142e0ae0f
@ -32,7 +32,7 @@
|
|||||||
/* we must assign addresses for configurable endpoints (like net2280) */
|
/* we must assign addresses for configurable endpoints (like net2280) */
|
||||||
static unsigned epnum;
|
static unsigned epnum;
|
||||||
|
|
||||||
// #define MANY_ENDPOINTS
|
/* #define MANY_ENDPOINTS */
|
||||||
#ifdef MANY_ENDPOINTS
|
#ifdef MANY_ENDPOINTS
|
||||||
/* more than 15 configurable endpoints */
|
/* more than 15 configurable endpoints */
|
||||||
static unsigned in_epnum;
|
static unsigned in_epnum;
|
||||||
@ -55,8 +55,7 @@ static unsigned in_epnum;
|
|||||||
* NOTE: each endpoint is unidirectional, as specified by its USB
|
* NOTE: each endpoint is unidirectional, as specified by its USB
|
||||||
* descriptor; and isn't specific to a configuration or altsetting.
|
* descriptor; and isn't specific to a configuration or altsetting.
|
||||||
*/
|
*/
|
||||||
static int
|
static int ep_matches(
|
||||||
ep_matches (
|
|
||||||
struct usb_gadget *gadget,
|
struct usb_gadget *gadget,
|
||||||
struct usb_ep *ep,
|
struct usb_ep *ep,
|
||||||
struct usb_endpoint_descriptor *desc
|
struct usb_endpoint_descriptor *desc
|
||||||
@ -90,7 +89,7 @@ ep_matches (
|
|||||||
/* bulk endpoints handle interrupt transfers,
|
/* bulk endpoints handle interrupt transfers,
|
||||||
* except the toggle-quirky iso-synch kind
|
* except the toggle-quirky iso-synch kind
|
||||||
*/
|
*/
|
||||||
if ('s' == tmp[2]) // == "-iso"
|
if ('s' == tmp[2]) /* == "-iso" */
|
||||||
return 0;
|
return 0;
|
||||||
/* for now, avoid PXA "interrupt-in";
|
/* for now, avoid PXA "interrupt-in";
|
||||||
* it's documented as never using DATA1.
|
* it's documented as never using DATA1.
|
||||||
@ -100,11 +99,11 @@ ep_matches (
|
|||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case USB_ENDPOINT_XFER_BULK:
|
case USB_ENDPOINT_XFER_BULK:
|
||||||
if ('b' != tmp[1]) // != "-bulk"
|
if ('b' != tmp[1]) /* != "-bulk" */
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case USB_ENDPOINT_XFER_ISOC:
|
case USB_ENDPOINT_XFER_ISOC:
|
||||||
if ('s' != tmp[2]) // != "-iso"
|
if ('s' != tmp[2]) /* != "-iso" */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -188,7 +188,8 @@ struct eth_dev {
|
|||||||
u8 host_mac[ETH_ALEN];
|
u8 host_mac[ETH_ALEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This version autoconfigures as much as possible at run-time.
|
/*
|
||||||
|
* This version autoconfigures as much as possible at run-time.
|
||||||
*
|
*
|
||||||
* It also ASSUMES a self-powered device, without remote wakeup,
|
* It also ASSUMES a self-powered device, without remote wakeup,
|
||||||
* although remote wakeup support would make sense.
|
* although remote wakeup support would make sense.
|
||||||
@ -196,17 +197,20 @@ struct eth_dev {
|
|||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
|
/*
|
||||||
|
* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
|
||||||
* Instead: allocate your own, using normal USB-IF procedures.
|
* Instead: allocate your own, using normal USB-IF procedures.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Thanks to NetChip Technologies for donating this product ID.
|
/*
|
||||||
|
* Thanks to NetChip Technologies for donating this product ID.
|
||||||
* It's for devices with only CDC Ethernet configurations.
|
* It's for devices with only CDC Ethernet configurations.
|
||||||
*/
|
*/
|
||||||
#define CDC_VENDOR_NUM 0x0525 /* NetChip */
|
#define CDC_VENDOR_NUM 0x0525 /* NetChip */
|
||||||
#define CDC_PRODUCT_NUM 0xa4a1 /* Linux-USB Ethernet Gadget */
|
#define CDC_PRODUCT_NUM 0xa4a1 /* Linux-USB Ethernet Gadget */
|
||||||
|
|
||||||
/* For hardware that can't talk CDC, we use the same vendor ID that
|
/*
|
||||||
|
* For hardware that can't talk CDC, we use the same vendor ID that
|
||||||
* ARM Linux has used for ethernet-over-usb, both with sa1100 and
|
* ARM Linux has used for ethernet-over-usb, both with sa1100 and
|
||||||
* with pxa250. We're protocol-compatible, if the host-side drivers
|
* with pxa250. We're protocol-compatible, if the host-side drivers
|
||||||
* use the endpoint descriptors. bcdDevice (version) is nonzero, so
|
* use the endpoint descriptors. bcdDevice (version) is nonzero, so
|
||||||
@ -220,7 +224,8 @@ struct eth_dev {
|
|||||||
#define SIMPLE_VENDOR_NUM 0x049f
|
#define SIMPLE_VENDOR_NUM 0x049f
|
||||||
#define SIMPLE_PRODUCT_NUM 0x505a
|
#define SIMPLE_PRODUCT_NUM 0x505a
|
||||||
|
|
||||||
/* Some systems will want different product identifers published in the
|
/*
|
||||||
|
* Some systems will want different product identifers published in the
|
||||||
* device descriptor, either numbers or strings or both. These string
|
* device descriptor, either numbers or strings or both. These string
|
||||||
* parameters are in UTF-8 (superset of ASCII's 7 bit characters).
|
* parameters are in UTF-8 (superset of ASCII's 7 bit characters).
|
||||||
*/
|
*/
|
||||||
@ -238,7 +243,8 @@ static char host_addr[18];
|
|||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* USB DRIVER HOOKUP (to the hardware driver, below us), mostly
|
/*
|
||||||
|
* USB DRIVER HOOKUP (to the hardware driver, below us), mostly
|
||||||
* ep0 implementation: descriptors, config management, setup().
|
* ep0 implementation: descriptors, config management, setup().
|
||||||
* also optional class-specific notification interrupt transfer.
|
* also optional class-specific notification interrupt transfer.
|
||||||
*/
|
*/
|
||||||
@ -356,7 +362,8 @@ static const struct usb_cdc_union_desc union_desc = {
|
|||||||
|
|
||||||
#ifndef DEV_CONFIG_CDC
|
#ifndef DEV_CONFIG_CDC
|
||||||
|
|
||||||
/* "SAFE" loosely follows CDC WMC MDLM, violating the spec in various
|
/*
|
||||||
|
* "SAFE" loosely follows CDC WMC MDLM, violating the spec in various
|
||||||
* ways: data endpoints live in the control interface, there's no data
|
* ways: data endpoints live in the control interface, there's no data
|
||||||
* interface, and it's not used to talk to a cell phone radio.
|
* interface, and it's not used to talk to a cell phone radio.
|
||||||
*/
|
*/
|
||||||
@ -373,7 +380,8 @@ static const struct usb_cdc_mdlm_desc mdlm_desc = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* since "usb_cdc_mdlm_detail_desc" is a variable length structure, we
|
/*
|
||||||
|
* since "usb_cdc_mdlm_detail_desc" is a variable length structure, we
|
||||||
* can't really use its struct. All we do here is say that we're using
|
* can't really use its struct. All we do here is say that we're using
|
||||||
* the submode of "SAFE" which directly matches the CDC Subset.
|
* the submode of "SAFE" which directly matches the CDC Subset.
|
||||||
*/
|
*/
|
||||||
@ -389,7 +397,6 @@ static const u8 mdlm_detail_desc[] = {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static const struct usb_cdc_ether_desc ether_desc = {
|
static const struct usb_cdc_ether_desc ether_desc = {
|
||||||
.bLength = sizeof(ether_desc),
|
.bLength = sizeof(ether_desc),
|
||||||
.bDescriptorType = USB_DT_CS_INTERFACE,
|
.bDescriptorType = USB_DT_CS_INTERFACE,
|
||||||
@ -403,10 +410,10 @@ static const struct usb_cdc_ether_desc ether_desc = {
|
|||||||
.bNumberPowerFilters = 0,
|
.bNumberPowerFilters = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#if defined(DEV_CONFIG_CDC)
|
#if defined(DEV_CONFIG_CDC)
|
||||||
|
|
||||||
/* include the status endpoint if we can, even where it's optional.
|
/*
|
||||||
|
* include the status endpoint if we can, even where it's optional.
|
||||||
* use wMaxPacketSize big enough to fit CDC_NOTIFY_SPEED_CHANGE in one
|
* use wMaxPacketSize big enough to fit CDC_NOTIFY_SPEED_CHANGE in one
|
||||||
* packet, to simplify cancellation; and a big transfer interval, to
|
* packet, to simplify cancellation; and a big transfer interval, to
|
||||||
* waste less bandwidth.
|
* waste less bandwidth.
|
||||||
@ -493,7 +500,6 @@ subset_data_intf = {
|
|||||||
|
|
||||||
#endif /* SUBSET */
|
#endif /* SUBSET */
|
||||||
|
|
||||||
|
|
||||||
static struct usb_endpoint_descriptor
|
static struct usb_endpoint_descriptor
|
||||||
fs_source_desc = {
|
fs_source_desc = {
|
||||||
.bLength = USB_DT_ENDPOINT_SIZE,
|
.bLength = USB_DT_ENDPOINT_SIZE,
|
||||||
@ -640,7 +646,6 @@ ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
|
|||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* descriptors that are built on-demand */
|
/* descriptors that are built on-demand */
|
||||||
@ -674,13 +679,11 @@ static struct usb_gadget_strings stringtab = {
|
|||||||
.strings = strings,
|
.strings = strings,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*============================================================================*/
|
/*============================================================================*/
|
||||||
static u8 control_req[USB_BUFSIZ];
|
static u8 control_req[USB_BUFSIZ];
|
||||||
static u8 status_req[STATUS_BYTECOUNT] __attribute__ ((aligned(4)));
|
static u8 status_req[STATUS_BYTECOUNT] __attribute__ ((aligned(4)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* strlcpy - Copy a %NUL terminated string into a sized buffer
|
* strlcpy - Copy a %NUL terminated string into a sized buffer
|
||||||
* @dest: Where to copy the string to
|
* @dest: Where to copy the string to
|
||||||
@ -704,7 +707,6 @@ size_t strlcpy(char *dest, const char *src, size_t size)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*============================================================================*/
|
/*============================================================================*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -775,7 +777,8 @@ set_ether_config (struct eth_dev *dev, gfp_t gfp_flags)
|
|||||||
dev->out = ep_desc(gadget, &hs_sink_desc, &fs_sink_desc);
|
dev->out = ep_desc(gadget, &hs_sink_desc, &fs_sink_desc);
|
||||||
dev->out_ep->driver_data = dev;
|
dev->out_ep->driver_data = dev;
|
||||||
|
|
||||||
/* With CDC, the host isn't allowed to use these two data
|
/*
|
||||||
|
* With CDC, the host isn't allowed to use these two data
|
||||||
* endpoints in the default altsetting for the interface.
|
* endpoints in the default altsetting for the interface.
|
||||||
* so we don't activate them yet. Reset from SET_INTERFACE.
|
* so we don't activate them yet. Reset from SET_INTERFACE.
|
||||||
*/
|
*/
|
||||||
@ -814,7 +817,6 @@ done:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void eth_reset_config(struct eth_dev *dev)
|
static void eth_reset_config(struct eth_dev *dev)
|
||||||
{
|
{
|
||||||
if (dev->config == 0)
|
if (dev->config == 0)
|
||||||
@ -822,7 +824,8 @@ static void eth_reset_config (struct eth_dev *dev)
|
|||||||
|
|
||||||
debug("%s\n", __func__);
|
debug("%s\n", __func__);
|
||||||
|
|
||||||
/* disable endpoints, forcing (synchronous) completion of
|
/*
|
||||||
|
* disable endpoints, forcing (synchronous) completion of
|
||||||
* pending i/o. then free the requests.
|
* pending i/o. then free the requests.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -840,17 +843,19 @@ static void eth_reset_config (struct eth_dev *dev)
|
|||||||
dev->rx_req = NULL;
|
dev->rx_req = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dev->status) {
|
if (dev->status)
|
||||||
usb_ep_disable(dev->status_ep);
|
usb_ep_disable(dev->status_ep);
|
||||||
}
|
|
||||||
dev->cdc_filter = 0;
|
dev->cdc_filter = 0;
|
||||||
dev->config = 0;
|
dev->config = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* change our operational config. must agree with the code
|
/*
|
||||||
|
* change our operational config. must agree with the code
|
||||||
* that returns config descriptors, and altsetting code.
|
* that returns config descriptors, and altsetting code.
|
||||||
*/
|
*/
|
||||||
static int eth_set_config (struct eth_dev *dev, unsigned number, gfp_t gfp_flags)
|
static int eth_set_config(struct eth_dev *dev, unsigned number,
|
||||||
|
gfp_t gfp_flags)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
struct usb_gadget *gadget = dev->gadget;
|
struct usb_gadget *gadget = dev->gadget;
|
||||||
@ -888,11 +893,14 @@ static int eth_set_config (struct eth_dev *dev, unsigned number, gfp_t gfp_flags
|
|||||||
usb_gadget_vbus_draw(dev->gadget, power);
|
usb_gadget_vbus_draw(dev->gadget, power);
|
||||||
|
|
||||||
switch (gadget->speed) {
|
switch (gadget->speed) {
|
||||||
case USB_SPEED_FULL: speed = "full"; break;
|
case USB_SPEED_FULL:
|
||||||
|
speed = "full"; break;
|
||||||
#ifdef CONFIG_USB_GADGET_DUALSPEED
|
#ifdef CONFIG_USB_GADGET_DUALSPEED
|
||||||
case USB_SPEED_HIGH: speed = "high"; break;
|
case USB_SPEED_HIGH:
|
||||||
|
speed = "high"; break;
|
||||||
#endif
|
#endif
|
||||||
default: speed = "?"; break;
|
default:
|
||||||
|
speed = "?"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->config = number;
|
dev->config = number;
|
||||||
@ -908,7 +916,8 @@ static int eth_set_config (struct eth_dev *dev, unsigned number, gfp_t gfp_flags
|
|||||||
|
|
||||||
#ifdef DEV_CONFIG_CDC
|
#ifdef DEV_CONFIG_CDC
|
||||||
|
|
||||||
/* The interrupt endpoint is used in CDC networking models (Ethernet, ATM)
|
/*
|
||||||
|
* The interrupt endpoint is used in CDC networking models (Ethernet, ATM)
|
||||||
* only to notify the host about link status changes (which we support) or
|
* only to notify the host about link status changes (which we support) or
|
||||||
* report completion of some encapsulated command. Since
|
* report completion of some encapsulated command. Since
|
||||||
* we want this CDC Ethernet code to be vendor-neutral, we don't use that
|
* we want this CDC Ethernet code to be vendor-neutral, we don't use that
|
||||||
@ -943,8 +952,7 @@ static void eth_status_complete (struct usb_ep *ep, struct usb_request *req)
|
|||||||
debug("event %02x --> %d\n",
|
debug("event %02x --> %d\n",
|
||||||
event->bNotificationType, value);
|
event->bNotificationType, value);
|
||||||
if (event->bNotificationType ==
|
if (event->bNotificationType ==
|
||||||
USB_CDC_NOTIFY_SPEED_CHANGE)
|
USB_CDC_NOTIFY_SPEED_CHANGE) {
|
||||||
{
|
|
||||||
l_ethdev.network_started = 1;
|
l_ethdev.network_started = 1;
|
||||||
printf("USB network up!\n");
|
printf("USB network up!\n");
|
||||||
}
|
}
|
||||||
@ -958,7 +966,8 @@ static void issue_start_status (struct eth_dev *dev)
|
|||||||
struct usb_cdc_notification *event;
|
struct usb_cdc_notification *event;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
/* flush old status
|
/*
|
||||||
|
* flush old status
|
||||||
*
|
*
|
||||||
* FIXME ugly idiom, maybe we'd be better with just
|
* FIXME ugly idiom, maybe we'd be better with just
|
||||||
* a "cancel the whole queue" primitive since any
|
* a "cancel the whole queue" primitive since any
|
||||||
@ -970,7 +979,8 @@ static void issue_start_status (struct eth_dev *dev)
|
|||||||
usb_ep_disable(dev->status_ep);
|
usb_ep_disable(dev->status_ep);
|
||||||
usb_ep_enable(dev->status_ep, dev->status);
|
usb_ep_enable(dev->status_ep, dev->status);
|
||||||
|
|
||||||
/* 3.8.1 says to issue first NETWORK_CONNECTION, then
|
/*
|
||||||
|
* 3.8.1 says to issue first NETWORK_CONNECTION, then
|
||||||
* a SPEED_CHANGE. could be useful in some configs.
|
* a SPEED_CHANGE. could be useful in some configs.
|
||||||
*/
|
*/
|
||||||
event = req->buf;
|
event = req->buf;
|
||||||
@ -1019,7 +1029,8 @@ eth_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
|
|||||||
u16 wValue = le16_to_cpu(ctrl->wValue);
|
u16 wValue = le16_to_cpu(ctrl->wValue);
|
||||||
u16 wLength = le16_to_cpu(ctrl->wLength);
|
u16 wLength = le16_to_cpu(ctrl->wLength);
|
||||||
|
|
||||||
/* descriptors just go into the pre-allocated ep0 buffer,
|
/*
|
||||||
|
* descriptors just go into the pre-allocated ep0 buffer,
|
||||||
* while config change events may enable network traffic.
|
* while config change events may enable network traffic.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1092,7 +1103,8 @@ eth_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
|
|||||||
if (!cdc_active(dev) && wIndex != 0)
|
if (!cdc_active(dev) && wIndex != 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* PXA hardware partially handles SET_INTERFACE;
|
/*
|
||||||
|
* PXA hardware partially handles SET_INTERFACE;
|
||||||
* we need to kluge around that interference.
|
* we need to kluge around that interference.
|
||||||
*/
|
*/
|
||||||
if (gadget_is_pxa(gadget)) {
|
if (gadget_is_pxa(gadget)) {
|
||||||
@ -1118,7 +1130,8 @@ eth_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
|
|||||||
usb_ep_disable(dev->in_ep);
|
usb_ep_disable(dev->in_ep);
|
||||||
usb_ep_disable(dev->out_ep);
|
usb_ep_disable(dev->out_ep);
|
||||||
|
|
||||||
/* CDC requires the data transfers not be done from
|
/*
|
||||||
|
* CDC requires the data transfers not be done from
|
||||||
* the default interface setting ... also, setting
|
* the default interface setting ... also, setting
|
||||||
* the non-default interface resets filters etc.
|
* the non-default interface resets filters etc.
|
||||||
*/
|
*/
|
||||||
@ -1136,7 +1149,8 @@ eth_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* FIXME this is wrong, as is the assumption that
|
/*
|
||||||
|
* FIXME this is wrong, as is the assumption that
|
||||||
* all non-PXA hardware talks real CDC ...
|
* all non-PXA hardware talks real CDC ...
|
||||||
*/
|
*/
|
||||||
debug("set_interface ignored!\n");
|
debug("set_interface ignored!\n");
|
||||||
@ -1165,7 +1179,8 @@ done_set_intf:
|
|||||||
|
|
||||||
#ifdef DEV_CONFIG_CDC
|
#ifdef DEV_CONFIG_CDC
|
||||||
case USB_CDC_SET_ETHERNET_PACKET_FILTER:
|
case USB_CDC_SET_ETHERNET_PACKET_FILTER:
|
||||||
/* see 6.2.30: no data, wIndex = interface,
|
/*
|
||||||
|
* see 6.2.30: no data, wIndex = interface,
|
||||||
* wValue = packet filter bitmap
|
* wValue = packet filter bitmap
|
||||||
*/
|
*/
|
||||||
if (ctrl->bRequestType != (USB_TYPE_CLASS|USB_RECIP_INTERFACE)
|
if (ctrl->bRequestType != (USB_TYPE_CLASS|USB_RECIP_INTERFACE)
|
||||||
@ -1178,7 +1193,8 @@ done_set_intf:
|
|||||||
value = 0;
|
value = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* and potentially:
|
/*
|
||||||
|
* and potentially:
|
||||||
* case USB_CDC_SET_ETHERNET_MULTICAST_FILTERS:
|
* case USB_CDC_SET_ETHERNET_MULTICAST_FILTERS:
|
||||||
* case USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER:
|
* case USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER:
|
||||||
* case USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER:
|
* case USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER:
|
||||||
@ -1211,18 +1227,18 @@ done_set_intf:
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void rx_complete(struct usb_ep *ep, struct usb_request *req);
|
static void rx_complete(struct usb_ep *ep, struct usb_request *req);
|
||||||
|
|
||||||
static int rx_submit ( struct eth_dev *dev, struct usb_request *req, \
|
static int rx_submit(struct eth_dev *dev, struct usb_request *req,
|
||||||
gfp_t gfp_flags)
|
gfp_t gfp_flags)
|
||||||
{
|
{
|
||||||
int retval = -ENOMEM;
|
int retval = -ENOMEM;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
/* Padding up to RX_EXTRA handles minor disagreements with host.
|
/*
|
||||||
|
* Padding up to RX_EXTRA handles minor disagreements with host.
|
||||||
* Normally we use the USB "terminate on short read" convention;
|
* Normally we use the USB "terminate on short read" convention;
|
||||||
* so allow up to (N*maxpacket), since that memory is normally
|
* so allow up to (N*maxpacket), since that memory is normally
|
||||||
* already allocated. Some hardware doesn't deal well with short
|
* already allocated. Some hardware doesn't deal well with short
|
||||||
@ -1236,8 +1252,8 @@ static int rx_submit ( struct eth_dev *dev, struct usb_request *req, \
|
|||||||
size += dev->out_ep->maxpacket - 1;
|
size += dev->out_ep->maxpacket - 1;
|
||||||
size -= size % dev->out_ep->maxpacket;
|
size -= size % dev->out_ep->maxpacket;
|
||||||
|
|
||||||
|
/*
|
||||||
/* Some platforms perform better when IP packets are aligned,
|
* Some platforms perform better when IP packets are aligned,
|
||||||
* but on at least one, checksumming fails otherwise.
|
* but on at least one, checksumming fails otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1247,13 +1263,12 @@ static int rx_submit ( struct eth_dev *dev, struct usb_request *req, \
|
|||||||
|
|
||||||
retval = usb_ep_queue(dev->out_ep, req, gfp_flags);
|
retval = usb_ep_queue(dev->out_ep, req, gfp_flags);
|
||||||
|
|
||||||
if (retval) {
|
if (retval)
|
||||||
error("rx submit --> %d", retval);
|
error("rx submit --> %d", retval);
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void rx_complete(struct usb_ep *ep, struct usb_request *req)
|
static void rx_complete(struct usb_ep *ep, struct usb_request *req)
|
||||||
{
|
{
|
||||||
struct eth_dev *dev = ep->driver_data;
|
struct eth_dev *dev = ep->driver_data;
|
||||||
@ -1266,7 +1281,6 @@ static void rx_complete (struct usb_ep *ep, struct usb_request *req)
|
|||||||
dev->rx_req = req;
|
dev->rx_req = req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int alloc_requests(struct eth_dev *dev, unsigned n, gfp_t gfp_flags)
|
static int alloc_requests(struct eth_dev *dev, unsigned n, gfp_t gfp_flags)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1287,7 +1301,6 @@ fail:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void tx_complete(struct usb_ep *ep, struct usb_request *req)
|
static void tx_complete(struct usb_ep *ep, struct usb_request *req)
|
||||||
{
|
{
|
||||||
debug("%s: status %s\n", __func__, (req->status) ? "failed" : "ok");
|
debug("%s: status %s\n", __func__, (req->status) ? "failed" : "ok");
|
||||||
@ -1534,7 +1547,8 @@ static int eth_bind(struct usb_gadget *gadget)
|
|||||||
#ifndef DEV_CONFIG_CDC
|
#ifndef DEV_CONFIG_CDC
|
||||||
cdc = 0;
|
cdc = 0;
|
||||||
#endif
|
#endif
|
||||||
/* Because most host side USB stacks handle CDC Ethernet, that
|
/*
|
||||||
|
* Because most host side USB stacks handle CDC Ethernet, that
|
||||||
* standard protocol is _strongly_ preferred for interop purposes.
|
* standard protocol is _strongly_ preferred for interop purposes.
|
||||||
* (By everyone except Microsoft.)
|
* (By everyone except Microsoft.)
|
||||||
*/
|
*/
|
||||||
@ -1550,7 +1564,8 @@ static int eth_bind(struct usb_gadget *gadget)
|
|||||||
} else if (gadget_is_sa1100(gadget)) {
|
} else if (gadget_is_sa1100(gadget)) {
|
||||||
/* hardware can't write zlps */
|
/* hardware can't write zlps */
|
||||||
zlp = 0;
|
zlp = 0;
|
||||||
/* sa1100 CAN do CDC, without status endpoint ... we use
|
/*
|
||||||
|
* sa1100 CAN do CDC, without status endpoint ... we use
|
||||||
* non-CDC to be compatible with ARM Linux-2.4 "usb-eth".
|
* non-CDC to be compatible with ARM Linux-2.4 "usb-eth".
|
||||||
*/
|
*/
|
||||||
cdc = 0;
|
cdc = 0;
|
||||||
@ -1560,7 +1575,8 @@ static int eth_bind(struct usb_gadget *gadget)
|
|||||||
if (gcnum >= 0)
|
if (gcnum >= 0)
|
||||||
device_desc.bcdDevice = cpu_to_le16(0x0300 + gcnum);
|
device_desc.bcdDevice = cpu_to_le16(0x0300 + gcnum);
|
||||||
else {
|
else {
|
||||||
/* can't assume CDC works. don't want to default to
|
/*
|
||||||
|
* can't assume CDC works. don't want to default to
|
||||||
* anything less functional on CDC-capable hardware,
|
* anything less functional on CDC-capable hardware,
|
||||||
* so we fail in this case.
|
* so we fail in this case.
|
||||||
*/
|
*/
|
||||||
@ -1569,7 +1585,8 @@ static int eth_bind(struct usb_gadget *gadget)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CDC subset ... recognized by Linux since 2.4.10, but Windows
|
/*
|
||||||
|
* CDC subset ... recognized by Linux since 2.4.10, but Windows
|
||||||
* drivers aren't widely available. (That may be improved by
|
* drivers aren't widely available. (That may be improved by
|
||||||
* supporting one submode of the "SAFE" variant of MDLM.)
|
* supporting one submode of the "SAFE" variant of MDLM.)
|
||||||
*/
|
*/
|
||||||
@ -1613,7 +1630,8 @@ autoconf_fail:
|
|||||||
out_ep->driver_data = out_ep; /* claim */
|
out_ep->driver_data = out_ep; /* claim */
|
||||||
|
|
||||||
#if defined(DEV_CONFIG_CDC)
|
#if defined(DEV_CONFIG_CDC)
|
||||||
/* CDC Ethernet control interface doesn't require a status endpoint.
|
/*
|
||||||
|
* CDC Ethernet control interface doesn't require a status endpoint.
|
||||||
* Since some hosts expect one, try to allocate one anyway.
|
* Since some hosts expect one, try to allocate one anyway.
|
||||||
*/
|
*/
|
||||||
if (cdc) {
|
if (cdc) {
|
||||||
@ -1632,7 +1650,8 @@ autoconf_fail:
|
|||||||
eth_config.bNumInterfaces = 1;
|
eth_config.bNumInterfaces = 1;
|
||||||
eth_config.iConfiguration = STRING_SUBSET;
|
eth_config.iConfiguration = STRING_SUBSET;
|
||||||
|
|
||||||
/* use functions to set these up, in case we're built to work
|
/*
|
||||||
|
* use functions to set these up, in case we're built to work
|
||||||
* with multiple controllers and must override CDC Ethernet.
|
* with multiple controllers and must override CDC Ethernet.
|
||||||
*/
|
*/
|
||||||
fs_subset_descriptors();
|
fs_subset_descriptors();
|
||||||
@ -1677,7 +1696,8 @@ autoconf_fail:
|
|||||||
dev->out_ep = out_ep;
|
dev->out_ep = out_ep;
|
||||||
dev->status_ep = status_ep;
|
dev->status_ep = status_ep;
|
||||||
|
|
||||||
/* Module params for these addresses should come from ID proms.
|
/*
|
||||||
|
* Module params for these addresses should come from ID proms.
|
||||||
* The host side address is used with CDC, and commonly
|
* The host side address is used with CDC, and commonly
|
||||||
* ends up in a persistent config database. It's not clear if
|
* ends up in a persistent config database. It's not clear if
|
||||||
* host side code for the SAFE thing cares -- its original BLAN
|
* host side code for the SAFE thing cares -- its original BLAN
|
||||||
@ -1712,8 +1732,10 @@ autoconf_fail:
|
|||||||
dev->host_mac[4], dev->host_mac[5]);
|
dev->host_mac[4], dev->host_mac[5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use PKTSIZE (or aligned... from u-boot) and set
|
/*
|
||||||
* wMaxSegmentSize accordingly*/
|
* use PKTSIZE (or aligned... from u-boot) and set
|
||||||
|
* wMaxSegmentSize accordingly
|
||||||
|
*/
|
||||||
dev->mtu = PKTSIZE_ALIGN; /* RNDIS does not like this, only 1514, TODO*/
|
dev->mtu = PKTSIZE_ALIGN; /* RNDIS does not like this, only 1514, TODO*/
|
||||||
|
|
||||||
/* preallocate control message data and buffer */
|
/* preallocate control message data and buffer */
|
||||||
@ -1726,7 +1748,8 @@ autoconf_fail:
|
|||||||
/* ... and maybe likewise for status transfer */
|
/* ... and maybe likewise for status transfer */
|
||||||
#if defined(DEV_CONFIG_CDC)
|
#if defined(DEV_CONFIG_CDC)
|
||||||
if (dev->status_ep) {
|
if (dev->status_ep) {
|
||||||
dev->stat_req = usb_ep_alloc_request(dev->status_ep, GFP_KERNEL);
|
dev->stat_req = usb_ep_alloc_request(dev->status_ep,
|
||||||
|
GFP_KERNEL);
|
||||||
if (!dev->stat_req) {
|
if (!dev->stat_req) {
|
||||||
usb_ep_free_request(dev->status_ep, dev->req);
|
usb_ep_free_request(dev->status_ep, dev->req);
|
||||||
|
|
||||||
@ -1742,7 +1765,8 @@ autoconf_fail:
|
|||||||
set_gadget_data(gadget, dev);
|
set_gadget_data(gadget, dev);
|
||||||
gadget->ep0->driver_data = dev;
|
gadget->ep0->driver_data = dev;
|
||||||
|
|
||||||
/* two kinds of host-initiated state changes:
|
/*
|
||||||
|
* two kinds of host-initiated state changes:
|
||||||
* - iff DATA transfer is active, carrier is "on"
|
* - iff DATA transfer is active, carrier is "on"
|
||||||
* - tx queueing enabled if open *and* carrier is "on"
|
* - tx queueing enabled if open *and* carrier is "on"
|
||||||
*/
|
*/
|
||||||
@ -1780,8 +1804,7 @@ static int usb_eth_init(struct eth_device* netdev, bd_t* bd)
|
|||||||
timeout = simple_strtoul(getenv("cdc_connect_timeout"),
|
timeout = simple_strtoul(getenv("cdc_connect_timeout"),
|
||||||
NULL, 10) * CONFIG_SYS_HZ;
|
NULL, 10) * CONFIG_SYS_HZ;
|
||||||
ts = get_timer(0);
|
ts = get_timer(0);
|
||||||
while (!l_ethdev.network_started)
|
while (!l_ethdev.network_started) {
|
||||||
{
|
|
||||||
/* Handle control-c and timeouts */
|
/* Handle control-c and timeouts */
|
||||||
if (ctrlc() || (get_timer(ts) > timeout)) {
|
if (ctrlc() || (get_timer(ts) > timeout)) {
|
||||||
error("The remote end did not respond in time.");
|
error("The remote end did not respond in time.");
|
||||||
@ -1796,7 +1819,8 @@ fail:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usb_eth_send(struct eth_device* netdev, volatile void* packet, int length)
|
static int usb_eth_send(struct eth_device *netdev,
|
||||||
|
volatile void *packet, int length)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
struct usb_request *req = NULL;
|
struct usb_request *req = NULL;
|
||||||
@ -1812,7 +1836,8 @@ static int usb_eth_send(struct eth_device* netdev, volatile void* packet, int le
|
|||||||
req->context = NULL;
|
req->context = NULL;
|
||||||
req->complete = tx_complete;
|
req->complete = tx_complete;
|
||||||
|
|
||||||
/* use zlp framing on tx for strict CDC-Ether conformance,
|
/*
|
||||||
|
* use zlp framing on tx for strict CDC-Ether conformance,
|
||||||
* though any robust network rx path ignores extra padding.
|
* though any robust network rx path ignores extra padding.
|
||||||
* and some hardware doesn't like to write zlps.
|
* and some hardware doesn't like to write zlps.
|
||||||
*/
|
*/
|
||||||
@ -1835,8 +1860,7 @@ static int usb_eth_send(struct eth_device* netdev, volatile void* packet, int le
|
|||||||
|
|
||||||
if (!retval)
|
if (!retval)
|
||||||
debug("%s: packet queued\n", __func__);
|
debug("%s: packet queued\n", __func__);
|
||||||
while(!packet_sent)
|
while (!packet_sent) {
|
||||||
{
|
|
||||||
if (get_timer(ts) > timeout) {
|
if (get_timer(ts) > timeout) {
|
||||||
printf("timeout sending packets to usb ethernet\n");
|
printf("timeout sending packets to usb ethernet\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -1853,18 +1877,16 @@ static int usb_eth_recv(struct eth_device* netdev)
|
|||||||
|
|
||||||
usb_gadget_handle_interrupts();
|
usb_gadget_handle_interrupts();
|
||||||
|
|
||||||
if (packet_received)
|
if (packet_received) {
|
||||||
{
|
|
||||||
debug("%s: packet received\n", __func__);
|
debug("%s: packet received\n", __func__);
|
||||||
if (dev->rx_req)
|
if (dev->rx_req) {
|
||||||
{
|
|
||||||
NetReceive(NetRxPackets[0], dev->rx_req->length);
|
NetReceive(NetRxPackets[0], dev->rx_req->length);
|
||||||
packet_received = 0;
|
packet_received = 0;
|
||||||
|
|
||||||
if (dev->rx_req)
|
if (dev->rx_req)
|
||||||
rx_submit(dev, dev->rx_req, 0);
|
rx_submit(dev, dev->rx_req, 0);
|
||||||
}
|
} else
|
||||||
else error("dev->rx_req invalid");
|
error("dev->rx_req invalid");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1873,8 +1895,7 @@ void usb_eth_halt(struct eth_device* netdev)
|
|||||||
{
|
{
|
||||||
struct eth_dev *dev = &l_ethdev;
|
struct eth_dev *dev = &l_ethdev;
|
||||||
|
|
||||||
if (!netdev)
|
if (!netdev) {
|
||||||
{
|
|
||||||
error("received NULL ptr");
|
error("received NULL ptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -15,109 +15,109 @@
|
|||||||
* Remy Bohmer <linux@bohmer.net>
|
* Remy Bohmer <linux@bohmer.net>
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_USB_GADGET_NET2280
|
#ifdef CONFIG_USB_GADGET_NET2280
|
||||||
#define gadget_is_net2280(g) !strcmp("net2280", (g)->name)
|
#define gadget_is_net2280(g) (!strcmp("net2280", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_net2280(g) 0
|
#define gadget_is_net2280(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USB_GADGET_AMD5536UDC
|
#ifdef CONFIG_USB_GADGET_AMD5536UDC
|
||||||
#define gadget_is_amd5536udc(g) !strcmp("amd5536udc", (g)->name)
|
#define gadget_is_amd5536udc(g) (!strcmp("amd5536udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_amd5536udc(g) 0
|
#define gadget_is_amd5536udc(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USB_GADGET_DUMMY_HCD
|
#ifdef CONFIG_USB_GADGET_DUMMY_HCD
|
||||||
#define gadget_is_dummy(g) !strcmp("dummy_udc", (g)->name)
|
#define gadget_is_dummy(g) (!strcmp("dummy_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_dummy(g) 0
|
#define gadget_is_dummy(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USB_GADGET_PXA2XX
|
#ifdef CONFIG_USB_GADGET_PXA2XX
|
||||||
#define gadget_is_pxa(g) !strcmp("pxa2xx_udc", (g)->name)
|
#define gadget_is_pxa(g) (!strcmp("pxa2xx_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_pxa(g) 0
|
#define gadget_is_pxa(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USB_GADGET_GOKU
|
#ifdef CONFIG_USB_GADGET_GOKU
|
||||||
#define gadget_is_goku(g) !strcmp("goku_udc", (g)->name)
|
#define gadget_is_goku(g) (!strcmp("goku_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_goku(g) 0
|
#define gadget_is_goku(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* SH3 UDC -- not yet ported 2.4 --> 2.6 */
|
/* SH3 UDC -- not yet ported 2.4 --> 2.6 */
|
||||||
#ifdef CONFIG_USB_GADGET_SUPERH
|
#ifdef CONFIG_USB_GADGET_SUPERH
|
||||||
#define gadget_is_sh(g) !strcmp("sh_udc", (g)->name)
|
#define gadget_is_sh(g) (!strcmp("sh_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_sh(g) 0
|
#define gadget_is_sh(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* not yet stable on 2.6 (would help "original Zaurus") */
|
/* not yet stable on 2.6 (would help "original Zaurus") */
|
||||||
#ifdef CONFIG_USB_GADGET_SA1100
|
#ifdef CONFIG_USB_GADGET_SA1100
|
||||||
#define gadget_is_sa1100(g) !strcmp("sa1100_udc", (g)->name)
|
#define gadget_is_sa1100(g) (!strcmp("sa1100_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_sa1100(g) 0
|
#define gadget_is_sa1100(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USB_GADGET_LH7A40X
|
#ifdef CONFIG_USB_GADGET_LH7A40X
|
||||||
#define gadget_is_lh7a40x(g) !strcmp("lh7a40x_udc", (g)->name)
|
#define gadget_is_lh7a40x(g) (!strcmp("lh7a40x_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_lh7a40x(g) 0
|
#define gadget_is_lh7a40x(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* handhelds.org tree (?) */
|
/* handhelds.org tree (?) */
|
||||||
#ifdef CONFIG_USB_GADGET_MQ11XX
|
#ifdef CONFIG_USB_GADGET_MQ11XX
|
||||||
#define gadget_is_mq11xx(g) !strcmp("mq11xx_udc", (g)->name)
|
#define gadget_is_mq11xx(g) (!strcmp("mq11xx_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_mq11xx(g) 0
|
#define gadget_is_mq11xx(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USB_GADGET_OMAP
|
#ifdef CONFIG_USB_GADGET_OMAP
|
||||||
#define gadget_is_omap(g) !strcmp("omap_udc", (g)->name)
|
#define gadget_is_omap(g) (!strcmp("omap_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_omap(g) 0
|
#define gadget_is_omap(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* not yet ported 2.4 --> 2.6 */
|
/* not yet ported 2.4 --> 2.6 */
|
||||||
#ifdef CONFIG_USB_GADGET_N9604
|
#ifdef CONFIG_USB_GADGET_N9604
|
||||||
#define gadget_is_n9604(g) !strcmp("n9604_udc", (g)->name)
|
#define gadget_is_n9604(g) (!strcmp("n9604_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_n9604(g) 0
|
#define gadget_is_n9604(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* various unstable versions available */
|
/* various unstable versions available */
|
||||||
#ifdef CONFIG_USB_GADGET_PXA27X
|
#ifdef CONFIG_USB_GADGET_PXA27X
|
||||||
#define gadget_is_pxa27x(g) !strcmp("pxa27x_udc", (g)->name)
|
#define gadget_is_pxa27x(g) (!strcmp("pxa27x_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_pxa27x(g) 0
|
#define gadget_is_pxa27x(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USB_GADGET_ATMEL_USBA
|
#ifdef CONFIG_USB_GADGET_ATMEL_USBA
|
||||||
#define gadget_is_atmel_usba(g) !strcmp("atmel_usba_udc", (g)->name)
|
#define gadget_is_atmel_usba(g) (!strcmp("atmel_usba_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_atmel_usba(g) 0
|
#define gadget_is_atmel_usba(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USB_GADGET_S3C2410
|
#ifdef CONFIG_USB_GADGET_S3C2410
|
||||||
#define gadget_is_s3c2410(g) !strcmp("s3c2410_udc", (g)->name)
|
#define gadget_is_s3c2410(g) (!strcmp("s3c2410_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_s3c2410(g) 0
|
#define gadget_is_s3c2410(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USB_GADGET_AT91
|
#ifdef CONFIG_USB_GADGET_AT91
|
||||||
#define gadget_is_at91(g) !strcmp("at91_udc", (g)->name)
|
#define gadget_is_at91(g) (!strcmp("at91_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_at91(g) 0
|
#define gadget_is_at91(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* status unclear */
|
/* status unclear */
|
||||||
#ifdef CONFIG_USB_GADGET_IMX
|
#ifdef CONFIG_USB_GADGET_IMX
|
||||||
#define gadget_is_imx(g) !strcmp("imx_udc", (g)->name)
|
#define gadget_is_imx(g) (!strcmp("imx_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_imx(g) 0
|
#define gadget_is_imx(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USB_GADGET_FSL_USB2
|
#ifdef CONFIG_USB_GADGET_FSL_USB2
|
||||||
#define gadget_is_fsl_usb2(g) !strcmp("fsl-usb2-udc", (g)->name)
|
#define gadget_is_fsl_usb2(g) (!strcmp("fsl-usb2-udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_fsl_usb2(g) 0
|
#define gadget_is_fsl_usb2(g) 0
|
||||||
#endif
|
#endif
|
||||||
@ -125,36 +125,37 @@
|
|||||||
/* Mentor high speed function controller */
|
/* Mentor high speed function controller */
|
||||||
/* from Montavista kernel (?) */
|
/* from Montavista kernel (?) */
|
||||||
#ifdef CONFIG_USB_GADGET_MUSBHSFC
|
#ifdef CONFIG_USB_GADGET_MUSBHSFC
|
||||||
#define gadget_is_musbhsfc(g) !strcmp("musbhsfc_udc", (g)->name)
|
#define gadget_is_musbhsfc(g) (!strcmp("musbhsfc_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_musbhsfc(g) 0
|
#define gadget_is_musbhsfc(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Mentor high speed "dual role" controller, in peripheral role */
|
/* Mentor high speed "dual role" controller, in peripheral role */
|
||||||
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
|
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
|
||||||
#define gadget_is_musbhdrc(g) !strcmp("musb_hdrc", (g)->name)
|
#define gadget_is_musbhdrc(g) (!strcmp("musb_hdrc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_musbhdrc(g) 0
|
#define gadget_is_musbhdrc(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* from Montavista kernel (?) */
|
/* from Montavista kernel (?) */
|
||||||
#ifdef CONFIG_USB_GADGET_MPC8272
|
#ifdef CONFIG_USB_GADGET_MPC8272
|
||||||
#define gadget_is_mpc8272(g) !strcmp("mpc8272_udc", (g)->name)
|
#define gadget_is_mpc8272(g) (!strcmp("mpc8272_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_mpc8272(g) 0
|
#define gadget_is_mpc8272(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USB_GADGET_M66592
|
#ifdef CONFIG_USB_GADGET_M66592
|
||||||
#define gadget_is_m66592(g) !strcmp("m66592_udc", (g)->name)
|
#define gadget_is_m66592(g) (!strcmp("m66592_udc", (g)->name))
|
||||||
#else
|
#else
|
||||||
#define gadget_is_m66592(g) 0
|
#define gadget_is_m66592(g) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// CONFIG_USB_GADGET_SX2
|
/*
|
||||||
// CONFIG_USB_GADGET_AU1X00
|
* CONFIG_USB_GADGET_SX2
|
||||||
// ...
|
* CONFIG_USB_GADGET_AU1X00
|
||||||
|
* ...
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* usb_gadget_controller_number - support bcdDevice id convention
|
* usb_gadget_controller_number - support bcdDevice id convention
|
||||||
|
@ -24,14 +24,17 @@ static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len)
|
|||||||
u8 c;
|
u8 c;
|
||||||
u16 uchar;
|
u16 uchar;
|
||||||
|
|
||||||
/* this insists on correct encodings, though not minimal ones.
|
/*
|
||||||
|
* this insists on correct encodings, though not minimal ones.
|
||||||
* BUT it currently rejects legit 4-byte UTF-8 code points,
|
* BUT it currently rejects legit 4-byte UTF-8 code points,
|
||||||
* which need surrogate pairs. (Unicode 3.1 can use them.)
|
* which need surrogate pairs. (Unicode 3.1 can use them.)
|
||||||
*/
|
*/
|
||||||
while (len != 0 && (c = (u8) *s++) != 0) {
|
while (len != 0 && (c = (u8) *s++) != 0) {
|
||||||
if ((c & 0x80)) {
|
if ((c & 0x80)) {
|
||||||
// 2-byte sequence:
|
/*
|
||||||
// 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx
|
* 2-byte sequence:
|
||||||
|
* 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx
|
||||||
|
*/
|
||||||
if ((c & 0xe0) == 0xc0) {
|
if ((c & 0xe0) == 0xc0) {
|
||||||
uchar = (c & 0x1f) << 6;
|
uchar = (c & 0x1f) << 6;
|
||||||
|
|
||||||
@ -41,8 +44,10 @@ static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len)
|
|||||||
c &= 0x3f;
|
c &= 0x3f;
|
||||||
uchar |= c;
|
uchar |= c;
|
||||||
|
|
||||||
// 3-byte sequence (most CJKV characters):
|
/*
|
||||||
// zzzzyyyyyyxxxxxx = 1110zzzz 10yyyyyy 10xxxxxx
|
* 3-byte sequence (most CJKV characters):
|
||||||
|
* zzzzyyyyyyxxxxxx = 1110zzzz 10yyyyyy 10xxxxxx
|
||||||
|
*/
|
||||||
} else if ((c & 0xf0) == 0xe0) {
|
} else if ((c & 0xf0) == 0xe0) {
|
||||||
uchar = (c & 0x0f) << 12;
|
uchar = (c & 0x0f) << 12;
|
||||||
|
|
||||||
@ -62,12 +67,13 @@ static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len)
|
|||||||
if (0xd800 <= uchar && uchar <= 0xdfff)
|
if (0xd800 <= uchar && uchar <= 0xdfff)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
// 4-byte sequence (surrogate pairs, currently rare):
|
/*
|
||||||
// 11101110wwwwzzzzyy + 110111yyyyxxxxxx
|
* 4-byte sequence (surrogate pairs, currently rare):
|
||||||
// = 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx
|
* 11101110wwwwzzzzyy + 110111yyyyxxxxxx
|
||||||
// (uuuuu = wwww + 1)
|
* = 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx
|
||||||
// FIXME accept the surrogate code points (only)
|
* (uuuuu = wwww + 1)
|
||||||
|
* FIXME accept the surrogate code points (only)
|
||||||
|
*/
|
||||||
} else
|
} else
|
||||||
goto fail;
|
goto fail;
|
||||||
} else
|
} else
|
||||||
|
@ -73,9 +73,10 @@ struct usb_ep;
|
|||||||
*
|
*
|
||||||
* Bulk endpoints can use any size buffers, and can also be used for interrupt
|
* Bulk endpoints can use any size buffers, and can also be used for interrupt
|
||||||
* transfers. interrupt-only endpoints can be much less functional.
|
* transfers. interrupt-only endpoints can be much less functional.
|
||||||
|
*
|
||||||
|
* NOTE: this is analagous to 'struct urb' on the host side, except that
|
||||||
|
* it's thinner and promotes more pre-allocation.
|
||||||
*/
|
*/
|
||||||
// NOTE this is analagous to 'struct urb' on the host side,
|
|
||||||
// except that it's thinner and promotes more pre-allocation.
|
|
||||||
|
|
||||||
struct usb_request {
|
struct usb_request {
|
||||||
void *buf;
|
void *buf;
|
||||||
@ -170,8 +171,8 @@ struct usb_ep {
|
|||||||
*
|
*
|
||||||
* returns zero, or a negative error code.
|
* returns zero, or a negative error code.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_ep_enable(struct usb_ep *ep,
|
||||||
usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc)
|
const struct usb_endpoint_descriptor *desc)
|
||||||
{
|
{
|
||||||
return ep->ops->enable(ep, desc);
|
return ep->ops->enable(ep, desc);
|
||||||
}
|
}
|
||||||
@ -188,8 +189,7 @@ usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc)
|
|||||||
*
|
*
|
||||||
* returns zero, or a negative error code.
|
* returns zero, or a negative error code.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_ep_disable(struct usb_ep *ep)
|
||||||
usb_ep_disable (struct usb_ep *ep)
|
|
||||||
{
|
{
|
||||||
return ep->ops->disable(ep);
|
return ep->ops->disable(ep);
|
||||||
}
|
}
|
||||||
@ -208,8 +208,8 @@ usb_ep_disable (struct usb_ep *ep)
|
|||||||
*
|
*
|
||||||
* Returns the request, or null if one could not be allocated.
|
* Returns the request, or null if one could not be allocated.
|
||||||
*/
|
*/
|
||||||
static inline struct usb_request *
|
static inline struct usb_request *usb_ep_alloc_request(struct usb_ep *ep,
|
||||||
usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags)
|
gfp_t gfp_flags)
|
||||||
{
|
{
|
||||||
return ep->ops->alloc_request(ep, gfp_flags);
|
return ep->ops->alloc_request(ep, gfp_flags);
|
||||||
}
|
}
|
||||||
@ -223,8 +223,8 @@ usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags)
|
|||||||
* Caller guarantees the request is not queued, and that it will
|
* Caller guarantees the request is not queued, and that it will
|
||||||
* no longer be requeued (or otherwise used).
|
* no longer be requeued (or otherwise used).
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void usb_ep_free_request(struct usb_ep *ep,
|
||||||
usb_ep_free_request (struct usb_ep *ep, struct usb_request *req)
|
struct usb_request *req)
|
||||||
{
|
{
|
||||||
ep->ops->free_request(ep, req);
|
ep->ops->free_request(ep, req);
|
||||||
}
|
}
|
||||||
@ -283,8 +283,8 @@ usb_ep_free_request (struct usb_ep *ep, struct usb_request *req)
|
|||||||
* report errors; errors will also be
|
* report errors; errors will also be
|
||||||
* reported when the usb peripheral is disconnected.
|
* reported when the usb peripheral is disconnected.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_ep_queue(struct usb_ep *ep,
|
||||||
usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags)
|
struct usb_request *req, gfp_t gfp_flags)
|
||||||
{
|
{
|
||||||
return ep->ops->queue(ep, req, gfp_flags);
|
return ep->ops->queue(ep, req, gfp_flags);
|
||||||
}
|
}
|
||||||
@ -329,8 +329,7 @@ static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req)
|
|||||||
* transfer requests are still queued, or if the controller hardware
|
* transfer requests are still queued, or if the controller hardware
|
||||||
* (usually a FIFO) still holds bytes that the host hasn't collected.
|
* (usually a FIFO) still holds bytes that the host hasn't collected.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_ep_set_halt(struct usb_ep *ep)
|
||||||
usb_ep_set_halt (struct usb_ep *ep)
|
|
||||||
{
|
{
|
||||||
return ep->ops->set_halt(ep, 1);
|
return ep->ops->set_halt(ep, 1);
|
||||||
}
|
}
|
||||||
@ -348,8 +347,7 @@ usb_ep_set_halt (struct usb_ep *ep)
|
|||||||
* Note that some hardware can't support this request (like pxa2xx_udc),
|
* Note that some hardware can't support this request (like pxa2xx_udc),
|
||||||
* and accordingly can't correctly implement interface altsettings.
|
* and accordingly can't correctly implement interface altsettings.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_ep_clear_halt(struct usb_ep *ep)
|
||||||
usb_ep_clear_halt (struct usb_ep *ep)
|
|
||||||
{
|
{
|
||||||
return ep->ops->set_halt(ep, 0);
|
return ep->ops->set_halt(ep, 0);
|
||||||
}
|
}
|
||||||
@ -369,8 +367,7 @@ usb_ep_clear_halt (struct usb_ep *ep)
|
|||||||
* errno if the endpoint doesn't use a FIFO or doesn't support such
|
* errno if the endpoint doesn't use a FIFO or doesn't support such
|
||||||
* precise handling.
|
* precise handling.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_ep_fifo_status(struct usb_ep *ep)
|
||||||
usb_ep_fifo_status (struct usb_ep *ep)
|
|
||||||
{
|
{
|
||||||
if (ep->ops->fifo_status)
|
if (ep->ops->fifo_status)
|
||||||
return ep->ops->fifo_status(ep);
|
return ep->ops->fifo_status(ep);
|
||||||
@ -387,8 +384,7 @@ usb_ep_fifo_status (struct usb_ep *ep)
|
|||||||
* must never be used except when endpoint is not being used for any
|
* must never be used except when endpoint is not being used for any
|
||||||
* protocol translation.
|
* protocol translation.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void usb_ep_fifo_flush(struct usb_ep *ep)
|
||||||
usb_ep_fifo_flush (struct usb_ep *ep)
|
|
||||||
{
|
{
|
||||||
if (ep->ops->fifo_flush)
|
if (ep->ops->fifo_flush)
|
||||||
ep->ops->fifo_flush(ep);
|
ep->ops->fifo_flush(ep);
|
||||||
@ -522,7 +518,6 @@ static inline int gadget_is_otg(struct usb_gadget *g)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* usb_gadget_frame_number - returns the current frame number
|
* usb_gadget_frame_number - returns the current frame number
|
||||||
* @gadget: controller that reports the frame number
|
* @gadget: controller that reports the frame number
|
||||||
@ -564,8 +559,7 @@ static inline int usb_gadget_wakeup (struct usb_gadget *gadget)
|
|||||||
*
|
*
|
||||||
* returns zero on success, else negative errno.
|
* returns zero on success, else negative errno.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_gadget_set_selfpowered(struct usb_gadget *gadget)
|
||||||
usb_gadget_set_selfpowered (struct usb_gadget *gadget)
|
|
||||||
{
|
{
|
||||||
if (!gadget->ops->set_selfpowered)
|
if (!gadget->ops->set_selfpowered)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
@ -582,8 +576,7 @@ usb_gadget_set_selfpowered (struct usb_gadget *gadget)
|
|||||||
*
|
*
|
||||||
* returns zero on success, else negative errno.
|
* returns zero on success, else negative errno.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_gadget_clear_selfpowered(struct usb_gadget *gadget)
|
||||||
usb_gadget_clear_selfpowered (struct usb_gadget *gadget)
|
|
||||||
{
|
{
|
||||||
if (!gadget->ops->set_selfpowered)
|
if (!gadget->ops->set_selfpowered)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
@ -602,8 +595,7 @@ usb_gadget_clear_selfpowered (struct usb_gadget *gadget)
|
|||||||
*
|
*
|
||||||
* Returns zero on success, else negative errno.
|
* Returns zero on success, else negative errno.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_gadget_vbus_connect(struct usb_gadget *gadget)
|
||||||
usb_gadget_vbus_connect(struct usb_gadget *gadget)
|
|
||||||
{
|
{
|
||||||
if (!gadget->ops->vbus_session)
|
if (!gadget->ops->vbus_session)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
@ -622,8 +614,7 @@ usb_gadget_vbus_connect(struct usb_gadget *gadget)
|
|||||||
*
|
*
|
||||||
* Returns zero on success, else negative errno.
|
* Returns zero on success, else negative errno.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
|
||||||
usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
|
|
||||||
{
|
{
|
||||||
if (!gadget->ops->vbus_draw)
|
if (!gadget->ops->vbus_draw)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
@ -640,8 +631,7 @@ usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
|
|||||||
*
|
*
|
||||||
* Returns zero on success, else negative errno.
|
* Returns zero on success, else negative errno.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
|
||||||
usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
|
|
||||||
{
|
{
|
||||||
if (!gadget->ops->vbus_session)
|
if (!gadget->ops->vbus_session)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
@ -659,8 +649,7 @@ usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
|
|||||||
*
|
*
|
||||||
* Returns zero on success, else negative errno.
|
* Returns zero on success, else negative errno.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_gadget_connect(struct usb_gadget *gadget)
|
||||||
usb_gadget_connect (struct usb_gadget *gadget)
|
|
||||||
{
|
{
|
||||||
if (!gadget->ops->pullup)
|
if (!gadget->ops->pullup)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
@ -682,8 +671,7 @@ usb_gadget_connect (struct usb_gadget *gadget)
|
|||||||
*
|
*
|
||||||
* Returns zero on success, else negative errno.
|
* Returns zero on success, else negative errno.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
|
||||||
usb_gadget_disconnect (struct usb_gadget *gadget)
|
|
||||||
{
|
{
|
||||||
if (!gadget->ops->pullup)
|
if (!gadget->ops->pullup)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
@ -691,7 +679,6 @@ usb_gadget_disconnect (struct usb_gadget *gadget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -774,7 +761,6 @@ struct usb_gadget_driver {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* driver modules register and unregister, as usual.
|
/* driver modules register and unregister, as usual.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user