usb: gadget: net2280: print error in ep_ops error paths
Hopefully, these prints will help localize the problems faster. [ balbi@ti.com: removed 2 unnecessary OOM error messages ] Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
parent
fb2a85dd93
commit
9ceafcc2b3
|
@ -145,31 +145,44 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
|
||||||
u32 max, tmp;
|
u32 max, tmp;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
static const u32 ep_key[9] = { 1, 0, 1, 0, 1, 1, 0, 1, 0 };
|
static const u32 ep_key[9] = { 1, 0, 1, 0, 1, 1, 0, 1, 0 };
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
ep = container_of(_ep, struct net2280_ep, ep);
|
ep = container_of(_ep, struct net2280_ep, ep);
|
||||||
if (!_ep || !desc || ep->desc || _ep->name == ep0name ||
|
if (!_ep || !desc || ep->desc || _ep->name == ep0name ||
|
||||||
desc->bDescriptorType != USB_DT_ENDPOINT)
|
desc->bDescriptorType != USB_DT_ENDPOINT) {
|
||||||
|
pr_err("%s: failed at line=%d\n", __func__, __LINE__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
dev = ep->dev;
|
dev = ep->dev;
|
||||||
if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
|
if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) {
|
||||||
return -ESHUTDOWN;
|
ret = -ESHUTDOWN;
|
||||||
|
goto print_err;
|
||||||
|
}
|
||||||
|
|
||||||
/* erratum 0119 workaround ties up an endpoint number */
|
/* erratum 0119 workaround ties up an endpoint number */
|
||||||
if ((desc->bEndpointAddress & 0x0f) == EP_DONTUSE)
|
if ((desc->bEndpointAddress & 0x0f) == EP_DONTUSE) {
|
||||||
return -EDOM;
|
ret = -EDOM;
|
||||||
|
goto print_err;
|
||||||
|
}
|
||||||
|
|
||||||
if (dev->quirks & PLX_SUPERSPEED) {
|
if (dev->quirks & PLX_SUPERSPEED) {
|
||||||
if ((desc->bEndpointAddress & 0x0f) >= 0x0c)
|
if ((desc->bEndpointAddress & 0x0f) >= 0x0c) {
|
||||||
return -EDOM;
|
ret = -EDOM;
|
||||||
|
goto print_err;
|
||||||
|
}
|
||||||
ep->is_in = !!usb_endpoint_dir_in(desc);
|
ep->is_in = !!usb_endpoint_dir_in(desc);
|
||||||
if (dev->enhanced_mode && ep->is_in && ep_key[ep->num])
|
if (dev->enhanced_mode && ep->is_in && ep_key[ep->num]) {
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto print_err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sanity check ep-e/ep-f since their fifos are small */
|
/* sanity check ep-e/ep-f since their fifos are small */
|
||||||
max = usb_endpoint_maxp(desc) & 0x1fff;
|
max = usb_endpoint_maxp(desc) & 0x1fff;
|
||||||
if (ep->num > 4 && max > 64 && (dev->quirks & PLX_LEGACY))
|
if (ep->num > 4 && max > 64 && (dev->quirks & PLX_LEGACY)) {
|
||||||
return -ERANGE;
|
ret = -ERANGE;
|
||||||
|
goto print_err;
|
||||||
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->lock, flags);
|
spin_lock_irqsave(&dev->lock, flags);
|
||||||
_ep->maxpacket = max & 0x7ff;
|
_ep->maxpacket = max & 0x7ff;
|
||||||
|
@ -199,7 +212,8 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
|
||||||
(dev->gadget.speed == USB_SPEED_HIGH && max != 512) ||
|
(dev->gadget.speed == USB_SPEED_HIGH && max != 512) ||
|
||||||
(dev->gadget.speed == USB_SPEED_FULL && max > 64)) {
|
(dev->gadget.speed == USB_SPEED_FULL && max > 64)) {
|
||||||
spin_unlock_irqrestore(&dev->lock, flags);
|
spin_unlock_irqrestore(&dev->lock, flags);
|
||||||
return -ERANGE;
|
ret = -ERANGE;
|
||||||
|
goto print_err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC);
|
ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC);
|
||||||
|
@ -278,7 +292,11 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
|
||||||
|
|
||||||
/* pci writes may still be posted */
|
/* pci writes may still be posted */
|
||||||
spin_unlock_irqrestore(&dev->lock, flags);
|
spin_unlock_irqrestore(&dev->lock, flags);
|
||||||
return 0;
|
return ret;
|
||||||
|
|
||||||
|
print_err:
|
||||||
|
dev_err(&ep->dev->pdev->dev, "%s: error=%d\n", __func__, ret);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handshake(u32 __iomem *ptr, u32 mask, u32 done, int usec)
|
static int handshake(u32 __iomem *ptr, u32 mask, u32 done, int usec)
|
||||||
|
@ -433,9 +451,10 @@ static int net2280_disable(struct usb_ep *_ep)
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
ep = container_of(_ep, struct net2280_ep, ep);
|
ep = container_of(_ep, struct net2280_ep, ep);
|
||||||
if (!_ep || !ep->desc || _ep->name == ep0name)
|
if (!_ep || !ep->desc || _ep->name == ep0name) {
|
||||||
|
pr_err("%s: Invalid ep=%p or ep->desc\n", __func__, _ep);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
spin_lock_irqsave(&ep->dev->lock, flags);
|
spin_lock_irqsave(&ep->dev->lock, flags);
|
||||||
nuke(ep);
|
nuke(ep);
|
||||||
|
|
||||||
|
@ -465,8 +484,10 @@ static struct usb_request
|
||||||
struct net2280_ep *ep;
|
struct net2280_ep *ep;
|
||||||
struct net2280_request *req;
|
struct net2280_request *req;
|
||||||
|
|
||||||
if (!_ep)
|
if (!_ep) {
|
||||||
|
pr_err("%s: Invalid ep\n", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
ep = container_of(_ep, struct net2280_ep, ep);
|
ep = container_of(_ep, struct net2280_ep, ep);
|
||||||
|
|
||||||
req = kzalloc(sizeof(*req), gfp_flags);
|
req = kzalloc(sizeof(*req), gfp_flags);
|
||||||
|
@ -498,8 +519,11 @@ static void net2280_free_request(struct usb_ep *_ep, struct usb_request *_req)
|
||||||
struct net2280_request *req;
|
struct net2280_request *req;
|
||||||
|
|
||||||
ep = container_of(_ep, struct net2280_ep, ep);
|
ep = container_of(_ep, struct net2280_ep, ep);
|
||||||
if (!_ep || !_req)
|
if (!_ep || !_req) {
|
||||||
|
dev_err(&ep->dev->pdev->dev, "%s: Inavlid ep=%p or req=%p\n",
|
||||||
|
__func__, _ep, _req);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
req = container_of(_req, struct net2280_request, req);
|
req = container_of(_req, struct net2280_request, req);
|
||||||
WARN_ON(!list_empty(&req->queue));
|
WARN_ON(!list_empty(&req->queue));
|
||||||
|
@ -903,35 +927,44 @@ net2280_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
|
||||||
struct net2280_ep *ep;
|
struct net2280_ep *ep;
|
||||||
struct net2280 *dev;
|
struct net2280 *dev;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
/* we always require a cpu-view buffer, so that we can
|
/* we always require a cpu-view buffer, so that we can
|
||||||
* always use pio (as fallback or whatever).
|
* always use pio (as fallback or whatever).
|
||||||
*/
|
*/
|
||||||
|
ep = container_of(_ep, struct net2280_ep, ep);
|
||||||
|
if (!_ep || (!ep->desc && ep->num != 0)) {
|
||||||
|
pr_err("%s: Invalid ep=%p or ep->desc\n", __func__, _ep);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
req = container_of(_req, struct net2280_request, req);
|
req = container_of(_req, struct net2280_request, req);
|
||||||
if (!_req || !_req->complete || !_req->buf ||
|
if (!_req || !_req->complete || !_req->buf ||
|
||||||
!list_empty(&req->queue))
|
!list_empty(&req->queue)) {
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
if (_req->length > (~0 & DMA_BYTE_COUNT_MASK))
|
goto print_err;
|
||||||
return -EDOM;
|
}
|
||||||
ep = container_of(_ep, struct net2280_ep, ep);
|
if (_req->length > (~0 & DMA_BYTE_COUNT_MASK)) {
|
||||||
if (!_ep || (!ep->desc && ep->num != 0))
|
ret = -EDOM;
|
||||||
return -EINVAL;
|
goto print_err;
|
||||||
|
}
|
||||||
dev = ep->dev;
|
dev = ep->dev;
|
||||||
if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
|
if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) {
|
||||||
return -ESHUTDOWN;
|
ret = -ESHUTDOWN;
|
||||||
|
goto print_err;
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME implement PIO fallback for ZLPs with DMA */
|
/* FIXME implement PIO fallback for ZLPs with DMA */
|
||||||
if (ep->dma && _req->length == 0)
|
if (ep->dma && _req->length == 0) {
|
||||||
return -EOPNOTSUPP;
|
ret = -EOPNOTSUPP;
|
||||||
|
goto print_err;
|
||||||
|
}
|
||||||
|
|
||||||
/* set up dma mapping in case the caller didn't */
|
/* set up dma mapping in case the caller didn't */
|
||||||
if (ep->dma) {
|
if (ep->dma) {
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = usb_gadget_map_request(&dev->gadget, _req,
|
ret = usb_gadget_map_request(&dev->gadget, _req,
|
||||||
ep->is_in);
|
ep->is_in);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto print_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ep_vdbg(dev, "%s queue req %p, len %d buf %p\n",
|
ep_vdbg(dev, "%s queue req %p, len %d buf %p\n",
|
||||||
|
@ -1020,7 +1053,11 @@ net2280_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
|
||||||
spin_unlock_irqrestore(&dev->lock, flags);
|
spin_unlock_irqrestore(&dev->lock, flags);
|
||||||
|
|
||||||
/* pci writes may still be posted */
|
/* pci writes may still be posted */
|
||||||
return 0;
|
return ret;
|
||||||
|
|
||||||
|
print_err:
|
||||||
|
dev_err(&ep->dev->pdev->dev, "%s: error=%d\n", __func__, ret);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
@ -1141,8 +1178,11 @@ static int net2280_dequeue(struct usb_ep *_ep, struct usb_request *_req)
|
||||||
int stopped;
|
int stopped;
|
||||||
|
|
||||||
ep = container_of(_ep, struct net2280_ep, ep);
|
ep = container_of(_ep, struct net2280_ep, ep);
|
||||||
if (!_ep || (!ep->desc && ep->num != 0) || !_req)
|
if (!_ep || (!ep->desc && ep->num != 0) || !_req) {
|
||||||
|
pr_err("%s: Invalid ep=%p or ep->desc or req=%p\n",
|
||||||
|
__func__, _ep, _req);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&ep->dev->lock, flags);
|
spin_lock_irqsave(&ep->dev->lock, flags);
|
||||||
stopped = ep->stopped;
|
stopped = ep->stopped;
|
||||||
|
@ -1164,6 +1204,8 @@ static int net2280_dequeue(struct usb_ep *_ep, struct usb_request *_req)
|
||||||
}
|
}
|
||||||
if (&req->req != _req) {
|
if (&req->req != _req) {
|
||||||
spin_unlock_irqrestore(&ep->dev->lock, flags);
|
spin_unlock_irqrestore(&ep->dev->lock, flags);
|
||||||
|
dev_err(&ep->dev->pdev->dev, "%s: Request mismatch\n",
|
||||||
|
__func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1221,20 +1263,28 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
ep = container_of(_ep, struct net2280_ep, ep);
|
ep = container_of(_ep, struct net2280_ep, ep);
|
||||||
if (!_ep || (!ep->desc && ep->num != 0))
|
if (!_ep || (!ep->desc && ep->num != 0)) {
|
||||||
|
pr_err("%s: Invalid ep=%p or ep->desc\n", __func__, _ep);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN)
|
}
|
||||||
return -ESHUTDOWN;
|
if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN) {
|
||||||
|
retval = -ESHUTDOWN;
|
||||||
|
goto print_err;
|
||||||
|
}
|
||||||
if (ep->desc /* not ep0 */ && (ep->desc->bmAttributes & 0x03)
|
if (ep->desc /* not ep0 */ && (ep->desc->bmAttributes & 0x03)
|
||||||
== USB_ENDPOINT_XFER_ISOC)
|
== USB_ENDPOINT_XFER_ISOC) {
|
||||||
return -EINVAL;
|
retval = -EINVAL;
|
||||||
|
goto print_err;
|
||||||
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&ep->dev->lock, flags);
|
spin_lock_irqsave(&ep->dev->lock, flags);
|
||||||
if (!list_empty(&ep->queue))
|
if (!list_empty(&ep->queue)) {
|
||||||
retval = -EAGAIN;
|
retval = -EAGAIN;
|
||||||
else if (ep->is_in && value && net2280_fifo_status(_ep) != 0)
|
goto print_unlock;
|
||||||
|
} else if (ep->is_in && value && net2280_fifo_status(_ep) != 0) {
|
||||||
retval = -EAGAIN;
|
retval = -EAGAIN;
|
||||||
else {
|
goto print_unlock;
|
||||||
|
} else {
|
||||||
ep_vdbg(ep->dev, "%s %s %s\n", _ep->name,
|
ep_vdbg(ep->dev, "%s %s %s\n", _ep->name,
|
||||||
value ? "set" : "clear",
|
value ? "set" : "clear",
|
||||||
wedged ? "wedge" : "halt");
|
wedged ? "wedge" : "halt");
|
||||||
|
@ -1258,6 +1308,12 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
|
||||||
spin_unlock_irqrestore(&ep->dev->lock, flags);
|
spin_unlock_irqrestore(&ep->dev->lock, flags);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
|
print_unlock:
|
||||||
|
spin_unlock_irqrestore(&ep->dev->lock, flags);
|
||||||
|
print_err:
|
||||||
|
dev_err(&ep->dev->pdev->dev, "%s: error=%d\n", __func__, retval);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int net2280_set_halt(struct usb_ep *_ep, int value)
|
static int net2280_set_halt(struct usb_ep *_ep, int value)
|
||||||
|
@ -1267,8 +1323,10 @@ static int net2280_set_halt(struct usb_ep *_ep, int value)
|
||||||
|
|
||||||
static int net2280_set_wedge(struct usb_ep *_ep)
|
static int net2280_set_wedge(struct usb_ep *_ep)
|
||||||
{
|
{
|
||||||
if (!_ep || _ep->name == ep0name)
|
if (!_ep || _ep->name == ep0name) {
|
||||||
|
pr_err("%s: Invalid ep=%p or ep0\n", __func__, _ep);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
return net2280_set_halt_and_wedge(_ep, 1, 1);
|
return net2280_set_halt_and_wedge(_ep, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1278,14 +1336,22 @@ static int net2280_fifo_status(struct usb_ep *_ep)
|
||||||
u32 avail;
|
u32 avail;
|
||||||
|
|
||||||
ep = container_of(_ep, struct net2280_ep, ep);
|
ep = container_of(_ep, struct net2280_ep, ep);
|
||||||
if (!_ep || (!ep->desc && ep->num != 0))
|
if (!_ep || (!ep->desc && ep->num != 0)) {
|
||||||
|
pr_err("%s: Invalid ep=%p or ep->desc\n", __func__, _ep);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN)
|
}
|
||||||
|
if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN) {
|
||||||
|
dev_err(&ep->dev->pdev->dev,
|
||||||
|
"%s: Invalid driver=%p or speed=%d\n",
|
||||||
|
__func__, ep->dev->driver, ep->dev->gadget.speed);
|
||||||
return -ESHUTDOWN;
|
return -ESHUTDOWN;
|
||||||
|
}
|
||||||
|
|
||||||
avail = readl(&ep->regs->ep_avail) & (BIT(12) - 1);
|
avail = readl(&ep->regs->ep_avail) & (BIT(12) - 1);
|
||||||
if (avail > ep->fifo_size)
|
if (avail > ep->fifo_size) {
|
||||||
|
dev_err(&ep->dev->pdev->dev, "%s: Fifo overflow\n", __func__);
|
||||||
return -EOVERFLOW;
|
return -EOVERFLOW;
|
||||||
|
}
|
||||||
if (ep->is_in)
|
if (ep->is_in)
|
||||||
avail = ep->fifo_size - avail;
|
avail = ep->fifo_size - avail;
|
||||||
return avail;
|
return avail;
|
||||||
|
@ -1296,10 +1362,16 @@ static void net2280_fifo_flush(struct usb_ep *_ep)
|
||||||
struct net2280_ep *ep;
|
struct net2280_ep *ep;
|
||||||
|
|
||||||
ep = container_of(_ep, struct net2280_ep, ep);
|
ep = container_of(_ep, struct net2280_ep, ep);
|
||||||
if (!_ep || (!ep->desc && ep->num != 0))
|
if (!_ep || (!ep->desc && ep->num != 0)) {
|
||||||
|
pr_err("%s: Invalid ep=%p or ep->desc\n", __func__, _ep);
|
||||||
return;
|
return;
|
||||||
if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN)
|
}
|
||||||
|
if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN) {
|
||||||
|
dev_err(&ep->dev->pdev->dev,
|
||||||
|
"%s: Invalid driver=%p or speed=%d\n",
|
||||||
|
__func__, ep->dev->driver, ep->dev->gadget.speed);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
writel(BIT(FIFO_FLUSH), &ep->regs->ep_stat);
|
writel(BIT(FIFO_FLUSH), &ep->regs->ep_stat);
|
||||||
(void) readl(&ep->regs->ep_rsp);
|
(void) readl(&ep->regs->ep_rsp);
|
||||||
|
|
Loading…
Reference in New Issue