Commit 0f089094 authored by Alexander Shishkin's avatar Alexander Shishkin Committed by Greg Kroah-Hartman

usb: gadget: ci13xxx: replace home-brewed logging with dev_{err,warn,info}

Logging output in the driver is mostly done using custom err/warn/info
macros which rely on the existence of the global variable _udc, which
is a global reference to the udc controller structure. This reference
will have to go in order to allow us to have more than one chipidea udc
in the system.

Thus, replace custom macros with dev_{err,warn,info} using the platform
device where possible. The trace() macro, which is a nop by default is
left for tracing purposes.
Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 62bb84ed
...@@ -781,9 +781,9 @@ static ssize_t show_device(struct device *dev, struct device_attribute *attr, ...@@ -781,9 +781,9 @@ static ssize_t show_device(struct device *dev, struct device_attribute *attr,
struct usb_gadget *gadget = &udc->gadget; struct usb_gadget *gadget = &udc->gadget;
int n = 0; int n = 0;
dbg_trace("[%s] %p\n", __func__, buf); trace(udc->dev, "%p\n", buf);
if (attr == NULL || buf == NULL) { if (attr == NULL || buf == NULL) {
dev_err(dev, "[%s] EINVAL\n", __func__); dev_err(udc->dev, "[%s] EINVAL\n", __func__);
return 0; return 0;
} }
...@@ -823,7 +823,7 @@ static ssize_t show_driver(struct device *dev, struct device_attribute *attr, ...@@ -823,7 +823,7 @@ static ssize_t show_driver(struct device *dev, struct device_attribute *attr,
struct usb_gadget_driver *driver = udc->driver; struct usb_gadget_driver *driver = udc->driver;
int n = 0; int n = 0;
dbg_trace("[%s] %p\n", __func__, buf); trace(udc->dev, "%p\n", buf);
if (attr == NULL || buf == NULL) { if (attr == NULL || buf == NULL) {
dev_err(dev, "[%s] EINVAL\n", __func__); dev_err(dev, "[%s] EINVAL\n", __func__);
return 0; return 0;
...@@ -984,9 +984,9 @@ static ssize_t show_events(struct device *dev, struct device_attribute *attr, ...@@ -984,9 +984,9 @@ static ssize_t show_events(struct device *dev, struct device_attribute *attr,
unsigned long flags; unsigned long flags;
unsigned i, j, n = 0; unsigned i, j, n = 0;
dbg_trace("[%s] %p\n", __func__, buf); trace(dev->parent, "%p\n", buf);
if (attr == NULL || buf == NULL) { if (attr == NULL || buf == NULL) {
dev_err(dev, "[%s] EINVAL\n", __func__); dev_err(dev->parent, "[%s] EINVAL\n", __func__);
return 0; return 0;
} }
...@@ -1019,7 +1019,7 @@ static ssize_t store_events(struct device *dev, struct device_attribute *attr, ...@@ -1019,7 +1019,7 @@ static ssize_t store_events(struct device *dev, struct device_attribute *attr,
{ {
unsigned tty; unsigned tty;
dbg_trace("[%s] %p, %d\n", __func__, buf, count); trace(dev->parent, "[%s] %p, %d\n", __func__, buf, count);
if (attr == NULL || buf == NULL) { if (attr == NULL || buf == NULL) {
dev_err(dev, "[%s] EINVAL\n", __func__); dev_err(dev, "[%s] EINVAL\n", __func__);
goto done; goto done;
...@@ -1051,9 +1051,9 @@ static ssize_t show_inters(struct device *dev, struct device_attribute *attr, ...@@ -1051,9 +1051,9 @@ static ssize_t show_inters(struct device *dev, struct device_attribute *attr,
u32 intr; u32 intr;
unsigned i, j, n = 0; unsigned i, j, n = 0;
dbg_trace("[%s] %p\n", __func__, buf); trace(udc->dev, "%p\n", buf);
if (attr == NULL || buf == NULL) { if (attr == NULL || buf == NULL) {
dev_err(dev, "[%s] EINVAL\n", __func__); dev_err(udc->dev, "[%s] EINVAL\n", __func__);
return 0; return 0;
} }
...@@ -1124,14 +1124,14 @@ static ssize_t store_inters(struct device *dev, struct device_attribute *attr, ...@@ -1124,14 +1124,14 @@ static ssize_t store_inters(struct device *dev, struct device_attribute *attr,
unsigned long flags; unsigned long flags;
unsigned en, bit; unsigned en, bit;
dbg_trace("[%s] %p, %d\n", __func__, buf, count); trace(udc->dev, "%p, %d\n", buf, count);
if (attr == NULL || buf == NULL) { if (attr == NULL || buf == NULL) {
dev_err(dev, "[%s] EINVAL\n", __func__); dev_err(udc->dev, "EINVAL\n");
goto done; goto done;
} }
if (sscanf(buf, "%u %u", &en, &bit) != 2 || en > 1) { if (sscanf(buf, "%u %u", &en, &bit) != 2 || en > 1) {
dev_err(dev, "<1|0> <bit>: enable|disable interrupt"); dev_err(udc->dev, "<1|0> <bit>: enable|disable interrupt\n");
goto done; goto done;
} }
...@@ -1164,9 +1164,9 @@ static ssize_t show_port_test(struct device *dev, ...@@ -1164,9 +1164,9 @@ static ssize_t show_port_test(struct device *dev,
unsigned long flags; unsigned long flags;
unsigned mode; unsigned mode;
dbg_trace("[%s] %p\n", __func__, buf); trace(udc->dev, "%p\n", buf);
if (attr == NULL || buf == NULL) { if (attr == NULL || buf == NULL) {
dev_err(dev, "[%s] EINVAL\n", __func__); dev_err(udc->dev, "EINVAL\n");
return 0; return 0;
} }
...@@ -1190,20 +1190,20 @@ static ssize_t store_port_test(struct device *dev, ...@@ -1190,20 +1190,20 @@ static ssize_t store_port_test(struct device *dev,
unsigned long flags; unsigned long flags;
unsigned mode; unsigned mode;
dbg_trace("[%s] %p, %d\n", __func__, buf, count); trace(udc->dev, "%p, %d\n", buf, count);
if (attr == NULL || buf == NULL) { if (attr == NULL || buf == NULL) {
dev_err(dev, "[%s] EINVAL\n", __func__); dev_err(udc->dev, "[%s] EINVAL\n", __func__);
goto done; goto done;
} }
if (sscanf(buf, "%u", &mode) != 1) { if (sscanf(buf, "%u", &mode) != 1) {
dev_err(dev, "<mode>: set port test mode"); dev_err(udc->dev, "<mode>: set port test mode");
goto done; goto done;
} }
spin_lock_irqsave(&udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (hw_port_test_set(udc, mode)) if (hw_port_test_set(udc, mode))
dev_err(dev, "invalid mode\n"); dev_err(udc->dev, "invalid mode\n");
spin_unlock_irqrestore(&udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
done: done:
...@@ -1224,9 +1224,9 @@ static ssize_t show_qheads(struct device *dev, struct device_attribute *attr, ...@@ -1224,9 +1224,9 @@ static ssize_t show_qheads(struct device *dev, struct device_attribute *attr,
unsigned long flags; unsigned long flags;
unsigned i, j, n = 0; unsigned i, j, n = 0;
dbg_trace("[%s] %p\n", __func__, buf); trace(udc->dev, "%p\n", buf);
if (attr == NULL || buf == NULL) { if (attr == NULL || buf == NULL) {
dev_err(dev, "[%s] EINVAL\n", __func__); dev_err(udc->dev, "[%s] EINVAL\n", __func__);
return 0; return 0;
} }
...@@ -1265,15 +1265,15 @@ static ssize_t show_registers(struct device *dev, ...@@ -1265,15 +1265,15 @@ static ssize_t show_registers(struct device *dev,
u32 *dump; u32 *dump;
unsigned i, k, n = 0; unsigned i, k, n = 0;
dbg_trace("[%s] %p\n", __func__, buf); trace(udc->dev, "%p\n", buf);
if (attr == NULL || buf == NULL) { if (attr == NULL || buf == NULL) {
dev_err(dev, "[%s] EINVAL\n", __func__); dev_err(udc->dev, "[%s] EINVAL\n", __func__);
return 0; return 0;
} }
dump = kmalloc(sizeof(u32) * DUMP_ENTRIES, GFP_KERNEL); dump = kmalloc(sizeof(u32) * DUMP_ENTRIES, GFP_KERNEL);
if (!dump) { if (!dump) {
dev_err(dev, "%s: out of memory\n", __func__); dev_err(udc->dev, "%s: out of memory\n", __func__);
return 0; return 0;
} }
...@@ -1303,20 +1303,21 @@ static ssize_t store_registers(struct device *dev, ...@@ -1303,20 +1303,21 @@ static ssize_t store_registers(struct device *dev,
struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev);
unsigned long addr, data, flags; unsigned long addr, data, flags;
dbg_trace("[%s] %p, %d\n", __func__, buf, count); trace(udc->dev, "%p, %d\n", buf, count);
if (attr == NULL || buf == NULL) { if (attr == NULL || buf == NULL) {
dev_err(dev, "[%s] EINVAL\n", __func__); dev_err(udc->dev, "[%s] EINVAL\n", __func__);
goto done; goto done;
} }
if (sscanf(buf, "%li %li", &addr, &data) != 2) { if (sscanf(buf, "%li %li", &addr, &data) != 2) {
dev_err(dev, "<addr> <data>: write data to register address"); dev_err(udc->dev,
"<addr> <data>: write data to register address\n");
goto done; goto done;
} }
spin_lock_irqsave(&udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (hw_register_write(udc, addr, data)) if (hw_register_write(udc, addr, data))
dev_err(dev, "invalid address range\n"); dev_err(udc->dev, "invalid address range\n");
spin_unlock_irqrestore(&udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
done: done:
...@@ -1339,9 +1340,9 @@ static ssize_t show_requests(struct device *dev, struct device_attribute *attr, ...@@ -1339,9 +1340,9 @@ static ssize_t show_requests(struct device *dev, struct device_attribute *attr,
struct ci13xxx_req *req = NULL; struct ci13xxx_req *req = NULL;
unsigned i, j, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32); unsigned i, j, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32);
dbg_trace("[%s] %p\n", __func__, buf); trace(udc->dev, "%p\n", buf);
if (attr == NULL || buf == NULL) { if (attr == NULL || buf == NULL) {
dev_err(dev, "[%s] EINVAL\n", __func__); dev_err(udc->dev, "[%s] EINVAL\n", __func__);
return 0; return 0;
} }
...@@ -1470,7 +1471,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) ...@@ -1470,7 +1471,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
int ret = 0; int ret = 0;
unsigned length = mReq->req.length; unsigned length = mReq->req.length;
trace("%p, %p", mEp, mReq); trace(udc->dev, "%p, %p", mEp, mReq);
/* don't queue twice */ /* don't queue twice */
if (mReq->req.status == -EALREADY) if (mReq->req.status == -EALREADY)
...@@ -1572,7 +1573,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) ...@@ -1572,7 +1573,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
*/ */
static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
{ {
trace("%p, %p", mEp, mReq); trace(mEp->udc->dev, "%p, %p", mEp, mReq);
if (mReq->req.status != -EALREADY) if (mReq->req.status != -EALREADY)
return -EINVAL; return -EINVAL;
...@@ -1623,7 +1624,7 @@ static int _ep_nuke(struct ci13xxx_ep *mEp) ...@@ -1623,7 +1624,7 @@ static int _ep_nuke(struct ci13xxx_ep *mEp)
__releases(mEp->lock) __releases(mEp->lock)
__acquires(mEp->lock) __acquires(mEp->lock)
{ {
trace("%p", mEp); trace(mEp->udc->dev, "%p", mEp);
if (mEp == NULL) if (mEp == NULL)
return -EINVAL; return -EINVAL;
...@@ -1660,7 +1661,7 @@ static int _gadget_stop_activity(struct usb_gadget *gadget) ...@@ -1660,7 +1661,7 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
struct ci13xxx *udc = container_of(gadget, struct ci13xxx, gadget); struct ci13xxx *udc = container_of(gadget, struct ci13xxx, gadget);
unsigned long flags; unsigned long flags;
trace("%p", gadget); trace(udc->dev, "%p", gadget);
if (gadget == NULL) if (gadget == NULL)
return -EINVAL; return -EINVAL;
...@@ -1708,12 +1709,7 @@ __acquires(udc->lock) ...@@ -1708,12 +1709,7 @@ __acquires(udc->lock)
{ {
int retval; int retval;
trace("%p", udc); trace(udc->dev, "%p", udc);
if (udc == NULL) {
pr_err("EINVAL\n");
return;
}
dbg_event(0xFF, "BUS RST", 0); dbg_event(0xFF, "BUS RST", 0);
...@@ -1734,7 +1730,7 @@ __acquires(udc->lock) ...@@ -1734,7 +1730,7 @@ __acquires(udc->lock)
done: done:
if (retval) if (retval)
pr_err("error: %i\n", retval); dev_err(udc->dev, "error: %i\n", retval);
} }
/** /**
...@@ -1746,12 +1742,10 @@ __acquires(udc->lock) ...@@ -1746,12 +1742,10 @@ __acquires(udc->lock)
*/ */
static void isr_get_status_complete(struct usb_ep *ep, struct usb_request *req) static void isr_get_status_complete(struct usb_ep *ep, struct usb_request *req)
{ {
trace("%p, %p", ep, req); trace(NULL, "%p, %p", ep, req);
if (ep == NULL || req == NULL) { if (ep == NULL || req == NULL)
pr_err("EINVAL\n");
return; return;
}
kfree(req->buf); kfree(req->buf);
usb_ep_free_request(ep, req); usb_ep_free_request(ep, req);
...@@ -1774,7 +1768,7 @@ __acquires(mEp->lock) ...@@ -1774,7 +1768,7 @@ __acquires(mEp->lock)
gfp_t gfp_flags = GFP_ATOMIC; gfp_t gfp_flags = GFP_ATOMIC;
int dir, num, retval; int dir, num, retval;
trace("%p, %p", mEp, setup); trace(udc->dev, "%p, %p", mEp, setup);
if (mEp == NULL || setup == NULL) if (mEp == NULL || setup == NULL)
return -EINVAL; return -EINVAL;
...@@ -1837,7 +1831,7 @@ isr_setup_status_complete(struct usb_ep *ep, struct usb_request *req) ...@@ -1837,7 +1831,7 @@ isr_setup_status_complete(struct usb_ep *ep, struct usb_request *req)
struct ci13xxx *udc = req->context; struct ci13xxx *udc = req->context;
unsigned long flags; unsigned long flags;
trace("%p, %p", ep, req); trace(udc->dev, "%p, %p", ep, req);
spin_lock_irqsave(&udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (udc->test_mode) if (udc->test_mode)
...@@ -1858,7 +1852,7 @@ __acquires(mEp->lock) ...@@ -1858,7 +1852,7 @@ __acquires(mEp->lock)
int retval; int retval;
struct ci13xxx_ep *mEp; struct ci13xxx_ep *mEp;
trace("%p", udc); trace(udc->dev, "%p", udc);
mEp = (udc->ep0_dir == TX) ? udc->ep0out : udc->ep0in; mEp = (udc->ep0_dir == TX) ? udc->ep0out : udc->ep0in;
udc->status->context = udc; udc->status->context = udc;
...@@ -1886,7 +1880,7 @@ __acquires(mEp->lock) ...@@ -1886,7 +1880,7 @@ __acquires(mEp->lock)
struct ci13xxx_ep *mEpTemp = mEp; struct ci13xxx_ep *mEpTemp = mEp;
int uninitialized_var(retval); int uninitialized_var(retval);
trace("%p", mEp); trace(mEp->udc->dev, "%p", mEp);
if (list_empty(&mEp->qh.queue)) if (list_empty(&mEp->qh.queue))
return -EINVAL; return -EINVAL;
...@@ -1929,12 +1923,7 @@ __acquires(udc->lock) ...@@ -1929,12 +1923,7 @@ __acquires(udc->lock)
unsigned i; unsigned i;
u8 tmode = 0; u8 tmode = 0;
trace("%p", udc); trace(udc->dev, "%p", udc);
if (udc == NULL) {
pr_err("EINVAL\n");
return;
}
for (i = 0; i < udc->hw_ep_max; i++) { for (i = 0; i < udc->hw_ep_max; i++) {
struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i]; struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];
...@@ -1954,7 +1943,7 @@ __acquires(udc->lock) ...@@ -1954,7 +1943,7 @@ __acquires(udc->lock)
"ERROR", err); "ERROR", err);
spin_unlock(&udc->lock); spin_unlock(&udc->lock);
if (usb_ep_set_halt(&mEp->ep)) if (usb_ep_set_halt(&mEp->ep))
dev_err(&udc->gadget.dev, dev_err(udc->dev,
"error: ep_set_halt\n"); "error: ep_set_halt\n");
spin_lock(&udc->lock); spin_lock(&udc->lock);
} }
...@@ -1966,8 +1955,7 @@ __acquires(udc->lock) ...@@ -1966,8 +1955,7 @@ __acquires(udc->lock)
continue; continue;
if (i != 0) { if (i != 0) {
dev_warn(&udc->gadget.dev, dev_warn(udc->dev, "ctrl traffic at endpoint %d\n", i);
"ctrl traffic received at endpoint\n");
continue; continue;
} }
...@@ -2107,8 +2095,7 @@ __acquires(udc->lock) ...@@ -2107,8 +2095,7 @@ __acquires(udc->lock)
spin_unlock(&udc->lock); spin_unlock(&udc->lock);
if (usb_ep_set_halt(&mEp->ep)) if (usb_ep_set_halt(&mEp->ep))
dev_err(&udc->gadget.dev, dev_err(udc->dev, "error: ep_set_halt\n");
"error: ep_set_halt\n");
spin_lock(&udc->lock); spin_lock(&udc->lock);
} }
} }
...@@ -2129,7 +2116,7 @@ static int ep_enable(struct usb_ep *ep, ...@@ -2129,7 +2116,7 @@ static int ep_enable(struct usb_ep *ep,
int retval = 0; int retval = 0;
unsigned long flags; unsigned long flags;
trace("%p, %p", ep, desc); trace(mEp->udc->dev, "%p, %p", ep, desc);
if (ep == NULL || desc == NULL) if (ep == NULL || desc == NULL)
return -EINVAL; return -EINVAL;
...@@ -2141,7 +2128,7 @@ static int ep_enable(struct usb_ep *ep, ...@@ -2141,7 +2128,7 @@ static int ep_enable(struct usb_ep *ep,
mEp->ep.desc = desc; mEp->ep.desc = desc;
if (!list_empty(&mEp->qh.queue)) if (!list_empty(&mEp->qh.queue))
warn("enabling a non-empty endpoint!"); dev_warn(mEp->udc->dev, "enabling a non-empty endpoint!\n");
mEp->dir = usb_endpoint_dir_in(desc) ? TX : RX; mEp->dir = usb_endpoint_dir_in(desc) ? TX : RX;
mEp->num = usb_endpoint_num(desc); mEp->num = usb_endpoint_num(desc);
...@@ -2186,7 +2173,7 @@ static int ep_disable(struct usb_ep *ep) ...@@ -2186,7 +2173,7 @@ static int ep_disable(struct usb_ep *ep)
int direction, retval = 0; int direction, retval = 0;
unsigned long flags; unsigned long flags;
trace("%p", ep); trace(mEp->udc->dev, "%p", ep);
if (ep == NULL) if (ep == NULL)
return -EINVAL; return -EINVAL;
...@@ -2225,12 +2212,10 @@ static struct usb_request *ep_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) ...@@ -2225,12 +2212,10 @@ static struct usb_request *ep_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep); struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
struct ci13xxx_req *mReq = NULL; struct ci13xxx_req *mReq = NULL;
trace("%p, %i", ep, gfp_flags); trace(mEp->udc->dev, "%p, %i", ep, gfp_flags);
if (ep == NULL) { if (ep == NULL)
pr_err("EINVAL\n");
return NULL; return NULL;
}
mReq = kzalloc(sizeof(struct ci13xxx_req), gfp_flags); mReq = kzalloc(sizeof(struct ci13xxx_req), gfp_flags);
if (mReq != NULL) { if (mReq != NULL) {
...@@ -2261,13 +2246,12 @@ static void ep_free_request(struct usb_ep *ep, struct usb_request *req) ...@@ -2261,13 +2246,12 @@ static void ep_free_request(struct usb_ep *ep, struct usb_request *req)
struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req); struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req);
unsigned long flags; unsigned long flags;
trace("%p, %p", ep, req); trace(mEp->udc->dev, "%p, %p", ep, req);
if (ep == NULL || req == NULL) { if (ep == NULL || req == NULL) {
pr_err("EINVAL\n");
return; return;
} else if (!list_empty(&mReq->queue)) { } else if (!list_empty(&mReq->queue)) {
pr_err("EBUSY\n"); dev_err(mEp->udc->dev, "freeing queued request\n");
return; return;
} }
...@@ -2295,7 +2279,7 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req, ...@@ -2295,7 +2279,7 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req,
int retval = 0; int retval = 0;
unsigned long flags; unsigned long flags;
trace("%p, %p, %X", ep, req, gfp_flags); trace(mEp->udc->dev, "%p, %p, %X", ep, req, gfp_flags);
if (ep == NULL || req == NULL || mEp->ep.desc == NULL) if (ep == NULL || req == NULL || mEp->ep.desc == NULL)
return -EINVAL; return -EINVAL;
...@@ -2309,21 +2293,22 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req, ...@@ -2309,21 +2293,22 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req,
if (!list_empty(&mEp->qh.queue)) { if (!list_empty(&mEp->qh.queue)) {
_ep_nuke(mEp); _ep_nuke(mEp);
retval = -EOVERFLOW; retval = -EOVERFLOW;
warn("endpoint ctrl %X nuked", _usb_addr(mEp)); dev_warn(mEp->udc->dev, "endpoint ctrl %X nuked\n",
_usb_addr(mEp));
} }
} }
/* first nuke then test link, e.g. previous status has not sent */ /* first nuke then test link, e.g. previous status has not sent */
if (!list_empty(&mReq->queue)) { if (!list_empty(&mReq->queue)) {
retval = -EBUSY; retval = -EBUSY;
pr_err("request already in queue\n"); dev_err(mEp->udc->dev, "request already in queue\n");
goto done; goto done;
} }
if (req->length > 4 * CI13XXX_PAGE_SIZE) { if (req->length > 4 * CI13XXX_PAGE_SIZE) {
req->length = 4 * CI13XXX_PAGE_SIZE; req->length = 4 * CI13XXX_PAGE_SIZE;
retval = -EMSGSIZE; retval = -EMSGSIZE;
warn("request length truncated"); dev_warn(mEp->udc->dev, "request length truncated\n");
} }
dbg_queue(_usb_addr(mEp), req, retval); dbg_queue(_usb_addr(mEp), req, retval);
...@@ -2357,7 +2342,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req) ...@@ -2357,7 +2342,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req); struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req);
unsigned long flags; unsigned long flags;
trace("%p, %p", ep, req); trace(mEp->udc->dev, "%p, %p", ep, req);
if (ep == NULL || req == NULL || mReq->req.status != -EALREADY || if (ep == NULL || req == NULL || mReq->req.status != -EALREADY ||
mEp->ep.desc == NULL || list_empty(&mReq->queue) || mEp->ep.desc == NULL || list_empty(&mReq->queue) ||
...@@ -2401,7 +2386,7 @@ static int ep_set_halt(struct usb_ep *ep, int value) ...@@ -2401,7 +2386,7 @@ static int ep_set_halt(struct usb_ep *ep, int value)
int direction, retval = 0; int direction, retval = 0;
unsigned long flags; unsigned long flags;
trace("%p, %i", ep, value); trace(mEp->udc->dev, "%p, %i", ep, value);
if (ep == NULL || mEp->ep.desc == NULL) if (ep == NULL || mEp->ep.desc == NULL)
return -EINVAL; return -EINVAL;
...@@ -2444,7 +2429,7 @@ static int ep_set_wedge(struct usb_ep *ep) ...@@ -2444,7 +2429,7 @@ static int ep_set_wedge(struct usb_ep *ep)
struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep); struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
unsigned long flags; unsigned long flags;
trace("%p", ep); trace(mEp->udc->dev, "%p", ep);
if (ep == NULL || mEp->ep.desc == NULL) if (ep == NULL || mEp->ep.desc == NULL)
return -EINVAL; return -EINVAL;
...@@ -2469,10 +2454,10 @@ static void ep_fifo_flush(struct usb_ep *ep) ...@@ -2469,10 +2454,10 @@ static void ep_fifo_flush(struct usb_ep *ep)
struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep); struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
unsigned long flags; unsigned long flags;
trace("%p", ep); trace(mEp->udc->dev, "%p", ep);
if (ep == NULL) { if (ep == NULL) {
pr_err("%02X: -EINVAL\n", _usb_addr(mEp)); dev_err(mEp->udc->dev, "%02X: -EINVAL\n", _usb_addr(mEp));
return; return;
} }
...@@ -2542,17 +2527,17 @@ static int ci13xxx_wakeup(struct usb_gadget *_gadget) ...@@ -2542,17 +2527,17 @@ static int ci13xxx_wakeup(struct usb_gadget *_gadget)
unsigned long flags; unsigned long flags;
int ret = 0; int ret = 0;
trace(); trace(udc->dev, "");
spin_lock_irqsave(&udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (!udc->remote_wakeup) { if (!udc->remote_wakeup) {
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
trace("remote wakeup feature is not enabled\n"); trace(udc->dev, "remote wakeup feature is not enabled\n");
goto out; goto out;
} }
if (!hw_read(udc, OP_PORTSC, PORTSC_SUSP)) { if (!hw_read(udc, OP_PORTSC, PORTSC_SUSP)) {
ret = -EINVAL; ret = -EINVAL;
trace("port is not suspended\n"); trace(udc->dev, "port is not suspended\n");
goto out; goto out;
} }
hw_write(udc, OP_PORTSC, PORTSC_FPR, PORTSC_FPR); hw_write(udc, OP_PORTSC, PORTSC_FPR, PORTSC_FPR);
...@@ -2602,7 +2587,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, ...@@ -2602,7 +2587,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver,
int i, j; int i, j;
int retval = -ENOMEM; int retval = -ENOMEM;
trace("%p", driver); trace(udc->dev, "%p", driver);
if (driver == NULL || if (driver == NULL ||
bind == NULL || bind == NULL ||
...@@ -2632,7 +2617,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, ...@@ -2632,7 +2617,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver,
spin_lock_irqsave(&udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
info("hw_ep_max = %d", udc->hw_ep_max); dev_info(udc->dev, "hw_ep_max = %d\n", udc->hw_ep_max);
udc->gadget.dev.driver = NULL; udc->gadget.dev.driver = NULL;
...@@ -2740,7 +2725,7 @@ static int ci13xxx_stop(struct usb_gadget_driver *driver) ...@@ -2740,7 +2725,7 @@ static int ci13xxx_stop(struct usb_gadget_driver *driver)
struct ci13xxx *udc = _udc; struct ci13xxx *udc = _udc;
unsigned long i, flags; unsigned long i, flags;
trace("%p", driver); trace(udc->dev, "%p", driver);
if (driver == NULL || if (driver == NULL ||
driver->unbind == NULL || driver->unbind == NULL ||
...@@ -2813,10 +2798,10 @@ static irqreturn_t udc_irq(int irq, void *data) ...@@ -2813,10 +2798,10 @@ static irqreturn_t udc_irq(int irq, void *data)
irqreturn_t retval; irqreturn_t retval;
u32 intr; u32 intr;
trace(); trace(udc ? udc->dev : NULL, "");
if (udc == NULL) { if (udc == NULL) {
pr_err("ENODEV\n"); dev_err(udc->dev, "ENODEV");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -2885,10 +2870,7 @@ static irqreturn_t udc_irq(int irq, void *data) ...@@ -2885,10 +2870,7 @@ static irqreturn_t udc_irq(int irq, void *data)
*/ */
static void udc_release(struct device *dev) static void udc_release(struct device *dev)
{ {
trace("%p", dev); trace(dev->parent, "%p", dev);
if (dev == NULL)
pr_err("EINVAL\n");
} }
/** /**
...@@ -2907,7 +2889,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, ...@@ -2907,7 +2889,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
struct ci13xxx *udc; struct ci13xxx *udc;
int retval = 0; int retval = 0;
trace("%p, %p, %p", dev, regs, driver->name); trace(dev, "%p, %p, %p", dev, regs, driver->name);
if (dev == NULL || regs == NULL || driver == NULL || if (dev == NULL || regs == NULL || driver == NULL ||
driver->name == NULL) driver->name == NULL)
...@@ -2936,6 +2918,8 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, ...@@ -2936,6 +2918,8 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
udc->gadget.dev.parent = dev; udc->gadget.dev.parent = dev;
udc->gadget.dev.release = udc_release; udc->gadget.dev.release = udc_release;
udc->dev = dev;
retval = hw_device_init(udc, regs, driver->capoffset); retval = hw_device_init(udc, regs, driver->capoffset);
if (retval < 0) if (retval < 0)
goto free_udc; goto free_udc;
...@@ -3015,10 +2999,9 @@ static void udc_remove(void) ...@@ -3015,10 +2999,9 @@ static void udc_remove(void)
{ {
struct ci13xxx *udc = _udc; struct ci13xxx *udc = _udc;
if (udc == NULL) { if (udc == NULL)
pr_err("EINVAL\n");
return; return;
}
usb_del_gadget_udc(&udc->gadget); usb_del_gadget_udc(&udc->gadget);
if (udc->transceiver) { if (udc->transceiver) {
......
...@@ -134,6 +134,7 @@ struct ci13xxx { ...@@ -134,6 +134,7 @@ struct ci13xxx {
struct dma_pool *td_pool; /* DMA pool for transfer descs */ struct dma_pool *td_pool; /* DMA pool for transfer descs */
struct usb_request *status; /* ep0 status request */ struct usb_request *status; /* ep0 status request */
struct device *dev;
struct usb_gadget gadget; /* USB slave device */ struct usb_gadget gadget; /* USB slave device */
struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */ struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */
u32 ep0_dir; /* ep0 direction */ u32 ep0_dir; /* ep0 direction */
...@@ -245,24 +246,18 @@ enum ci13xxx_regs { ...@@ -245,24 +246,18 @@ enum ci13xxx_regs {
/****************************************************************************** /******************************************************************************
* LOGGING * LOGGING
*****************************************************************************/ *****************************************************************************/
#define ci13xxx_printk(level, format, args...) \
do { \
if (_udc == NULL) \
printk(level "[%s] " format "\n", __func__, ## args); \
else \
dev_printk(level, _udc->gadget.dev.parent, \
"[%s] " format "\n", __func__, ## args); \
} while (0)
#define warn(format, args...) ci13xxx_printk(KERN_WARNING, format, ## args)
#define info(format, args...) ci13xxx_printk(KERN_INFO, format, ## args)
#ifdef TRACE #ifdef TRACE
#define trace(format, args...) ci13xxx_printk(KERN_DEBUG, format, ## args) #define trace(dev, format, args...) \
#define dbg_trace(format, args...) dev_dbg(dev, format, ##args) do { \
if (dev == NULL) \
pr_debug("[%s] " format "\n", __func__, \
## args); \
else \
dev_printk(KERN_DEBUG, dev, "[%s] " format "\n", \
__func__, ## args); \
} while (0)
#else #else
#define trace(format, args...) do {} while (0) #define trace(dev, format, args...) do {} while (0)
#define dbg_trace(format, args...) do {} while (0)
#endif #endif
#endif /* _CI13XXX_h_ */ #endif /* _CI13XXX_h_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment