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:
Vitaly Kuzmichev 2010-09-13 18:37:11 +04:00 committed by Remy Bohmer
parent a170f2c797
commit 6142e0ae0f
8 changed files with 420 additions and 407 deletions

View File

@ -101,7 +101,7 @@ int usb_gadget_config_buf(
*cp = *config;
/* then interface/endpoint/class/vendor/... */
len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (u8*)buf,
len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (u8 *)buf,
length - USB_DT_CONFIG_SIZE, desc);
if (len < 0)
return len;

View File

@ -32,7 +32,7 @@
/* we must assign addresses for configurable endpoints (like net2280) */
static unsigned epnum;
// #define MANY_ENDPOINTS
/* #define MANY_ENDPOINTS */
#ifdef MANY_ENDPOINTS
/* more than 15 configurable endpoints */
static unsigned in_epnum;
@ -55,8 +55,7 @@ static unsigned in_epnum;
* NOTE: each endpoint is unidirectional, as specified by its USB
* descriptor; and isn't specific to a configuration or altsetting.
*/
static int
ep_matches (
static int ep_matches(
struct usb_gadget *gadget,
struct usb_ep *ep,
struct usb_endpoint_descriptor *desc
@ -83,37 +82,37 @@ ep_matches (
* direction-restriction: "in", "out".
*/
if ('-' != ep->name[2]) {
tmp = strrchr (ep->name, '-');
tmp = strrchr(ep->name, '-');
if (tmp) {
switch (type) {
case USB_ENDPOINT_XFER_INT:
/* bulk endpoints handle interrupt transfers,
* except the toggle-quirky iso-synch kind
*/
if ('s' == tmp[2]) // == "-iso"
if ('s' == tmp[2]) /* == "-iso" */
return 0;
/* for now, avoid PXA "interrupt-in";
* it's documented as never using DATA1.
*/
if (gadget_is_pxa (gadget)
&& 'i' == tmp [1])
if (gadget_is_pxa(gadget)
&& 'i' == tmp[1])
return 0;
break;
case USB_ENDPOINT_XFER_BULK:
if ('b' != tmp[1]) // != "-bulk"
if ('b' != tmp[1]) /* != "-bulk" */
return 0;
break;
case USB_ENDPOINT_XFER_ISOC:
if ('s' != tmp[2]) // != "-iso"
if ('s' != tmp[2]) /* != "-iso" */
return 0;
}
} else {
tmp = ep->name + strlen (ep->name);
tmp = ep->name + strlen(ep->name);
}
/* direction-restriction: "..in-..", "out-.." */
tmp--;
if (!isdigit (*tmp)) {
if (!isdigit(*tmp)) {
if (desc->bEndpointAddress & USB_DIR_IN) {
if ('n' != *tmp)
return 0;
@ -155,8 +154,8 @@ ep_matches (
/* MATCH!! */
/* report address */
if (isdigit (ep->name [2])) {
u8 num = simple_strtoul (&ep->name [2], NULL, 10);
if (isdigit(ep->name[2])) {
u8 num = simple_strtoul(&ep->name[2], NULL, 10);
desc->bEndpointAddress |= num;
#ifdef MANY_ENDPOINTS
} else if (desc->bEndpointAddress & USB_DIR_IN) {
@ -183,12 +182,12 @@ ep_matches (
}
static struct usb_ep *
find_ep (struct usb_gadget *gadget, const char *name)
find_ep(struct usb_gadget *gadget, const char *name)
{
struct usb_ep *ep;
list_for_each_entry (ep, &gadget->ep_list, ep_list) {
if (0 == strcmp (ep->name, name))
list_for_each_entry(ep, &gadget->ep_list, ep_list) {
if (0 == strcmp(ep->name, name))
return ep;
}
return NULL;
@ -224,7 +223,7 @@ find_ep (struct usb_gadget *gadget, const char *name)
*
* On failure, this returns a null endpoint descriptor.
*/
struct usb_ep * usb_ep_autoconfig (
struct usb_ep *usb_ep_autoconfig(
struct usb_gadget *gadget,
struct usb_endpoint_descriptor *desc
)
@ -237,44 +236,44 @@ struct usb_ep * usb_ep_autoconfig (
/* First, apply chip-specific "best usage" knowledge.
* This might make a good usb_gadget_ops hook ...
*/
if (gadget_is_net2280 (gadget) && type == USB_ENDPOINT_XFER_INT) {
if (gadget_is_net2280(gadget) && type == USB_ENDPOINT_XFER_INT) {
/* ep-e, ep-f are PIO with only 64 byte fifos */
ep = find_ep (gadget, "ep-e");
if (ep && ep_matches (gadget, ep, desc))
ep = find_ep(gadget, "ep-e");
if (ep && ep_matches(gadget, ep, desc))
return ep;
ep = find_ep (gadget, "ep-f");
if (ep && ep_matches (gadget, ep, desc))
ep = find_ep(gadget, "ep-f");
if (ep && ep_matches(gadget, ep, desc))
return ep;
} else if (gadget_is_goku (gadget)) {
} else if (gadget_is_goku(gadget)) {
if (USB_ENDPOINT_XFER_INT == type) {
/* single buffering is enough */
ep = find_ep (gadget, "ep3-bulk");
if (ep && ep_matches (gadget, ep, desc))
ep = find_ep(gadget, "ep3-bulk");
if (ep && ep_matches(gadget, ep, desc))
return ep;
} else if (USB_ENDPOINT_XFER_BULK == type
&& (USB_DIR_IN & desc->bEndpointAddress)) {
/* DMA may be available */
ep = find_ep (gadget, "ep2-bulk");
if (ep && ep_matches (gadget, ep, desc))
ep = find_ep(gadget, "ep2-bulk");
if (ep && ep_matches(gadget, ep, desc))
return ep;
}
} else if (gadget_is_sh (gadget) && USB_ENDPOINT_XFER_INT == type) {
} else if (gadget_is_sh(gadget) && USB_ENDPOINT_XFER_INT == type) {
/* single buffering is enough; maybe 8 byte fifo is too */
ep = find_ep (gadget, "ep3in-bulk");
if (ep && ep_matches (gadget, ep, desc))
ep = find_ep(gadget, "ep3in-bulk");
if (ep && ep_matches(gadget, ep, desc))
return ep;
} else if (gadget_is_mq11xx (gadget) && USB_ENDPOINT_XFER_INT == type) {
ep = find_ep (gadget, "ep1-bulk");
if (ep && ep_matches (gadget, ep, desc))
} else if (gadget_is_mq11xx(gadget) && USB_ENDPOINT_XFER_INT == type) {
ep = find_ep(gadget, "ep1-bulk");
if (ep && ep_matches(gadget, ep, desc))
return ep;
}
/* Second, look at endpoints until an unclaimed one looks usable */
list_for_each_entry (ep, &gadget->ep_list, ep_list) {
if (ep_matches (gadget, ep, desc))
list_for_each_entry(ep, &gadget->ep_list, ep_list) {
if (ep_matches(gadget, ep, desc))
return ep;
}
@ -291,11 +290,11 @@ struct usb_ep * usb_ep_autoconfig (
* state such as ep->driver_data and the record of assigned endpoints
* used by usb_ep_autoconfig().
*/
void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
void usb_ep_autoconfig_reset(struct usb_gadget *gadget)
{
struct usb_ep *ep;
list_for_each_entry (ep, &gadget->ep_list, ep_list) {
list_for_each_entry(ep, &gadget->ep_list, ep_list) {
ep->driver_data = NULL;
}
#ifdef MANY_ENDPOINTS

File diff suppressed because it is too large Load Diff

View File

@ -15,109 +15,109 @@
* Remy Bohmer <linux@bohmer.net>
*/
#ifdef CONFIG_USB_GADGET_NET2280
#define gadget_is_net2280(g) !strcmp("net2280", (g)->name)
#define gadget_is_net2280(g) (!strcmp("net2280", (g)->name))
#else
#define gadget_is_net2280(g) 0
#endif
#ifdef CONFIG_USB_GADGET_AMD5536UDC
#define gadget_is_amd5536udc(g) !strcmp("amd5536udc", (g)->name)
#define gadget_is_amd5536udc(g) (!strcmp("amd5536udc", (g)->name))
#else
#define gadget_is_amd5536udc(g) 0
#endif
#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
#define gadget_is_dummy(g) 0
#endif
#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
#define gadget_is_pxa(g) 0
#endif
#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
#define gadget_is_goku(g) 0
#endif
/* SH3 UDC -- not yet ported 2.4 --> 2.6 */
#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
#define gadget_is_sh(g) 0
#endif
/* not yet stable on 2.6 (would help "original Zaurus") */
#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
#define gadget_is_sa1100(g) 0
#endif
#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
#define gadget_is_lh7a40x(g) 0
#endif
/* handhelds.org tree (?) */
#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
#define gadget_is_mq11xx(g) 0
#endif
#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
#define gadget_is_omap(g) 0
#endif
/* not yet ported 2.4 --> 2.6 */
#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
#define gadget_is_n9604(g) 0
#endif
/* various unstable versions available */
#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
#define gadget_is_pxa27x(g) 0
#endif
#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
#define gadget_is_atmel_usba(g) 0
#endif
#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
#define gadget_is_s3c2410(g) 0
#endif
#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
#define gadget_is_at91(g) 0
#endif
/* status unclear */
#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
#define gadget_is_imx(g) 0
#endif
#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
#define gadget_is_fsl_usb2(g) 0
#endif
@ -125,36 +125,37 @@
/* Mentor high speed function controller */
/* from Montavista kernel (?) */
#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
#define gadget_is_musbhsfc(g) 0
#endif
/* Mentor high speed "dual role" controller, in peripheral role */
#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
#define gadget_is_musbhdrc(g) 0
#endif
/* from Montavista kernel (?) */
#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
#define gadget_is_mpc8272(g) 0
#endif
#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
#define gadget_is_m66592(g) 0
#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

View File

@ -24,14 +24,17 @@ static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len)
u8 c;
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,
* which need surrogate pairs. (Unicode 3.1 can use them.)
*/
while (len != 0 && (c = (u8) *s++) != 0) {
if ((c & 0x80)) {
// 2-byte sequence:
// 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx
/*
* 2-byte sequence:
* 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx
*/
if ((c & 0xe0) == 0xc0) {
uchar = (c & 0x1f) << 6;
@ -41,8 +44,10 @@ static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len)
c &= 0x3f;
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) {
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)
goto fail;
// 4-byte sequence (surrogate pairs, currently rare):
// 11101110wwwwzzzzyy + 110111yyyyxxxxxx
// = 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx
// (uuuuu = wwww + 1)
// FIXME accept the surrogate code points (only)
/*
* 4-byte sequence (surrogate pairs, currently rare):
* 11101110wwwwzzzzyy + 110111yyyyxxxxxx
* = 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx
* (uuuuu = wwww + 1)
* FIXME accept the surrogate code points (only)
*/
} else
goto fail;
} else
@ -100,17 +106,17 @@ fail:
* characters (which are also widely used in C strings).
*/
int
usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf)
usb_gadget_get_string(struct usb_gadget_strings *table, int id, u8 *buf)
{
struct usb_string *s;
int len;
/* descriptor 0 has the language id */
if (id == 0) {
buf [0] = 4;
buf [1] = USB_DT_STRING;
buf [2] = (u8) table->language;
buf [3] = (u8) (table->language >> 8);
buf[0] = 4;
buf[1] = USB_DT_STRING;
buf[2] = (u8) table->language;
buf[3] = (u8) (table->language >> 8);
return 4;
}
for (s = table->strings; s && s->s; s++)
@ -122,13 +128,13 @@ usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf)
return -EINVAL;
/* string descriptors have length, tag, then UTF16-LE text */
len = min ((size_t) 126, strlen (s->s));
memset (buf + 2, 0, 2 * len); /* zero all the bytes */
len = min((size_t) 126, strlen(s->s));
memset(buf + 2, 0, 2 * len); /* zero all the bytes */
len = utf8_to_utf16le(s->s, (__le16 *)&buf[2], len);
if (len < 0)
return -EINVAL;
buf [0] = (len + 1) * 2;
buf [1] = USB_DT_STRING;
return buf [0];
buf[0] = (len + 1) * 2;
buf[1] = USB_DT_STRING;
return buf[0];
}

View File

@ -34,16 +34,16 @@
* Class-Specific descriptors ... there are a couple dozen of them
*/
#define USB_CDC_HEADER_TYPE 0x00 /* header_desc */
#define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */
#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */
#define USB_CDC_UNION_TYPE 0x06 /* union_desc */
#define USB_CDC_HEADER_TYPE 0x00 /* header_desc */
#define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */
#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */
#define USB_CDC_UNION_TYPE 0x06 /* union_desc */
#define USB_CDC_COUNTRY_TYPE 0x07
#define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */
#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */
#define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */
#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */
#define USB_CDC_WHCM_TYPE 0x11
#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */
#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */
#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */
#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */
#define USB_CDC_DMM_TYPE 0x14
#define USB_CDC_OBEX_TYPE 0x15

View File

@ -69,8 +69,8 @@
#define USB_RECIP_ENDPOINT 0x02
#define USB_RECIP_OTHER 0x03
/* From Wireless USB 1.0 */
#define USB_RECIP_PORT 0x04
#define USB_RECIP_RPIPE 0x05
#define USB_RECIP_PORT 0x04
#define USB_RECIP_RPIPE 0x05
/*
* Standard requests, for the bRequest field of a SETUP packet.

View File

@ -73,9 +73,10 @@ struct usb_ep;
*
* Bulk endpoints can use any size buffers, and can also be used for interrupt
* 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 {
void *buf;
@ -170,10 +171,10 @@ struct usb_ep {
*
* returns zero, or a negative error code.
*/
static inline int
usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc)
static inline int usb_ep_enable(struct usb_ep *ep,
const struct usb_endpoint_descriptor *desc)
{
return ep->ops->enable (ep, desc);
return ep->ops->enable(ep, desc);
}
/**
@ -188,10 +189,9 @@ usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc)
*
* returns zero, or a negative error code.
*/
static inline int
usb_ep_disable (struct usb_ep *ep)
static inline int usb_ep_disable(struct usb_ep *ep)
{
return ep->ops->disable (ep);
return ep->ops->disable(ep);
}
/**
@ -208,10 +208,10 @@ usb_ep_disable (struct usb_ep *ep)
*
* Returns the request, or null if one could not be allocated.
*/
static inline struct usb_request *
usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags)
static inline struct usb_request *usb_ep_alloc_request(struct usb_ep *ep,
gfp_t gfp_flags)
{
return ep->ops->alloc_request (ep, gfp_flags);
return ep->ops->alloc_request(ep, gfp_flags);
}
/**
@ -223,10 +223,10 @@ usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags)
* Caller guarantees the request is not queued, and that it will
* no longer be requeued (or otherwise used).
*/
static inline void
usb_ep_free_request (struct usb_ep *ep, struct usb_request *req)
static inline void usb_ep_free_request(struct usb_ep *ep,
struct usb_request *req)
{
ep->ops->free_request (ep, req);
ep->ops->free_request(ep, req);
}
/**
@ -283,10 +283,10 @@ usb_ep_free_request (struct usb_ep *ep, struct usb_request *req)
* report errors; errors will also be
* reported when the usb peripheral is disconnected.
*/
static inline int
usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags)
static inline int usb_ep_queue(struct usb_ep *ep,
struct usb_request *req, gfp_t gfp_flags)
{
return ep->ops->queue (ep, req, gfp_flags);
return ep->ops->queue(ep, req, gfp_flags);
}
/**
@ -303,9 +303,9 @@ usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags)
* restrictions prevent drivers from supporting configuration changes,
* even to configuration zero (a "chapter 9" requirement).
*/
static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req)
static inline int usb_ep_dequeue(struct usb_ep *ep, struct usb_request *req)
{
return ep->ops->dequeue (ep, req);
return ep->ops->dequeue(ep, req);
}
/**
@ -329,10 +329,9 @@ static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req)
* transfer requests are still queued, or if the controller hardware
* (usually a FIFO) still holds bytes that the host hasn't collected.
*/
static inline int
usb_ep_set_halt (struct usb_ep *ep)
static inline int usb_ep_set_halt(struct usb_ep *ep)
{
return ep->ops->set_halt (ep, 1);
return ep->ops->set_halt(ep, 1);
}
/**
@ -348,10 +347,9 @@ usb_ep_set_halt (struct usb_ep *ep)
* Note that some hardware can't support this request (like pxa2xx_udc),
* and accordingly can't correctly implement interface altsettings.
*/
static inline int
usb_ep_clear_halt (struct usb_ep *ep)
static inline int usb_ep_clear_halt(struct usb_ep *ep)
{
return ep->ops->set_halt (ep, 0);
return ep->ops->set_halt(ep, 0);
}
/**
@ -369,11 +367,10 @@ usb_ep_clear_halt (struct usb_ep *ep)
* errno if the endpoint doesn't use a FIFO or doesn't support such
* precise handling.
*/
static inline int
usb_ep_fifo_status (struct usb_ep *ep)
static inline int usb_ep_fifo_status(struct usb_ep *ep)
{
if (ep->ops->fifo_status)
return ep->ops->fifo_status (ep);
return ep->ops->fifo_status(ep);
else
return -EOPNOTSUPP;
}
@ -387,11 +384,10 @@ usb_ep_fifo_status (struct usb_ep *ep)
* must never be used except when endpoint is not being used for any
* protocol translation.
*/
static inline void
usb_ep_fifo_flush (struct usb_ep *ep)
static inline void usb_ep_fifo_flush(struct usb_ep *ep)
{
if (ep->ops->fifo_flush)
ep->ops->fifo_flush (ep);
ep->ops->fifo_flush(ep);
}
@ -475,18 +471,18 @@ struct usb_gadget {
struct device dev;
};
static inline void set_gadget_data (struct usb_gadget *gadget, void *data)
static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
{
gadget->dev.driver_data = data;
}
static inline void *get_gadget_data (struct usb_gadget *gadget)
static inline void *get_gadget_data(struct usb_gadget *gadget)
{
return gadget->dev.driver_data;
}
/* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */
#define gadget_for_each_ep(tmp,gadget) \
#define gadget_for_each_ep(tmp, gadget) \
list_for_each_entry(tmp, &(gadget)->ep_list, ep_list)
@ -522,7 +518,6 @@ static inline int gadget_is_otg(struct usb_gadget *g)
#endif
}
/**
* usb_gadget_frame_number - returns the current frame number
* @gadget: controller that reports the frame number
@ -530,9 +525,9 @@ static inline int gadget_is_otg(struct usb_gadget *g)
* Returns the usb frame number, normally eleven bits from a SOF packet,
* or negative errno if this device doesn't support this capability.
*/
static inline int usb_gadget_frame_number (struct usb_gadget *gadget)
static inline int usb_gadget_frame_number(struct usb_gadget *gadget)
{
return gadget->ops->get_frame (gadget);
return gadget->ops->get_frame(gadget);
}
/**
@ -548,11 +543,11 @@ static inline int usb_gadget_frame_number (struct usb_gadget *gadget)
* even if OTG isn't otherwise in use. OTG devices may also start
* remote wakeup even when hosts don't explicitly enable it.
*/
static inline int usb_gadget_wakeup (struct usb_gadget *gadget)
static inline int usb_gadget_wakeup(struct usb_gadget *gadget)
{
if (!gadget->ops->wakeup)
return -EOPNOTSUPP;
return gadget->ops->wakeup (gadget);
return gadget->ops->wakeup(gadget);
}
/**
@ -564,12 +559,11 @@ static inline int usb_gadget_wakeup (struct usb_gadget *gadget)
*
* returns zero on success, else negative errno.
*/
static inline int
usb_gadget_set_selfpowered (struct usb_gadget *gadget)
static inline int usb_gadget_set_selfpowered(struct usb_gadget *gadget)
{
if (!gadget->ops->set_selfpowered)
return -EOPNOTSUPP;
return gadget->ops->set_selfpowered (gadget, 1);
return gadget->ops->set_selfpowered(gadget, 1);
}
/**
@ -582,12 +576,11 @@ usb_gadget_set_selfpowered (struct usb_gadget *gadget)
*
* returns zero on success, else negative errno.
*/
static inline int
usb_gadget_clear_selfpowered (struct usb_gadget *gadget)
static inline int usb_gadget_clear_selfpowered(struct usb_gadget *gadget)
{
if (!gadget->ops->set_selfpowered)
return -EOPNOTSUPP;
return gadget->ops->set_selfpowered (gadget, 0);
return gadget->ops->set_selfpowered(gadget, 0);
}
/**
@ -602,12 +595,11 @@ usb_gadget_clear_selfpowered (struct usb_gadget *gadget)
*
* Returns zero on success, else negative errno.
*/
static inline int
usb_gadget_vbus_connect(struct usb_gadget *gadget)
static inline int usb_gadget_vbus_connect(struct usb_gadget *gadget)
{
if (!gadget->ops->vbus_session)
return -EOPNOTSUPP;
return gadget->ops->vbus_session (gadget, 1);
return gadget->ops->vbus_session(gadget, 1);
}
/**
@ -622,12 +614,11 @@ usb_gadget_vbus_connect(struct usb_gadget *gadget)
*
* Returns zero on success, else negative errno.
*/
static inline int
usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
{
if (!gadget->ops->vbus_draw)
return -EOPNOTSUPP;
return gadget->ops->vbus_draw (gadget, mA);
return gadget->ops->vbus_draw(gadget, mA);
}
/**
@ -640,12 +631,11 @@ usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
*
* Returns zero on success, else negative errno.
*/
static inline int
usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
static inline int usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
{
if (!gadget->ops->vbus_session)
return -EOPNOTSUPP;
return gadget->ops->vbus_session (gadget, 0);
return gadget->ops->vbus_session(gadget, 0);
}
/**
@ -659,12 +649,11 @@ usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
*
* Returns zero on success, else negative errno.
*/
static inline int
usb_gadget_connect (struct usb_gadget *gadget)
static inline int usb_gadget_connect(struct usb_gadget *gadget)
{
if (!gadget->ops->pullup)
return -EOPNOTSUPP;
return gadget->ops->pullup (gadget, 1);
return gadget->ops->pullup(gadget, 1);
}
/**
@ -682,16 +671,14 @@ usb_gadget_connect (struct usb_gadget *gadget)
*
* Returns zero on success, else negative errno.
*/
static inline int
usb_gadget_disconnect (struct usb_gadget *gadget)
static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
{
if (!gadget->ops->pullup)
return -EOPNOTSUPP;
return gadget->ops->pullup (gadget, 0);
return gadget->ops->pullup(gadget, 0);
}
/*-------------------------------------------------------------------------*/
/**
@ -774,7 +761,6 @@ struct usb_gadget_driver {
};
/*-------------------------------------------------------------------------*/
/* driver modules register and unregister, as usual.
@ -795,7 +781,7 @@ struct usb_gadget_driver {
* the bind() functions will be in init sections.
* This function must be called in a context that can sleep.
*/
int usb_gadget_register_driver (struct usb_gadget_driver *driver);
int usb_gadget_register_driver(struct usb_gadget_driver *driver);
/**
* usb_gadget_unregister_driver - unregister a gadget driver
@ -810,7 +796,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver);
* will in in exit sections, so may not be linked in some kernels.
* This function must be called in a context that can sleep.
*/
int usb_gadget_unregister_driver (struct usb_gadget_driver *driver);
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver);
/*-------------------------------------------------------------------------*/
@ -843,7 +829,7 @@ struct usb_gadget_strings {
};
/* put descriptor for string with that id into buf (buflen >= 256) */
int usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf);
int usb_gadget_get_string(struct usb_gadget_strings *table, int id, u8 *buf);
/*-------------------------------------------------------------------------*/
@ -861,10 +847,10 @@ int usb_gadget_config_buf(const struct usb_config_descriptor *config,
/* utility wrapping a simple endpoint selection policy */
extern struct usb_ep *usb_ep_autoconfig (struct usb_gadget *,
extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,
struct usb_endpoint_descriptor *);
extern void usb_ep_autoconfig_reset (struct usb_gadget *);
extern void usb_ep_autoconfig_reset(struct usb_gadget *);
extern int usb_gadget_handle_interrupts(void);