From 183c6e0fb4e39c860960de4abd7541bd260491bb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 12 Jan 2009 15:19:08 +0100 Subject: drivers/usb/gadget: Convert to snd_card_create() Convert from snd_card_new() to the new snd_card_create() function for gmidi. Signed-off-by: Takashi Iwai --- drivers/usb/gadget/gmidi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 60d3f9e9b51..14e09abbddf 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c @@ -1099,10 +1099,9 @@ static int gmidi_register_card(struct gmidi_device *dev) .dev_free = gmidi_snd_free, }; - card = snd_card_new(index, id, THIS_MODULE, 0); - if (!card) { - ERROR(dev, "snd_card_new failed\n"); - err = -ENOMEM; + err = snd_card_create(index, id, THIS_MODULE, 0, &card); + if (err < 0) { + ERROR(dev, "snd_card_create failed\n"); goto fail; } dev->card = card; -- cgit v1.2.3 From dd4dff8b035f6dda69ece98e20d4c2d76b9f97d1 Mon Sep 17 00:00:00 2001 From: Bryan Wu Date: Thu, 8 Jan 2009 00:21:18 +0800 Subject: USB: composite: Fix bug: should test set_alt function pointer before use it Signed-off-by: Bryan Wu Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index f2da0269e1b..363951eb333 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -772,7 +772,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) f = cdev->config->interface[w_index]; if (!f) break; - if (w_value && !f->get_alt) + if (w_value && !f->set_alt) break; value = f->set_alt(f, w_index, w_value); break; -- cgit v1.2.3 From 08889517b3713926169d79d99782192e86acdc67 Mon Sep 17 00:00:00 2001 From: Bryan Wu Date: Thu, 8 Jan 2009 00:21:19 +0800 Subject: USB: composite: Fix bug: low byte of w_index is the usb interface number not the whole 2 bytes of w_index In some usb gadget driver, for example usb audio class device, the high byte of w_index is the entity id and low byte is the interface number. If we use the 2 bytes of w_index as the array number, we will get a wrong pointer or NULL pointer. This patch fixes this issue. Signed-off-by: Bryan Wu Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/composite.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 363951eb333..5d11c291f1a 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -683,6 +683,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) struct usb_request *req = cdev->req; int value = -EOPNOTSUPP; u16 w_index = le16_to_cpu(ctrl->wIndex); + u8 intf = w_index & 0xFF; u16 w_value = le16_to_cpu(ctrl->wValue); u16 w_length = le16_to_cpu(ctrl->wLength); struct usb_function *f = NULL; @@ -769,7 +770,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) goto unknown; if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES) break; - f = cdev->config->interface[w_index]; + f = cdev->config->interface[intf]; if (!f) break; if (w_value && !f->set_alt) @@ -781,7 +782,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) goto unknown; if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES) break; - f = cdev->config->interface[w_index]; + f = cdev->config->interface[intf]; if (!f) break; /* lots of interfaces only need altsetting zero... */ @@ -808,7 +809,7 @@ unknown: */ if ((ctrl->bRequestType & USB_RECIP_MASK) == USB_RECIP_INTERFACE) { - f = cdev->config->interface[w_index]; + f = cdev->config->interface[intf]; if (f && f->setup) value = f->setup(f, ctrl); else -- cgit v1.2.3 From 0df2479232eeea20c924350a11788c724b8c218d Mon Sep 17 00:00:00 2001 From: Roel Kluin Date: Sat, 17 Jan 2009 16:52:17 +0100 Subject: USB: GADGET: fix !x & y ! has a higher precedence than & Signed-off-by: Roel Kluin Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/imx_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c index cde8fdf15d5..77c5d0a8a06 100644 --- a/drivers/usb/gadget/imx_udc.c +++ b/drivers/usb/gadget/imx_udc.c @@ -297,7 +297,7 @@ void imx_ep_stall(struct imx_ep_struct *imx_ep) for (i = 0; i < 100; i ++) { temp = __raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); - if (!temp & EPSTAT_STALL) + if (!(temp & EPSTAT_STALL)) break; udelay(20); } -- cgit v1.2.3 From 94f341db3dd080851f918da37e84659ef760da26 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Thu, 25 Dec 2008 17:15:02 +0300 Subject: USB: fsl_qe_udc: Fix oops on QE UDC probe failure In case of probing errors the driver kfrees the udc_controller, but it doesn't set the pointer to NULL. When usb_gadget_register_driver is called, it checks for udc_controller != NULL, the check passes and the driver accesses nonexistent memory. Fix this by setting udc_controller to NULL in case of errors. While at it, also implement irq_of_parse_and_map()'s failure and cleanup cases. Signed-off-by: Anton Vorontsov Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/fsl_qe_udc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index d6c5bcd4006..e8f7862acb3 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c @@ -2604,6 +2604,10 @@ static int __devinit qe_udc_probe(struct of_device *ofdev, (unsigned long)udc_controller); /* request irq and disable DR */ udc_controller->usb_irq = irq_of_parse_and_map(np, 0); + if (!udc_controller->usb_irq) { + ret = -EINVAL; + goto err_noirq; + } ret = request_irq(udc_controller->usb_irq, qe_udc_irq, 0, driver_name, udc_controller); @@ -2625,6 +2629,8 @@ static int __devinit qe_udc_probe(struct of_device *ofdev, err6: free_irq(udc_controller->usb_irq, udc_controller); err5: + irq_dispose_mapping(udc_controller->usb_irq); +err_noirq: if (udc_controller->nullmap) { dma_unmap_single(udc_controller->gadget.dev.parent, udc_controller->nullp, 256, @@ -2648,7 +2654,7 @@ err2: iounmap(udc_controller->usb_regs); err1: kfree(udc_controller); - + udc_controller = NULL; return ret; } @@ -2710,6 +2716,7 @@ static int __devexit qe_udc_remove(struct of_device *ofdev) kfree(ep->txframe); free_irq(udc_controller->usb_irq, udc_controller); + irq_dispose_mapping(udc_controller->usb_irq); tasklet_kill(&udc_controller->rx_tasklet); -- cgit v1.2.3 From a30551db66afa1b53a4fa7ceadddb7122bdcf491 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Thu, 25 Dec 2008 17:15:05 +0300 Subject: USB: fsl_qe_udc: Fix recursive locking bug in ch9getstatus() The call chain is this: qe_udc_irq() <- grabs the udc->lock spinlock rx_irq() qe_ep0_rx() ep0_setup_handle() setup_received_handle() ch9getstatus() qe_ep_queue() <- tries to grab the udc->lock again It seems unsafe to temporarily drop the lock in the ch9getstatus(), so to fix that bug the lock-less __qe_ep_queue() function implemented and used by the ch9getstatus(). Signed-off-by: Anton Vorontsov Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/fsl_qe_udc.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index e8f7862acb3..064582fb6a8 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c @@ -1681,14 +1681,11 @@ static void qe_free_request(struct usb_ep *_ep, struct usb_request *_req) kfree(req); } -/* queues (submits) an I/O request to an endpoint */ -static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req, - gfp_t gfp_flags) +static int __qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req) { struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); struct qe_req *req = container_of(_req, struct qe_req, req); struct qe_udc *udc; - unsigned long flags; int reval; udc = ep->udc; @@ -1732,7 +1729,7 @@ static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req, list_add_tail(&req->queue, &ep->queue); dev_vdbg(udc->dev, "gadget have request in %s! %d\n", ep->name, req->req.length); - spin_lock_irqsave(&udc->lock, flags); + /* push the request to device */ if (ep_is_in(ep)) reval = ep_req_send(ep, req); @@ -1748,11 +1745,24 @@ static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req, if (ep->dir == USB_DIR_OUT) reval = ep_req_receive(ep, req); - spin_unlock_irqrestore(&udc->lock, flags); - return 0; } +/* queues (submits) an I/O request to an endpoint */ +static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req, + gfp_t gfp_flags) +{ + struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); + struct qe_udc *udc = ep->udc; + unsigned long flags; + int ret; + + spin_lock_irqsave(&udc->lock, flags); + ret = __qe_ep_queue(_ep, _req); + spin_unlock_irqrestore(&udc->lock, flags); + return ret; +} + /* dequeues (cancels, unlinks) an I/O request from an endpoint */ static int qe_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) { @@ -2008,7 +2018,7 @@ static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, udc->ep0_dir = USB_DIR_IN; /* data phase */ - status = qe_ep_queue(&ep->ep, &req->req, GFP_ATOMIC); + status = __qe_ep_queue(&ep->ep, &req->req); if (status == 0) return; -- cgit v1.2.3 From 2247818a329687f30d1e5c3a62efc33d07c47522 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Thu, 25 Dec 2008 17:15:07 +0300 Subject: USB: fsl_qe_udc: Fix QE USB controller initialization qe_udc_reg_init() leaves the USB controller enabled before muram memory initialized. Sometimes the uninitialized muram memory confuses the controller, and it start sending the busy interrupts. Fix this by disabling the controller, it will be enabled later by the gadget driver, at bind time. Signed-off-by: Anton Vorontsov Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/fsl_qe_udc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index 064582fb6a8..1319f8f7acb 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c @@ -2452,8 +2452,12 @@ static int __devinit qe_udc_reg_init(struct qe_udc *udc) struct usb_ctlr __iomem *qe_usbregs; qe_usbregs = udc->usb_regs; - /* Init the usb register */ + /* Spec says that we must enable the USB controller to change mode. */ out_8(&qe_usbregs->usb_usmod, 0x01); + /* Mode changed, now disable it, since muram isn't initialized yet. */ + out_8(&qe_usbregs->usb_usmod, 0x00); + + /* Initialize the rest. */ out_be16(&qe_usbregs->usb_usbmr, 0); out_8(&qe_usbregs->usb_uscom, 0); out_be16(&qe_usbregs->usb_usber, USBER_ALL_CLEAR); -- cgit v1.2.3 From ef84e4055f3561495c4c0e0dfb0b9f4a6e20479d Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Thu, 25 Dec 2008 17:15:09 +0300 Subject: USB: fsl_qe_udc: Fix disconnects reporting during bus reset Freescale QE UDC controllers can't report the "port change" states, so the only way to handle disconnects is to process bus reset interrupts. The bus reset can take some time, that is, few irqs. Gadgets may print the disconnection events, and this causes few repetitive messages in the kernel log. This patch fixes the issue by using the usb_state machine, if the usb controller has been already reset, just quit the reset irq early. Signed-off-by: Anton Vorontsov Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/fsl_qe_udc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index 1319f8f7acb..7a820a3b4ac 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c @@ -2161,6 +2161,9 @@ static int reset_irq(struct qe_udc *udc) { unsigned char i; + if (udc->usb_state == USB_STATE_DEFAULT) + return 0; + qe_usb_disable(); out_8(&udc->usb_regs->usb_usadr, 0); -- cgit v1.2.3 From 82341b3690fce8f70998e3cfb79fbffff0eb7e6b Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Thu, 25 Dec 2008 17:15:11 +0300 Subject: USB: fsl_qe_udc: Fix muram corruption by disabled endpoints Before freeing an endpoint's muram memory, we should stop all activity of the endpoint, otherwise the QE UDC controller might do nasty things with the muram memory that isn't belong to that endpoint anymore. The qe_ep_reset() effectively flushes the hardware fifos, finishes all late transaction and thus prevents the corruption. Signed-off-by: Anton Vorontsov Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/fsl_qe_udc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index 7a820a3b4ac..32f415ebd3d 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c @@ -1622,6 +1622,7 @@ static int qe_ep_disable(struct usb_ep *_ep) nuke(ep, -ESHUTDOWN); ep->desc = NULL; ep->stopped = 1; + qe_ep_reset(udc, ep->epnum); spin_unlock_irqrestore(&udc->lock, flags); cpm_muram_free(cpm_muram_offset(ep->rxbase)); -- cgit v1.2.3 From af3ddbd76304f9f602c970f9b09a0c9d8cf8336c Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Thu, 25 Dec 2008 17:15:14 +0300 Subject: USB: fsl_qe_udc: Fix stalled TX requests bug While disabling an endpoint the driver nuking any pending requests, thus completing them with -ESHUTDOWN status. But the driver doesn't clear the tx_req, which means that a next TX request (after ep_enable), might get stalled, since the driver won't queue the new reqests. This patch fixes a bug I'm observing with ethernet gadget while playing with ifconfig usb0 up/down (the up/down sequence disables and enables `in' and `out' endpoints). Signed-off-by: Anton Vorontsov Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/fsl_qe_udc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index 32f415ebd3d..d701bf4698d 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c @@ -1622,6 +1622,7 @@ static int qe_ep_disable(struct usb_ep *_ep) nuke(ep, -ESHUTDOWN); ep->desc = NULL; ep->stopped = 1; + ep->tx_req = NULL; qe_ep_reset(udc, ep->epnum); spin_unlock_irqrestore(&udc->lock, flags); -- cgit v1.2.3 From 35c26c2cf6a6a2d1c48add732d8ba002bd90784c Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Sat, 14 Feb 2009 22:56:56 -0800 Subject: rndis: remove private wrapper of __constant_cpu_to_le32 Use cpu_to_le32 directly as it handles constant folding now, replace direct uses of __constant_cpu_to_{endian} as well. Signed-off-by: Harvey Harrison Acked-by: David Brownell Signed-off-by: David S. Miller --- drivers/usb/gadget/rndis.c | 92 +++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index 8c26f5ea2b8..d2860a82368 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c @@ -63,7 +63,7 @@ MODULE_PARM_DESC (rndis_debug, "enable debugging"); static rndis_params rndis_per_dev_params [RNDIS_MAX_CONFIGS]; /* Driver Version */ -static const __le32 rndis_driver_version = __constant_cpu_to_le32 (1); +static const __le32 rndis_driver_version = cpu_to_le32 (1); /* Function Prototypes */ static rndis_resp_t *rndis_add_response (int configNr, u32 length); @@ -190,7 +190,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* response goes here, right after the header */ outbuf = (__le32 *) &resp[1]; - resp->InformationBufferOffset = __constant_cpu_to_le32 (16); + resp->InformationBufferOffset = cpu_to_le32 (16); net = rndis_per_dev_params[configNr].dev; if (net->get_stats) @@ -221,7 +221,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, * reddite ergo quae sunt Caesaris Caesari * et quae sunt Dei Deo! */ - *outbuf = __constant_cpu_to_le32 (0); + *outbuf = cpu_to_le32 (0); retval = 0; break; @@ -256,7 +256,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__); if (rndis_per_dev_params [configNr].media_state == NDIS_MEDIA_STATE_DISCONNECTED) - *outbuf = __constant_cpu_to_le32 (0); + *outbuf = cpu_to_le32 (0); else *outbuf = cpu_to_le32 ( rndis_per_dev_params [configNr].speed); @@ -317,7 +317,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_GEN_MAXIMUM_TOTAL_SIZE: pr_debug("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__); - *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); + *outbuf = cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); retval = 0; break; @@ -332,7 +332,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, case OID_GEN_PHYSICAL_MEDIUM: pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); - *outbuf = __constant_cpu_to_le32 (0); + *outbuf = cpu_to_le32 (0); retval = 0; break; @@ -342,7 +342,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, */ case OID_GEN_MAC_OPTIONS: /* from WinME */ pr_debug("%s: OID_GEN_MAC_OPTIONS\n", __func__); - *outbuf = __constant_cpu_to_le32( + *outbuf = cpu_to_le32( NDIS_MAC_OPTION_RECEIVE_SERIALIZED | NDIS_MAC_OPTION_FULL_DUPLEX); retval = 0; @@ -431,7 +431,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, case OID_802_3_MULTICAST_LIST: pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__); /* Multicast base address only */ - *outbuf = __constant_cpu_to_le32 (0xE0000000); + *outbuf = cpu_to_le32 (0xE0000000); retval = 0; break; @@ -439,7 +439,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, case OID_802_3_MAXIMUM_LIST_SIZE: pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); /* Multicast base address only */ - *outbuf = __constant_cpu_to_le32 (1); + *outbuf = cpu_to_le32 (1); retval = 0; break; @@ -461,14 +461,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, /* mandatory */ case OID_802_3_XMIT_ONE_COLLISION: pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); - *outbuf = __constant_cpu_to_le32 (0); + *outbuf = cpu_to_le32 (0); retval = 0; break; /* mandatory */ case OID_802_3_XMIT_MORE_COLLISIONS: pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); - *outbuf = __constant_cpu_to_le32 (0); + *outbuf = cpu_to_le32 (0); retval = 0; break; @@ -572,24 +572,24 @@ static int rndis_init_response (int configNr, rndis_init_msg_type *buf) return -ENOMEM; resp = (rndis_init_cmplt_type *) r->buf; - resp->MessageType = __constant_cpu_to_le32 ( + resp->MessageType = cpu_to_le32 ( REMOTE_NDIS_INITIALIZE_CMPLT); - resp->MessageLength = __constant_cpu_to_le32 (52); + resp->MessageLength = cpu_to_le32 (52); resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ - resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); - resp->MajorVersion = __constant_cpu_to_le32 (RNDIS_MAJOR_VERSION); - resp->MinorVersion = __constant_cpu_to_le32 (RNDIS_MINOR_VERSION); - resp->DeviceFlags = __constant_cpu_to_le32 (RNDIS_DF_CONNECTIONLESS); - resp->Medium = __constant_cpu_to_le32 (RNDIS_MEDIUM_802_3); - resp->MaxPacketsPerTransfer = __constant_cpu_to_le32 (1); + resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); + resp->MajorVersion = cpu_to_le32 (RNDIS_MAJOR_VERSION); + resp->MinorVersion = cpu_to_le32 (RNDIS_MINOR_VERSION); + resp->DeviceFlags = cpu_to_le32 (RNDIS_DF_CONNECTIONLESS); + resp->Medium = cpu_to_le32 (RNDIS_MEDIUM_802_3); + resp->MaxPacketsPerTransfer = cpu_to_le32 (1); resp->MaxTransferSize = cpu_to_le32 ( params->dev->mtu + sizeof (struct ethhdr) + sizeof (struct rndis_packet_msg_type) + 22); - resp->PacketAlignmentFactor = __constant_cpu_to_le32 (0); - resp->AFListOffset = __constant_cpu_to_le32 (0); - resp->AFListSize = __constant_cpu_to_le32 (0); + resp->PacketAlignmentFactor = cpu_to_le32 (0); + resp->AFListOffset = cpu_to_le32 (0); + resp->AFListSize = cpu_to_le32 (0); params->resp_avail(params->v); return 0; @@ -617,7 +617,7 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf) return -ENOMEM; resp = (rndis_query_cmplt_type *) r->buf; - resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_QUERY_CMPLT); + resp->MessageType = cpu_to_le32 (REMOTE_NDIS_QUERY_CMPLT); resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ if (gen_ndis_query_resp (configNr, le32_to_cpu (buf->OID), @@ -626,13 +626,13 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf) le32_to_cpu(buf->InformationBufferLength), r)) { /* OID not supported */ - resp->Status = __constant_cpu_to_le32 ( + resp->Status = cpu_to_le32 ( RNDIS_STATUS_NOT_SUPPORTED); - resp->MessageLength = __constant_cpu_to_le32 (sizeof *resp); - resp->InformationBufferLength = __constant_cpu_to_le32 (0); - resp->InformationBufferOffset = __constant_cpu_to_le32 (0); + resp->MessageLength = cpu_to_le32 (sizeof *resp); + resp->InformationBufferLength = cpu_to_le32 (0); + resp->InformationBufferOffset = cpu_to_le32 (0); } else - resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); + resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); params->resp_avail(params->v); return 0; @@ -665,14 +665,14 @@ static int rndis_set_response (int configNr, rndis_set_msg_type *buf) pr_debug("\n"); #endif - resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_SET_CMPLT); - resp->MessageLength = __constant_cpu_to_le32 (16); + resp->MessageType = cpu_to_le32 (REMOTE_NDIS_SET_CMPLT); + resp->MessageLength = cpu_to_le32 (16); resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ if (gen_ndis_set_resp (configNr, le32_to_cpu (buf->OID), ((u8 *) buf) + 8 + BufOffset, BufLength, r)) - resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_NOT_SUPPORTED); + resp->Status = cpu_to_le32 (RNDIS_STATUS_NOT_SUPPORTED); else - resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); + resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); params->resp_avail(params->v); return 0; @@ -689,11 +689,11 @@ static int rndis_reset_response (int configNr, rndis_reset_msg_type *buf) return -ENOMEM; resp = (rndis_reset_cmplt_type *) r->buf; - resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_RESET_CMPLT); - resp->MessageLength = __constant_cpu_to_le32 (16); - resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); + resp->MessageType = cpu_to_le32 (REMOTE_NDIS_RESET_CMPLT); + resp->MessageLength = cpu_to_le32 (16); + resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); /* resent information */ - resp->AddressingReset = __constant_cpu_to_le32 (1); + resp->AddressingReset = cpu_to_le32 (1); params->resp_avail(params->v); return 0; @@ -713,11 +713,11 @@ static int rndis_keepalive_response (int configNr, return -ENOMEM; resp = (rndis_keepalive_cmplt_type *) r->buf; - resp->MessageType = __constant_cpu_to_le32 ( + resp->MessageType = cpu_to_le32 ( REMOTE_NDIS_KEEPALIVE_CMPLT); - resp->MessageLength = __constant_cpu_to_le32 (16); + resp->MessageLength = cpu_to_le32 (16); resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ - resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); + resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); params->resp_avail(params->v); return 0; @@ -742,12 +742,12 @@ static int rndis_indicate_status_msg (int configNr, u32 status) return -ENOMEM; resp = (rndis_indicate_status_msg_type *) r->buf; - resp->MessageType = __constant_cpu_to_le32 ( + resp->MessageType = cpu_to_le32 ( REMOTE_NDIS_INDICATE_STATUS_MSG); - resp->MessageLength = __constant_cpu_to_le32 (20); + resp->MessageLength = cpu_to_le32 (20); resp->Status = cpu_to_le32 (status); - resp->StatusBufferLength = __constant_cpu_to_le32 (0); - resp->StatusBufferOffset = __constant_cpu_to_le32 (0); + resp->StatusBufferLength = cpu_to_le32 (0); + resp->StatusBufferOffset = cpu_to_le32 (0); params->resp_avail(params->v); return 0; @@ -963,9 +963,9 @@ void rndis_add_hdr (struct sk_buff *skb) return; header = (void *) skb_push (skb, sizeof *header); memset (header, 0, sizeof *header); - header->MessageType = __constant_cpu_to_le32(REMOTE_NDIS_PACKET_MSG); + header->MessageType = cpu_to_le32(REMOTE_NDIS_PACKET_MSG); header->MessageLength = cpu_to_le32(skb->len); - header->DataOffset = __constant_cpu_to_le32 (36); + header->DataOffset = cpu_to_le32 (36); header->DataLength = cpu_to_le32(skb->len - sizeof *header); } @@ -1029,7 +1029,7 @@ int rndis_rm_hdr(struct sk_buff *skb) __le32 *tmp = (void *) skb->data; /* MessageType, MessageLength */ - if (__constant_cpu_to_le32(REMOTE_NDIS_PACKET_MSG) + if (cpu_to_le32(REMOTE_NDIS_PACKET_MSG) != get_unaligned(tmp++)) return -EINVAL; tmp++; -- cgit v1.2.3 From 22eb36f49e24e922ca6594a99157a3fcb92d3824 Mon Sep 17 00:00:00 2001 From: Roel Kluin Date: Thu, 19 Feb 2009 11:57:46 +0100 Subject: [ARM] 5403/1: pxa25x_ep_fifo_flush() *ep->reg_udccs always set to 0 *ep->reg_udccs is always set to 0. Signed-off-by: Roel Kluin Acked-by: Eric Miao Signed-off-by: Russell King --- drivers/usb/gadget/pxa25x_udc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index 9b36205c575..0ce4e281984 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c @@ -904,8 +904,8 @@ static void pxa25x_ep_fifo_flush(struct usb_ep *_ep) /* most IN status is the same, but ISO can't stall */ *ep->reg_udccs = UDCCS_BI_TPC|UDCCS_BI_FTF|UDCCS_BI_TUR - | (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC) - ? 0 : UDCCS_BI_SST; + | (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC + ? 0 : UDCCS_BI_SST); } -- cgit v1.2.3 From 9a6e184c804b33a2c2ea974efcd3c9798d30cb39 Mon Sep 17 00:00:00 2001 From: Li Yang Date: Fri, 13 Feb 2009 16:14:39 +0800 Subject: USB: fsl_usb2_udc: fix potential queue head corruption Clear next TD field and status field in queue head initialization code to prevent unpredictable result caused by residue of usb reset. Signed-off-by: Li Yang Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/fsl_usb2_udc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c index f3c6703cffd..d8d9a52a44b 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.c +++ b/drivers/usb/gadget/fsl_usb2_udc.c @@ -404,7 +404,10 @@ static void struct_ep_qh_setup(struct fsl_udc *udc, unsigned char ep_num, } if (zlt) tmp |= EP_QUEUE_HEAD_ZLT_SEL; + p_QH->max_pkt_length = cpu_to_le32(tmp); + p_QH->next_dtd_ptr = 1; + p_QH->size_ioc_int_sts = 0; return; } -- cgit v1.2.3 From 29a46bf6f4f57df22f91573bb482a24237741347 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Tue, 10 Feb 2009 19:01:52 +0200 Subject: usb: gadget: obex: select correct ep descriptors We where selecting wrong ep descriptors causing some troubles while sending files over obex interface. The problem was a typo while usb_find_endpoint() was being called for HS endpoints. Acked-by: David Brownell Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/f_obex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c index 80c2e7e9622..38aa896cc5d 100644 --- a/drivers/usb/gadget/f_obex.c +++ b/drivers/usb/gadget/f_obex.c @@ -366,9 +366,9 @@ obex_bind(struct usb_configuration *c, struct usb_function *f) f->hs_descriptors = usb_copy_descriptors(hs_function); obex->hs.obex_in = usb_find_endpoint(hs_function, - f->descriptors, &obex_hs_ep_in_desc); + f->hs_descriptors, &obex_hs_ep_in_desc); obex->hs.obex_out = usb_find_endpoint(hs_function, - f->descriptors, &obex_hs_ep_out_desc); + f->hs_descriptors, &obex_hs_ep_out_desc); } /* Avoid letting this gadget enumerate until the userspace -- cgit v1.2.3 From ce459ec1d278b19be8e0719dbfd47dd1d6687bfb Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 24 Feb 2009 16:19:47 -0500 Subject: USB: g_file_storage: automatically disable stalls under Atmel This patch (as1220) automatically disables stalls when g_file_storage finds itself running with an Atmel device controller, because the Atmel hardware/driver isn't capable of halting bulk endpoints correctly. Reported-by: Stanislaw Gruszka Signed-off-by: Alan Stern Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/file_storage.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index b10fa31cc91..1ab9dac7e12 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c @@ -3879,7 +3879,11 @@ static int __init check_parameters(struct fsg_dev *fsg) mod_data.protocol_type = USB_SC_SCSI; mod_data.protocol_name = "Transparent SCSI"; - if (gadget_is_sh(fsg->gadget)) + /* Some peripheral controllers are known not to be able to + * halt bulk endpoints correctly. If one of them is present, + * disable stalls. + */ + if (gadget_is_sh(fsg->gadget) || gadget_is_at91(fsg->gadget)) mod_data.can_stall = 0; if (mod_data.release == 0xffff) { // Parameter wasn't set -- cgit v1.2.3 From 54b9ed35aea88b05d711884a3c2dc21bba047bd8 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 11 Feb 2009 22:31:12 -0800 Subject: USB: gadget: fix build error in omap_apollon_2420_defconfig In apollon case, it only used udc, so udc configuration should select USB_OTG_UTILS also. Signed-off-by: Kyungmin Park Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 3219d137340..e55fef52a5d 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -191,6 +191,7 @@ config USB_GADGET_OMAP boolean "OMAP USB Device Controller" depends on ARCH_OMAP select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_H4_OTG + select USB_OTG_UTILS if ARCH_OMAP help Many Texas Instruments OMAP processors have flexible full speed USB device controllers, with support for up to 30 -- cgit v1.2.3 From db1dd4d376134eba0e08af523b61cc566a4ea1cd Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Fri, 6 Feb 2009 15:25:24 -0700 Subject: Use f_lock to protect f_flags Traditionally, changes to struct file->f_flags have been done under BKL protection, or with no protection at all. This patch causes all f_flags changes after file open/creation time to be done under protection of f_lock. This allows the removal of some BKL usage and fixes a number of longstanding (if microscopic) races. Reviewed-by: Christoph Hellwig Cc: Al Viro Signed-off-by: Jonathan Corbet --- drivers/usb/gadget/file_storage.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 1ab9dac7e12..33bb76cef33 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c @@ -1711,7 +1711,9 @@ static int do_write(struct fsg_dev *fsg) curlun->sense_data = SS_WRITE_PROTECTED; return -EINVAL; } + spin_lock(&curlun->filp->f_lock); curlun->filp->f_flags &= ~O_SYNC; // Default is not to wait + spin_unlock(&curlun->filp->f_lock); /* Get the starting Logical Block Address and check that it's * not too big */ @@ -1728,8 +1730,11 @@ static int do_write(struct fsg_dev *fsg) curlun->sense_data = SS_INVALID_FIELD_IN_CDB; return -EINVAL; } - if (fsg->cmnd[1] & 0x08) // FUA + if (fsg->cmnd[1] & 0x08) { // FUA + spin_lock(&curlun->filp->f_lock); curlun->filp->f_flags |= O_SYNC; + spin_unlock(&curlun->filp->f_lock); + } } if (lba >= curlun->num_sectors) { curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; -- cgit v1.2.3 From b5556498b60a237cca173dfd60109f3504ce25ca Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 20 Mar 2009 19:35:59 +0000 Subject: usbnet: convert rndis driver to use dev_get_stats dev_get_stats() handles all issues with net_device_ops Signed-off-by: Stephen Hemminger Acked-by: David Brownell Signed-off-by: David S. Miller --- drivers/usb/gadget/rndis.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index d2860a82368..2b4660e08c4 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c @@ -170,7 +170,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, int i, count; rndis_query_cmplt_type *resp; struct net_device *net; - struct net_device_stats *stats; + const struct net_device_stats *stats; if (!r) return -ENOMEM; resp = (rndis_query_cmplt_type *) r->buf; @@ -193,10 +193,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, resp->InformationBufferOffset = cpu_to_le32 (16); net = rndis_per_dev_params[configNr].dev; - if (net->get_stats) - stats = net->get_stats(net); - else - stats = NULL; + stats = dev_get_stats(net); switch (OID) { -- cgit v1.2.3 From 090b90118207e786d2990310d063fda5d52cce6e Mon Sep 17 00:00:00 2001 From: David Brownell Date: Fri, 20 Mar 2009 01:08:20 -0700 Subject: USB: gadget: fix rndis regression Restore some code that was wrongly dropped from the RNDIS driver, and caused interop problems observed with OpenMoko. The issue is with hardware which needs help conforming to part of the USB 2.0 spec (section 8.5.3.2); some can automagically send a ZLP in response to an unexpected IN, but not all chips will do that. We don't need to check the packet length ourselves the way earlier code did, since the UDC must already check it. But we do need to tell the UDC when it must force a short packet termination of the data stage. (Based on a patch from Aric D. Blumer ) Signed-off-by: David Brownell Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/f_rndis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c index 3a8bb53fc47..fd7b356f902 100644 --- a/drivers/usb/gadget/f_rndis.c +++ b/drivers/usb/gadget/f_rndis.c @@ -437,7 +437,7 @@ invalid: DBG(cdev, "rndis req%02x.%02x v%04x i%04x l%d\n", ctrl->bRequestType, ctrl->bRequest, w_value, w_index, w_length); - req->zero = 0; + req->zero = (value < w_length); req->length = value; value = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC); if (value < 0) -- cgit v1.2.3 From eb50702539f9be3765127d927d3e9ccfeb65f26e Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Sat, 24 Jan 2009 23:55:34 -0800 Subject: USB: pxa27x_udc: factor pullup code to prepare otg transceiver Prepare pxa27x_udc to handle usb D+ pullup properly : it should connect the pullup resistor and disconnect it only if no external transceiver is handling it. [ dbrownell@users.sourceforge.net: kerneldoc and gpio fixes ] Signed-off-by: Robert Jarzmik Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/pxa27x_udc.c | 140 +++++++++++++++++++++++++++++++++++++--- drivers/usb/gadget/pxa27x_udc.h | 6 ++ 2 files changed, 138 insertions(+), 8 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index 990f40f988d..f8145590944 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -1471,6 +1472,32 @@ static struct usb_ep_ops pxa_ep_ops = { .fifo_flush = pxa_ep_fifo_flush, }; +/** + * dplus_pullup - Connect or disconnect pullup resistor to D+ pin + * @udc: udc device + * @on: 0 if disconnect pullup resistor, 1 otherwise + * Context: any + * + * Handle D+ pullup resistor, make the device visible to the usb bus, and + * declare it as a full speed usb device + */ +static void dplus_pullup(struct pxa_udc *udc, int on) +{ + if (on) { + if (gpio_is_valid(udc->mach->gpio_pullup)) + gpio_set_value(udc->mach->gpio_pullup, + !udc->mach->gpio_pullup_inverted); + if (udc->mach->udc_command) + udc->mach->udc_command(PXA2XX_UDC_CMD_CONNECT); + } else { + if (gpio_is_valid(udc->mach->gpio_pullup)) + gpio_set_value(udc->mach->gpio_pullup, + udc->mach->gpio_pullup_inverted); + if (udc->mach->udc_command) + udc->mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); + } + udc->pullup_on = on; +} /** * pxa_udc_get_frame - Returns usb frame number @@ -1500,21 +1527,91 @@ static int pxa_udc_wakeup(struct usb_gadget *_gadget) return 0; } +static void udc_enable(struct pxa_udc *udc); +static void udc_disable(struct pxa_udc *udc); + +/** + * should_enable_udc - Tells if UDC should be enabled + * @udc: udc device + * Context: any + * + * The UDC should be enabled if : + * - the pullup resistor is connected + * - and a gadget driver is bound + * + * Returns 1 if UDC should be enabled, 0 otherwise + */ +static int should_enable_udc(struct pxa_udc *udc) +{ + int put_on; + + put_on = ((udc->pullup_on) && (udc->driver)); + return put_on; +} + +/** + * should_disable_udc - Tells if UDC should be disabled + * @udc: udc device + * Context: any + * + * The UDC should be disabled if : + * - the pullup resistor is not connected + * - or no gadget driver is bound + * + * Returns 1 if UDC should be disabled + */ +static int should_disable_udc(struct pxa_udc *udc) +{ + int put_off; + + put_off = ((!udc->pullup_on) || (!udc->driver)); + return put_off; +} + +/** + * pxa_udc_pullup - Offer manual D+ pullup control + * @_gadget: usb gadget using the control + * @is_active: 0 if disconnect, else connect D+ pullup resistor + * Context: !in_interrupt() + * + * Returns 0 if OK, -EOPNOTSUPP if udc driver doesn't handle D+ pullup + */ +static int pxa_udc_pullup(struct usb_gadget *_gadget, int is_active) +{ + struct pxa_udc *udc = to_gadget_udc(_gadget); + + if (!gpio_is_valid(udc->mach->gpio_pullup) && !udc->mach->udc_command) + return -EOPNOTSUPP; + + dplus_pullup(udc, is_active); + + if (should_enable_udc(udc)) + udc_enable(udc); + if (should_disable_udc(udc)) + udc_disable(udc); + return 0; +} + static const struct usb_gadget_ops pxa_udc_ops = { .get_frame = pxa_udc_get_frame, .wakeup = pxa_udc_wakeup, + .pullup = pxa_udc_pullup, /* current versions must always be self-powered */ }; /** * udc_disable - disable udc device controller * @udc: udc device + * Context: any * * Disables the udc device : disables clocks, udc interrupts, control endpoint * interrupts. */ static void udc_disable(struct pxa_udc *udc) { + if (!udc->enabled) + return; + udc_writel(udc, UDCICR0, 0); udc_writel(udc, UDCICR1, 0); @@ -1523,8 +1620,8 @@ static void udc_disable(struct pxa_udc *udc) ep0_idle(udc); udc->gadget.speed = USB_SPEED_UNKNOWN; - if (udc->mach->udc_command) - udc->mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); + + udc->enabled = 0; } /** @@ -1570,6 +1667,9 @@ static __init void udc_init_data(struct pxa_udc *dev) */ static void udc_enable(struct pxa_udc *udc) { + if (udc->enabled) + return; + udc_writel(udc, UDCICR0, 0); udc_writel(udc, UDCICR1, 0); udc_clear_mask_UDCCR(udc, UDCCR_UDE); @@ -1598,9 +1698,7 @@ static void udc_enable(struct pxa_udc *udc) /* enable ep0 irqs */ pio_irq_enable(&udc->pxa_ep[0]); - dev_info(udc->dev, "UDC connecting\n"); - if (udc->mach->udc_command) - udc->mach->udc_command(PXA2XX_UDC_CMD_CONNECT); + udc->enabled = 1; } /** @@ -1612,6 +1710,9 @@ static void udc_enable(struct pxa_udc *udc) * usb traffic follows until a disconnect is reported. Then a host may connect * again, or the driver might get unbound. * + * Note that the udc is not automatically enabled. Check function + * should_enable_udc(). + * * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise */ int usb_gadget_register_driver(struct usb_gadget_driver *driver) @@ -1630,6 +1731,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) /* first hook up the driver ... */ udc->driver = driver; udc->gadget.dev.driver = &driver->driver; + dplus_pullup(udc, 1); retval = device_add(&udc->gadget.dev); if (retval) { @@ -1645,7 +1747,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) dev_dbg(udc->dev, "registered gadget driver '%s'\n", driver->driver.name); - udc_enable(udc); + if (should_enable_udc(udc)) + udc_enable(udc); return 0; bind_fail: @@ -1699,6 +1802,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) stop_activity(udc, driver); udc_disable(udc); + dplus_pullup(udc, 0); driver->unbind(&udc->gadget); udc->driver = NULL; @@ -2212,7 +2316,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev) { struct resource *regs; struct pxa_udc *udc = &memory; - int retval; + int retval = 0, gpio; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!regs) @@ -2224,6 +2328,19 @@ static int __init pxa_udc_probe(struct platform_device *pdev) udc->dev = &pdev->dev; udc->mach = pdev->dev.platform_data; + gpio = udc->mach->gpio_pullup; + if (gpio_is_valid(gpio)) { + retval = gpio_request(gpio, "USB D+ pullup"); + if (retval == 0) + gpio_direction_output(gpio, + udc->mach->gpio_pullup_inverted); + } + if (retval) { + dev_err(&pdev->dev, "Couldn't request gpio %d : %d\n", + gpio, retval); + return retval; + } + udc->clk = clk_get(&pdev->dev, NULL); if (IS_ERR(udc->clk)) { retval = PTR_ERR(udc->clk); @@ -2273,10 +2390,13 @@ err_clk: static int __exit pxa_udc_remove(struct platform_device *_dev) { struct pxa_udc *udc = platform_get_drvdata(_dev); + int gpio = udc->mach->gpio_pullup; usb_gadget_unregister_driver(udc->driver); free_irq(udc->irq, udc); pxa_cleanup_debugfs(udc); + if (gpio_is_valid(gpio)) + gpio_free(gpio); platform_set_drvdata(_dev, NULL); the_controller = NULL; @@ -2319,6 +2439,8 @@ static int pxa_udc_suspend(struct platform_device *_dev, pm_message_t state) } udc_disable(udc); + udc->pullup_resume = udc->pullup_on; + dplus_pullup(udc, 0); return 0; } @@ -2346,7 +2468,9 @@ static int pxa_udc_resume(struct platform_device *_dev) ep->udccsr_value, ep->udccr_value); } - udc_enable(udc); + dplus_pullup(udc, udc->pullup_resume); + if (should_enable_udc(udc)) + udc_enable(udc); /* * We do not handle OTG yet. * diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h index 1d1b7936ee1..6f5234dff8a 100644 --- a/drivers/usb/gadget/pxa27x_udc.h +++ b/drivers/usb/gadget/pxa27x_udc.h @@ -425,6 +425,9 @@ struct udc_stats { * @stats: statistics on udc usage * @udc_usb_ep: array of usb endpoints offered by the gadget * @pxa_ep: array of pxa available endpoints + * @enabled: UDC was enabled by a previous udc_enable() + * @pullup_on: if pullup resistor connected to D+ pin + * @pullup_resume: if pullup resistor should be connected to D+ pin on resume * @config: UDC active configuration * @last_interface: UDC interface of the last SET_INTERFACE host request * @last_alternate: UDC altsetting of the last SET_INTERFACE host request @@ -450,6 +453,9 @@ struct pxa_udc { struct udc_usb_ep udc_usb_ep[NR_USB_ENDPOINTS]; struct pxa_ep pxa_ep[NR_PXA_ENDPOINTS]; + unsigned enabled:1; + unsigned pullup_on:1; + unsigned pullup_resume:1; unsigned config:2; unsigned last_interface:3; unsigned last_alternate:3; -- cgit v1.2.3 From b799a7eb68082af620b7e37b6f41c98802e831f6 Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Sat, 24 Jan 2009 23:56:42 -0800 Subject: USB: pxa27x_udc: add vbus session handling On vbus_session() call, optionally activate D+ pullup resistor and enable the udc, or deactivate D+ pullup resistor and disable the udc. It is intentional to not handle any VBus sense related irq. An external transceiver driver (like gpio_vbus) should catch VBus sense signal, and call usb_gadget_vbus_connect() or usb_gadget_vbus_disconnect(). Signed-off-by: Robert Jarzmik Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/pxa27x_udc.c | 33 +++++++++++++++++++++++++++++++++ drivers/usb/gadget/pxa27x_udc.h | 1 + 2 files changed, 34 insertions(+) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index f8145590944..0c9307118b5 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c @@ -1536,8 +1536,10 @@ static void udc_disable(struct pxa_udc *udc); * Context: any * * The UDC should be enabled if : + * - the pullup resistor is connected * - and a gadget driver is bound + * - and vbus is sensed (or no vbus sense is available) * * Returns 1 if UDC should be enabled, 0 otherwise */ @@ -1546,6 +1548,7 @@ static int should_enable_udc(struct pxa_udc *udc) int put_on; put_on = ((udc->pullup_on) && (udc->driver)); + put_on &= ((udc->vbus_sensed) || (!udc->transceiver)); return put_on; } @@ -1557,6 +1560,7 @@ static int should_enable_udc(struct pxa_udc *udc) * The UDC should be disabled if : * - the pullup resistor is not connected * - or no gadget driver is bound + * - or no vbus is sensed (when vbus sesing is available) * * Returns 1 if UDC should be disabled */ @@ -1565,6 +1569,7 @@ static int should_disable_udc(struct pxa_udc *udc) int put_off; put_off = ((!udc->pullup_on) || (!udc->driver)); + put_off |= ((!udc->vbus_sensed) && (udc->transceiver)); return put_off; } @@ -1592,10 +1597,37 @@ static int pxa_udc_pullup(struct usb_gadget *_gadget, int is_active) return 0; } +static void udc_enable(struct pxa_udc *udc); +static void udc_disable(struct pxa_udc *udc); + +/** + * pxa_udc_vbus_session - Called by external transceiver to enable/disable udc + * @_gadget: usb gadget + * @is_active: 0 if should disable the udc, 1 if should enable + * + * Enables the udc, and optionnaly activates D+ pullup resistor. Or disables the + * udc, and deactivates D+ pullup resistor. + * + * Returns 0 + */ +static int pxa_udc_vbus_session(struct usb_gadget *_gadget, int is_active) +{ + struct pxa_udc *udc = to_gadget_udc(_gadget); + + udc->vbus_sensed = is_active; + if (should_enable_udc(udc)) + udc_enable(udc); + if (should_disable_udc(udc)) + udc_disable(udc); + + return 0; +} + static const struct usb_gadget_ops pxa_udc_ops = { .get_frame = pxa_udc_get_frame, .wakeup = pxa_udc_wakeup, .pullup = pxa_udc_pullup, + .vbus_session = pxa_udc_vbus_session, /* current versions must always be self-powered */ }; @@ -2357,6 +2389,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev) device_initialize(&udc->gadget.dev); udc->gadget.dev.parent = &pdev->dev; udc->gadget.dev.dma_mask = NULL; + udc->vbus_sensed = 0; the_controller = udc; platform_set_drvdata(pdev, udc); diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h index 6f5234dff8a..64741e19920 100644 --- a/drivers/usb/gadget/pxa27x_udc.h +++ b/drivers/usb/gadget/pxa27x_udc.h @@ -456,6 +456,7 @@ struct pxa_udc { unsigned enabled:1; unsigned pullup_on:1; unsigned pullup_resume:1; + unsigned vbus_sensed:1; unsigned config:2; unsigned last_interface:3; unsigned last_alternate:3; -- cgit v1.2.3 From 7fec3c25b773883bd50c4078bcccdd23d3dadeac Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Sat, 24 Jan 2009 23:57:30 -0800 Subject: USB: pxa27x_udc: add otg transceiver support When a transceiver driver is used, no automatic udc enable is done. The transceiver (OTG or not) should : - take care of VBus sensing - call usb_gadget_vbus_connect() - call usb_gadget_vbus_disconnect() The pullup should remain within this driver's management, either by gpio_pullup of udc_command() fields. Signed-off-by: Robert Jarzmik Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/Kconfig | 1 + drivers/usb/gadget/pxa27x_udc.c | 19 ++++++++++++++++++- drivers/usb/gadget/pxa27x_udc.h | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index e55fef52a5d..770b3eaa918 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -254,6 +254,7 @@ config USB_PXA25X_SMALL config USB_GADGET_PXA27X boolean "PXA 27x" depends on ARCH_PXA && PXA27x + select USB_OTG_UTILS help Intel's PXA 27x series XScale ARM v5TE processors include an integrated full speed USB 1.1 device controller. diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index 0c9307118b5..11510472ee0 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c @@ -1779,10 +1779,21 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) dev_dbg(udc->dev, "registered gadget driver '%s'\n", driver->driver.name); + if (udc->transceiver) { + retval = otg_set_peripheral(udc->transceiver, &udc->gadget); + if (retval) { + dev_err(udc->dev, "can't bind to transceiver\n"); + goto transceiver_fail; + } + } + if (should_enable_udc(udc)) udc_enable(udc); return 0; +transceiver_fail: + if (driver->unbind) + driver->unbind(&udc->gadget); bind_fail: device_del(&udc->gadget.dev); add_fail: @@ -1840,9 +1851,11 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) udc->driver = NULL; device_del(&udc->gadget.dev); - dev_info(udc->dev, "unregistered gadget driver '%s'\n", driver->driver.name); + + if (udc->transceiver) + return otg_set_peripheral(udc->transceiver, NULL); return 0; } EXPORT_SYMBOL(usb_gadget_unregister_driver); @@ -2359,6 +2372,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev) udc->dev = &pdev->dev; udc->mach = pdev->dev.platform_data; + udc->transceiver = otg_get_transceiver(); gpio = udc->mach->gpio_pullup; if (gpio_is_valid(gpio)) { @@ -2431,6 +2445,9 @@ static int __exit pxa_udc_remove(struct platform_device *_dev) if (gpio_is_valid(gpio)) gpio_free(gpio); + otg_put_transceiver(udc->transceiver); + + udc->transceiver = NULL; platform_set_drvdata(_dev, NULL); the_controller = NULL; clk_put(udc->clk); diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h index 64741e19920..db58125331d 100644 --- a/drivers/usb/gadget/pxa27x_udc.h +++ b/drivers/usb/gadget/pxa27x_udc.h @@ -26,6 +26,7 @@ #include #include #include +#include /* * Register definitions @@ -421,6 +422,7 @@ struct udc_stats { * @driver: bound gadget (zero, g_ether, g_file_storage, ...) * @dev: device * @mach: machine info, used to activate specific GPIO + * @transceiver: external transceiver to handle vbus sense and D+ pullup * @ep0state: control endpoint state machine state * @stats: statistics on udc usage * @udc_usb_ep: array of usb endpoints offered by the gadget @@ -446,6 +448,7 @@ struct pxa_udc { struct usb_gadget_driver *driver; struct device *dev; struct pxa2xx_udc_mach_info *mach; + struct otg_transceiver *transceiver; enum ep0_state ep0state; struct udc_stats stats; -- cgit v1.2.3 From ee069fb1185895e725ad942c7a529f947e25166d Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Sat, 24 Jan 2009 23:59:38 -0800 Subject: USB: pxa27x_udc: add vbus_draw callback Add the vbus_draw() callback to inform the transceiver, if it exists, how much current may be drawn. The decision is taken on gadget driver side using the configuration chosen by the host and its bMaxPower field. Some systems can use the host's VBUS supply to augment or recharge a battery. (There's also a default of 100 mA for unconfigured devices, or 8 mA if they're OTG devices.) Signed-off-by: Robert Jarzmik Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/pxa27x_udc.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index 11510472ee0..e50419d0899 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c @@ -1623,12 +1623,34 @@ static int pxa_udc_vbus_session(struct usb_gadget *_gadget, int is_active) return 0; } +/** + * pxa_udc_vbus_draw - Called by gadget driver after SET_CONFIGURATION completed + * @_gadget: usb gadget + * @mA: current drawn + * + * Context: !in_interrupt() + * + * Called after a configuration was chosen by a USB host, to inform how much + * current can be drawn by the device from VBus line. + * + * Returns 0 or -EOPNOTSUPP if no transceiver is handling the udc + */ +static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA) +{ + struct pxa_udc *udc; + + udc = to_gadget_udc(_gadget); + if (udc->transceiver) + return otg_set_power(udc->transceiver, mA); + return -EOPNOTSUPP; +} + static const struct usb_gadget_ops pxa_udc_ops = { .get_frame = pxa_udc_get_frame, .wakeup = pxa_udc_wakeup, .pullup = pxa_udc_pullup, .vbus_session = pxa_udc_vbus_session, - /* current versions must always be self-powered */ + .vbus_draw = pxa_udc_vbus_draw, }; /** -- cgit v1.2.3 From 00185a60c37549531b9eee562d3eba19020875d5 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 21 Dec 2008 16:41:36 +0100 Subject: USB: Remove redundant test in pxa27x_udc and ftdi_sio priv is checked not to be NULL near the beginning of the function and not changed subsequently, making the test redundant. A simplified version of the semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r exists@ local idexpression x; expression E; position p1,p2; @@ if (x@p1 == NULL || ...) { ... when forall return ...; } ... when != \(x=E\|x--\|x++\|--x\|++x\|x-=E\|x+=E\|x|=E\|x&=E\|&x\) ( x@p2 == NULL | x@p2 != NULL ) // another path to the test that is not through p1? @s exists@ local idexpression r.x; position r.p1,r.p2; @@ ... when != x@p1 ( x@p2 == NULL | x@p2 != NULL ) @fix depends on !s@ position r.p1,r.p2; expression x,E; statement S1,S2; @@ ( - if ((x@p2 != NULL) || ...) S1 | - if ((x@p2 == NULL) && ...) S1 | - BUG_ON(x@p2 == NULL); ) // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/pxa27x_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index e50419d0899..91ba1e93947 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c @@ -279,7 +279,7 @@ static void pxa_init_debugfs(struct pxa_udc *udc) goto err_queues; eps = debugfs_create_file("epstate", 0400, root, udc, &eps_dbg_fops); - if (!queues) + if (!eps) goto err_eps; udc->debugfs_root = root; -- cgit v1.2.3 From bcbbbfc169e837f0bf54dd4a6ef0a6494fb14925 Mon Sep 17 00:00:00 2001 From: Huang Weiyi Date: Sun, 11 Jan 2009 17:25:13 +0800 Subject: USB: gadget: remove duplicated #include Removed duplicated #include in drivers/usb/gadget/ci13xxx_udc.c Signed-off-by: Huang Weiyi Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/ci13xxx_udc.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c index bebf911c7e5..0e310b9aa7a 100644 --- a/drivers/usb/gadget/ci13xxx_udc.c +++ b/drivers/usb/gadget/ci13xxx_udc.c @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 8f182e5ddc84a30d7014a753ae359d85b1238e7f Mon Sep 17 00:00:00 2001 From: Darius Augulis Date: Wed, 21 Jan 2009 15:17:25 +0200 Subject: USB: imx_udc: Fix IMX UDC gadget bugs Fix small bugs and add some omptimization in IMX UDC Gadget. Signed-off-by: Darius Augulis Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/imx_udc.c | 33 +++++++++++++++++++-------------- drivers/usb/gadget/imx_udc.h | 2 +- 2 files changed, 20 insertions(+), 15 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c index 77c5d0a8a06..9e3fe306301 100644 --- a/drivers/usb/gadget/imx_udc.c +++ b/drivers/usb/gadget/imx_udc.c @@ -283,7 +283,7 @@ void imx_ep_stall(struct imx_ep_struct *imx_ep) imx_flush(imx_ep); /* Special care for ep0 */ - if (EP_NO(imx_ep)) { + if (!EP_NO(imx_ep)) { temp = __raw_readl(imx_usb->base + USB_CTRL); __raw_writel(temp | CTRL_CMDOVER | CTRL_CMDERROR, imx_usb->base + USB_CTRL); do { } while (__raw_readl(imx_usb->base + USB_CTRL) & CTRL_CMDOVER); @@ -301,7 +301,7 @@ void imx_ep_stall(struct imx_ep_struct *imx_ep) break; udelay(20); } - if (i == 50) + if (i == 100) D_ERR(imx_usb->dev, "<%s> Non finished stall on %s\n", __func__, imx_ep->ep.name); } @@ -539,10 +539,9 @@ static int handle_ep0(struct imx_ep_struct *imx_ep) struct imx_request *req = NULL; int ret = 0; - if (!list_empty(&imx_ep->queue)) + if (!list_empty(&imx_ep->queue)) { req = list_entry(imx_ep->queue.next, struct imx_request, queue); - if (req) { switch (imx_ep->imx_usb->ep0state) { case EP0_IN_DATA_PHASE: /* GET_DESCRIPTOR */ @@ -561,6 +560,10 @@ static int handle_ep0(struct imx_ep_struct *imx_ep) } } + else + D_ERR(imx_ep->imx_usb->dev, "<%s> no request on %s\n", + __func__, imx_ep->ep.name); + return ret; } @@ -759,7 +762,7 @@ static int imx_ep_queue */ if (imx_usb->set_config && !EP_NO(imx_ep)) { imx_usb->set_config = 0; - D_EPX(imx_usb->dev, + D_ERR(imx_usb->dev, "<%s> gadget reply set config\n", __func__); return 0; } @@ -779,8 +782,6 @@ static int imx_ep_queue return -ESHUTDOWN; } - local_irq_save(flags); - /* Debug */ D_REQ(imx_usb->dev, "<%s> ep%d %s request for [%d] bytes\n", __func__, EP_NO(imx_ep), @@ -790,17 +791,18 @@ static int imx_ep_queue if (imx_ep->stopped) { usb_req->status = -ESHUTDOWN; - ret = -ESHUTDOWN; - goto out; + return -ESHUTDOWN; } if (req->in_use) { D_ERR(imx_usb->dev, "<%s> refusing to queue req %p (already queued)\n", __func__, req); - goto out; + return 0; } + local_irq_save(flags); + usb_req->status = -EINPROGRESS; usb_req->actual = 0; @@ -810,7 +812,7 @@ static int imx_ep_queue ret = handle_ep0(imx_ep); else ret = handle_ep(imx_ep); -out: + local_irq_restore(flags); return ret; } @@ -1010,10 +1012,8 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) dump_usb_stat(__func__, imx_usb); } - if (!imx_usb->driver) { - /*imx_udc_disable(imx_usb);*/ + if (!imx_usb->driver) goto end_irq; - } if (intr & INTR_WAKEUP) { if (imx_usb->gadget.speed == USB_SPEED_UNKNOWN @@ -1095,6 +1095,11 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) } if (intr & INTR_SOF) { + /* Copy from Freescale BSP. + We must enable SOF intr and set CMDOVER. + Datasheet don't specifiy this action, but it + is done in Freescale BSP, so just copy it. + */ if (imx_usb->ep0state == EP0_IDLE) { temp = __raw_readl(imx_usb->base + USB_CTRL); __raw_writel(temp | CTRL_CMDOVER, imx_usb->base + USB_CTRL); diff --git a/drivers/usb/gadget/imx_udc.h b/drivers/usb/gadget/imx_udc.h index 850076937d8..d1dfb2d2fa8 100644 --- a/drivers/usb/gadget/imx_udc.h +++ b/drivers/usb/gadget/imx_udc.h @@ -170,7 +170,7 @@ struct imx_udc_struct { /* #define DEBUG_IRQ */ /* #define DEBUG_EPIRQ */ /* #define DEBUG_DUMP */ -#define DEBUG_ERR +/* #define DEBUG_ERR */ #ifdef DEBUG_REQ #define D_REQ(dev, args...) dev_dbg(dev, ## args) -- cgit v1.2.3 From 593bef6c75e11d2edb5396bd9775cf49a4cda659 Mon Sep 17 00:00:00 2001 From: Darius Augulis Date: Wed, 21 Jan 2009 15:17:55 +0200 Subject: USB: imx_udc: Fix IMX UDC gadget code style Fix code style errors in IMX UDC Gadget. Signed-off-by: Darius Augulis Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/imx_udc.c | 59 +++++++++++++++++++++++++++++--------------- drivers/usb/gadget/imx_udc.h | 46 ++++++++++++++++++++++------------ 2 files changed, 69 insertions(+), 36 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c index 9e3fe306301..3ee5bd8bea7 100644 --- a/drivers/usb/gadget/imx_udc.c +++ b/drivers/usb/gadget/imx_udc.c @@ -1,7 +1,7 @@ /* * driver/usb/gadget/imx_udc.c * - * Copyright (C) 2005 Mike Lee(eemike@gmail.com) + * Copyright (C) 2005 Mike Lee * Copyright (C) 2008 Darius Augulis * * This program is free software; you can redistribute it and/or modify @@ -51,7 +51,8 @@ void ep0_chg_stat(const char *label, struct imx_udc_struct *imx_usb, void imx_udc_enable(struct imx_udc_struct *imx_usb) { int temp = __raw_readl(imx_usb->base + USB_CTRL); - __raw_writel(temp | CTRL_FE_ENA | CTRL_AFE_ENA, imx_usb->base + USB_CTRL); + __raw_writel(temp | CTRL_FE_ENA | CTRL_AFE_ENA, + imx_usb->base + USB_CTRL); imx_usb->gadget.speed = USB_SPEED_FULL; } @@ -126,7 +127,8 @@ void imx_udc_config(struct imx_udc_struct *imx_usb) for (j = 0; j < 5; j++) { __raw_writeb(ep_conf[j], imx_usb->base + USB_DDAT); - do {} while (__raw_readl(imx_usb->base + USB_DADR) + do {} while (__raw_readl(imx_usb->base + + USB_DADR) & DADR_BSY); } } @@ -183,7 +185,8 @@ void imx_udc_init_ep(struct imx_udc_struct *imx_usb) temp = (EP_DIR(imx_ep) << 7) | (max << 5) | (imx_ep->bmAttributes << 3); __raw_writel(temp, imx_usb->base + USB_EP_STAT(i)); - __raw_writel(temp | EPSTAT_FLUSH, imx_usb->base + USB_EP_STAT(i)); + __raw_writel(temp | EPSTAT_FLUSH, + imx_usb->base + USB_EP_STAT(i)); D_INI(imx_usb->dev, "<%s> ep%d_stat %08x\n", __func__, i, __raw_readl(imx_usb->base + USB_EP_STAT(i))); } @@ -278,15 +281,18 @@ void imx_ep_stall(struct imx_ep_struct *imx_ep) struct imx_udc_struct *imx_usb = imx_ep->imx_usb; int temp, i; - D_ERR(imx_usb->dev, "<%s> Forced stall on %s\n", __func__, imx_ep->ep.name); + D_ERR(imx_usb->dev, + "<%s> Forced stall on %s\n", __func__, imx_ep->ep.name); imx_flush(imx_ep); /* Special care for ep0 */ if (!EP_NO(imx_ep)) { temp = __raw_readl(imx_usb->base + USB_CTRL); - __raw_writel(temp | CTRL_CMDOVER | CTRL_CMDERROR, imx_usb->base + USB_CTRL); - do { } while (__raw_readl(imx_usb->base + USB_CTRL) & CTRL_CMDOVER); + __raw_writel(temp | CTRL_CMDOVER | CTRL_CMDERROR, + imx_usb->base + USB_CTRL); + do { } while (__raw_readl(imx_usb->base + USB_CTRL) + & CTRL_CMDOVER); temp = __raw_readl(imx_usb->base + USB_CTRL); __raw_writel(temp & ~CTRL_CMDERROR, imx_usb->base + USB_CTRL); } @@ -296,7 +302,8 @@ void imx_ep_stall(struct imx_ep_struct *imx_ep) imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); for (i = 0; i < 100; i ++) { - temp = __raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); + temp = __raw_readl(imx_usb->base + + USB_EP_STAT(EP_NO(imx_ep))); if (!(temp & EPSTAT_STALL)) break; udelay(20); @@ -325,7 +332,8 @@ static int imx_udc_wakeup(struct usb_gadget *_gadget) ******************************************************************************* */ -static void ep_add_request(struct imx_ep_struct *imx_ep, struct imx_request *req) +static void ep_add_request(struct imx_ep_struct *imx_ep, + struct imx_request *req) { if (unlikely(!req)) return; @@ -334,7 +342,8 @@ static void ep_add_request(struct imx_ep_struct *imx_ep, struct imx_request *req list_add_tail(&req->queue, &imx_ep->queue); } -static void ep_del_request(struct imx_ep_struct *imx_ep, struct imx_request *req) +static void ep_del_request(struct imx_ep_struct *imx_ep, + struct imx_request *req) { if (unlikely(!req)) return; @@ -343,7 +352,8 @@ static void ep_del_request(struct imx_ep_struct *imx_ep, struct imx_request *req req->in_use = 0; } -static void done(struct imx_ep_struct *imx_ep, struct imx_request *req, int status) +static void done(struct imx_ep_struct *imx_ep, + struct imx_request *req, int status) { ep_del_request(imx_ep, req); @@ -494,7 +504,8 @@ static int write_fifo(struct imx_ep_struct *imx_ep, struct imx_request *req) __func__, imx_ep->ep.name, req, completed ? "completed" : "not completed"); if (!EP_NO(imx_ep)) - ep0_chg_stat(__func__, imx_ep->imx_usb, EP0_IDLE); + ep0_chg_stat(__func__, + imx_ep->imx_usb, EP0_IDLE); } } @@ -586,7 +597,8 @@ static void handle_ep0_devreq(struct imx_udc_struct *imx_usb) "<%s> no setup packet received\n", __func__); goto stall; } - u.word[i] = __raw_readl(imx_usb->base + USB_EP_FDAT(EP_NO(imx_ep))); + u.word[i] = __raw_readl(imx_usb->base + + USB_EP_FDAT(EP_NO(imx_ep))); } temp = imx_ep_empty(imx_ep); @@ -785,8 +797,10 @@ static int imx_ep_queue /* Debug */ D_REQ(imx_usb->dev, "<%s> ep%d %s request for [%d] bytes\n", __func__, EP_NO(imx_ep), - ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state == EP0_IN_DATA_PHASE) - || (EP_NO(imx_ep) && EP_DIR(imx_ep))) ? "IN" : "OUT", usb_req->length); + ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state + == EP0_IN_DATA_PHASE) + || (EP_NO(imx_ep) && EP_DIR(imx_ep))) + ? "IN" : "OUT", usb_req->length); dump_req(__func__, imx_ep, usb_req); if (imx_ep->stopped) { @@ -1061,7 +1075,8 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) /* Config setup */ if (imx_usb->cfg != cfg) { - D_REQ(imx_usb->dev, "<%s> Change config start\n",__func__); + D_REQ(imx_usb->dev, + "<%s> Change config start\n", __func__); u.bRequest = USB_REQ_SET_CONFIGURATION; u.bRequestType = USB_DIR_OUT | USB_TYPE_STANDARD | @@ -1073,11 +1088,13 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) imx_usb->set_config = 1; imx_usb->driver->setup(&imx_usb->gadget, &u); imx_usb->set_config = 0; - D_REQ(imx_usb->dev, "<%s> Change config done\n",__func__); + D_REQ(imx_usb->dev, + "<%s> Change config done\n", __func__); } if (imx_usb->intf != intf || imx_usb->alt != alt) { - D_REQ(imx_usb->dev, "<%s> Change interface start\n",__func__); + D_REQ(imx_usb->dev, + "<%s> Change interface start\n", __func__); u.bRequest = USB_REQ_SET_INTERFACE; u.bRequestType = USB_DIR_OUT | USB_TYPE_STANDARD | @@ -1090,7 +1107,8 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) imx_usb->set_config = 1; imx_usb->driver->setup(&imx_usb->gadget, &u); imx_usb->set_config = 0; - D_REQ(imx_usb->dev, "<%s> Change interface done\n",__func__); + D_REQ(imx_usb->dev, + "<%s> Change interface done\n", __func__); } } @@ -1102,7 +1120,8 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) */ if (imx_usb->ep0state == EP0_IDLE) { temp = __raw_readl(imx_usb->base + USB_CTRL); - __raw_writel(temp | CTRL_CMDOVER, imx_usb->base + USB_CTRL); + __raw_writel(temp | CTRL_CMDOVER, + imx_usb->base + USB_CTRL); } } diff --git a/drivers/usb/gadget/imx_udc.h b/drivers/usb/gadget/imx_udc.h index d1dfb2d2fa8..6b0b1e3d6fc 100644 --- a/drivers/usb/gadget/imx_udc.h +++ b/drivers/usb/gadget/imx_udc.h @@ -23,7 +23,8 @@ /* Helper macros */ #define EP_NO(ep) ((ep->bEndpointAddress) & ~USB_DIR_IN) /* IN:1, OUT:0 */ #define EP_DIR(ep) ((ep->bEndpointAddress) & USB_DIR_IN ? 1 : 0) -#define irq_to_ep(irq) (((irq) >= USBD_INT0) || ((irq) <= USBD_INT6) ? ((irq) - USBD_INT0) : (USBD_INT6)) /*should not happen*/ +#define irq_to_ep(irq) (((irq) >= USBD_INT0) || ((irq) <= USBD_INT6) \ + ? ((irq) - USBD_INT0) : (USBD_INT6)) /*should not happen*/ #define ep_to_irq(ep) (EP_NO((ep)) + USBD_INT0) #define IMX_USB_NB_EP 6 @@ -88,8 +89,8 @@ struct imx_udc_struct { #define USB_EP_FDAT3(x) (0x3F + (x*0x30)) /* USB FIFO data */ #define USB_EP_FSTAT(x) (0x40 + (x*0x30)) /* USB FIFO status */ #define USB_EP_FCTRL(x) (0x44 + (x*0x30)) /* USB FIFO control */ -#define USB_EP_LRFP(x) (0x48 + (x*0x30)) /* USB last read frame pointer */ -#define USB_EP_LWFP(x) (0x4C + (x*0x30)) /* USB last write frame pointer */ +#define USB_EP_LRFP(x) (0x48 + (x*0x30)) /* USB last rd f. pointer */ +#define USB_EP_LWFP(x) (0x4C + (x*0x30)) /* USB last wr f. pointer */ #define USB_EP_FALRM(x) (0x50 + (x*0x30)) /* USB FIFO alarm */ #define USB_EP_FRDP(x) (0x54 + (x*0x30)) /* USB FIFO read pointer */ #define USB_EP_FWRP(x) (0x58 + (x*0x30)) /* USB FIFO write pointer */ @@ -228,7 +229,8 @@ struct imx_udc_struct { #endif /* DEBUG_IRQ */ #ifdef DEBUG_EPIRQ - static void dump_ep_intr(const char *label, int nr, int irqreg, struct device *dev) + static void dump_ep_intr(const char *label, int nr, int irqreg, + struct device *dev) { dev_dbg(dev, "<%s> EP%d_INTR=[%s%s%s%s%s%s%s%s%s]\n", label, nr, (irqreg & EPINTR_FIFO_FULL) ? " full" : "", @@ -246,7 +248,8 @@ struct imx_udc_struct { #endif /* DEBUG_IRQ */ #ifdef DEBUG_DUMP - static void dump_usb_stat(const char *label, struct imx_udc_struct *imx_usb) + static void dump_usb_stat(const char *label, + struct imx_udc_struct *imx_usb) { int temp = __raw_readl(imx_usb->base + USB_STAT); @@ -259,12 +262,15 @@ struct imx_udc_struct { (temp & STAT_ALTSET)); } - static void dump_ep_stat(const char *label, struct imx_ep_struct *imx_ep) + static void dump_ep_stat(const char *label, + struct imx_ep_struct *imx_ep) { - int temp = __raw_readl(imx_ep->imx_usb->base + USB_EP_INTR(EP_NO(imx_ep))); + int temp = __raw_readl(imx_ep->imx_usb->base + + USB_EP_INTR(EP_NO(imx_ep))); dev_dbg(imx_ep->imx_usb->dev, - "<%s> EP%d_INTR=[%s%s%s%s%s%s%s%s%s]\n", label, EP_NO(imx_ep), + "<%s> EP%d_INTR=[%s%s%s%s%s%s%s%s%s]\n", + label, EP_NO(imx_ep), (temp & EPINTR_FIFO_FULL) ? " full" : "", (temp & EPINTR_FIFO_EMPTY) ? " fempty" : "", (temp & EPINTR_FIFO_ERROR) ? " ferr" : "", @@ -275,18 +281,22 @@ struct imx_udc_struct { (temp & EPINTR_DEVREQ) ? " devreq" : "", (temp & EPINTR_EOT) ? " eot" : ""); - temp = __raw_readl(imx_ep->imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); + temp = __raw_readl(imx_ep->imx_usb->base + + USB_EP_STAT(EP_NO(imx_ep))); dev_dbg(imx_ep->imx_usb->dev, - "<%s> EP%d_STAT=[%s%s bcount=%d]\n", label, EP_NO(imx_ep), + "<%s> EP%d_STAT=[%s%s bcount=%d]\n", + label, EP_NO(imx_ep), (temp & EPSTAT_SIP) ? " sip" : "", (temp & EPSTAT_STALL) ? " stall" : "", (temp & EPSTAT_BCOUNT) >> 16); - temp = __raw_readl(imx_ep->imx_usb->base + USB_EP_FSTAT(EP_NO(imx_ep))); + temp = __raw_readl(imx_ep->imx_usb->base + + USB_EP_FSTAT(EP_NO(imx_ep))); dev_dbg(imx_ep->imx_usb->dev, - "<%s> EP%d_FSTAT=[%s%s%s%s%s%s%s]\n", label, EP_NO(imx_ep), + "<%s> EP%d_FSTAT=[%s%s%s%s%s%s%s]\n", + label, EP_NO(imx_ep), (temp & FSTAT_ERR) ? " ferr" : "", (temp & FSTAT_UF) ? " funder" : "", (temp & FSTAT_OF) ? " fover" : "", @@ -296,19 +306,23 @@ struct imx_udc_struct { (temp & FSTAT_EMPTY) ? " fempty" : ""); } - static void dump_req(const char *label, struct imx_ep_struct *imx_ep, struct usb_request *req) + static void dump_req(const char *label, struct imx_ep_struct *imx_ep, + struct usb_request *req) { int i; if (!req || !req->buf) { - dev_dbg(imx_ep->imx_usb->dev, "<%s> req or req buf is free\n", label); + dev_dbg(imx_ep->imx_usb->dev, + "<%s> req or req buf is free\n", label); return; } - if ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state == EP0_IN_DATA_PHASE) + if ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state + == EP0_IN_DATA_PHASE) || (EP_NO(imx_ep) && EP_DIR(imx_ep))) { - dev_dbg(imx_ep->imx_usb->dev, "<%s> request dump <", label); + dev_dbg(imx_ep->imx_usb->dev, + "<%s> request dump <", label); for (i = 0; i < req->length; i++) printk("%02x-", *((u8 *)req->buf + i)); printk(">\n"); -- cgit v1.2.3 From d24921a36df31332c32e1bb539671284d9e36bfa Mon Sep 17 00:00:00 2001 From: Darius Augulis Date: Wed, 21 Jan 2009 15:18:33 +0200 Subject: USB: imx_udc: Fix IMX UDC gadget ep0 irq handling Fix ep0 interrupt handling in IMX UDC Gadget. Signed-off-by: Darius Augulis Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/imx_udc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c index 3ee5bd8bea7..e590464c3a5 100644 --- a/drivers/usb/gadget/imx_udc.c +++ b/drivers/usb/gadget/imx_udc.c @@ -1133,6 +1133,7 @@ end_irq: static irqreturn_t imx_udc_ctrl_irq(int irq, void *dev) { struct imx_udc_struct *imx_usb = dev; + struct imx_ep_struct *imx_ep = &imx_usb->imx_ep[0]; int intr = __raw_readl(imx_usb->base + USB_EP_INTR(0)); dump_ep_intr(__func__, 0, intr, imx_usb->dev); @@ -1142,16 +1143,15 @@ static irqreturn_t imx_udc_ctrl_irq(int irq, void *dev) return IRQ_HANDLED; } - /* DEVREQ IRQ has highest priority */ + /* DEVREQ has highest priority */ if (intr & (EPINTR_DEVREQ | EPINTR_MDEVREQ)) handle_ep0_devreq(imx_usb); /* Seem i.MX is missing EOF interrupt sometimes. - * Therefore we monitor both EOF and FIFO_EMPTY interrups - * when transmiting, and both EOF and FIFO_FULL when - * receiving data. + * Therefore we don't monitor EOF. + * We call handle_ep0() only if a request is queued for ep0. */ - else if (intr & (EPINTR_EOF | EPINTR_FIFO_EMPTY | EPINTR_FIFO_FULL)) - handle_ep0(&imx_usb->imx_ep[0]); + else if (!list_empty(&imx_ep->queue)) + handle_ep0(imx_ep); __raw_writel(intr, imx_usb->base + USB_EP_INTR(0)); -- cgit v1.2.3 From b633d28e2c5fbe1c8d163892644f57df04aa1421 Mon Sep 17 00:00:00 2001 From: Darius Augulis Date: Wed, 21 Jan 2009 15:19:19 +0200 Subject: USB: imx_udc: Fix IMX UDC gadget general irq handling Workaround of hw bug in IMX UDC. This bug causes wrong handling of CFG_CHG interrupt. Workaround is documented inline source code. Signed-off-by: Darius Augulis Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/imx_udc.c | 158 +++++++++++++++++++++++++------------------ drivers/usb/gadget/imx_udc.h | 1 + 2 files changed, 94 insertions(+), 65 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c index e590464c3a5..8d3c6a96098 100644 --- a/drivers/usb/gadget/imx_udc.c +++ b/drivers/usb/gadget/imx_udc.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -1013,70 +1014,32 @@ static void udc_stop_activity(struct imx_udc_struct *imx_usb, ******************************************************************************* */ -static irqreturn_t imx_udc_irq(int irq, void *dev) +/* + * Called when timer expires. + * Timer is started when CFG_CHG is received. + */ +static void handle_config(unsigned long data) { - struct imx_udc_struct *imx_usb = dev; + struct imx_udc_struct *imx_usb = (void *)data; struct usb_ctrlrequest u; int temp, cfg, intf, alt; - int intr = __raw_readl(imx_usb->base + USB_INTR); - - if (intr & (INTR_WAKEUP | INTR_SUSPEND | INTR_RESUME | INTR_RESET_START - | INTR_RESET_STOP | INTR_CFG_CHG)) { - dump_intr(__func__, intr, imx_usb->dev); - dump_usb_stat(__func__, imx_usb); - } - - if (!imx_usb->driver) - goto end_irq; - - if (intr & INTR_WAKEUP) { - if (imx_usb->gadget.speed == USB_SPEED_UNKNOWN - && imx_usb->driver && imx_usb->driver->resume) - imx_usb->driver->resume(&imx_usb->gadget); - imx_usb->set_config = 0; - imx_usb->gadget.speed = USB_SPEED_FULL; - } - - if (intr & INTR_SUSPEND) { - if (imx_usb->gadget.speed != USB_SPEED_UNKNOWN - && imx_usb->driver && imx_usb->driver->suspend) - imx_usb->driver->suspend(&imx_usb->gadget); - imx_usb->set_config = 0; - imx_usb->gadget.speed = USB_SPEED_UNKNOWN; - } - if (intr & INTR_RESET_START) { - __raw_writel(intr, imx_usb->base + USB_INTR); - udc_stop_activity(imx_usb, imx_usb->driver); - imx_usb->set_config = 0; - imx_usb->gadget.speed = USB_SPEED_UNKNOWN; - } - - if (intr & INTR_RESET_STOP) - imx_usb->gadget.speed = USB_SPEED_FULL; + local_irq_disable(); - if (intr & INTR_CFG_CHG) { - __raw_writel(INTR_CFG_CHG, imx_usb->base + USB_INTR); - temp = __raw_readl(imx_usb->base + USB_STAT); - cfg = (temp & STAT_CFG) >> 5; - intf = (temp & STAT_INTF) >> 3; - alt = temp & STAT_ALTSET; + temp = __raw_readl(imx_usb->base + USB_STAT); + cfg = (temp & STAT_CFG) >> 5; + intf = (temp & STAT_INTF) >> 3; + alt = temp & STAT_ALTSET; - D_REQ(imx_usb->dev, - "<%s> orig config C=%d, I=%d, A=%d / " - "req config C=%d, I=%d, A=%d\n", - __func__, imx_usb->cfg, imx_usb->intf, imx_usb->alt, - cfg, intf, alt); + D_REQ(imx_usb->dev, + "<%s> orig config C=%d, I=%d, A=%d / " + "req config C=%d, I=%d, A=%d\n", + __func__, imx_usb->cfg, imx_usb->intf, imx_usb->alt, + cfg, intf, alt); - if (cfg != 1 && cfg != 2) - goto end_irq; + if (cfg == 1 || cfg == 2) { - imx_usb->set_config = 0; - - /* Config setup */ if (imx_usb->cfg != cfg) { - D_REQ(imx_usb->dev, - "<%s> Change config start\n", __func__); u.bRequest = USB_REQ_SET_CONFIGURATION; u.bRequestType = USB_DIR_OUT | USB_TYPE_STANDARD | @@ -1085,16 +1048,10 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) u.wIndex = 0; u.wLength = 0; imx_usb->cfg = cfg; - imx_usb->set_config = 1; imx_usb->driver->setup(&imx_usb->gadget, &u); - imx_usb->set_config = 0; - D_REQ(imx_usb->dev, - "<%s> Change config done\n", __func__); } if (imx_usb->intf != intf || imx_usb->alt != alt) { - D_REQ(imx_usb->dev, - "<%s> Change interface start\n", __func__); u.bRequest = USB_REQ_SET_INTERFACE; u.bRequestType = USB_DIR_OUT | USB_TYPE_STANDARD | @@ -1104,14 +1061,30 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) u.wLength = 0; imx_usb->intf = intf; imx_usb->alt = alt; - imx_usb->set_config = 1; imx_usb->driver->setup(&imx_usb->gadget, &u); - imx_usb->set_config = 0; - D_REQ(imx_usb->dev, - "<%s> Change interface done\n", __func__); } } + imx_usb->set_config = 0; + + local_irq_enable(); +} + +static irqreturn_t imx_udc_irq(int irq, void *dev) +{ + struct imx_udc_struct *imx_usb = dev; + int intr = __raw_readl(imx_usb->base + USB_INTR); + int temp; + + if (intr & (INTR_WAKEUP | INTR_SUSPEND | INTR_RESUME | INTR_RESET_START + | INTR_RESET_STOP | INTR_CFG_CHG)) { + dump_intr(__func__, intr, imx_usb->dev); + dump_usb_stat(__func__, imx_usb); + } + + if (!imx_usb->driver) + goto end_irq; + if (intr & INTR_SOF) { /* Copy from Freescale BSP. We must enable SOF intr and set CMDOVER. @@ -1125,6 +1098,55 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) } } + if (intr & INTR_CFG_CHG) { + /* A workaround of serious IMX UDC bug. + Handling of CFG_CHG should be delayed for some time, because + IMX does not NACK the host when CFG_CHG interrupt is pending. + There is no time to handle current CFG_CHG + if next CFG_CHG or SETUP packed is send immediately. + We have to clear CFG_CHG, start the timer and + NACK the host by setting CTRL_CMDOVER + if it sends any SETUP packet. + When timer expires, handler is called to handle configuration + changes. While CFG_CHG is not handled (set_config=1), + we must NACK the host to every SETUP packed. + This delay prevents from going out of sync with host. + */ + __raw_writel(INTR_CFG_CHG, imx_usb->base + USB_INTR); + imx_usb->set_config = 1; + mod_timer(&imx_usb->timer, jiffies + 5); + goto end_irq; + } + + if (intr & INTR_WAKEUP) { + if (imx_usb->gadget.speed == USB_SPEED_UNKNOWN + && imx_usb->driver && imx_usb->driver->resume) + imx_usb->driver->resume(&imx_usb->gadget); + imx_usb->set_config = 0; + del_timer(&imx_usb->timer); + imx_usb->gadget.speed = USB_SPEED_FULL; + } + + if (intr & INTR_SUSPEND) { + if (imx_usb->gadget.speed != USB_SPEED_UNKNOWN + && imx_usb->driver && imx_usb->driver->suspend) + imx_usb->driver->suspend(&imx_usb->gadget); + imx_usb->set_config = 0; + del_timer(&imx_usb->timer); + imx_usb->gadget.speed = USB_SPEED_UNKNOWN; + } + + if (intr & INTR_RESET_START) { + __raw_writel(intr, imx_usb->base + USB_INTR); + udc_stop_activity(imx_usb, imx_usb->driver); + imx_usb->set_config = 0; + del_timer(&imx_usb->timer); + imx_usb->gadget.speed = USB_SPEED_UNKNOWN; + } + + if (intr & INTR_RESET_STOP) + imx_usb->gadget.speed = USB_SPEED_FULL; + end_irq: __raw_writel(intr, imx_usb->base + USB_INTR); return IRQ_HANDLED; @@ -1342,6 +1364,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) udc_stop_activity(imx_usb, driver); imx_udc_disable(imx_usb); + del_timer(&imx_usb->timer); driver->unbind(&imx_usb->gadget); imx_usb->gadget.dev.driver = NULL; @@ -1459,6 +1482,10 @@ static int __init imx_udc_probe(struct platform_device *pdev) usb_init_data(imx_usb); imx_udc_init(imx_usb); + init_timer(&imx_usb->timer); + imx_usb->timer.function = handle_config; + imx_usb->timer.data = (unsigned long)imx_usb; + return 0; fail3: @@ -1481,6 +1508,7 @@ static int __exit imx_udc_remove(struct platform_device *pdev) int i; imx_udc_disable(imx_usb); + del_timer(&imx_usb->timer); for (i = 0; i < IMX_USB_NB_EP + 1; i++) free_irq(imx_usb->usbd_int[i], imx_usb); diff --git a/drivers/usb/gadget/imx_udc.h b/drivers/usb/gadget/imx_udc.h index 6b0b1e3d6fc..b48ad59603d 100644 --- a/drivers/usb/gadget/imx_udc.h +++ b/drivers/usb/gadget/imx_udc.h @@ -59,6 +59,7 @@ struct imx_udc_struct { struct device *dev; struct imx_ep_struct imx_ep[IMX_USB_NB_EP]; struct clk *clk; + struct timer_list timer; enum ep0_state ep0state; struct resource *res; void __iomem *base; -- cgit v1.2.3 From 6f8aa65b52037123beab573432e371c0f70b7b9a Mon Sep 17 00:00:00 2001 From: Frank Seidel Date: Thu, 5 Feb 2009 16:16:24 +0100 Subject: USB: add missing KERN_* constants to printks According to kerneljanitors todo list all printk calls (beginning a new line) should have an according KERN_* constant. Those are the missing peaces here for the usb subsystem. Signed-off-by: Frank Seidel Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/fsl_usb2_udc.c | 8 +++++--- drivers/usb/gadget/lh7a40x_udc.c | 16 +++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c index d8d9a52a44b..9d7b95d4e3d 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.c +++ b/drivers/usb/gadget/fsl_usb2_udc.c @@ -1802,7 +1802,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) out: if (retval) - printk("gadget driver register failed %d\n", retval); + printk(KERN_WARNING "gadget driver register failed %d\n", + retval); return retval; } EXPORT_SYMBOL(usb_gadget_register_driver); @@ -1847,7 +1848,8 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) udc_controller->gadget.dev.driver = NULL; udc_controller->driver = NULL; - printk("unregistered gadget driver '%s'\n", driver->driver.name); + printk(KERN_WARNING "unregistered gadget driver '%s'\n", + driver->driver.name); return 0; } EXPORT_SYMBOL(usb_gadget_unregister_driver); @@ -2455,7 +2457,7 @@ module_init(udc_init); static void __exit udc_exit(void) { platform_driver_unregister(&udc_driver); - printk("%s unregistered\n", driver_desc); + printk(KERN_WARNING "%s unregistered\n", driver_desc); } module_exit(udc_exit); diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c index d554b089560..6cd3d54f564 100644 --- a/drivers/usb/gadget/lh7a40x_udc.c +++ b/drivers/usb/gadget/lh7a40x_udc.c @@ -432,8 +432,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) device_add(&dev->gadget.dev); retval = driver->bind(&dev->gadget); if (retval) { - printk("%s: bind to driver %s --> error %d\n", dev->gadget.name, - driver->driver.name, retval); + printk(KERN_WARNING "%s: bind to driver %s --> error %d\n", + dev->gadget.name, driver->driver.name, retval); device_del(&dev->gadget.dev); dev->driver = 0; @@ -445,8 +445,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) * for set_configuration as well as eventual disconnect. * NOTE: this shouldn't power up until later. */ - printk("%s: registered gadget driver '%s'\n", dev->gadget.name, - driver->driver.name); + printk(KERN_WARNING "%s: registered gadget driver '%s'\n", + dev->gadget.name, driver->driver.name); udc_enable(dev); @@ -581,7 +581,8 @@ static int read_fifo(struct lh7a40x_ep *ep, struct lh7a40x_request *req) * discard the extra data. */ if (req->req.status != -EOVERFLOW) - printk("%s overflow %d\n", ep->ep.name, count); + printk(KERN_WARNING "%s overflow %d\n", + ep->ep.name, count); req->req.status = -EOVERFLOW; } else { *buf++ = byte; @@ -831,7 +832,8 @@ static void lh7a40x_out_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr) queue); if (!req) { - printk("%s: NULL REQ %d\n", + printk(KERN_WARNING + "%s: NULL REQ %d\n", __func__, ep_idx); flush(ep); break; @@ -844,7 +846,7 @@ static void lh7a40x_out_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr) } else { /* Throw packet away.. */ - printk("%s: No descriptor?!?\n", __func__); + printk(KERN_WARNING "%s: No descriptor?!?\n", __func__); flush(ep); } } -- cgit v1.2.3 From 551509d267905705f6d723e51ec706916f06b859 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Wed, 11 Feb 2009 14:11:36 -0800 Subject: USB: replace uses of __constant_{endian} The base versions handle constant folding now. Signed-off-by: Harvey Harrison Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/amd5536udc.c | 2 +- drivers/usb/gadget/atmel_usba_udc.c | 20 ++++++++++---------- drivers/usb/gadget/cdc2.c | 8 ++++---- drivers/usb/gadget/dummy_hcd.c | 2 +- drivers/usb/gadget/epautoconf.c | 2 +- drivers/usb/gadget/ether.c | 8 ++++---- drivers/usb/gadget/f_acm.c | 10 +++++----- drivers/usb/gadget/f_ecm.c | 16 ++++++++-------- drivers/usb/gadget/f_loopback.c | 4 ++-- drivers/usb/gadget/f_obex.c | 8 ++++---- drivers/usb/gadget/f_phonet.c | 8 ++++---- drivers/usb/gadget/f_rndis.c | 10 +++++----- drivers/usb/gadget/f_serial.c | 4 ++-- drivers/usb/gadget/f_sourcesink.c | 4 ++-- drivers/usb/gadget/f_subset.c | 14 +++++++------- drivers/usb/gadget/file_storage.c | 22 +++++++++++----------- drivers/usb/gadget/gmidi.c | 16 ++++++++-------- drivers/usb/gadget/goku_udc.c | 8 ++++---- drivers/usb/gadget/inode.c | 4 ++-- drivers/usb/gadget/net2280.c | 16 ++++++++-------- drivers/usb/gadget/printer.c | 18 +++++++++--------- drivers/usb/gadget/serial.c | 12 ++++++------ drivers/usb/gadget/u_serial.c | 2 +- drivers/usb/gadget/zero.c | 8 ++++---- 24 files changed, 113 insertions(+), 113 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index abf8192f89e..826f3adde5d 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c @@ -551,7 +551,7 @@ udc_alloc_request(struct usb_ep *usbep, gfp_t gfp) dma_desc->status = AMD_ADDBITS(dma_desc->status, UDC_DMA_STP_STS_BS_HOST_BUSY, UDC_DMA_STP_STS_BS); - dma_desc->bufptr = __constant_cpu_to_le32(DMA_DONT_USE); + dma_desc->bufptr = cpu_to_le32(DMA_DONT_USE); req->td_data = dma_desc; req->td_data_last = NULL; req->chain_len = 1; diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 65b03e3445a..c22fab16411 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c @@ -1017,7 +1017,7 @@ static struct usb_endpoint_descriptor usba_ep0_desc = { .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = 0, .bmAttributes = USB_ENDPOINT_XFER_CONTROL, - .wMaxPacketSize = __constant_cpu_to_le16(64), + .wMaxPacketSize = cpu_to_le16(64), /* FIXME: I have no idea what to put here */ .bInterval = 1, }; @@ -1207,21 +1207,21 @@ static int do_test_mode(struct usba_udc *udc) /* Avoid overly long expressions */ static inline bool feature_is_dev_remote_wakeup(struct usb_ctrlrequest *crq) { - if (crq->wValue == __constant_cpu_to_le16(USB_DEVICE_REMOTE_WAKEUP)) + if (crq->wValue == cpu_to_le16(USB_DEVICE_REMOTE_WAKEUP)) return true; return false; } static inline bool feature_is_dev_test_mode(struct usb_ctrlrequest *crq) { - if (crq->wValue == __constant_cpu_to_le16(USB_DEVICE_TEST_MODE)) + if (crq->wValue == cpu_to_le16(USB_DEVICE_TEST_MODE)) return true; return false; } static inline bool feature_is_ep_halt(struct usb_ctrlrequest *crq) { - if (crq->wValue == __constant_cpu_to_le16(USB_ENDPOINT_HALT)) + if (crq->wValue == cpu_to_le16(USB_ENDPOINT_HALT)) return true; return false; } @@ -1239,7 +1239,7 @@ static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep, status = cpu_to_le16(udc->devstatus); } else if (crq->bRequestType == (USB_DIR_IN | USB_RECIP_INTERFACE)) { - status = __constant_cpu_to_le16(0); + status = cpu_to_le16(0); } else if (crq->bRequestType == (USB_DIR_IN | USB_RECIP_ENDPOINT)) { struct usba_ep *target; @@ -1250,12 +1250,12 @@ static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep, status = 0; if (is_stalled(udc, target)) - status |= __constant_cpu_to_le16(1); + status |= cpu_to_le16(1); } else goto delegate; /* Write directly to the FIFO. No queueing is done. */ - if (crq->wLength != __constant_cpu_to_le16(sizeof(status))) + if (crq->wLength != cpu_to_le16(sizeof(status))) goto stall; ep->state = DATA_STAGE_IN; __raw_writew(status, ep->fifo); @@ -1274,7 +1274,7 @@ static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep, } else if (crq->bRequestType == USB_RECIP_ENDPOINT) { struct usba_ep *target; - if (crq->wLength != __constant_cpu_to_le16(0) + if (crq->wLength != cpu_to_le16(0) || !feature_is_ep_halt(crq)) goto stall; target = get_ep_by_addr(udc, le16_to_cpu(crq->wIndex)); @@ -1308,7 +1308,7 @@ static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep, } else if (crq->bRequestType == USB_RECIP_ENDPOINT) { struct usba_ep *target; - if (crq->wLength != __constant_cpu_to_le16(0) + if (crq->wLength != cpu_to_le16(0) || !feature_is_ep_halt(crq)) goto stall; @@ -1514,7 +1514,7 @@ restart: */ ep->state = DATA_STAGE_IN; } else { - if (crq.crq.wLength != __constant_cpu_to_le16(0)) + if (crq.crq.wLength != cpu_to_le16(0)) ep->state = DATA_STAGE_OUT; else ep->state = STATUS_STAGE_IN; diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index 5495b171cf2..928137d3dbd 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c @@ -66,7 +66,7 @@ static struct usb_device_descriptor device_desc = { .bLength = sizeof device_desc, .bDescriptorType = USB_DT_DEVICE, - .bcdUSB = __constant_cpu_to_le16(0x0200), + .bcdUSB = cpu_to_le16(0x0200), .bDeviceClass = USB_CLASS_COMM, .bDeviceSubClass = 0, @@ -74,8 +74,8 @@ static struct usb_device_descriptor device_desc = { /* .bMaxPacketSize0 = f(hardware) */ /* Vendor and product id can be overridden by module parameters. */ - .idVendor = __constant_cpu_to_le16(CDC_VENDOR_NUM), - .idProduct = __constant_cpu_to_le16(CDC_PRODUCT_NUM), + .idVendor = cpu_to_le16(CDC_VENDOR_NUM), + .idProduct = cpu_to_le16(CDC_PRODUCT_NUM), /* .bcdDevice = f(hardware) */ /* .iManufacturer = DYNAMIC */ /* .iProduct = DYNAMIC */ @@ -193,7 +193,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) gadget->name, cdc_config_driver.label); device_desc.bcdDevice = - __constant_cpu_to_le16(0x0300 | 0x0099); + cpu_to_le16(0x0300 | 0x0099); } diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 9064696636a..3b42888b72f 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c @@ -1626,7 +1626,7 @@ static int dummy_hub_control ( hub_descriptor ((struct usb_hub_descriptor *) buf); break; case GetHubStatus: - *(__le32 *) buf = __constant_cpu_to_le32 (0); + *(__le32 *) buf = cpu_to_le32 (0); break; case GetPortStatus: if (wIndex != 1) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index a36b1175b18..cd0914ec898 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -148,7 +148,7 @@ ep_matches ( return 0; /* BOTH: "high bandwidth" works only at high speed */ - if ((desc->wMaxPacketSize & __constant_cpu_to_le16(3<<11))) { + if ((desc->wMaxPacketSize & cpu_to_le16(3<<11))) { if (!gadget->is_dualspeed) return 0; /* configure your hardware with enough buffering!! */ diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 37252d0012a..d006dc652e0 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -156,7 +156,7 @@ static struct usb_device_descriptor device_desc = { .bLength = sizeof device_desc, .bDescriptorType = USB_DT_DEVICE, - .bcdUSB = __constant_cpu_to_le16 (0x0200), + .bcdUSB = cpu_to_le16 (0x0200), .bDeviceClass = USB_CLASS_COMM, .bDeviceSubClass = 0, @@ -167,8 +167,8 @@ static struct usb_device_descriptor device_desc = { * we support. (As does bNumConfigurations.) These values can * also be overridden by module parameters. */ - .idVendor = __constant_cpu_to_le16 (CDC_VENDOR_NUM), - .idProduct = __constant_cpu_to_le16 (CDC_PRODUCT_NUM), + .idVendor = cpu_to_le16 (CDC_VENDOR_NUM), + .idProduct = cpu_to_le16 (CDC_PRODUCT_NUM), /* .bcdDevice = f(hardware) */ /* .iManufacturer = DYNAMIC */ /* .iProduct = DYNAMIC */ @@ -318,7 +318,7 @@ static int __init eth_bind(struct usb_composite_dev *cdev) gadget->name, eth_config_driver.label); device_desc.bcdDevice = - __constant_cpu_to_le16(0x0300 | 0x0099); + cpu_to_le16(0x0300 | 0x0099); } diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c index c1d34df0b15..7953948bfe4 100644 --- a/drivers/usb/gadget/f_acm.c +++ b/drivers/usb/gadget/f_acm.c @@ -125,7 +125,7 @@ static struct usb_cdc_header_desc acm_header_desc __initdata = { .bLength = sizeof(acm_header_desc), .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = USB_CDC_HEADER_TYPE, - .bcdCDC = __constant_cpu_to_le16(0x0110), + .bcdCDC = cpu_to_le16(0x0110), }; static struct usb_cdc_call_mgmt_descriptor @@ -159,7 +159,7 @@ static struct usb_endpoint_descriptor acm_fs_notify_desc __initdata = { .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_INT, - .wMaxPacketSize = __constant_cpu_to_le16(GS_NOTIFY_MAXPACKET), + .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), .bInterval = 1 << GS_LOG2_NOTIFY_INTERVAL, }; @@ -197,7 +197,7 @@ static struct usb_endpoint_descriptor acm_hs_notify_desc __initdata = { .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_INT, - .wMaxPacketSize = __constant_cpu_to_le16(GS_NOTIFY_MAXPACKET), + .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), .bInterval = GS_LOG2_NOTIFY_INTERVAL+4, }; @@ -205,14 +205,14 @@ static struct usb_endpoint_descriptor acm_hs_in_desc __initdata = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor acm_hs_out_desc __initdata = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_descriptor_header *acm_hs_function[] __initdata = { diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c index 4ae579948e5..ecf5bdd0ae0 100644 --- a/drivers/usb/gadget/f_ecm.c +++ b/drivers/usb/gadget/f_ecm.c @@ -130,7 +130,7 @@ static struct usb_cdc_header_desc ecm_header_desc __initdata = { .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = USB_CDC_HEADER_TYPE, - .bcdCDC = __constant_cpu_to_le16(0x0110), + .bcdCDC = cpu_to_le16(0x0110), }; static struct usb_cdc_union_desc ecm_union_desc __initdata = { @@ -148,9 +148,9 @@ static struct usb_cdc_ether_desc ecm_desc __initdata = { /* this descriptor actually adds value, surprise! */ /* .iMACAddress = DYNAMIC */ - .bmEthernetStatistics = __constant_cpu_to_le32(0), /* no statistics */ - .wMaxSegmentSize = __constant_cpu_to_le16(ETH_FRAME_LEN), - .wNumberMCFilters = __constant_cpu_to_le16(0), + .bmEthernetStatistics = cpu_to_le32(0), /* no statistics */ + .wMaxSegmentSize = cpu_to_le16(ETH_FRAME_LEN), + .wNumberMCFilters = cpu_to_le16(0), .bNumberPowerFilters = 0, }; @@ -192,7 +192,7 @@ static struct usb_endpoint_descriptor fs_ecm_notify_desc __initdata = { .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_INT, - .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT), + .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, }; @@ -236,7 +236,7 @@ static struct usb_endpoint_descriptor hs_ecm_notify_desc __initdata = { .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_INT, - .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT), + .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, }; static struct usb_endpoint_descriptor hs_ecm_in_desc __initdata = { @@ -245,7 +245,7 @@ static struct usb_endpoint_descriptor hs_ecm_in_desc __initdata = { .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor hs_ecm_out_desc __initdata = { @@ -254,7 +254,7 @@ static struct usb_endpoint_descriptor hs_ecm_out_desc __initdata = { .bEndpointAddress = USB_DIR_OUT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_descriptor_header *ecm_hs_function[] __initdata = { diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c index 8affe1dfc2c..83301bdcdd1 100644 --- a/drivers/usb/gadget/f_loopback.c +++ b/drivers/usb/gadget/f_loopback.c @@ -100,7 +100,7 @@ static struct usb_endpoint_descriptor hs_loop_source_desc = { .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor hs_loop_sink_desc = { @@ -108,7 +108,7 @@ static struct usb_endpoint_descriptor hs_loop_sink_desc = { .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_descriptor_header *hs_loopback_descs[] = { diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c index 38aa896cc5d..46d6266f30e 100644 --- a/drivers/usb/gadget/f_obex.c +++ b/drivers/usb/gadget/f_obex.c @@ -123,7 +123,7 @@ static struct usb_cdc_header_desc obex_cdc_header_desc __initdata = { .bLength = sizeof(obex_cdc_header_desc), .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = USB_CDC_HEADER_TYPE, - .bcdCDC = __constant_cpu_to_le16(0x0120), + .bcdCDC = cpu_to_le16(0x0120), }; static struct usb_cdc_union_desc obex_cdc_union_desc __initdata = { @@ -138,7 +138,7 @@ static struct usb_cdc_obex_desc obex_desc __initdata = { .bLength = sizeof(obex_desc), .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = USB_CDC_OBEX_TYPE, - .bcdVersion = __constant_cpu_to_le16(0x0100), + .bcdVersion = cpu_to_le16(0x0100), }; /* High-Speed Support */ @@ -149,7 +149,7 @@ static struct usb_endpoint_descriptor obex_hs_ep_out_desc __initdata = { .bEndpointAddress = USB_DIR_OUT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor obex_hs_ep_in_desc __initdata = { @@ -158,7 +158,7 @@ static struct usb_endpoint_descriptor obex_hs_ep_in_desc __initdata = { .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_descriptor_header *hs_function[] __initdata = { diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c index c0916c7b217..c1abeb89b41 100644 --- a/drivers/usb/gadget/f_phonet.c +++ b/drivers/usb/gadget/f_phonet.c @@ -79,7 +79,7 @@ pn_header_desc = { .bLength = sizeof pn_header_desc, .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = USB_CDC_HEADER_TYPE, - .bcdCDC = __constant_cpu_to_le16(0x0110), + .bcdCDC = cpu_to_le16(0x0110), }; static const struct usb_cdc_header_desc @@ -87,7 +87,7 @@ pn_phonet_desc = { .bLength = sizeof pn_phonet_desc, .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = USB_CDC_PHONET_TYPE, - .bcdCDC = __constant_cpu_to_le16(0x1505), /* ??? */ + .bcdCDC = cpu_to_le16(0x1505), /* ??? */ }; static struct usb_cdc_union_desc @@ -138,7 +138,7 @@ pn_hs_sink_desc = { .bEndpointAddress = USB_DIR_OUT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor @@ -157,7 +157,7 @@ pn_hs_source_desc = { .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_descriptor_header *fs_pn_function[] = { diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c index fd7b356f902..3279a472604 100644 --- a/drivers/usb/gadget/f_rndis.c +++ b/drivers/usb/gadget/f_rndis.c @@ -137,7 +137,7 @@ static struct usb_cdc_header_desc header_desc __initdata = { .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = USB_CDC_HEADER_TYPE, - .bcdCDC = __constant_cpu_to_le16(0x0110), + .bcdCDC = cpu_to_le16(0x0110), }; static struct usb_cdc_call_mgmt_descriptor call_mgmt_descriptor __initdata = { @@ -187,7 +187,7 @@ static struct usb_endpoint_descriptor fs_notify_desc __initdata = { .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_INT, - .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT), + .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, }; @@ -230,7 +230,7 @@ static struct usb_endpoint_descriptor hs_notify_desc __initdata = { .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_INT, - .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT), + .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, }; static struct usb_endpoint_descriptor hs_in_desc __initdata = { @@ -239,7 +239,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = { .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor hs_out_desc __initdata = { @@ -248,7 +248,7 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = { .bEndpointAddress = USB_DIR_OUT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_descriptor_header *eth_hs_function[] __initdata = { diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c index fe5674db344..db0aa93606e 100644 --- a/drivers/usb/gadget/f_serial.c +++ b/drivers/usb/gadget/f_serial.c @@ -89,14 +89,14 @@ static struct usb_endpoint_descriptor gser_hs_in_desc __initdata = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor gser_hs_out_desc __initdata = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_descriptor_header *gser_hs_function[] __initdata = { diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c index dc84d26d283..6aca5c81414 100644 --- a/drivers/usb/gadget/f_sourcesink.c +++ b/drivers/usb/gadget/f_sourcesink.c @@ -118,7 +118,7 @@ static struct usb_endpoint_descriptor hs_source_desc = { .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor hs_sink_desc = { @@ -126,7 +126,7 @@ static struct usb_endpoint_descriptor hs_sink_desc = { .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_descriptor_header *hs_source_sink_descs[] = { diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c index fe183287577..a9c98fdb626 100644 --- a/drivers/usb/gadget/f_subset.c +++ b/drivers/usb/gadget/f_subset.c @@ -108,7 +108,7 @@ static struct usb_cdc_header_desc mdlm_header_desc __initdata = { .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = USB_CDC_HEADER_TYPE, - .bcdCDC = __constant_cpu_to_le16(0x0110), + .bcdCDC = cpu_to_le16(0x0110), }; static struct usb_cdc_mdlm_desc mdlm_desc __initdata = { @@ -116,7 +116,7 @@ static struct usb_cdc_mdlm_desc mdlm_desc __initdata = { .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = USB_CDC_MDLM_TYPE, - .bcdVersion = __constant_cpu_to_le16(0x0100), + .bcdVersion = cpu_to_le16(0x0100), .bGUID = { 0x5d, 0x34, 0xcf, 0x66, 0x11, 0x18, 0x11, 0xd6, 0xa2, 0x1a, 0x00, 0x01, 0x02, 0xca, 0x9a, 0x7f, @@ -144,9 +144,9 @@ static struct usb_cdc_ether_desc ether_desc __initdata = { /* this descriptor actually adds value, surprise! */ /* .iMACAddress = DYNAMIC */ - .bmEthernetStatistics = __constant_cpu_to_le32(0), /* no statistics */ - .wMaxSegmentSize = __constant_cpu_to_le16(ETH_FRAME_LEN), - .wNumberMCFilters = __constant_cpu_to_le16(0), + .bmEthernetStatistics = cpu_to_le32(0), /* no statistics */ + .wMaxSegmentSize = cpu_to_le16(ETH_FRAME_LEN), + .wNumberMCFilters = cpu_to_le16(0), .bNumberPowerFilters = 0, }; @@ -186,7 +186,7 @@ static struct usb_endpoint_descriptor hs_subset_in_desc __initdata = { .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = { @@ -194,7 +194,7 @@ static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = { .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_descriptor_header *hs_eth_function[] __initdata = { diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 1ab9dac7e12..d3c2464dee8 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c @@ -847,13 +847,13 @@ device_desc = { .bLength = sizeof device_desc, .bDescriptorType = USB_DT_DEVICE, - .bcdUSB = __constant_cpu_to_le16(0x0200), + .bcdUSB = cpu_to_le16(0x0200), .bDeviceClass = USB_CLASS_PER_INTERFACE, /* The next three values can be overridden by module parameters */ - .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_ID), - .idProduct = __constant_cpu_to_le16(DRIVER_PRODUCT_ID), - .bcdDevice = __constant_cpu_to_le16(0xffff), + .idVendor = cpu_to_le16(DRIVER_VENDOR_ID), + .idProduct = cpu_to_le16(DRIVER_PRODUCT_ID), + .bcdDevice = cpu_to_le16(0xffff), .iManufacturer = STRING_MANUFACTURER, .iProduct = STRING_PRODUCT, @@ -926,7 +926,7 @@ fs_intr_in_desc = { .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_INT, - .wMaxPacketSize = __constant_cpu_to_le16(2), + .wMaxPacketSize = cpu_to_le16(2), .bInterval = 32, // frames -> 32 ms }; @@ -954,7 +954,7 @@ dev_qualifier = { .bLength = sizeof dev_qualifier, .bDescriptorType = USB_DT_DEVICE_QUALIFIER, - .bcdUSB = __constant_cpu_to_le16(0x0200), + .bcdUSB = cpu_to_le16(0x0200), .bDeviceClass = USB_CLASS_PER_INTERFACE, .bNumConfigurations = 1, @@ -967,7 +967,7 @@ hs_bulk_in_desc = { /* bEndpointAddress copied from fs_bulk_in_desc during fsg_bind() */ .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor @@ -977,7 +977,7 @@ hs_bulk_out_desc = { /* bEndpointAddress copied from fs_bulk_out_desc during fsg_bind() */ .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = cpu_to_le16(512), .bInterval = 1, // NAK every 1 uframe }; @@ -988,7 +988,7 @@ hs_intr_in_desc = { /* bEndpointAddress copied from fs_intr_in_desc during fsg_bind() */ .bmAttributes = USB_ENDPOINT_XFER_INT, - .wMaxPacketSize = __constant_cpu_to_le16(2), + .wMaxPacketSize = cpu_to_le16(2), .bInterval = 9, // 2**(9-1) = 256 uframes -> 32 ms }; @@ -2646,7 +2646,7 @@ static int send_status(struct fsg_dev *fsg) struct bulk_cs_wrap *csw = bh->buf; /* Store and send the Bulk-only CSW */ - csw->Signature = __constant_cpu_to_le32(USB_BULK_CS_SIG); + csw->Signature = cpu_to_le32(USB_BULK_CS_SIG); csw->Tag = fsg->tag; csw->Residue = cpu_to_le32(fsg->residue); csw->Status = status; @@ -3089,7 +3089,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) /* Is the CBW valid? */ if (req->actual != USB_BULK_CB_WRAP_LEN || - cbw->Signature != __constant_cpu_to_le32( + cbw->Signature != cpu_to_le32( USB_BULK_CB_SIG)) { DBG(fsg, "invalid CBW: len %u sig 0x%x\n", req->actual, diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 60d3f9e9b51..bb738bc96d4 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c @@ -199,10 +199,10 @@ DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(1); static struct usb_device_descriptor device_desc = { .bLength = USB_DT_DEVICE_SIZE, .bDescriptorType = USB_DT_DEVICE, - .bcdUSB = __constant_cpu_to_le16(0x0200), + .bcdUSB = cpu_to_le16(0x0200), .bDeviceClass = USB_CLASS_PER_INTERFACE, - .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_NUM), - .idProduct = __constant_cpu_to_le16(DRIVER_PRODUCT_NUM), + .idVendor = cpu_to_le16(DRIVER_VENDOR_NUM), + .idProduct = cpu_to_le16(DRIVER_PRODUCT_NUM), .iManufacturer = STRING_MANUFACTURER, .iProduct = STRING_PRODUCT, .bNumConfigurations = 1, @@ -241,8 +241,8 @@ static const struct usb_ac_header_descriptor_1 ac_header_desc = { .bLength = USB_DT_AC_HEADER_SIZE(1), .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubtype = USB_MS_HEADER, - .bcdADC = __constant_cpu_to_le16(0x0100), - .wTotalLength = __constant_cpu_to_le16(USB_DT_AC_HEADER_SIZE(1)), + .bcdADC = cpu_to_le16(0x0100), + .wTotalLength = cpu_to_le16(USB_DT_AC_HEADER_SIZE(1)), .bInCollection = 1, .baInterfaceNr = { [0] = GMIDI_MS_INTERFACE, @@ -265,8 +265,8 @@ static const struct usb_ms_header_descriptor ms_header_desc = { .bLength = USB_DT_MS_HEADER_SIZE, .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubtype = USB_MS_HEADER, - .bcdMSC = __constant_cpu_to_le16(0x0100), - .wTotalLength = __constant_cpu_to_le16(USB_DT_MS_HEADER_SIZE + .bcdMSC = cpu_to_le16(0x0100), + .wTotalLength = cpu_to_le16(USB_DT_MS_HEADER_SIZE + 2*USB_DT_MIDI_IN_SIZE + 2*USB_DT_MIDI_OUT_SIZE(1)), }; @@ -1227,7 +1227,7 @@ autoconf_fail: */ pr_warning("%s: controller '%s' not recognized\n", shortname, gadget->name); - device_desc.bcdDevice = __constant_cpu_to_le16(0x9999); + device_desc.bcdDevice = cpu_to_le16(0x9999); } diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 63419c4d503..de010c939db 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c @@ -1472,7 +1472,7 @@ static void ep0_setup(struct goku_udc *dev) /* active endpoint */ if (tmp > 3 || (!dev->ep[tmp].desc && tmp != 0)) goto stall; - if (ctrl.wIndex & __constant_cpu_to_le16( + if (ctrl.wIndex & cpu_to_le16( USB_DIR_IN)) { if (!dev->ep[tmp].is_in) goto stall; @@ -1480,7 +1480,7 @@ static void ep0_setup(struct goku_udc *dev) if (dev->ep[tmp].is_in) goto stall; } - if (ctrl.wValue != __constant_cpu_to_le16( + if (ctrl.wValue != cpu_to_le16( USB_ENDPOINT_HALT)) goto stall; if (tmp) @@ -1493,7 +1493,7 @@ succeed: return; case USB_RECIP_DEVICE: /* device remote wakeup: always clear */ - if (ctrl.wValue != __constant_cpu_to_le16(1)) + if (ctrl.wValue != cpu_to_le16(1)) goto stall; VDBG(dev, "clear dev remote wakeup\n"); goto succeed; @@ -1519,7 +1519,7 @@ succeed: dev->req_config = (ctrl.bRequest == USB_REQ_SET_CONFIGURATION && ctrl.bRequestType == USB_RECIP_DEVICE); if (unlikely(dev->req_config)) - dev->configured = (ctrl.wValue != __constant_cpu_to_le16(0)); + dev->configured = (ctrl.wValue != cpu_to_le16(0)); /* delegate everything to the gadget driver. * it may respond after this irq handler returns. diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index 317b48fdbf0..d20937f28a1 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c @@ -1334,7 +1334,7 @@ static void make_qualifier (struct dev_data *dev) qual.bLength = sizeof qual; qual.bDescriptorType = USB_DT_DEVICE_QUALIFIER; - qual.bcdUSB = __constant_cpu_to_le16 (0x0200); + qual.bcdUSB = cpu_to_le16 (0x0200); desc = dev->dev; qual.bDeviceClass = desc->bDeviceClass; @@ -1908,7 +1908,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) || dev->dev->bNumConfigurations != 1) goto fail; dev->dev->bNumConfigurations = 1; - dev->dev->bcdUSB = __constant_cpu_to_le16 (0x0200); + dev->dev->bcdUSB = cpu_to_le16 (0x0200); /* triggers gadgetfs_bind(); then we can enumerate. */ spin_unlock_irq (&dev->lock); diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index 12c6d83b218..9498be87a72 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c @@ -142,8 +142,8 @@ static char *type_string (u8 bmAttributes) #include "net2280.h" -#define valid_bit __constant_cpu_to_le32 (1 << VALID_BIT) -#define dma_done_ie __constant_cpu_to_le32 (1 << DMA_DONE_INTERRUPT_ENABLE) +#define valid_bit cpu_to_le32 (1 << VALID_BIT) +#define dma_done_ie cpu_to_le32 (1 << DMA_DONE_INTERRUPT_ENABLE) /*-------------------------------------------------------------------------*/ @@ -425,7 +425,7 @@ net2280_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags) return NULL; } td->dmacount = 0; /* not VALID */ - td->dmaaddr = __constant_cpu_to_le32 (DMA_ADDR_INVALID); + td->dmaaddr = cpu_to_le32 (DMA_ADDR_INVALID); td->dmadesc = td->dmaaddr; req->td = td; } @@ -775,7 +775,7 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req) fill_dma_desc (ep, req, 1); if (!use_dma_chaining) - req->td->dmacount |= __constant_cpu_to_le32 (1 << END_OF_CHAIN); + req->td->dmacount |= cpu_to_le32 (1 << END_OF_CHAIN); start_queue (ep, tmp, req->td_dma); } @@ -2407,9 +2407,9 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) if (readl (&e->regs->ep_rsp) & (1 << SET_ENDPOINT_HALT)) - status = __constant_cpu_to_le32 (1); + status = cpu_to_le32 (1); else - status = __constant_cpu_to_le32 (0); + status = cpu_to_le32 (0); /* don't bother with a request object! */ writel (0, &dev->epregs [0].ep_irqenb); @@ -2667,7 +2667,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat) req = list_entry (ep->queue.next, struct net2280_request, queue); dmacount = req->td->dmacount; - dmacount &= __constant_cpu_to_le32 ( + dmacount &= cpu_to_le32 ( (1 << VALID_BIT) | DMA_BYTE_COUNT_MASK); if (dmacount && (dmacount & valid_bit) == 0) @@ -2881,7 +2881,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) goto done; } td->dmacount = 0; /* not VALID */ - td->dmaaddr = __constant_cpu_to_le32 (DMA_ADDR_INVALID); + td->dmaaddr = cpu_to_le32 (DMA_ADDR_INVALID); td->dmadesc = td->dmaaddr; dev->ep [i].dummy = td; } diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 5a3034fdfe4..29500154d00 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c @@ -225,12 +225,12 @@ module_param(qlen, uint, S_IRUGO|S_IWUSR); static struct usb_device_descriptor device_desc = { .bLength = sizeof device_desc, .bDescriptorType = USB_DT_DEVICE, - .bcdUSB = __constant_cpu_to_le16(0x0200), + .bcdUSB = cpu_to_le16(0x0200), .bDeviceClass = USB_CLASS_PER_INTERFACE, .bDeviceSubClass = 0, .bDeviceProtocol = 0, - .idVendor = __constant_cpu_to_le16(PRINTER_VENDOR_NUM), - .idProduct = __constant_cpu_to_le16(PRINTER_PRODUCT_NUM), + .idVendor = cpu_to_le16(PRINTER_VENDOR_NUM), + .idProduct = cpu_to_le16(PRINTER_PRODUCT_NUM), .iManufacturer = STRING_MANUFACTURER, .iProduct = STRING_PRODUCT, .iSerialNumber = STRING_SERIALNUM, @@ -299,20 +299,20 @@ static struct usb_endpoint_descriptor hs_ep_in_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512) + .wMaxPacketSize = cpu_to_le16(512) }; static struct usb_endpoint_descriptor hs_ep_out_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512) + .wMaxPacketSize = cpu_to_le16(512) }; static struct usb_qualifier_descriptor dev_qualifier = { .bLength = sizeof dev_qualifier, .bDescriptorType = USB_DT_DEVICE_QUALIFIER, - .bcdUSB = __constant_cpu_to_le16(0x0200), + .bcdUSB = cpu_to_le16(0x0200), .bDeviceClass = USB_CLASS_PRINTER, .bNumConfigurations = 1 }; @@ -1406,16 +1406,16 @@ printer_bind(struct usb_gadget *gadget) gadget->name); /* unrecognized, but safe unless bulk is REALLY quirky */ device_desc.bcdDevice = - __constant_cpu_to_le16(0xFFFF); + cpu_to_le16(0xFFFF); } snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s", init_utsname()->sysname, init_utsname()->release, gadget->name); device_desc.idVendor = - __constant_cpu_to_le16(PRINTER_VENDOR_NUM); + cpu_to_le16(PRINTER_VENDOR_NUM); device_desc.idProduct = - __constant_cpu_to_le16(PRINTER_PRODUCT_NUM); + cpu_to_le16(PRINTER_PRODUCT_NUM); /* support optional vendor/distro customization */ if (idVendor) { diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 37879af1c43..f46a60962da 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c @@ -87,12 +87,12 @@ static struct usb_gadget_strings *dev_strings[] = { static struct usb_device_descriptor device_desc = { .bLength = USB_DT_DEVICE_SIZE, .bDescriptorType = USB_DT_DEVICE, - .bcdUSB = __constant_cpu_to_le16(0x0200), + .bcdUSB = cpu_to_le16(0x0200), /* .bDeviceClass = f(use_acm) */ .bDeviceSubClass = 0, .bDeviceProtocol = 0, /* .bMaxPacketSize0 = f(hardware) */ - .idVendor = __constant_cpu_to_le16(GS_VENDOR_ID), + .idVendor = cpu_to_le16(GS_VENDOR_ID), /* .idProduct = f(use_acm) */ /* .bcdDevice = f(hardware) */ /* .iManufacturer = DYNAMIC */ @@ -216,7 +216,7 @@ static int __init gs_bind(struct usb_composite_dev *cdev) pr_warning("gs_bind: controller '%s' not recognized\n", gadget->name); device_desc.bcdDevice = - __constant_cpu_to_le16(GS_VERSION_NUM | 0x0099); + cpu_to_le16(GS_VERSION_NUM | 0x0099); } if (gadget_is_otg(cdev->gadget)) { @@ -255,19 +255,19 @@ static int __init init(void) serial_config_driver.bConfigurationValue = 2; device_desc.bDeviceClass = USB_CLASS_COMM; device_desc.idProduct = - __constant_cpu_to_le16(GS_CDC_PRODUCT_ID); + cpu_to_le16(GS_CDC_PRODUCT_ID); } else if (use_obex) { serial_config_driver.label = "CDC OBEX config"; serial_config_driver.bConfigurationValue = 3; device_desc.bDeviceClass = USB_CLASS_COMM; device_desc.idProduct = - __constant_cpu_to_le16(GS_CDC_OBEX_PRODUCT_ID); + cpu_to_le16(GS_CDC_OBEX_PRODUCT_ID); } else { serial_config_driver.label = "Generic Serial config"; serial_config_driver.bConfigurationValue = 1; device_desc.bDeviceClass = USB_CLASS_VENDOR_SPEC; device_desc.idProduct = - __constant_cpu_to_le16(GS_PRODUCT_ID); + cpu_to_le16(GS_PRODUCT_ID); } strings_dev[STRING_DESCRIPTION_IDX].s = serial_config_driver.label; diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c index 53d59287f2b..0a4d99ab40d 100644 --- a/drivers/usb/gadget/u_serial.c +++ b/drivers/usb/gadget/u_serial.c @@ -1092,7 +1092,7 @@ int __init gserial_setup(struct usb_gadget *g, unsigned count) gs_tty_driver->init_termios.c_ispeed = 9600; gs_tty_driver->init_termios.c_ospeed = 9600; - coding.dwDTERate = __constant_cpu_to_le32(9600); + coding.dwDTERate = cpu_to_le32(9600); coding.bCharFormat = 8; coding.bParityType = USB_CDC_NO_PARITY; coding.bDataBits = USB_CDC_1_STOP_BITS; diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 361d9659ac4..20614dce8db 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c @@ -113,11 +113,11 @@ static struct usb_device_descriptor device_desc = { .bLength = sizeof device_desc, .bDescriptorType = USB_DT_DEVICE, - .bcdUSB = __constant_cpu_to_le16(0x0200), + .bcdUSB = cpu_to_le16(0x0200), .bDeviceClass = USB_CLASS_VENDOR_SPEC, - .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_NUM), - .idProduct = __constant_cpu_to_le16(DRIVER_PRODUCT_NUM), + .idVendor = cpu_to_le16(DRIVER_VENDOR_NUM), + .idProduct = cpu_to_le16(DRIVER_PRODUCT_NUM), .bNumConfigurations = 2, }; @@ -265,7 +265,7 @@ static int __init zero_bind(struct usb_composite_dev *cdev) */ pr_warning("%s: controller '%s' not recognized\n", longname, gadget->name); - device_desc.bcdDevice = __constant_cpu_to_le16(0x9999); + device_desc.bcdDevice = cpu_to_le16(0x9999); } -- cgit v1.2.3 From b2bdf3a789162aa6ff9c6f139bee9cc7954bc5b4 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 12 Feb 2009 15:09:47 +0200 Subject: USB: composite: avoid inconsistent lock state Avoid the following INFO from lock debugging: [ 369.126112] ================================= [ 369.132063] [ INFO: inconsistent lock state ] [ 369.136457] 2.6.28-maemo1 #1 [ 369.139387] --------------------------------- [ 369.143782] inconsistent {hardirq-on-W} -> {in-hardirq-W} usage. [ 369.149855] swapper/0 [HC1[1]:SC0[0]:HE0:SE1] takes: [ 369.154890] (&cdev->lock){+-..}, at: [] composite_disconnect+0x1c/0] [ 369.163404] {hardirq-on-W} state was registered at: [ 369.168348] [] __lock_acquire+0x5d0/0x7d8 [ 369.173506] [] lock_acquire+0x64/0x78 [ 369.178266] [] _spin_lock+0x4c/0x80 [ 369.182905] [] usb_function_deactivate+0x20/0x70 [g_nokia] [ 369.189527] [] 0xbf1a0a88 [ 369.193281] [] 0xbf19f450 [ 369.197004] [] 0xbf19fa3c [ 369.200758] [] 0xbf1a03a0 [ 369.204481] [] 0xbf19f254 [ 369.208204] [] 0xbf1a0158 [ 369.211927] [] 0xbf1a130c [ 369.215650] [] usb_gadget_register_driver+0x12c/0x28c [ 369.221846] [] 0xbf1a06bc [ 369.225569] [] 0xbf1a06e8 [ 369.229322] [] __exception_text_end+0x64/0x19c [ 369.234877] [] sys_init_module+0x9c/0x194 [ 369.240004] [] ret_fast_syscall+0x0/0x2c [ 369.245039] [] 0xffffffff [ 369.248793] irq event stamp: 218356 [ 369.252302] hardirqs last enabled at (218355): [] omap3_enter_idle+8 [ 369.260420] hardirqs last disabled at (218356): [] __irq_svc+0x34/0x0 [ 369.267927] softirqs last enabled at (218348): [] __do_softirq+0x134 [ 369.275892] softirqs last disabled at (218335): [] irq_exit+0x60/0xb0 [ 369.283308] [ 369.283308] other info that might help us debug this: [ 369.289930] no locks held by swapper/0. Cc: David Brownell Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/composite.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 5d11c291f1a..40f1da77a00 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -149,16 +149,17 @@ done: int usb_function_deactivate(struct usb_function *function) { struct usb_composite_dev *cdev = function->config->cdev; + unsigned long flags; int status = 0; - spin_lock(&cdev->lock); + spin_lock_irqsave(&cdev->lock, flags); if (cdev->deactivations == 0) status = usb_gadget_disconnect(cdev->gadget); if (status == 0) cdev->deactivations++; - spin_unlock(&cdev->lock); + spin_unlock_irqrestore(&cdev->lock, flags); return status; } -- cgit v1.2.3 From 16e2e5f634f86ccda18366967c4e592eb61bc9cc Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 3 Mar 2009 16:44:13 -0800 Subject: USB: make transfer_buffer_lengths in struct urb field u32 Roel Kluin pointed out that transfer_buffer_lengths in struct urb was declared as an 'int'. This patch changes this field to be 'u32' to prevent any potential negative conversion and comparison errors. This triggered a few compiler warning messages when these fields were being used with the min macro, so they have also been fixed up in this patch. Cc: Roel Kluin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/dummy_hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 3b42888b72f..a56b24d305f 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c @@ -1437,7 +1437,7 @@ restart: } if (urb->transfer_buffer_length > 1) buf [1] = 0; - urb->actual_length = min (2, + urb->actual_length = min_t(u32, 2, urb->transfer_buffer_length); value = 0; status = 0; -- cgit v1.2.3 From 8942939a6c83f34615de5ae041cc9ca846923f94 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Thu, 19 Mar 2009 14:14:17 -0700 Subject: USB: gadget: composite device-level suspend/resume hooks Address one open question in the composite gadget framework: Yes, we should have device-level suspend/resume callbacks in addition to the function-level ones. We have at least one scenario (with gadget zero in OTG test mode) that's awkward to handle without it. Signed-off-by: David Brownell Cc: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/composite.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 40f1da77a00..59e85234fa0 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1014,7 +1014,7 @@ composite_suspend(struct usb_gadget *gadget) struct usb_composite_dev *cdev = get_gadget_data(gadget); struct usb_function *f; - /* REVISIT: should we have config and device level + /* REVISIT: should we have config level * suspend/resume callbacks? */ DBG(cdev, "suspend\n"); @@ -1024,6 +1024,8 @@ composite_suspend(struct usb_gadget *gadget) f->suspend(f); } } + if (composite->suspend) + composite->suspend(cdev); } static void @@ -1032,10 +1034,12 @@ composite_resume(struct usb_gadget *gadget) struct usb_composite_dev *cdev = get_gadget_data(gadget); struct usb_function *f; - /* REVISIT: should we have config and device level + /* REVISIT: should we have config level * suspend/resume callbacks? */ DBG(cdev, "resume\n"); + if (composite->resume) + composite->resume(cdev); if (cdev->config) { list_for_each_entry(f, &cdev->config->functions, list) { if (f->resume) -- cgit v1.2.3 From ab943a2e125b098489ccaa0166c2c52f8266d9ed Mon Sep 17 00:00:00 2001 From: David Brownell Date: Thu, 19 Mar 2009 14:16:09 -0700 Subject: USB: gadget: gadget zero uses new suspend/resume hooks Use the new device-level suspend/resume hooks for Gadget Zero; always enable them with the OTG test mode; and support remote wakeup on both configurations even in non-OTG mode. This ensures that both configurations can pass the USBCV remote wakeup tests when the OTG test mode is enabled. This changes behavior by adding autoresume support to the loopback config even in non-OTG mode; the test failure was that it didn't work in OTG mode. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/f_loopback.c | 6 +++- drivers/usb/gadget/f_sourcesink.c | 52 +---------------------------- drivers/usb/gadget/g_zero.h | 4 +-- drivers/usb/gadget/zero.c | 70 ++++++++++++++++++++++++++++++++++++--- 4 files changed, 74 insertions(+), 58 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c index 83301bdcdd1..eb6ddfc2085 100644 --- a/drivers/usb/gadget/f_loopback.c +++ b/drivers/usb/gadget/f_loopback.c @@ -359,7 +359,7 @@ static struct usb_configuration loopback_driver = { * loopback_add - add a loopback testing configuration to a device * @cdev: the device to support the loopback configuration */ -int __init loopback_add(struct usb_composite_dev *cdev) +int __init loopback_add(struct usb_composite_dev *cdev, bool autoresume) { int id; @@ -372,6 +372,10 @@ int __init loopback_add(struct usb_composite_dev *cdev) loopback_intf.iInterface = id; loopback_driver.iConfiguration = id; + /* support autoresume for remote wakeup testing */ + if (autoresume) + sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; + /* support OTG systems */ if (gadget_is_otg(cdev->gadget)) { loopback_driver.descriptors = otg_desc; diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c index 6aca5c81414..bffe91d525f 100644 --- a/drivers/usb/gadget/f_sourcesink.c +++ b/drivers/usb/gadget/f_sourcesink.c @@ -59,7 +59,6 @@ struct f_sourcesink { struct usb_ep *in_ep; struct usb_ep *out_ep; - struct timer_list resume; }; static inline struct f_sourcesink *func_to_ss(struct usb_function *f) @@ -67,10 +66,6 @@ static inline struct f_sourcesink *func_to_ss(struct usb_function *f) return container_of(f, struct f_sourcesink, function); } -static unsigned autoresume; -module_param(autoresume, uint, 0); -MODULE_PARM_DESC(autoresume, "zero, or seconds before remote wakeup"); - static unsigned pattern; module_param(pattern, uint, 0); MODULE_PARM_DESC(pattern, "0 = all zeroes, 1 = mod63 "); @@ -155,21 +150,6 @@ static struct usb_gadget_strings *sourcesink_strings[] = { /*-------------------------------------------------------------------------*/ -static void sourcesink_autoresume(unsigned long _c) -{ - struct usb_composite_dev *cdev = (void *)_c; - struct usb_gadget *g = cdev->gadget; - - /* Normally the host would be woken up for something - * more significant than just a timer firing; likely - * because of some direct user request. - */ - if (g->speed != USB_SPEED_UNKNOWN) { - int status = usb_gadget_wakeup(g); - DBG(cdev, "%s --> %d\n", __func__, status); - } -} - static int __init sourcesink_bind(struct usb_configuration *c, struct usb_function *f) { @@ -198,9 +178,6 @@ autoconf_fail: goto autoconf_fail; ss->out_ep->driver_data = cdev; /* claim */ - setup_timer(&ss->resume, sourcesink_autoresume, - (unsigned long) c->cdev); - /* support high speed hardware */ if (gadget_is_dualspeed(c->cdev->gadget)) { hs_source_desc.bEndpointAddress = @@ -359,7 +336,6 @@ static void disable_source_sink(struct f_sourcesink *ss) cdev = ss->function.config->cdev; disable_endpoints(cdev, ss->in_ep, ss->out_ep); - del_timer(&ss->resume); VDBG(cdev, "%s disabled\n", ss->function.name); } @@ -426,30 +402,6 @@ static void sourcesink_disable(struct usb_function *f) disable_source_sink(ss); } -static void sourcesink_suspend(struct usb_function *f) -{ - struct f_sourcesink *ss = func_to_ss(f); - struct usb_composite_dev *cdev = f->config->cdev; - - if (cdev->gadget->speed == USB_SPEED_UNKNOWN) - return; - - if (autoresume) { - mod_timer(&ss->resume, jiffies + (HZ * autoresume)); - DBG(cdev, "suspend, wakeup in %d seconds\n", autoresume); - } else - DBG(cdev, "%s\n", __func__); -} - -static void sourcesink_resume(struct usb_function *f) -{ - struct f_sourcesink *ss = func_to_ss(f); - struct usb_composite_dev *cdev = f->config->cdev; - - DBG(cdev, "%s\n", __func__); - del_timer(&ss->resume); -} - /*-------------------------------------------------------------------------*/ static int __init sourcesink_bind_config(struct usb_configuration *c) @@ -467,8 +419,6 @@ static int __init sourcesink_bind_config(struct usb_configuration *c) ss->function.unbind = sourcesink_unbind; ss->function.set_alt = sourcesink_set_alt; ss->function.disable = sourcesink_disable; - ss->function.suspend = sourcesink_suspend; - ss->function.resume = sourcesink_resume; status = usb_add_function(c, &ss->function); if (status) @@ -559,7 +509,7 @@ static struct usb_configuration sourcesink_driver = { * sourcesink_add - add a source/sink testing configuration to a device * @cdev: the device to support the configuration */ -int __init sourcesink_add(struct usb_composite_dev *cdev) +int __init sourcesink_add(struct usb_composite_dev *cdev, bool autoresume) { int id; diff --git a/drivers/usb/gadget/g_zero.h b/drivers/usb/gadget/g_zero.h index dd2f16ad5a8..e84b3c47ed3 100644 --- a/drivers/usb/gadget/g_zero.h +++ b/drivers/usb/gadget/g_zero.h @@ -19,7 +19,7 @@ void disable_endpoints(struct usb_composite_dev *cdev, struct usb_ep *in, struct usb_ep *out); /* configuration-specific linkup */ -int sourcesink_add(struct usb_composite_dev *cdev); -int loopback_add(struct usb_composite_dev *cdev); +int sourcesink_add(struct usb_composite_dev *cdev, bool autoresume); +int loopback_add(struct usb_composite_dev *cdev, bool autoresume); #endif /* __G_ZERO_H */ diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 20614dce8db..2d772401b7a 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c @@ -102,11 +102,21 @@ module_param(loopdefault, bool, S_IRUGO|S_IWUSR); #ifndef CONFIG_USB_ZERO_HNPTEST #define DRIVER_VENDOR_NUM 0x0525 /* NetChip */ #define DRIVER_PRODUCT_NUM 0xa4a0 /* Linux-USB "Gadget Zero" */ +#define DEFAULT_AUTORESUME 0 #else #define DRIVER_VENDOR_NUM 0x1a0a /* OTG test device IDs */ #define DRIVER_PRODUCT_NUM 0xbadd +#define DEFAULT_AUTORESUME 5 #endif +/* If the optional "autoresume" mode is enabled, it provides good + * functional coverage for the "USBCV" test harness from USB-IF. + * It's always set if OTG mode is enabled. + */ +unsigned autoresume = DEFAULT_AUTORESUME; +module_param(autoresume, uint, S_IRUGO); +MODULE_PARM_DESC(autoresume, "zero, or seconds before remote wakeup"); + /*-------------------------------------------------------------------------*/ static struct usb_device_descriptor device_desc = { @@ -212,6 +222,47 @@ void disable_endpoints(struct usb_composite_dev *cdev, /*-------------------------------------------------------------------------*/ +static struct timer_list autoresume_timer; + +static void zero_autoresume(unsigned long _c) +{ + struct usb_composite_dev *cdev = (void *)_c; + struct usb_gadget *g = cdev->gadget; + + /* unconfigured devices can't issue wakeups */ + if (!cdev->config) + return; + + /* Normally the host would be woken up for something + * more significant than just a timer firing; likely + * because of some direct user request. + */ + if (g->speed != USB_SPEED_UNKNOWN) { + int status = usb_gadget_wakeup(g); + INFO(cdev, "%s --> %d\n", __func__, status); + } +} + +static void zero_suspend(struct usb_composite_dev *cdev) +{ + if (cdev->gadget->speed == USB_SPEED_UNKNOWN) + return; + + if (autoresume) { + mod_timer(&autoresume_timer, jiffies + (HZ * autoresume)); + DBG(cdev, "suspend, wakeup in %d seconds\n", autoresume); + } else + DBG(cdev, "%s\n", __func__); +} + +static void zero_resume(struct usb_composite_dev *cdev) +{ + DBG(cdev, "%s\n", __func__); + del_timer(&autoresume_timer); +} + +/*-------------------------------------------------------------------------*/ + static int __init zero_bind(struct usb_composite_dev *cdev) { int gcnum; @@ -239,17 +290,19 @@ static int __init zero_bind(struct usb_composite_dev *cdev) strings_dev[STRING_SERIAL_IDX].id = id; device_desc.iSerialNumber = id; + setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev); + /* Register primary, then secondary configuration. Note that * SH3 only allows one config... */ if (loopdefault) { - loopback_add(cdev); + loopback_add(cdev, autoresume != 0); if (!gadget_is_sh(gadget)) - sourcesink_add(cdev); + sourcesink_add(cdev, autoresume != 0); } else { - sourcesink_add(cdev); + sourcesink_add(cdev, autoresume != 0); if (!gadget_is_sh(gadget)) - loopback_add(cdev); + loopback_add(cdev, autoresume != 0); } gcnum = usb_gadget_controller_number(gadget); @@ -278,11 +331,20 @@ static int __init zero_bind(struct usb_composite_dev *cdev) return 0; } +static int zero_unbind(struct usb_composite_dev *cdev) +{ + del_timer_sync(&autoresume_timer); + return 0; +} + static struct usb_composite_driver zero_driver = { .name = "zero", .dev = &device_desc, .strings = dev_strings, .bind = zero_bind, + .unbind = zero_unbind, + .suspend = zero_suspend, + .resume = zero_resume, }; MODULE_AUTHOR("David Brownell"); -- cgit v1.2.3 From 4c24b6d045a9d355c95ca4e6beb10ce2fd263390 Mon Sep 17 00:00:00 2001 From: Vernon Sauder Date: Fri, 20 Mar 2009 01:44:50 -0700 Subject: USB: pxa27x_udc: typo fixes and code cleanups This patch is a merge of patches : - fix function doc and debug - cleanup loop count - optimize code to remove local variable and extra check - init 'req' before use - add missing iounmap call [dbrownell@users.sourceforge.net: capitalize IN/OUT directions in doc] Signed-off-by: Vernon Sauder [folded by Robert Jarzmik Signed-off-by: Robert Jarzmik Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/pxa27x_udc.c | 54 ++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 30 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index 91ba1e93947..8cc676ecbb2 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c @@ -748,13 +748,13 @@ static void req_done(struct pxa_ep *ep, struct pxa27x_request *req, int status) } /** - * ep_end_out_req - Ends control endpoint in request + * ep_end_out_req - Ends endpoint OUT request * @ep: physical endpoint * @req: pxa request * * Context: ep->lock held * - * Ends endpoint in request (completes usb request). + * Ends endpoint OUT request (completes usb request). */ static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) { @@ -763,13 +763,13 @@ static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) } /** - * ep0_end_out_req - Ends control endpoint in request (ends data stage) + * ep0_end_out_req - Ends control endpoint OUT request (ends data stage) * @ep: physical endpoint * @req: pxa request * * Context: ep->lock held * - * Ends control endpoint in request (completes usb request), and puts + * Ends control endpoint OUT request (completes usb request), and puts * control endpoint into idle state */ static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) @@ -780,13 +780,13 @@ static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) } /** - * ep_end_in_req - Ends endpoint out request + * ep_end_in_req - Ends endpoint IN request * @ep: physical endpoint * @req: pxa request * * Context: ep->lock held * - * Ends endpoint out request (completes usb request). + * Ends endpoint IN request (completes usb request). */ static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) { @@ -795,20 +795,18 @@ static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) } /** - * ep0_end_in_req - Ends control endpoint out request (ends data stage) + * ep0_end_in_req - Ends control endpoint IN request (ends data stage) * @ep: physical endpoint * @req: pxa request * * Context: ep->lock held * - * Ends control endpoint out request (completes usb request), and puts + * Ends control endpoint IN request (completes usb request), and puts * control endpoint into status state */ static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) { - struct pxa_udc *udc = ep->dev; - - set_ep0state(udc, IN_STATUS_STAGE); + set_ep0state(ep->dev, IN_STATUS_STAGE); ep_end_in_req(ep, req); } @@ -1168,7 +1166,7 @@ static int pxa_ep_queue(struct usb_ep *_ep, struct usb_request *_req, ep_end_in_req(ep, req); } else { ep_err(ep, "got a request of %d bytes while" - "in state WATI_ACK_SET_CONF_INTERF\n", + "in state WAIT_ACK_SET_CONF_INTERF\n", length); ep_del_request(ep, req); rc = -EL2HLT; @@ -1214,30 +1212,26 @@ static int pxa_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) struct udc_usb_ep *udc_usb_ep; struct pxa27x_request *req; unsigned long flags; - int rc; + int rc = -EINVAL; if (!_ep) - return -EINVAL; + return rc; udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); ep = udc_usb_ep->pxa_ep; if (!ep || is_ep0(ep)) - return -EINVAL; + return rc; spin_lock_irqsave(&ep->lock, flags); /* make sure it's actually queued on this endpoint */ list_for_each_entry(req, &ep->queue, queue) { - if (&req->req == _req) + if (&req->req == _req) { + req_done(ep, req, -ECONNRESET); + rc = 0; break; + } } - rc = -EINVAL; - if (&req->req != _req) - goto out; - - rc = 0; - req_done(ep, req, -ECONNRESET); -out: spin_unlock_irqrestore(&ep->lock, flags); return rc; } @@ -1706,10 +1700,9 @@ static __init void udc_init_data(struct pxa_udc *dev) } /* USB endpoints init */ - for (i = 0; i < NR_USB_ENDPOINTS; i++) - if (i != 0) - list_add_tail(&dev->udc_usb_ep[i].usb_ep.ep_list, - &dev->gadget.ep_list); + for (i = 1; i < NR_USB_ENDPOINTS; i++) + list_add_tail(&dev->udc_usb_ep[i].usb_ep.ep_list, + &dev->gadget.ep_list); } /** @@ -1994,14 +1987,14 @@ static void handle_ep0(struct pxa_udc *udc, int fifo_irq, int opc_irq) struct pxa27x_request *req = NULL; int completed = 0; + if (!list_empty(&ep->queue)) + req = list_entry(ep->queue.next, struct pxa27x_request, queue); + udccsr0 = udc_ep_readl(ep, UDCCSR); ep_dbg(ep, "state=%s, req=%p, udccsr0=0x%03x, udcbcr=%d, irq_msk=%x\n", EP0_STNAME(udc), req, udccsr0, udc_ep_readl(ep, UDCBCR), (fifo_irq << 1 | opc_irq)); - if (!list_empty(&ep->queue)) - req = list_entry(ep->queue.next, struct pxa27x_request, queue); - if (udccsr0 & UDCCSR0_SST) { ep_dbg(ep, "clearing stall status\n"); nuke(ep, -EPIPE); @@ -2473,6 +2466,7 @@ static int __exit pxa_udc_remove(struct platform_device *_dev) platform_set_drvdata(_dev, NULL); the_controller = NULL; clk_put(udc->clk); + iounmap(udc->regs); return 0; } -- cgit v1.2.3 From 5df5852446196c9713e897ab5f9b8a168d971a00 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Tue, 24 Mar 2009 16:38:23 -0700 Subject: usb: struct device - replace bus_id with dev_name(), dev_set_name() Acked-by: Greg Kroah-Hartman Signed-off-by: Kay Sievers --- drivers/usb/gadget/ci13xxx_udc.c | 2 +- drivers/usb/gadget/imx_udc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/usb/gadget') diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c index bebf911c7e5..7f4e5eb1dc8 100644 --- a/drivers/usb/gadget/ci13xxx_udc.c +++ b/drivers/usb/gadget/ci13xxx_udc.c @@ -2626,7 +2626,7 @@ static int udc_probe(struct device *dev, void __iomem *regs, const char *name) INIT_LIST_HEAD(&udc->gadget.ep_list); udc->gadget.ep0 = NULL; - strcpy(udc->gadget.dev.bus_id, "gadget"); + dev_set_name(&udc->gadget.dev, "gadget"); udc->gadget.dev.dma_mask = dev->dma_mask; udc->gadget.dev.parent = dev; udc->gadget.dev.release = udc_release; diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c index 77c5d0a8a06..cd67ac75e62 100644 --- a/drivers/usb/gadget/imx_udc.c +++ b/drivers/usb/gadget/imx_udc.c @@ -1186,8 +1186,8 @@ static struct imx_udc_struct controller = { .ep0 = &controller.imx_ep[0].ep, .name = driver_name, .dev = { - .bus_id = "gadget", - }, + .init_name = "gadget", + }, }, .imx_ep[0] = { -- cgit v1.2.3