Commit 18f2cbaa authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Felipe Balbi

usb: gadget: dummy_hcd: clean up checkpatch

This patch converts checkpatch output of
|./scripts/checkpatch.pl drivers/usb/gadget/dummy_hcd.c -file

from
|total: 22 errors, 174 warnings, 2642 lines checked

to
|total: 0 errors, 0 warnings, 2632 lines checked
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 59f08e6d
...@@ -42,25 +42,24 @@ ...@@ -42,25 +42,24 @@
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <asm/io.h> #include <linux/io.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#define DRIVER_DESC "USB Host+Gadget Emulator" #define DRIVER_DESC "USB Host+Gadget Emulator"
#define DRIVER_VERSION "02 May 2005" #define DRIVER_VERSION "02 May 2005"
#define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */ #define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */
static const char driver_name [] = "dummy_hcd"; static const char driver_name[] = "dummy_hcd";
static const char driver_desc [] = "USB Host+Gadget Emulator"; static const char driver_desc[] = "USB Host+Gadget Emulator";
static const char gadget_name [] = "dummy_udc"; static const char gadget_name[] = "dummy_udc";
MODULE_DESCRIPTION (DRIVER_DESC); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_AUTHOR ("David Brownell"); MODULE_AUTHOR("David Brownell");
MODULE_LICENSE ("GPL"); MODULE_LICENSE("GPL");
struct dummy_hcd_module_parameters { struct dummy_hcd_module_parameters {
bool is_super_speed; bool is_super_speed;
...@@ -84,10 +83,10 @@ struct dummy_ep { ...@@ -84,10 +83,10 @@ struct dummy_ep {
struct usb_gadget *gadget; struct usb_gadget *gadget;
const struct usb_endpoint_descriptor *desc; const struct usb_endpoint_descriptor *desc;
struct usb_ep ep; struct usb_ep ep;
unsigned halted : 1; unsigned halted:1;
unsigned wedged : 1; unsigned wedged:1;
unsigned already_seen : 1; unsigned already_seen:1;
unsigned setup_stage : 1; unsigned setup_stage:1;
unsigned stream_en:1; unsigned stream_en:1;
}; };
...@@ -96,15 +95,15 @@ struct dummy_request { ...@@ -96,15 +95,15 @@ struct dummy_request {
struct usb_request req; struct usb_request req;
}; };
static inline struct dummy_ep *usb_ep_to_dummy_ep (struct usb_ep *_ep) static inline struct dummy_ep *usb_ep_to_dummy_ep(struct usb_ep *_ep)
{ {
return container_of (_ep, struct dummy_ep, ep); return container_of(_ep, struct dummy_ep, ep);
} }
static inline struct dummy_request *usb_request_to_dummy_request static inline struct dummy_request *usb_request_to_dummy_request
(struct usb_request *_req) (struct usb_request *_req)
{ {
return container_of (_req, struct dummy_request, req); return container_of(_req, struct dummy_request, req);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -123,9 +122,9 @@ static inline struct dummy_request *usb_request_to_dummy_request ...@@ -123,9 +122,9 @@ static inline struct dummy_request *usb_request_to_dummy_request
* configurations, illegal or unsupported packet lengths, and so on. * configurations, illegal or unsupported packet lengths, and so on.
*/ */
static const char ep0name [] = "ep0"; static const char ep0name[] = "ep0";
static const char *const ep_name [] = { static const char *const ep_name[] = {
ep0name, /* everyone has ep0 */ ep0name, /* everyone has ep0 */
/* act like a net2280: high speed, six configurable endpoints */ /* act like a net2280: high speed, six configurable endpoints */
...@@ -184,12 +183,12 @@ struct dummy { ...@@ -184,12 +183,12 @@ struct dummy {
/* /*
* SLAVE/GADGET side support * SLAVE/GADGET side support
*/ */
struct dummy_ep ep [DUMMY_ENDPOINTS]; struct dummy_ep ep[DUMMY_ENDPOINTS];
int address; int address;
struct usb_gadget gadget; struct usb_gadget gadget;
struct usb_gadget_driver *driver; struct usb_gadget_driver *driver;
struct dummy_request fifo_req; struct dummy_request fifo_req;
u8 fifo_buf [FIFO_SIZE]; u8 fifo_buf[FIFO_SIZE];
u16 devstatus; u16 devstatus;
unsigned udc_suspended:1; unsigned udc_suspended:1;
unsigned pullup:1; unsigned pullup:1;
...@@ -216,14 +215,14 @@ static inline struct device *dummy_dev(struct dummy_hcd *dum) ...@@ -216,14 +215,14 @@ static inline struct device *dummy_dev(struct dummy_hcd *dum)
return dummy_hcd_to_hcd(dum)->self.controller; return dummy_hcd_to_hcd(dum)->self.controller;
} }
static inline struct device *udc_dev (struct dummy *dum) static inline struct device *udc_dev(struct dummy *dum)
{ {
return dum->gadget.dev.parent; return dum->gadget.dev.parent;
} }
static inline struct dummy *ep_to_dummy (struct dummy_ep *ep) static inline struct dummy *ep_to_dummy(struct dummy_ep *ep)
{ {
return container_of (ep->gadget, struct dummy, gadget); return container_of(ep->gadget, struct dummy, gadget);
} }
static inline struct dummy_hcd *gadget_to_dummy_hcd(struct usb_gadget *gadget) static inline struct dummy_hcd *gadget_to_dummy_hcd(struct usb_gadget *gadget)
...@@ -235,9 +234,9 @@ static inline struct dummy_hcd *gadget_to_dummy_hcd(struct usb_gadget *gadget) ...@@ -235,9 +234,9 @@ static inline struct dummy_hcd *gadget_to_dummy_hcd(struct usb_gadget *gadget)
return dum->hs_hcd; return dum->hs_hcd;
} }
static inline struct dummy *gadget_dev_to_dummy (struct device *dev) static inline struct dummy *gadget_dev_to_dummy(struct device *dev)
{ {
return container_of (dev, struct dummy, gadget.dev); return container_of(dev, struct dummy, gadget.dev);
} }
static struct dummy the_controller; static struct dummy the_controller;
...@@ -247,24 +246,23 @@ static struct dummy the_controller; ...@@ -247,24 +246,23 @@ static struct dummy the_controller;
/* SLAVE/GADGET SIDE UTILITY ROUTINES */ /* SLAVE/GADGET SIDE UTILITY ROUTINES */
/* called with spinlock held */ /* called with spinlock held */
static void nuke (struct dummy *dum, struct dummy_ep *ep) static void nuke(struct dummy *dum, struct dummy_ep *ep)
{ {
while (!list_empty (&ep->queue)) { while (!list_empty(&ep->queue)) {
struct dummy_request *req; struct dummy_request *req;
req = list_entry (ep->queue.next, struct dummy_request, queue); req = list_entry(ep->queue.next, struct dummy_request, queue);
list_del_init (&req->queue); list_del_init(&req->queue);
req->req.status = -ESHUTDOWN; req->req.status = -ESHUTDOWN;
spin_unlock (&dum->lock); spin_unlock(&dum->lock);
req->req.complete (&ep->ep, &req->req); req->req.complete(&ep->ep, &req->req);
spin_lock (&dum->lock); spin_lock(&dum->lock);
} }
} }
/* caller must hold lock */ /* caller must hold lock */
static void static void stop_activity(struct dummy *dum)
stop_activity (struct dummy *dum)
{ {
struct dummy_ep *ep; struct dummy_ep *ep;
...@@ -274,8 +272,8 @@ stop_activity (struct dummy *dum) ...@@ -274,8 +272,8 @@ stop_activity (struct dummy *dum)
/* The timer is left running so that outstanding URBs can fail */ /* The timer is left running so that outstanding URBs can fail */
/* nuke any pending requests first, so driver i/o is quiesced */ /* nuke any pending requests first, so driver i/o is quiesced */
list_for_each_entry (ep, &dum->gadget.ep_list, ep.ep_list) list_for_each_entry(ep, &dum->gadget.ep_list, ep.ep_list)
nuke (dum, ep); nuke(dum, ep);
/* driver now does any non-usb quiescing necessary */ /* driver now does any non-usb quiescing necessary */
} }
...@@ -410,8 +408,8 @@ static void set_link_state(struct dummy_hcd *dum_hcd) ...@@ -410,8 +408,8 @@ static void set_link_state(struct dummy_hcd *dum_hcd)
#define is_enabled(dum) \ #define is_enabled(dum) \
(dum->port_status & USB_PORT_STAT_ENABLE) (dum->port_status & USB_PORT_STAT_ENABLE)
static int static int dummy_enable(struct usb_ep *_ep,
dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) const struct usb_endpoint_descriptor *desc)
{ {
struct dummy *dum; struct dummy *dum;
struct dummy_hcd *dum_hcd; struct dummy_hcd *dum_hcd;
...@@ -419,11 +417,11 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) ...@@ -419,11 +417,11 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
unsigned max; unsigned max;
int retval; int retval;
ep = usb_ep_to_dummy_ep (_ep); ep = usb_ep_to_dummy_ep(_ep);
if (!_ep || !desc || ep->desc || _ep->name == ep0name if (!_ep || !desc || ep->desc || _ep->name == ep0name
|| desc->bDescriptorType != USB_DT_ENDPOINT) || desc->bDescriptorType != USB_DT_ENDPOINT)
return -EINVAL; return -EINVAL;
dum = ep_to_dummy (ep); dum = ep_to_dummy(ep);
if (!dum->driver) if (!dum->driver)
return -ESHUTDOWN; return -ESHUTDOWN;
...@@ -449,8 +447,8 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) ...@@ -449,8 +447,8 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
retval = -EINVAL; retval = -EINVAL;
switch (usb_endpoint_type(desc)) { switch (usb_endpoint_type(desc)) {
case USB_ENDPOINT_XFER_BULK: case USB_ENDPOINT_XFER_BULK:
if (strstr (ep->ep.name, "-iso") if (strstr(ep->ep.name, "-iso")
|| strstr (ep->ep.name, "-int")) { || strstr(ep->ep.name, "-int")) {
goto done; goto done;
} }
switch (dum->gadget.speed) { switch (dum->gadget.speed) {
...@@ -472,7 +470,7 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) ...@@ -472,7 +470,7 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
} }
break; break;
case USB_ENDPOINT_XFER_INT: case USB_ENDPOINT_XFER_INT:
if (strstr (ep->ep.name, "-iso")) /* bulk is ok */ if (strstr(ep->ep.name, "-iso")) /* bulk is ok */
goto done; goto done;
/* real hardware might not handle all packet sizes */ /* real hardware might not handle all packet sizes */
switch (dum->gadget.speed) { switch (dum->gadget.speed) {
...@@ -492,8 +490,8 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) ...@@ -492,8 +490,8 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
} }
break; break;
case USB_ENDPOINT_XFER_ISOC: case USB_ENDPOINT_XFER_ISOC:
if (strstr (ep->ep.name, "-bulk") if (strstr(ep->ep.name, "-bulk")
|| strstr (ep->ep.name, "-int")) || strstr(ep->ep.name, "-int"))
goto done; goto done;
/* real hardware might not handle all packet sizes */ /* real hardware might not handle all packet sizes */
switch (dum->gadget.speed) { switch (dum->gadget.speed) {
...@@ -556,68 +554,65 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) ...@@ -556,68 +554,65 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
return retval; return retval;
} }
static int dummy_disable (struct usb_ep *_ep) static int dummy_disable(struct usb_ep *_ep)
{ {
struct dummy_ep *ep; struct dummy_ep *ep;
struct dummy *dum; struct dummy *dum;
unsigned long flags; unsigned long flags;
int retval; int retval;
ep = usb_ep_to_dummy_ep (_ep); ep = usb_ep_to_dummy_ep(_ep);
if (!_ep || !ep->desc || _ep->name == ep0name) if (!_ep || !ep->desc || _ep->name == ep0name)
return -EINVAL; return -EINVAL;
dum = ep_to_dummy (ep); dum = ep_to_dummy(ep);
spin_lock_irqsave (&dum->lock, flags); spin_lock_irqsave(&dum->lock, flags);
ep->desc = NULL; ep->desc = NULL;
ep->stream_en = 0; ep->stream_en = 0;
retval = 0; retval = 0;
nuke (dum, ep); nuke(dum, ep);
spin_unlock_irqrestore (&dum->lock, flags); spin_unlock_irqrestore(&dum->lock, flags);
dev_dbg (udc_dev(dum), "disabled %s\n", _ep->name); dev_dbg(udc_dev(dum), "disabled %s\n", _ep->name);
return retval; return retval;
} }
static struct usb_request * static struct usb_request *dummy_alloc_request(struct usb_ep *_ep,
dummy_alloc_request (struct usb_ep *_ep, gfp_t mem_flags) gfp_t mem_flags)
{ {
struct dummy_ep *ep; struct dummy_ep *ep;
struct dummy_request *req; struct dummy_request *req;
if (!_ep) if (!_ep)
return NULL; return NULL;
ep = usb_ep_to_dummy_ep (_ep); ep = usb_ep_to_dummy_ep(_ep);
req = kzalloc(sizeof(*req), mem_flags); req = kzalloc(sizeof(*req), mem_flags);
if (!req) if (!req)
return NULL; return NULL;
INIT_LIST_HEAD (&req->queue); INIT_LIST_HEAD(&req->queue);
return &req->req; return &req->req;
} }
static void static void dummy_free_request(struct usb_ep *_ep, struct usb_request *_req)
dummy_free_request (struct usb_ep *_ep, struct usb_request *_req)
{ {
struct dummy_ep *ep; struct dummy_ep *ep;
struct dummy_request *req; struct dummy_request *req;
ep = usb_ep_to_dummy_ep (_ep); ep = usb_ep_to_dummy_ep(_ep);
if (!ep || !_req || (!ep->desc && _ep->name != ep0name)) if (!ep || !_req || (!ep->desc && _ep->name != ep0name))
return; return;
req = usb_request_to_dummy_request (_req); req = usb_request_to_dummy_request(_req);
WARN_ON (!list_empty (&req->queue)); WARN_ON(!list_empty(&req->queue));
kfree (req); kfree(req);
} }
static void static void fifo_complete(struct usb_ep *ep, struct usb_request *req)
fifo_complete (struct usb_ep *ep, struct usb_request *req)
{ {
} }
static int static int dummy_queue(struct usb_ep *_ep, struct usb_request *_req,
dummy_queue (struct usb_ep *_ep, struct usb_request *_req,
gfp_t mem_flags) gfp_t mem_flags)
{ {
struct dummy_ep *ep; struct dummy_ep *ep;
...@@ -626,49 +621,48 @@ dummy_queue (struct usb_ep *_ep, struct usb_request *_req, ...@@ -626,49 +621,48 @@ dummy_queue (struct usb_ep *_ep, struct usb_request *_req,
struct dummy_hcd *dum_hcd; struct dummy_hcd *dum_hcd;
unsigned long flags; unsigned long flags;
req = usb_request_to_dummy_request (_req); req = usb_request_to_dummy_request(_req);
if (!_req || !list_empty (&req->queue) || !_req->complete) if (!_req || !list_empty(&req->queue) || !_req->complete)
return -EINVAL; return -EINVAL;
ep = usb_ep_to_dummy_ep (_ep); ep = usb_ep_to_dummy_ep(_ep);
if (!_ep || (!ep->desc && _ep->name != ep0name)) if (!_ep || (!ep->desc && _ep->name != ep0name))
return -EINVAL; return -EINVAL;
dum = ep_to_dummy (ep); dum = ep_to_dummy(ep);
dum_hcd = gadget_to_dummy_hcd(&dum->gadget); dum_hcd = gadget_to_dummy_hcd(&dum->gadget);
if (!dum->driver || !is_enabled(dum_hcd)) if (!dum->driver || !is_enabled(dum_hcd))
return -ESHUTDOWN; return -ESHUTDOWN;
#if 0 #if 0
dev_dbg (udc_dev(dum), "ep %p queue req %p to %s, len %d buf %p\n", dev_dbg(udc_dev(dum), "ep %p queue req %p to %s, len %d buf %p\n",
ep, _req, _ep->name, _req->length, _req->buf); ep, _req, _ep->name, _req->length, _req->buf);
#endif #endif
_req->status = -EINPROGRESS; _req->status = -EINPROGRESS;
_req->actual = 0; _req->actual = 0;
spin_lock_irqsave (&dum->lock, flags); spin_lock_irqsave(&dum->lock, flags);
/* implement an emulated single-request FIFO */ /* implement an emulated single-request FIFO */
if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) &&
list_empty (&dum->fifo_req.queue) && list_empty(&dum->fifo_req.queue) &&
list_empty (&ep->queue) && list_empty(&ep->queue) &&
_req->length <= FIFO_SIZE) { _req->length <= FIFO_SIZE) {
req = &dum->fifo_req; req = &dum->fifo_req;
req->req = *_req; req->req = *_req;
req->req.buf = dum->fifo_buf; req->req.buf = dum->fifo_buf;
memcpy (dum->fifo_buf, _req->buf, _req->length); memcpy(dum->fifo_buf, _req->buf, _req->length);
req->req.context = dum; req->req.context = dum;
req->req.complete = fifo_complete; req->req.complete = fifo_complete;
list_add_tail(&req->queue, &ep->queue); list_add_tail(&req->queue, &ep->queue);
spin_unlock (&dum->lock); spin_unlock(&dum->lock);
_req->actual = _req->length; _req->actual = _req->length;
_req->status = 0; _req->status = 0;
_req->complete (_ep, _req); _req->complete(_ep, _req);
spin_lock (&dum->lock); spin_lock(&dum->lock);
} else } else
list_add_tail(&req->queue, &ep->queue); list_add_tail(&req->queue, &ep->queue);
spin_unlock_irqrestore (&dum->lock, flags); spin_unlock_irqrestore(&dum->lock, flags);
/* real hardware would likely enable transfers here, in case /* real hardware would likely enable transfers here, in case
* it'd been left NAKing. * it'd been left NAKing.
...@@ -676,7 +670,7 @@ dummy_queue (struct usb_ep *_ep, struct usb_request *_req, ...@@ -676,7 +670,7 @@ dummy_queue (struct usb_ep *_ep, struct usb_request *_req,
return 0; return 0;
} }
static int dummy_dequeue (struct usb_ep *_ep, struct usb_request *_req) static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req)
{ {
struct dummy_ep *ep; struct dummy_ep *ep;
struct dummy *dum; struct dummy *dum;
...@@ -686,31 +680,31 @@ static int dummy_dequeue (struct usb_ep *_ep, struct usb_request *_req) ...@@ -686,31 +680,31 @@ static int dummy_dequeue (struct usb_ep *_ep, struct usb_request *_req)
if (!_ep || !_req) if (!_ep || !_req)
return retval; return retval;
ep = usb_ep_to_dummy_ep (_ep); ep = usb_ep_to_dummy_ep(_ep);
dum = ep_to_dummy (ep); dum = ep_to_dummy(ep);
if (!dum->driver) if (!dum->driver)
return -ESHUTDOWN; return -ESHUTDOWN;
local_irq_save (flags); local_irq_save(flags);
spin_lock (&dum->lock); spin_lock(&dum->lock);
list_for_each_entry (req, &ep->queue, queue) { list_for_each_entry(req, &ep->queue, queue) {
if (&req->req == _req) { if (&req->req == _req) {
list_del_init (&req->queue); list_del_init(&req->queue);
_req->status = -ECONNRESET; _req->status = -ECONNRESET;
retval = 0; retval = 0;
break; break;
} }
} }
spin_unlock (&dum->lock); spin_unlock(&dum->lock);
if (retval == 0) { if (retval == 0) {
dev_dbg (udc_dev(dum), dev_dbg(udc_dev(dum),
"dequeued req %p from %s, len %d buf %p\n", "dequeued req %p from %s, len %d buf %p\n",
req, _ep->name, _req->length, _req->buf); req, _ep->name, _req->length, _req->buf);
_req->complete (_ep, _req); _req->complete(_ep, _req);
} }
local_irq_restore (flags); local_irq_restore(flags);
return retval; return retval;
} }
...@@ -722,14 +716,14 @@ dummy_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged) ...@@ -722,14 +716,14 @@ dummy_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
if (!_ep) if (!_ep)
return -EINVAL; return -EINVAL;
ep = usb_ep_to_dummy_ep (_ep); ep = usb_ep_to_dummy_ep(_ep);
dum = ep_to_dummy (ep); dum = ep_to_dummy(ep);
if (!dum->driver) if (!dum->driver)
return -ESHUTDOWN; return -ESHUTDOWN;
if (!value) if (!value)
ep->halted = ep->wedged = 0; ep->halted = ep->wedged = 0;
else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) &&
!list_empty (&ep->queue)) !list_empty(&ep->queue))
return -EAGAIN; return -EAGAIN;
else { else {
ep->halted = 1; ep->halted = 1;
...@@ -770,15 +764,15 @@ static const struct usb_ep_ops dummy_ep_ops = { ...@@ -770,15 +764,15 @@ static const struct usb_ep_ops dummy_ep_ops = {
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* there are both host and device side versions of this call ... */ /* there are both host and device side versions of this call ... */
static int dummy_g_get_frame (struct usb_gadget *_gadget) static int dummy_g_get_frame(struct usb_gadget *_gadget)
{ {
struct timeval tv; struct timeval tv;
do_gettimeofday (&tv); do_gettimeofday(&tv);
return tv.tv_usec / 1000; return tv.tv_usec / 1000;
} }
static int dummy_wakeup (struct usb_gadget *_gadget) static int dummy_wakeup(struct usb_gadget *_gadget)
{ {
struct dummy_hcd *dum_hcd; struct dummy_hcd *dum_hcd;
...@@ -801,11 +795,11 @@ static int dummy_wakeup (struct usb_gadget *_gadget) ...@@ -801,11 +795,11 @@ static int dummy_wakeup (struct usb_gadget *_gadget)
return 0; return 0;
} }
static int dummy_set_selfpowered (struct usb_gadget *_gadget, int value) static int dummy_set_selfpowered(struct usb_gadget *_gadget, int value)
{ {
struct dummy *dum; struct dummy *dum;
dum = (gadget_to_dummy_hcd(_gadget))->dum; dum = gadget_to_dummy_hcd(_gadget)->dum;
if (value) if (value)
dum->devstatus |= (1 << USB_DEVICE_SELF_POWERED); dum->devstatus |= (1 << USB_DEVICE_SELF_POWERED);
else else
...@@ -821,7 +815,7 @@ static void dummy_udc_update_ep0(struct dummy *dum) ...@@ -821,7 +815,7 @@ static void dummy_udc_update_ep0(struct dummy *dum)
dum->ep[0].ep.maxpacket = 64; dum->ep[0].ep.maxpacket = 64;
} }
static int dummy_pullup (struct usb_gadget *_gadget, int value) static int dummy_pullup(struct usb_gadget *_gadget, int value)
{ {
struct dummy_hcd *dum_hcd; struct dummy_hcd *dum_hcd;
struct dummy *dum; struct dummy *dum;
...@@ -846,10 +840,10 @@ static int dummy_pullup (struct usb_gadget *_gadget, int value) ...@@ -846,10 +840,10 @@ static int dummy_pullup (struct usb_gadget *_gadget, int value)
} }
dum_hcd = gadget_to_dummy_hcd(_gadget); dum_hcd = gadget_to_dummy_hcd(_gadget);
spin_lock_irqsave (&dum->lock, flags); spin_lock_irqsave(&dum->lock, flags);
dum->pullup = (value != 0); dum->pullup = (value != 0);
set_link_state(dum_hcd); set_link_state(dum_hcd);
spin_unlock_irqrestore (&dum->lock, flags); spin_unlock_irqrestore(&dum->lock, flags);
usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd)); usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd));
return 0; return 0;
...@@ -872,16 +866,16 @@ static const struct usb_gadget_ops dummy_ops = { ...@@ -872,16 +866,16 @@ static const struct usb_gadget_ops dummy_ops = {
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* "function" sysfs attribute */ /* "function" sysfs attribute */
static ssize_t static ssize_t show_function(struct device *dev, struct device_attribute *attr,
show_function (struct device *dev, struct device_attribute *attr, char *buf) char *buf)
{ {
struct dummy *dum = gadget_dev_to_dummy (dev); struct dummy *dum = gadget_dev_to_dummy(dev);
if (!dum->driver || !dum->driver->function) if (!dum->driver || !dum->driver->function)
return 0; return 0;
return scnprintf (buf, PAGE_SIZE, "%s\n", dum->driver->function); return scnprintf(buf, PAGE_SIZE, "%s\n", dum->driver->function);
} }
static DEVICE_ATTR (function, S_IRUGO, show_function, NULL); static DEVICE_ATTR(function, S_IRUGO, show_function, NULL);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -916,7 +910,7 @@ static int dummy_udc_start(struct usb_gadget *g, ...@@ -916,7 +910,7 @@ static int dummy_udc_start(struct usb_gadget *g,
dum->devstatus = 0; dum->devstatus = 0;
dum->driver = driver; dum->driver = driver;
dev_dbg (udc_dev(dum), "binding gadget driver '%s'\n", dev_dbg(udc_dev(dum), "binding gadget driver '%s'\n",
driver->driver.name); driver->driver.name);
return 0; return 0;
} }
...@@ -927,7 +921,7 @@ static int dummy_udc_stop(struct usb_gadget *g, ...@@ -927,7 +921,7 @@ static int dummy_udc_stop(struct usb_gadget *g,
struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(g); struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(g);
struct dummy *dum = dum_hcd->dum; struct dummy *dum = dum_hcd->dum;
dev_dbg (udc_dev(dum), "unregister gadget driver '%s'\n", dev_dbg(udc_dev(dum), "unregister gadget driver '%s'\n",
driver->driver.name); driver->driver.name);
dum->driver = NULL; dum->driver = NULL;
...@@ -940,8 +934,7 @@ static int dummy_udc_stop(struct usb_gadget *g, ...@@ -940,8 +934,7 @@ static int dummy_udc_stop(struct usb_gadget *g,
/* The gadget structure is stored inside the hcd structure and will be /* The gadget structure is stored inside the hcd structure and will be
* released along with it. */ * released along with it. */
static void static void dummy_gadget_release(struct device *dev)
dummy_gadget_release (struct device *dev)
{ {
return; return;
} }
...@@ -978,7 +971,7 @@ static void init_dummy_udc_hw(struct dummy *dum) ...@@ -978,7 +971,7 @@ static void init_dummy_udc_hw(struct dummy *dum)
#endif #endif
} }
static int dummy_udc_probe (struct platform_device *pdev) static int dummy_udc_probe(struct platform_device *pdev)
{ {
struct dummy *dum = &the_controller; struct dummy *dum = &the_controller;
int rc; int rc;
...@@ -990,7 +983,7 @@ static int dummy_udc_probe (struct platform_device *pdev) ...@@ -990,7 +983,7 @@ static int dummy_udc_probe (struct platform_device *pdev)
dev_set_name(&dum->gadget.dev, "gadget"); dev_set_name(&dum->gadget.dev, "gadget");
dum->gadget.dev.parent = &pdev->dev; dum->gadget.dev.parent = &pdev->dev;
dum->gadget.dev.release = dummy_gadget_release; dum->gadget.dev.release = dummy_gadget_release;
rc = device_register (&dum->gadget.dev); rc = device_register(&dum->gadget.dev);
if (rc < 0) { if (rc < 0) {
put_device(&dum->gadget.dev); put_device(&dum->gadget.dev);
return rc; return rc;
...@@ -1002,7 +995,7 @@ static int dummy_udc_probe (struct platform_device *pdev) ...@@ -1002,7 +995,7 @@ static int dummy_udc_probe (struct platform_device *pdev)
if (rc < 0) if (rc < 0)
goto err_udc; goto err_udc;
rc = device_create_file (&dum->gadget.dev, &dev_attr_function); rc = device_create_file(&dum->gadget.dev, &dev_attr_function);
if (rc < 0) if (rc < 0)
goto err_dev; goto err_dev;
platform_set_drvdata(pdev, dum); platform_set_drvdata(pdev, dum);
...@@ -1015,14 +1008,14 @@ static int dummy_udc_probe (struct platform_device *pdev) ...@@ -1015,14 +1008,14 @@ static int dummy_udc_probe (struct platform_device *pdev)
return rc; return rc;
} }
static int dummy_udc_remove (struct platform_device *pdev) static int dummy_udc_remove(struct platform_device *pdev)
{ {
struct dummy *dum = platform_get_drvdata (pdev); struct dummy *dum = platform_get_drvdata(pdev);
usb_del_gadget_udc(&dum->gadget); usb_del_gadget_udc(&dum->gadget);
platform_set_drvdata (pdev, NULL); platform_set_drvdata(pdev, NULL);
device_remove_file (&dum->gadget.dev, &dev_attr_function); device_remove_file(&dum->gadget.dev, &dev_attr_function);
device_unregister (&dum->gadget.dev); device_unregister(&dum->gadget.dev);
return 0; return 0;
} }
...@@ -1167,7 +1160,7 @@ static int dummy_validate_stream(struct dummy_hcd *dum_hcd, struct urb *urb) ...@@ -1167,7 +1160,7 @@ static int dummy_validate_stream(struct dummy_hcd *dum_hcd, struct urb *urb)
return 0; return 0;
} }
static int dummy_urb_enqueue ( static int dummy_urb_enqueue(
struct usb_hcd *hcd, struct usb_hcd *hcd,
struct urb *urb, struct urb *urb,
gfp_t mem_flags gfp_t mem_flags
...@@ -1177,7 +1170,7 @@ static int dummy_urb_enqueue ( ...@@ -1177,7 +1170,7 @@ static int dummy_urb_enqueue (
unsigned long flags; unsigned long flags;
int rc; int rc;
urbp = kmalloc (sizeof *urbp, mem_flags); urbp = kmalloc(sizeof *urbp, mem_flags);
if (!urbp) if (!urbp)
return -ENOMEM; return -ENOMEM;
urbp->urb = urb; urbp->urb = urb;
...@@ -1206,7 +1199,7 @@ static int dummy_urb_enqueue ( ...@@ -1206,7 +1199,7 @@ static int dummy_urb_enqueue (
list_add_tail(&urbp->urbp_list, &dum_hcd->urbp_list); list_add_tail(&urbp->urbp_list, &dum_hcd->urbp_list);
urb->hcpriv = urbp; urb->hcpriv = urbp;
if (usb_pipetype (urb->pipe) == PIPE_CONTROL) if (usb_pipetype(urb->pipe) == PIPE_CONTROL)
urb->error_count = 1; /* mark as a new urb */ urb->error_count = 1; /* mark as a new urb */
/* kick the scheduler, it'll do the rest */ /* kick the scheduler, it'll do the rest */
...@@ -1313,7 +1306,7 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb, ...@@ -1313,7 +1306,7 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb,
top: top:
/* if there's no request queued, the device is NAKing; return */ /* if there's no request queued, the device is NAKing; return */
list_for_each_entry (req, &ep->queue, queue) { list_for_each_entry(req, &ep->queue, queue) {
unsigned host_len, dev_len, len; unsigned host_len, dev_len, len;
int is_short, to_host; int is_short, to_host;
int rescan = 0; int rescan = 0;
...@@ -1332,18 +1325,18 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb, ...@@ -1332,18 +1325,18 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb,
*/ */
host_len = urb->transfer_buffer_length - urb->actual_length; host_len = urb->transfer_buffer_length - urb->actual_length;
dev_len = req->req.length - req->req.actual; dev_len = req->req.length - req->req.actual;
len = min (host_len, dev_len); len = min(host_len, dev_len);
/* FIXME update emulated data toggle too */ /* FIXME update emulated data toggle too */
to_host = usb_pipein (urb->pipe); to_host = usb_pipein(urb->pipe);
if (unlikely (len == 0)) if (unlikely(len == 0))
is_short = 1; is_short = 1;
else { else {
/* not enough bandwidth left? */ /* not enough bandwidth left? */
if (limit < ep->ep.maxpacket && limit < len) if (limit < ep->ep.maxpacket && limit < len)
break; break;
len = min (len, (unsigned) limit); len = min_t(unsigned, len, limit);
if (len == 0) if (len == 0)
break; break;
...@@ -1404,11 +1397,11 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb, ...@@ -1404,11 +1397,11 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb,
/* device side completion --> continuable */ /* device side completion --> continuable */
if (req->req.status != -EINPROGRESS) { if (req->req.status != -EINPROGRESS) {
list_del_init (&req->queue); list_del_init(&req->queue);
spin_unlock (&dum->lock); spin_unlock(&dum->lock);
req->req.complete (&ep->ep, &req->req); req->req.complete(&ep->ep, &req->req);
spin_lock (&dum->lock); spin_lock(&dum->lock);
/* requests might have been unlinked... */ /* requests might have been unlinked... */
rescan = 1; rescan = 1;
...@@ -1425,7 +1418,7 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb, ...@@ -1425,7 +1418,7 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb,
return limit; return limit;
} }
static int periodic_bytes (struct dummy *dum, struct dummy_ep *ep) static int periodic_bytes(struct dummy *dum, struct dummy_ep *ep)
{ {
int limit = ep->ep.maxpacket; int limit = ep->ep.maxpacket;
...@@ -1461,7 +1454,7 @@ static int periodic_bytes (struct dummy *dum, struct dummy_ep *ep) ...@@ -1461,7 +1454,7 @@ static int periodic_bytes (struct dummy *dum, struct dummy_ep *ep)
USB_PORT_STAT_SUSPEND)) \ USB_PORT_STAT_SUSPEND)) \
== (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE)) == (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE))
static struct dummy_ep *find_endpoint (struct dummy *dum, u8 address) static struct dummy_ep *find_endpoint(struct dummy *dum, u8 address)
{ {
int i; int i;
...@@ -1469,9 +1462,9 @@ static struct dummy_ep *find_endpoint (struct dummy *dum, u8 address) ...@@ -1469,9 +1462,9 @@ static struct dummy_ep *find_endpoint (struct dummy *dum, u8 address)
dum->ss_hcd : dum->hs_hcd))) dum->ss_hcd : dum->hs_hcd)))
return NULL; return NULL;
if ((address & ~USB_DIR_IN) == 0) if ((address & ~USB_DIR_IN) == 0)
return &dum->ep [0]; return &dum->ep[0];
for (i = 1; i < DUMMY_ENDPOINTS; i++) { for (i = 1; i < DUMMY_ENDPOINTS; i++) {
struct dummy_ep *ep = &dum->ep [i]; struct dummy_ep *ep = &dum->ep[i];
if (!ep->desc) if (!ep->desc)
continue; continue;
...@@ -1701,19 +1694,19 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1701,19 +1694,19 @@ static void dummy_timer(unsigned long _dum_hcd)
/* FIXME if HZ != 1000 this will probably misbehave ... */ /* FIXME if HZ != 1000 this will probably misbehave ... */
/* look at each urb queued by the host side driver */ /* look at each urb queued by the host side driver */
spin_lock_irqsave (&dum->lock, flags); spin_lock_irqsave(&dum->lock, flags);
if (!dum_hcd->udev) { if (!dum_hcd->udev) {
dev_err(dummy_dev(dum_hcd), dev_err(dummy_dev(dum_hcd),
"timer fired with no URBs pending?\n"); "timer fired with no URBs pending?\n");
spin_unlock_irqrestore (&dum->lock, flags); spin_unlock_irqrestore(&dum->lock, flags);
return; return;
} }
for (i = 0; i < DUMMY_ENDPOINTS; i++) { for (i = 0; i < DUMMY_ENDPOINTS; i++) {
if (!ep_name [i]) if (!ep_name[i])
break; break;
dum->ep [i].already_seen = 0; dum->ep[i].already_seen = 0;
} }
restart: restart:
...@@ -1730,7 +1723,7 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1730,7 +1723,7 @@ static void dummy_timer(unsigned long _dum_hcd)
goto return_urb; goto return_urb;
else if (dum_hcd->rh_state != DUMMY_RH_RUNNING) else if (dum_hcd->rh_state != DUMMY_RH_RUNNING)
continue; continue;
type = usb_pipetype (urb->pipe); type = usb_pipetype(urb->pipe);
/* used up this frame's non-periodic bandwidth? /* used up this frame's non-periodic bandwidth?
* FIXME there's infinite bandwidth for control and * FIXME there's infinite bandwidth for control and
...@@ -1741,7 +1734,7 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1741,7 +1734,7 @@ static void dummy_timer(unsigned long _dum_hcd)
/* find the gadget's ep for this request (if configured) */ /* find the gadget's ep for this request (if configured) */
address = usb_pipeendpoint (urb->pipe); address = usb_pipeendpoint (urb->pipe);
if (usb_pipein (urb->pipe)) if (usb_pipein(urb->pipe))
address |= USB_DIR_IN; address |= USB_DIR_IN;
ep = find_endpoint(dum, address); ep = find_endpoint(dum, address);
if (!ep) { if (!ep) {
...@@ -1756,7 +1749,7 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1756,7 +1749,7 @@ static void dummy_timer(unsigned long _dum_hcd)
if (ep->already_seen) if (ep->already_seen)
continue; continue;
ep->already_seen = 1; ep->already_seen = 1;
if (ep == &dum->ep [0] && urb->error_count) { if (ep == &dum->ep[0] && urb->error_count) {
ep->setup_stage = 1; /* a new urb */ ep->setup_stage = 1; /* a new urb */
urb->error_count = 0; urb->error_count = 0;
} }
...@@ -1770,21 +1763,21 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1770,21 +1763,21 @@ static void dummy_timer(unsigned long _dum_hcd)
/* FIXME make sure both ends agree on maxpacket */ /* FIXME make sure both ends agree on maxpacket */
/* handle control requests */ /* handle control requests */
if (ep == &dum->ep [0] && ep->setup_stage) { if (ep == &dum->ep[0] && ep->setup_stage) {
struct usb_ctrlrequest setup; struct usb_ctrlrequest setup;
int value = 1; int value = 1;
setup = *(struct usb_ctrlrequest*) urb->setup_packet; setup = *(struct usb_ctrlrequest *) urb->setup_packet;
/* paranoia, in case of stale queued data */ /* paranoia, in case of stale queued data */
list_for_each_entry (req, &ep->queue, queue) { list_for_each_entry(req, &ep->queue, queue) {
list_del_init (&req->queue); list_del_init(&req->queue);
req->req.status = -EOVERFLOW; req->req.status = -EOVERFLOW;
dev_dbg (udc_dev(dum), "stale req = %p\n", dev_dbg(udc_dev(dum), "stale req = %p\n",
req); req);
spin_unlock (&dum->lock); spin_unlock(&dum->lock);
req->req.complete (&ep->ep, &req->req); req->req.complete(&ep->ep, &req->req);
spin_lock (&dum->lock); spin_lock(&dum->lock);
ep->already_seen = 0; ep->already_seen = 0;
goto restart; goto restart;
} }
...@@ -1804,10 +1797,10 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1804,10 +1797,10 @@ static void dummy_timer(unsigned long _dum_hcd)
* until setup() returns; no reentrancy issues etc. * until setup() returns; no reentrancy issues etc.
*/ */
if (value > 0) { if (value > 0) {
spin_unlock (&dum->lock); spin_unlock(&dum->lock);
value = dum->driver->setup (&dum->gadget, value = dum->driver->setup(&dum->gadget,
&setup); &setup);
spin_lock (&dum->lock); spin_lock(&dum->lock);
if (value >= 0) { if (value >= 0) {
/* no delays (max 64KB data stage) */ /* no delays (max 64KB data stage) */
...@@ -1819,7 +1812,7 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1819,7 +1812,7 @@ static void dummy_timer(unsigned long _dum_hcd)
if (value < 0) { if (value < 0) {
if (value != -EOPNOTSUPP) if (value != -EOPNOTSUPP)
dev_dbg (udc_dev(dum), dev_dbg(udc_dev(dum),
"setup --> %d\n", "setup --> %d\n",
value); value);
status = -EPIPE; status = -EPIPE;
...@@ -1831,14 +1824,14 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1831,14 +1824,14 @@ static void dummy_timer(unsigned long _dum_hcd)
/* non-control requests */ /* non-control requests */
limit = total; limit = total;
switch (usb_pipetype (urb->pipe)) { switch (usb_pipetype(urb->pipe)) {
case PIPE_ISOCHRONOUS: case PIPE_ISOCHRONOUS:
/* FIXME is it urb->interval since the last xfer? /* FIXME is it urb->interval since the last xfer?
* use urb->iso_frame_desc[i]. * use urb->iso_frame_desc[i].
* complete whether or not ep has requests queued. * complete whether or not ep has requests queued.
* report random errors, to debug drivers. * report random errors, to debug drivers.
*/ */
limit = max (limit, periodic_bytes (dum, ep)); limit = max(limit, periodic_bytes(dum, ep));
status = -ENOSYS; status = -ENOSYS;
break; break;
...@@ -1846,12 +1839,11 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1846,12 +1839,11 @@ static void dummy_timer(unsigned long _dum_hcd)
/* FIXME is it urb->interval since the last xfer? /* FIXME is it urb->interval since the last xfer?
* this almost certainly polls too fast. * this almost certainly polls too fast.
*/ */
limit = max (limit, periodic_bytes (dum, ep)); limit = max(limit, periodic_bytes(dum, ep));
/* FALLTHROUGH */ /* FALLTHROUGH */
// case PIPE_BULK: case PIPE_CONTROL:
default: default:
treat_control_like_bulk: treat_control_like_bulk:
ep->last_io = jiffies; ep->last_io = jiffies;
total = transfer(dum_hcd, urb, ep, limit, &status); total = transfer(dum_hcd, urb, ep, limit, &status);
break; break;
...@@ -1862,15 +1854,15 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1862,15 +1854,15 @@ static void dummy_timer(unsigned long _dum_hcd)
continue; continue;
return_urb: return_urb:
list_del (&urbp->urbp_list); list_del(&urbp->urbp_list);
kfree (urbp); kfree(urbp);
if (ep) if (ep)
ep->already_seen = ep->setup_stage = 0; ep->already_seen = ep->setup_stage = 0;
usb_hcd_unlink_urb_from_ep(dummy_hcd_to_hcd(dum_hcd), urb); usb_hcd_unlink_urb_from_ep(dummy_hcd_to_hcd(dum_hcd), urb);
spin_unlock (&dum->lock); spin_unlock(&dum->lock);
usb_hcd_giveback_urb(dummy_hcd_to_hcd(dum_hcd), urb, status); usb_hcd_giveback_urb(dummy_hcd_to_hcd(dum_hcd), urb, status);
spin_lock (&dum->lock); spin_lock(&dum->lock);
goto restart; goto restart;
} }
...@@ -1883,7 +1875,7 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1883,7 +1875,7 @@ static void dummy_timer(unsigned long _dum_hcd)
mod_timer(&dum_hcd->timer, jiffies + msecs_to_jiffies(1)); mod_timer(&dum_hcd->timer, jiffies + msecs_to_jiffies(1));
} }
spin_unlock_irqrestore (&dum->lock, flags); spin_unlock_irqrestore(&dum->lock, flags);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -1895,7 +1887,7 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1895,7 +1887,7 @@ static void dummy_timer(unsigned long _dum_hcd)
| USB_PORT_STAT_C_OVERCURRENT \ | USB_PORT_STAT_C_OVERCURRENT \
| USB_PORT_STAT_C_RESET) << 16) | USB_PORT_STAT_C_RESET) << 16)
static int dummy_hub_status (struct usb_hcd *hcd, char *buf) static int dummy_hub_status(struct usb_hcd *hcd, char *buf)
{ {
struct dummy_hcd *dum_hcd; struct dummy_hcd *dum_hcd;
unsigned long flags; unsigned long flags;
...@@ -1919,7 +1911,7 @@ static int dummy_hub_status (struct usb_hcd *hcd, char *buf) ...@@ -1919,7 +1911,7 @@ static int dummy_hub_status (struct usb_hcd *hcd, char *buf)
dum_hcd->port_status); dum_hcd->port_status);
retval = 1; retval = 1;
if (dum_hcd->rh_state == DUMMY_RH_SUSPENDED) if (dum_hcd->rh_state == DUMMY_RH_SUSPENDED)
usb_hcd_resume_root_hub (hcd); usb_hcd_resume_root_hub(hcd);
} }
done: done:
spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); spin_unlock_irqrestore(&dum_hcd->dum->lock, flags);
...@@ -1938,10 +1930,9 @@ ss_hub_descriptor(struct usb_hub_descriptor *desc) ...@@ -1938,10 +1930,9 @@ ss_hub_descriptor(struct usb_hub_descriptor *desc)
desc->u.ss.DeviceRemovable = 0xffff; desc->u.ss.DeviceRemovable = 0xffff;
} }
static inline void static inline void hub_descriptor(struct usb_hub_descriptor *desc)
hub_descriptor (struct usb_hub_descriptor *desc)
{ {
memset (desc, 0, sizeof *desc); memset(desc, 0, sizeof *desc);
desc->bDescriptorType = 0x29; desc->bDescriptorType = 0x29;
desc->bDescLength = 9; desc->bDescLength = 9;
desc->wHubCharacteristics = cpu_to_le16(0x0001); desc->wHubCharacteristics = cpu_to_le16(0x0001);
...@@ -1950,7 +1941,7 @@ hub_descriptor (struct usb_hub_descriptor *desc) ...@@ -1950,7 +1941,7 @@ hub_descriptor (struct usb_hub_descriptor *desc)
desc->u.hs.DeviceRemovable[1] = 0xff; desc->u.hs.DeviceRemovable[1] = 0xff;
} }
static int dummy_hub_control ( static int dummy_hub_control(
struct usb_hcd *hcd, struct usb_hcd *hcd,
u16 typeReq, u16 typeReq,
u16 wValue, u16 wValue,
...@@ -2018,7 +2009,7 @@ static int dummy_hub_control ( ...@@ -2018,7 +2009,7 @@ static int dummy_hub_control (
hub_descriptor((struct usb_hub_descriptor *) buf); hub_descriptor((struct usb_hub_descriptor *) buf);
break; break;
case GetHubStatus: case GetHubStatus:
*(__le32 *) buf = cpu_to_le32 (0); *(__le32 *) buf = cpu_to_le32(0);
break; break;
case GetPortStatus: case GetPortStatus:
if (wIndex != 1) if (wIndex != 1)
...@@ -2060,8 +2051,8 @@ static int dummy_hub_control ( ...@@ -2060,8 +2051,8 @@ static int dummy_hub_control (
} }
} }
set_link_state(dum_hcd); set_link_state(dum_hcd);
((__le16 *) buf)[0] = cpu_to_le16 (dum_hcd->port_status); ((__le16 *) buf)[0] = cpu_to_le16(dum_hcd->port_status);
((__le16 *) buf)[1] = cpu_to_le16 (dum_hcd->port_status >> 16); ((__le16 *) buf)[1] = cpu_to_le16(dum_hcd->port_status >> 16);
break; break;
case SetHubFeature: case SetHubFeature:
retval = -EPIPE; retval = -EPIPE;
...@@ -2195,15 +2186,15 @@ static int dummy_hub_control ( ...@@ -2195,15 +2186,15 @@ static int dummy_hub_control (
spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); spin_unlock_irqrestore(&dum_hcd->dum->lock, flags);
if ((dum_hcd->port_status & PORT_C_MASK) != 0) if ((dum_hcd->port_status & PORT_C_MASK) != 0)
usb_hcd_poll_rh_status (hcd); usb_hcd_poll_rh_status(hcd);
return retval; return retval;
} }
static int dummy_bus_suspend (struct usb_hcd *hcd) static int dummy_bus_suspend(struct usb_hcd *hcd)
{ {
struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd);
dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
spin_lock_irq(&dum_hcd->dum->lock); spin_lock_irq(&dum_hcd->dum->lock);
dum_hcd->rh_state = DUMMY_RH_SUSPENDED; dum_hcd->rh_state = DUMMY_RH_SUSPENDED;
...@@ -2213,12 +2204,12 @@ static int dummy_bus_suspend (struct usb_hcd *hcd) ...@@ -2213,12 +2204,12 @@ static int dummy_bus_suspend (struct usb_hcd *hcd)
return 0; return 0;
} }
static int dummy_bus_resume (struct usb_hcd *hcd) static int dummy_bus_resume(struct usb_hcd *hcd)
{ {
struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd);
int rc = 0; int rc = 0;
dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
spin_lock_irq(&dum_hcd->dum->lock); spin_lock_irq(&dum_hcd->dum->lock);
if (!HCD_HW_ACCESSIBLE(hcd)) { if (!HCD_HW_ACCESSIBLE(hcd)) {
...@@ -2236,12 +2227,11 @@ static int dummy_bus_resume (struct usb_hcd *hcd) ...@@ -2236,12 +2227,11 @@ static int dummy_bus_resume (struct usb_hcd *hcd)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static inline ssize_t static inline ssize_t show_urb(char *buf, size_t size, struct urb *urb)
show_urb (char *buf, size_t size, struct urb *urb)
{ {
int ep = usb_pipeendpoint (urb->pipe); int ep = usb_pipeendpoint(urb->pipe);
return snprintf (buf, size, return snprintf(buf, size,
"urb/%p %s ep%d%s%s len %d/%d\n", "urb/%p %s ep%d%s%s len %d/%d\n",
urb, urb,
({ char *s; ({ char *s;
...@@ -2262,9 +2252,9 @@ show_urb (char *buf, size_t size, struct urb *urb) ...@@ -2262,9 +2252,9 @@ show_urb (char *buf, size_t size, struct urb *urb)
s = "?"; s = "?";
break; break;
}; s; }), }; s; }),
ep, ep ? (usb_pipein (urb->pipe) ? "in" : "out") : "", ep, ep ? (usb_pipein(urb->pipe) ? "in" : "out") : "",
({ char *s; \ ({ char *s; \
switch (usb_pipetype (urb->pipe)) { \ switch (usb_pipetype(urb->pipe)) { \
case PIPE_CONTROL: \ case PIPE_CONTROL: \
s = ""; \ s = ""; \
break; \ break; \
...@@ -2277,14 +2267,14 @@ show_urb (char *buf, size_t size, struct urb *urb) ...@@ -2277,14 +2267,14 @@ show_urb (char *buf, size_t size, struct urb *urb)
default: \ default: \
s = "-iso"; \ s = "-iso"; \
break; \ break; \
}; s;}), }; s; }),
urb->actual_length, urb->transfer_buffer_length); urb->actual_length, urb->transfer_buffer_length);
} }
static ssize_t static ssize_t show_urbs(struct device *dev, struct device_attribute *attr,
show_urbs (struct device *dev, struct device_attribute *attr, char *buf) char *buf)
{ {
struct usb_hcd *hcd = dev_get_drvdata (dev); struct usb_hcd *hcd = dev_get_drvdata(dev);
struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd);
struct urbp *urbp; struct urbp *urbp;
size_t size = 0; size_t size = 0;
...@@ -2294,7 +2284,7 @@ show_urbs (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -2294,7 +2284,7 @@ show_urbs (struct device *dev, struct device_attribute *attr, char *buf)
list_for_each_entry(urbp, &dum_hcd->urbp_list, urbp_list) { list_for_each_entry(urbp, &dum_hcd->urbp_list, urbp_list) {
size_t temp; size_t temp;
temp = show_urb (buf, PAGE_SIZE - size, urbp->urb); temp = show_urb(buf, PAGE_SIZE - size, urbp->urb);
buf += temp; buf += temp;
size += temp; size += temp;
} }
...@@ -2302,7 +2292,7 @@ show_urbs (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -2302,7 +2292,7 @@ show_urbs (struct device *dev, struct device_attribute *attr, char *buf)
return size; return size;
} }
static DEVICE_ATTR (urbs, S_IRUGO, show_urbs, NULL); static DEVICE_ATTR(urbs, S_IRUGO, show_urbs, NULL);
static int dummy_start_ss(struct dummy_hcd *dum_hcd) static int dummy_start_ss(struct dummy_hcd *dum_hcd)
{ {
...@@ -2356,11 +2346,11 @@ static int dummy_start(struct usb_hcd *hcd) ...@@ -2356,11 +2346,11 @@ static int dummy_start(struct usb_hcd *hcd)
return device_create_file(dummy_dev(dum_hcd), &dev_attr_urbs); return device_create_file(dummy_dev(dum_hcd), &dev_attr_urbs);
} }
static void dummy_stop (struct usb_hcd *hcd) static void dummy_stop(struct usb_hcd *hcd)
{ {
struct dummy *dum; struct dummy *dum;
dum = (hcd_to_dummy_hcd(hcd))->dum; dum = hcd_to_dummy_hcd(hcd)->dum;
device_remove_file(dummy_dev(hcd_to_dummy_hcd(hcd)), &dev_attr_urbs); device_remove_file(dummy_dev(hcd_to_dummy_hcd(hcd)), &dev_attr_urbs);
usb_gadget_unregister_driver(dum->driver); usb_gadget_unregister_driver(dum->driver);
dev_info(dummy_dev(hcd_to_dummy_hcd(hcd)), "stopped\n"); dev_info(dummy_dev(hcd_to_dummy_hcd(hcd)), "stopped\n");
...@@ -2368,9 +2358,9 @@ static void dummy_stop (struct usb_hcd *hcd) ...@@ -2368,9 +2358,9 @@ static void dummy_stop (struct usb_hcd *hcd)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static int dummy_h_get_frame (struct usb_hcd *hcd) static int dummy_h_get_frame(struct usb_hcd *hcd)
{ {
return dummy_g_get_frame (NULL); return dummy_g_get_frame(NULL);
} }
static int dummy_setup(struct usb_hcd *hcd) static int dummy_setup(struct usb_hcd *hcd)
...@@ -2546,7 +2536,7 @@ static int dummy_hcd_remove(struct platform_device *pdev) ...@@ -2546,7 +2536,7 @@ static int dummy_hcd_remove(struct platform_device *pdev)
{ {
struct dummy *dum; struct dummy *dum;
dum = (hcd_to_dummy_hcd(platform_get_drvdata(pdev)))->dum; dum = hcd_to_dummy_hcd(platform_get_drvdata(pdev))->dum;
if (dum->ss_hcd) { if (dum->ss_hcd) {
usb_remove_hcd(dummy_hcd_to_hcd(dum->ss_hcd)); usb_remove_hcd(dummy_hcd_to_hcd(dum->ss_hcd));
...@@ -2562,15 +2552,15 @@ static int dummy_hcd_remove(struct platform_device *pdev) ...@@ -2562,15 +2552,15 @@ static int dummy_hcd_remove(struct platform_device *pdev)
return 0; return 0;
} }
static int dummy_hcd_suspend (struct platform_device *pdev, pm_message_t state) static int dummy_hcd_suspend(struct platform_device *pdev, pm_message_t state)
{ {
struct usb_hcd *hcd; struct usb_hcd *hcd;
struct dummy_hcd *dum_hcd; struct dummy_hcd *dum_hcd;
int rc = 0; int rc = 0;
dev_dbg (&pdev->dev, "%s\n", __func__); dev_dbg(&pdev->dev, "%s\n", __func__);
hcd = platform_get_drvdata (pdev); hcd = platform_get_drvdata(pdev);
dum_hcd = hcd_to_dummy_hcd(hcd); dum_hcd = hcd_to_dummy_hcd(hcd);
if (dum_hcd->rh_state == DUMMY_RH_RUNNING) { if (dum_hcd->rh_state == DUMMY_RH_RUNNING) {
dev_warn(&pdev->dev, "Root hub isn't suspended!\n"); dev_warn(&pdev->dev, "Root hub isn't suspended!\n");
...@@ -2580,15 +2570,15 @@ static int dummy_hcd_suspend (struct platform_device *pdev, pm_message_t state) ...@@ -2580,15 +2570,15 @@ static int dummy_hcd_suspend (struct platform_device *pdev, pm_message_t state)
return rc; return rc;
} }
static int dummy_hcd_resume (struct platform_device *pdev) static int dummy_hcd_resume(struct platform_device *pdev)
{ {
struct usb_hcd *hcd; struct usb_hcd *hcd;
dev_dbg (&pdev->dev, "%s\n", __func__); dev_dbg(&pdev->dev, "%s\n", __func__);
hcd = platform_get_drvdata (pdev); hcd = platform_get_drvdata(pdev);
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
usb_hcd_poll_rh_status (hcd); usb_hcd_poll_rh_status(hcd);
return 0; return 0;
} }
...@@ -2608,11 +2598,11 @@ static struct platform_driver dummy_hcd_driver = { ...@@ -2608,11 +2598,11 @@ static struct platform_driver dummy_hcd_driver = {
static struct platform_device *the_udc_pdev; static struct platform_device *the_udc_pdev;
static struct platform_device *the_hcd_pdev; static struct platform_device *the_hcd_pdev;
static int __init init (void) static int __init init(void)
{ {
int retval = -ENOMEM; int retval = -ENOMEM;
if (usb_disabled ()) if (usb_disabled())
return -ENODEV; return -ENODEV;
if (!mod_data.is_high_speed && mod_data.is_super_speed) if (!mod_data.is_high_speed && mod_data.is_super_speed)
...@@ -2671,13 +2661,13 @@ static int __init init (void) ...@@ -2671,13 +2661,13 @@ static int __init init (void)
platform_device_put(the_hcd_pdev); platform_device_put(the_hcd_pdev);
return retval; return retval;
} }
module_init (init); module_init(init);
static void __exit cleanup (void) static void __exit cleanup(void)
{ {
platform_device_unregister(the_udc_pdev); platform_device_unregister(the_udc_pdev);
platform_device_unregister(the_hcd_pdev); platform_device_unregister(the_hcd_pdev);
platform_driver_unregister(&dummy_udc_driver); platform_driver_unregister(&dummy_udc_driver);
platform_driver_unregister(&dummy_hcd_driver); platform_driver_unregister(&dummy_hcd_driver);
} }
module_exit (cleanup); module_exit(cleanup);
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