diff options
author | Alexander Shishkin <alexander.shishkin@linux.intel.com> | 2012-05-08 16:29:02 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-09 18:00:26 -0400 |
commit | 0f089094cde53a2639c965cd3bd3fdef27006446 (patch) | |
tree | d5637886cb65cd949fc2388fefcd52b387e27da1 | |
parent | 62bb84ed0e4d14b0a5070f44b2387a42f7f535d9 (diff) |
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: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/gadget/ci13xxx_udc.c | 169 | ||||
-rw-r--r-- | drivers/usb/gadget/ci13xxx_udc.h | 27 |
2 files changed, 87 insertions, 109 deletions
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c index 009a3cd5895d..ce50af97ab3f 100644 --- a/drivers/usb/gadget/ci13xxx_udc.c +++ b/drivers/usb/gadget/ci13xxx_udc.c | |||
@@ -781,9 +781,9 @@ static ssize_t show_device(struct device *dev, struct device_attribute *attr, | |||
781 | struct usb_gadget *gadget = &udc->gadget; | 781 | struct usb_gadget *gadget = &udc->gadget; |
782 | int n = 0; | 782 | int n = 0; |
783 | 783 | ||
784 | dbg_trace("[%s] %p\n", __func__, buf); | 784 | trace(udc->dev, "%p\n", buf); |
785 | if (attr == NULL || buf == NULL) { | 785 | if (attr == NULL || buf == NULL) { |
786 | dev_err(dev, "[%s] EINVAL\n", __func__); | 786 | dev_err(udc->dev, "[%s] EINVAL\n", __func__); |
787 | return 0; | 787 | return 0; |
788 | } | 788 | } |
789 | 789 | ||
@@ -823,7 +823,7 @@ static ssize_t show_driver(struct device *dev, struct device_attribute *attr, | |||
823 | struct usb_gadget_driver *driver = udc->driver; | 823 | struct usb_gadget_driver *driver = udc->driver; |
824 | int n = 0; | 824 | int n = 0; |
825 | 825 | ||
826 | dbg_trace("[%s] %p\n", __func__, buf); | 826 | trace(udc->dev, "%p\n", buf); |
827 | if (attr == NULL || buf == NULL) { | 827 | if (attr == NULL || buf == NULL) { |
828 | dev_err(dev, "[%s] EINVAL\n", __func__); | 828 | dev_err(dev, "[%s] EINVAL\n", __func__); |
829 | return 0; | 829 | return 0; |
@@ -984,9 +984,9 @@ static ssize_t show_events(struct device *dev, struct device_attribute *attr, | |||
984 | unsigned long flags; | 984 | unsigned long flags; |
985 | unsigned i, j, n = 0; | 985 | unsigned i, j, n = 0; |
986 | 986 | ||
987 | dbg_trace("[%s] %p\n", __func__, buf); | 987 | trace(dev->parent, "%p\n", buf); |
988 | if (attr == NULL || buf == NULL) { | 988 | if (attr == NULL || buf == NULL) { |
989 | dev_err(dev, "[%s] EINVAL\n", __func__); | 989 | dev_err(dev->parent, "[%s] EINVAL\n", __func__); |
990 | return 0; | 990 | return 0; |
991 | } | 991 | } |
992 | 992 | ||
@@ -1019,7 +1019,7 @@ static ssize_t store_events(struct device *dev, struct device_attribute *attr, | |||
1019 | { | 1019 | { |
1020 | unsigned tty; | 1020 | unsigned tty; |
1021 | 1021 | ||
1022 | dbg_trace("[%s] %p, %d\n", __func__, buf, count); | 1022 | trace(dev->parent, "[%s] %p, %d\n", __func__, buf, count); |
1023 | if (attr == NULL || buf == NULL) { | 1023 | if (attr == NULL || buf == NULL) { |
1024 | dev_err(dev, "[%s] EINVAL\n", __func__); | 1024 | dev_err(dev, "[%s] EINVAL\n", __func__); |
1025 | goto done; | 1025 | goto done; |
@@ -1051,9 +1051,9 @@ static ssize_t show_inters(struct device *dev, struct device_attribute *attr, | |||
1051 | u32 intr; | 1051 | u32 intr; |
1052 | unsigned i, j, n = 0; | 1052 | unsigned i, j, n = 0; |
1053 | 1053 | ||
1054 | dbg_trace("[%s] %p\n", __func__, buf); | 1054 | trace(udc->dev, "%p\n", buf); |
1055 | if (attr == NULL || buf == NULL) { | 1055 | if (attr == NULL || buf == NULL) { |
1056 | dev_err(dev, "[%s] EINVAL\n", __func__); | 1056 | dev_err(udc->dev, "[%s] EINVAL\n", __func__); |
1057 | return 0; | 1057 | return 0; |
1058 | } | 1058 | } |
1059 | 1059 | ||
@@ -1124,14 +1124,14 @@ static ssize_t store_inters(struct device *dev, struct device_attribute *attr, | |||
1124 | unsigned long flags; | 1124 | unsigned long flags; |
1125 | unsigned en, bit; | 1125 | unsigned en, bit; |
1126 | 1126 | ||
1127 | dbg_trace("[%s] %p, %d\n", __func__, buf, count); | 1127 | trace(udc->dev, "%p, %d\n", buf, count); |
1128 | if (attr == NULL || buf == NULL) { | 1128 | if (attr == NULL || buf == NULL) { |
1129 | dev_err(dev, "[%s] EINVAL\n", __func__); | 1129 | dev_err(udc->dev, "EINVAL\n"); |
1130 | goto done; | 1130 | goto done; |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | if (sscanf(buf, "%u %u", &en, &bit) != 2 || en > 1) { | 1133 | if (sscanf(buf, "%u %u", &en, &bit) != 2 || en > 1) { |
1134 | dev_err(dev, "<1|0> <bit>: enable|disable interrupt"); | 1134 | dev_err(udc->dev, "<1|0> <bit>: enable|disable interrupt\n"); |
1135 | goto done; | 1135 | goto done; |
1136 | } | 1136 | } |
1137 | 1137 | ||
@@ -1164,9 +1164,9 @@ static ssize_t show_port_test(struct device *dev, | |||
1164 | unsigned long flags; | 1164 | unsigned long flags; |
1165 | unsigned mode; | 1165 | unsigned mode; |
1166 | 1166 | ||
1167 | dbg_trace("[%s] %p\n", __func__, buf); | 1167 | trace(udc->dev, "%p\n", buf); |
1168 | if (attr == NULL || buf == NULL) { | 1168 | if (attr == NULL || buf == NULL) { |
1169 | dev_err(dev, "[%s] EINVAL\n", __func__); | 1169 | dev_err(udc->dev, "EINVAL\n"); |
1170 | return 0; | 1170 | return 0; |
1171 | } | 1171 | } |
1172 | 1172 | ||
@@ -1190,20 +1190,20 @@ static ssize_t store_port_test(struct device *dev, | |||
1190 | unsigned long flags; | 1190 | unsigned long flags; |
1191 | unsigned mode; | 1191 | unsigned mode; |
1192 | 1192 | ||
1193 | dbg_trace("[%s] %p, %d\n", __func__, buf, count); | 1193 | trace(udc->dev, "%p, %d\n", buf, count); |
1194 | if (attr == NULL || buf == NULL) { | 1194 | if (attr == NULL || buf == NULL) { |
1195 | dev_err(dev, "[%s] EINVAL\n", __func__); | 1195 | dev_err(udc->dev, "[%s] EINVAL\n", __func__); |
1196 | goto done; | 1196 | goto done; |
1197 | } | 1197 | } |
1198 | 1198 | ||
1199 | if (sscanf(buf, "%u", &mode) != 1) { | 1199 | if (sscanf(buf, "%u", &mode) != 1) { |
1200 | dev_err(dev, "<mode>: set port test mode"); | 1200 | dev_err(udc->dev, "<mode>: set port test mode"); |
1201 | goto done; | 1201 | goto done; |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | spin_lock_irqsave(&udc->lock, flags); | 1204 | spin_lock_irqsave(&udc->lock, flags); |
1205 | if (hw_port_test_set(udc, mode)) | 1205 | if (hw_port_test_set(udc, mode)) |
1206 | dev_err(dev, "invalid mode\n"); | 1206 | dev_err(udc->dev, "invalid mode\n"); |
1207 | spin_unlock_irqrestore(&udc->lock, flags); | 1207 | spin_unlock_irqrestore(&udc->lock, flags); |
1208 | 1208 | ||
1209 | done: | 1209 | done: |
@@ -1224,9 +1224,9 @@ static ssize_t show_qheads(struct device *dev, struct device_attribute *attr, | |||
1224 | unsigned long flags; | 1224 | unsigned long flags; |
1225 | unsigned i, j, n = 0; | 1225 | unsigned i, j, n = 0; |
1226 | 1226 | ||
1227 | dbg_trace("[%s] %p\n", __func__, buf); | 1227 | trace(udc->dev, "%p\n", buf); |
1228 | if (attr == NULL || buf == NULL) { | 1228 | if (attr == NULL || buf == NULL) { |
1229 | dev_err(dev, "[%s] EINVAL\n", __func__); | 1229 | dev_err(udc->dev, "[%s] EINVAL\n", __func__); |
1230 | return 0; | 1230 | return 0; |
1231 | } | 1231 | } |
1232 | 1232 | ||
@@ -1265,15 +1265,15 @@ static ssize_t show_registers(struct device *dev, | |||
1265 | u32 *dump; | 1265 | u32 *dump; |
1266 | unsigned i, k, n = 0; | 1266 | unsigned i, k, n = 0; |
1267 | 1267 | ||
1268 | dbg_trace("[%s] %p\n", __func__, buf); | 1268 | trace(udc->dev, "%p\n", buf); |
1269 | if (attr == NULL || buf == NULL) { | 1269 | if (attr == NULL || buf == NULL) { |
1270 | dev_err(dev, "[%s] EINVAL\n", __func__); | 1270 | dev_err(udc->dev, "[%s] EINVAL\n", __func__); |
1271 | return 0; | 1271 | return 0; |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | dump = kmalloc(sizeof(u32) * DUMP_ENTRIES, GFP_KERNEL); | 1274 | dump = kmalloc(sizeof(u32) * DUMP_ENTRIES, GFP_KERNEL); |
1275 | if (!dump) { | 1275 | if (!dump) { |
1276 | dev_err(dev, "%s: out of memory\n", __func__); | 1276 | dev_err(udc->dev, "%s: out of memory\n", __func__); |
1277 | return 0; | 1277 | return 0; |
1278 | } | 1278 | } |
1279 | 1279 | ||
@@ -1303,20 +1303,21 @@ static ssize_t store_registers(struct device *dev, | |||
1303 | struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); | 1303 | struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); |
1304 | unsigned long addr, data, flags; | 1304 | unsigned long addr, data, flags; |
1305 | 1305 | ||
1306 | dbg_trace("[%s] %p, %d\n", __func__, buf, count); | 1306 | trace(udc->dev, "%p, %d\n", buf, count); |
1307 | if (attr == NULL || buf == NULL) { | 1307 | if (attr == NULL || buf == NULL) { |
1308 | dev_err(dev, "[%s] EINVAL\n", __func__); | 1308 | dev_err(udc->dev, "[%s] EINVAL\n", __func__); |
1309 | goto done; | 1309 | goto done; |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | if (sscanf(buf, "%li %li", &addr, &data) != 2) { | 1312 | if (sscanf(buf, "%li %li", &addr, &data) != 2) { |
1313 | dev_err(dev, "<addr> <data>: write data to register address"); | 1313 | dev_err(udc->dev, |
1314 | "<addr> <data>: write data to register address\n"); | ||
1314 | goto done; | 1315 | goto done; |
1315 | } | 1316 | } |
1316 | 1317 | ||
1317 | spin_lock_irqsave(&udc->lock, flags); | 1318 | spin_lock_irqsave(&udc->lock, flags); |
1318 | if (hw_register_write(udc, addr, data)) | 1319 | if (hw_register_write(udc, addr, data)) |
1319 | dev_err(dev, "invalid address range\n"); | 1320 | dev_err(udc->dev, "invalid address range\n"); |
1320 | spin_unlock_irqrestore(&udc->lock, flags); | 1321 | spin_unlock_irqrestore(&udc->lock, flags); |
1321 | 1322 | ||
1322 | done: | 1323 | done: |
@@ -1339,9 +1340,9 @@ static ssize_t show_requests(struct device *dev, struct device_attribute *attr, | |||
1339 | struct ci13xxx_req *req = NULL; | 1340 | struct ci13xxx_req *req = NULL; |
1340 | unsigned i, j, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32); | 1341 | unsigned i, j, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32); |
1341 | 1342 | ||
1342 | dbg_trace("[%s] %p\n", __func__, buf); | 1343 | trace(udc->dev, "%p\n", buf); |
1343 | if (attr == NULL || buf == NULL) { | 1344 | if (attr == NULL || buf == NULL) { |
1344 | dev_err(dev, "[%s] EINVAL\n", __func__); | 1345 | dev_err(udc->dev, "[%s] EINVAL\n", __func__); |
1345 | return 0; | 1346 | return 0; |
1346 | } | 1347 | } |
1347 | 1348 | ||
@@ -1470,7 +1471,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) | |||
1470 | int ret = 0; | 1471 | int ret = 0; |
1471 | unsigned length = mReq->req.length; | 1472 | unsigned length = mReq->req.length; |
1472 | 1473 | ||
1473 | trace("%p, %p", mEp, mReq); | 1474 | trace(udc->dev, "%p, %p", mEp, mReq); |
1474 | 1475 | ||
1475 | /* don't queue twice */ | 1476 | /* don't queue twice */ |
1476 | if (mReq->req.status == -EALREADY) | 1477 | if (mReq->req.status == -EALREADY) |
@@ -1572,7 +1573,7 @@ done: | |||
1572 | */ | 1573 | */ |
1573 | static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) | 1574 | static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) |
1574 | { | 1575 | { |
1575 | trace("%p, %p", mEp, mReq); | 1576 | trace(mEp->udc->dev, "%p, %p", mEp, mReq); |
1576 | 1577 | ||
1577 | if (mReq->req.status != -EALREADY) | 1578 | if (mReq->req.status != -EALREADY) |
1578 | return -EINVAL; | 1579 | return -EINVAL; |
@@ -1623,7 +1624,7 @@ static int _ep_nuke(struct ci13xxx_ep *mEp) | |||
1623 | __releases(mEp->lock) | 1624 | __releases(mEp->lock) |
1624 | __acquires(mEp->lock) | 1625 | __acquires(mEp->lock) |
1625 | { | 1626 | { |
1626 | trace("%p", mEp); | 1627 | trace(mEp->udc->dev, "%p", mEp); |
1627 | 1628 | ||
1628 | if (mEp == NULL) | 1629 | if (mEp == NULL) |
1629 | return -EINVAL; | 1630 | return -EINVAL; |
@@ -1660,7 +1661,7 @@ static int _gadget_stop_activity(struct usb_gadget *gadget) | |||
1660 | struct ci13xxx *udc = container_of(gadget, struct ci13xxx, gadget); | 1661 | struct ci13xxx *udc = container_of(gadget, struct ci13xxx, gadget); |
1661 | unsigned long flags; | 1662 | unsigned long flags; |
1662 | 1663 | ||
1663 | trace("%p", gadget); | 1664 | trace(udc->dev, "%p", gadget); |
1664 | 1665 | ||
1665 | if (gadget == NULL) | 1666 | if (gadget == NULL) |
1666 | return -EINVAL; | 1667 | return -EINVAL; |
@@ -1708,12 +1709,7 @@ __acquires(udc->lock) | |||
1708 | { | 1709 | { |
1709 | int retval; | 1710 | int retval; |
1710 | 1711 | ||
1711 | trace("%p", udc); | 1712 | trace(udc->dev, "%p", udc); |
1712 | |||
1713 | if (udc == NULL) { | ||
1714 | pr_err("EINVAL\n"); | ||
1715 | return; | ||
1716 | } | ||
1717 | 1713 | ||
1718 | dbg_event(0xFF, "BUS RST", 0); | 1714 | dbg_event(0xFF, "BUS RST", 0); |
1719 | 1715 | ||
@@ -1734,7 +1730,7 @@ __acquires(udc->lock) | |||
1734 | 1730 | ||
1735 | done: | 1731 | done: |
1736 | if (retval) | 1732 | if (retval) |
1737 | pr_err("error: %i\n", retval); | 1733 | dev_err(udc->dev, "error: %i\n", retval); |
1738 | } | 1734 | } |
1739 | 1735 | ||
1740 | /** | 1736 | /** |
@@ -1746,12 +1742,10 @@ __acquires(udc->lock) | |||
1746 | */ | 1742 | */ |
1747 | static void isr_get_status_complete(struct usb_ep *ep, struct usb_request *req) | 1743 | static void isr_get_status_complete(struct usb_ep *ep, struct usb_request *req) |
1748 | { | 1744 | { |
1749 | trace("%p, %p", ep, req); | 1745 | trace(NULL, "%p, %p", ep, req); |
1750 | 1746 | ||
1751 | if (ep == NULL || req == NULL) { | 1747 | if (ep == NULL || req == NULL) |
1752 | pr_err("EINVAL\n"); | ||
1753 | return; | 1748 | return; |
1754 | } | ||
1755 | 1749 | ||
1756 | kfree(req->buf); | 1750 | kfree(req->buf); |
1757 | usb_ep_free_request(ep, req); | 1751 | usb_ep_free_request(ep, req); |
@@ -1774,7 +1768,7 @@ __acquires(mEp->lock) | |||
1774 | gfp_t gfp_flags = GFP_ATOMIC; | 1768 | gfp_t gfp_flags = GFP_ATOMIC; |
1775 | int dir, num, retval; | 1769 | int dir, num, retval; |
1776 | 1770 | ||
1777 | trace("%p, %p", mEp, setup); | 1771 | trace(udc->dev, "%p, %p", mEp, setup); |
1778 | 1772 | ||
1779 | if (mEp == NULL || setup == NULL) | 1773 | if (mEp == NULL || setup == NULL) |
1780 | return -EINVAL; | 1774 | return -EINVAL; |
@@ -1837,7 +1831,7 @@ isr_setup_status_complete(struct usb_ep *ep, struct usb_request *req) | |||
1837 | struct ci13xxx *udc = req->context; | 1831 | struct ci13xxx *udc = req->context; |
1838 | unsigned long flags; | 1832 | unsigned long flags; |
1839 | 1833 | ||
1840 | trace("%p, %p", ep, req); | 1834 | trace(udc->dev, "%p, %p", ep, req); |
1841 | 1835 | ||
1842 | spin_lock_irqsave(&udc->lock, flags); | 1836 | spin_lock_irqsave(&udc->lock, flags); |
1843 | if (udc->test_mode) | 1837 | if (udc->test_mode) |
@@ -1858,7 +1852,7 @@ __acquires(mEp->lock) | |||
1858 | int retval; | 1852 | int retval; |
1859 | struct ci13xxx_ep *mEp; | 1853 | struct ci13xxx_ep *mEp; |
1860 | 1854 | ||
1861 | trace("%p", udc); | 1855 | trace(udc->dev, "%p", udc); |
1862 | 1856 | ||
1863 | mEp = (udc->ep0_dir == TX) ? udc->ep0out : udc->ep0in; | 1857 | mEp = (udc->ep0_dir == TX) ? udc->ep0out : udc->ep0in; |
1864 | udc->status->context = udc; | 1858 | udc->status->context = udc; |
@@ -1886,7 +1880,7 @@ __acquires(mEp->lock) | |||
1886 | struct ci13xxx_ep *mEpTemp = mEp; | 1880 | struct ci13xxx_ep *mEpTemp = mEp; |
1887 | int uninitialized_var(retval); | 1881 | int uninitialized_var(retval); |
1888 | 1882 | ||
1889 | trace("%p", mEp); | 1883 | trace(mEp->udc->dev, "%p", mEp); |
1890 | 1884 | ||
1891 | if (list_empty(&mEp->qh.queue)) | 1885 | if (list_empty(&mEp->qh.queue)) |
1892 | return -EINVAL; | 1886 | return -EINVAL; |
@@ -1929,12 +1923,7 @@ __acquires(udc->lock) | |||
1929 | unsigned i; | 1923 | unsigned i; |
1930 | u8 tmode = 0; | 1924 | u8 tmode = 0; |
1931 | 1925 | ||
1932 | trace("%p", udc); | 1926 | trace(udc->dev, "%p", udc); |
1933 | |||
1934 | if (udc == NULL) { | ||
1935 | pr_err("EINVAL\n"); | ||
1936 | return; | ||
1937 | } | ||
1938 | 1927 | ||
1939 | for (i = 0; i < udc->hw_ep_max; i++) { | 1928 | for (i = 0; i < udc->hw_ep_max; i++) { |
1940 | struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i]; | 1929 | struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i]; |
@@ -1954,7 +1943,7 @@ __acquires(udc->lock) | |||
1954 | "ERROR", err); | 1943 | "ERROR", err); |
1955 | spin_unlock(&udc->lock); | 1944 | spin_unlock(&udc->lock); |
1956 | if (usb_ep_set_halt(&mEp->ep)) | 1945 | if (usb_ep_set_halt(&mEp->ep)) |
1957 | dev_err(&udc->gadget.dev, | 1946 | dev_err(udc->dev, |
1958 | "error: ep_set_halt\n"); | 1947 | "error: ep_set_halt\n"); |
1959 | spin_lock(&udc->lock); | 1948 | spin_lock(&udc->lock); |
1960 | } | 1949 | } |
@@ -1966,8 +1955,7 @@ __acquires(udc->lock) | |||
1966 | continue; | 1955 | continue; |
1967 | 1956 | ||
1968 | if (i != 0) { | 1957 | if (i != 0) { |
1969 | dev_warn(&udc->gadget.dev, | 1958 | dev_warn(udc->dev, "ctrl traffic at endpoint %d\n", i); |
1970 | "ctrl traffic received at endpoint\n"); | ||
1971 | continue; | 1959 | continue; |
1972 | } | 1960 | } |
1973 | 1961 | ||
@@ -2107,8 +2095,7 @@ delegate: | |||
2107 | 2095 | ||
2108 | spin_unlock(&udc->lock); | 2096 | spin_unlock(&udc->lock); |
2109 | if (usb_ep_set_halt(&mEp->ep)) | 2097 | if (usb_ep_set_halt(&mEp->ep)) |
2110 | dev_err(&udc->gadget.dev, | 2098 | dev_err(udc->dev, "error: ep_set_halt\n"); |
2111 | "error: ep_set_halt\n"); | ||
2112 | spin_lock(&udc->lock); | 2099 | spin_lock(&udc->lock); |
2113 | } | 2100 | } |
2114 | } | 2101 | } |
@@ -2129,7 +2116,7 @@ static int ep_enable(struct usb_ep *ep, | |||
2129 | int retval = 0; | 2116 | int retval = 0; |
2130 | unsigned long flags; | 2117 | unsigned long flags; |
2131 | 2118 | ||
2132 | trace("%p, %p", ep, desc); | 2119 | trace(mEp->udc->dev, "%p, %p", ep, desc); |
2133 | 2120 | ||
2134 | if (ep == NULL || desc == NULL) | 2121 | if (ep == NULL || desc == NULL) |
2135 | return -EINVAL; | 2122 | return -EINVAL; |
@@ -2141,7 +2128,7 @@ static int ep_enable(struct usb_ep *ep, | |||
2141 | mEp->ep.desc = desc; | 2128 | mEp->ep.desc = desc; |
2142 | 2129 | ||
2143 | if (!list_empty(&mEp->qh.queue)) | 2130 | if (!list_empty(&mEp->qh.queue)) |
2144 | warn("enabling a non-empty endpoint!"); | 2131 | dev_warn(mEp->udc->dev, "enabling a non-empty endpoint!\n"); |
2145 | 2132 | ||
2146 | mEp->dir = usb_endpoint_dir_in(desc) ? TX : RX; | 2133 | mEp->dir = usb_endpoint_dir_in(desc) ? TX : RX; |
2147 | mEp->num = usb_endpoint_num(desc); | 2134 | mEp->num = usb_endpoint_num(desc); |
@@ -2186,7 +2173,7 @@ static int ep_disable(struct usb_ep *ep) | |||
2186 | int direction, retval = 0; | 2173 | int direction, retval = 0; |
2187 | unsigned long flags; | 2174 | unsigned long flags; |
2188 | 2175 | ||
2189 | trace("%p", ep); | 2176 | trace(mEp->udc->dev, "%p", ep); |
2190 | 2177 | ||
2191 | if (ep == NULL) | 2178 | if (ep == NULL) |
2192 | return -EINVAL; | 2179 | return -EINVAL; |
@@ -2225,12 +2212,10 @@ static struct usb_request *ep_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) | |||
2225 | struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep); | 2212 | struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep); |
2226 | struct ci13xxx_req *mReq = NULL; | 2213 | struct ci13xxx_req *mReq = NULL; |
2227 | 2214 | ||
2228 | trace("%p, %i", ep, gfp_flags); | 2215 | trace(mEp->udc->dev, "%p, %i", ep, gfp_flags); |
2229 | 2216 | ||
2230 | if (ep == NULL) { | 2217 | if (ep == NULL) |
2231 | pr_err("EINVAL\n"); | ||
2232 | return NULL; | 2218 | return NULL; |
2233 | } | ||
2234 | 2219 | ||
2235 | mReq = kzalloc(sizeof(struct ci13xxx_req), gfp_flags); | 2220 | mReq = kzalloc(sizeof(struct ci13xxx_req), gfp_flags); |
2236 | if (mReq != NULL) { | 2221 | if (mReq != NULL) { |
@@ -2261,13 +2246,12 @@ static void ep_free_request(struct usb_ep *ep, struct usb_request *req) | |||
2261 | struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req); | 2246 | struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req); |
2262 | unsigned long flags; | 2247 | unsigned long flags; |
2263 | 2248 | ||
2264 | trace("%p, %p", ep, req); | 2249 | trace(mEp->udc->dev, "%p, %p", ep, req); |
2265 | 2250 | ||
2266 | if (ep == NULL || req == NULL) { | 2251 | if (ep == NULL || req == NULL) { |
2267 | pr_err("EINVAL\n"); | ||
2268 | return; | 2252 | return; |
2269 | } else if (!list_empty(&mReq->queue)) { | 2253 | } else if (!list_empty(&mReq->queue)) { |
2270 | pr_err("EBUSY\n"); | 2254 | dev_err(mEp->udc->dev, "freeing queued request\n"); |
2271 | return; | 2255 | return; |
2272 | } | 2256 | } |
2273 | 2257 | ||
@@ -2295,7 +2279,7 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req, | |||
2295 | int retval = 0; | 2279 | int retval = 0; |
2296 | unsigned long flags; | 2280 | unsigned long flags; |
2297 | 2281 | ||
2298 | trace("%p, %p, %X", ep, req, gfp_flags); | 2282 | trace(mEp->udc->dev, "%p, %p, %X", ep, req, gfp_flags); |
2299 | 2283 | ||
2300 | if (ep == NULL || req == NULL || mEp->ep.desc == NULL) | 2284 | if (ep == NULL || req == NULL || mEp->ep.desc == NULL) |
2301 | return -EINVAL; | 2285 | return -EINVAL; |
@@ -2309,21 +2293,22 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req, | |||
2309 | if (!list_empty(&mEp->qh.queue)) { | 2293 | if (!list_empty(&mEp->qh.queue)) { |
2310 | _ep_nuke(mEp); | 2294 | _ep_nuke(mEp); |
2311 | retval = -EOVERFLOW; | 2295 | retval = -EOVERFLOW; |
2312 | warn("endpoint ctrl %X nuked", _usb_addr(mEp)); | 2296 | dev_warn(mEp->udc->dev, "endpoint ctrl %X nuked\n", |
2297 | _usb_addr(mEp)); | ||
2313 | } | 2298 | } |
2314 | } | 2299 | } |
2315 | 2300 | ||
2316 | /* first nuke then test link, e.g. previous status has not sent */ | 2301 | /* first nuke then test link, e.g. previous status has not sent */ |
2317 | if (!list_empty(&mReq->queue)) { | 2302 | if (!list_empty(&mReq->queue)) { |
2318 | retval = -EBUSY; | 2303 | retval = -EBUSY; |
2319 | pr_err("request already in queue\n"); | 2304 | dev_err(mEp->udc->dev, "request already in queue\n"); |
2320 | goto done; | 2305 | goto done; |
2321 | } | 2306 | } |
2322 | 2307 | ||
2323 | if (req->length > 4 * CI13XXX_PAGE_SIZE) { | 2308 | if (req->length > 4 * CI13XXX_PAGE_SIZE) { |
2324 | req->length = 4 * CI13XXX_PAGE_SIZE; | 2309 | req->length = 4 * CI13XXX_PAGE_SIZE; |
2325 | retval = -EMSGSIZE; | 2310 | retval = -EMSGSIZE; |
2326 | warn("request length truncated"); | 2311 | dev_warn(mEp->udc->dev, "request length truncated\n"); |
2327 | } | 2312 | } |
2328 | 2313 | ||
2329 | dbg_queue(_usb_addr(mEp), req, retval); | 2314 | dbg_queue(_usb_addr(mEp), req, retval); |
@@ -2357,7 +2342,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req) | |||
2357 | struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req); | 2342 | struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req); |
2358 | unsigned long flags; | 2343 | unsigned long flags; |
2359 | 2344 | ||
2360 | trace("%p, %p", ep, req); | 2345 | trace(mEp->udc->dev, "%p, %p", ep, req); |
2361 | 2346 | ||
2362 | if (ep == NULL || req == NULL || mReq->req.status != -EALREADY || | 2347 | if (ep == NULL || req == NULL || mReq->req.status != -EALREADY || |
2363 | mEp->ep.desc == NULL || list_empty(&mReq->queue) || | 2348 | mEp->ep.desc == NULL || list_empty(&mReq->queue) || |
@@ -2401,7 +2386,7 @@ static int ep_set_halt(struct usb_ep *ep, int value) | |||
2401 | int direction, retval = 0; | 2386 | int direction, retval = 0; |
2402 | unsigned long flags; | 2387 | unsigned long flags; |
2403 | 2388 | ||
2404 | trace("%p, %i", ep, value); | 2389 | trace(mEp->udc->dev, "%p, %i", ep, value); |
2405 | 2390 | ||
2406 | if (ep == NULL || mEp->ep.desc == NULL) | 2391 | if (ep == NULL || mEp->ep.desc == NULL) |
2407 | return -EINVAL; | 2392 | return -EINVAL; |
@@ -2444,7 +2429,7 @@ static int ep_set_wedge(struct usb_ep *ep) | |||
2444 | struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep); | 2429 | struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep); |
2445 | unsigned long flags; | 2430 | unsigned long flags; |
2446 | 2431 | ||
2447 | trace("%p", ep); | 2432 | trace(mEp->udc->dev, "%p", ep); |
2448 | 2433 | ||
2449 | if (ep == NULL || mEp->ep.desc == NULL) | 2434 | if (ep == NULL || mEp->ep.desc == NULL) |
2450 | return -EINVAL; | 2435 | return -EINVAL; |
@@ -2469,10 +2454,10 @@ static void ep_fifo_flush(struct usb_ep *ep) | |||
2469 | struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep); | 2454 | struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep); |
2470 | unsigned long flags; | 2455 | unsigned long flags; |
2471 | 2456 | ||
2472 | trace("%p", ep); | 2457 | trace(mEp->udc->dev, "%p", ep); |
2473 | 2458 | ||
2474 | if (ep == NULL) { | 2459 | if (ep == NULL) { |
2475 | pr_err("%02X: -EINVAL\n", _usb_addr(mEp)); | 2460 | dev_err(mEp->udc->dev, "%02X: -EINVAL\n", _usb_addr(mEp)); |
2476 | return; | 2461 | return; |
2477 | } | 2462 | } |
2478 | 2463 | ||
@@ -2542,17 +2527,17 @@ static int ci13xxx_wakeup(struct usb_gadget *_gadget) | |||
2542 | unsigned long flags; | 2527 | unsigned long flags; |
2543 | int ret = 0; | 2528 | int ret = 0; |
2544 | 2529 | ||
2545 | trace(); | 2530 | trace(udc->dev, ""); |
2546 | 2531 | ||
2547 | spin_lock_irqsave(&udc->lock, flags); | 2532 | spin_lock_irqsave(&udc->lock, flags); |
2548 | if (!udc->remote_wakeup) { | 2533 | if (!udc->remote_wakeup) { |
2549 | ret = -EOPNOTSUPP; | 2534 | ret = -EOPNOTSUPP; |
2550 | trace("remote wakeup feature is not enabled\n"); | 2535 | trace(udc->dev, "remote wakeup feature is not enabled\n"); |
2551 | goto out; | 2536 | goto out; |
2552 | } | 2537 | } |
2553 | if (!hw_read(udc, OP_PORTSC, PORTSC_SUSP)) { | 2538 | if (!hw_read(udc, OP_PORTSC, PORTSC_SUSP)) { |
2554 | ret = -EINVAL; | 2539 | ret = -EINVAL; |
2555 | trace("port is not suspended\n"); | 2540 | trace(udc->dev, "port is not suspended\n"); |
2556 | goto out; | 2541 | goto out; |
2557 | } | 2542 | } |
2558 | hw_write(udc, OP_PORTSC, PORTSC_FPR, PORTSC_FPR); | 2543 | hw_write(udc, OP_PORTSC, PORTSC_FPR, PORTSC_FPR); |
@@ -2602,7 +2587,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, | |||
2602 | int i, j; | 2587 | int i, j; |
2603 | int retval = -ENOMEM; | 2588 | int retval = -ENOMEM; |
2604 | 2589 | ||
2605 | trace("%p", driver); | 2590 | trace(udc->dev, "%p", driver); |
2606 | 2591 | ||
2607 | if (driver == NULL || | 2592 | if (driver == NULL || |
2608 | bind == NULL || | 2593 | bind == NULL || |
@@ -2632,7 +2617,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, | |||
2632 | 2617 | ||
2633 | spin_lock_irqsave(&udc->lock, flags); | 2618 | spin_lock_irqsave(&udc->lock, flags); |
2634 | 2619 | ||
2635 | info("hw_ep_max = %d", udc->hw_ep_max); | 2620 | dev_info(udc->dev, "hw_ep_max = %d\n", udc->hw_ep_max); |
2636 | 2621 | ||
2637 | udc->gadget.dev.driver = NULL; | 2622 | udc->gadget.dev.driver = NULL; |
2638 | 2623 | ||
@@ -2740,7 +2725,7 @@ static int ci13xxx_stop(struct usb_gadget_driver *driver) | |||
2740 | struct ci13xxx *udc = _udc; | 2725 | struct ci13xxx *udc = _udc; |
2741 | unsigned long i, flags; | 2726 | unsigned long i, flags; |
2742 | 2727 | ||
2743 | trace("%p", driver); | 2728 | trace(udc->dev, "%p", driver); |
2744 | 2729 | ||
2745 | if (driver == NULL || | 2730 | if (driver == NULL || |
2746 | driver->unbind == NULL || | 2731 | driver->unbind == NULL || |
@@ -2813,10 +2798,10 @@ static irqreturn_t udc_irq(int irq, void *data) | |||
2813 | irqreturn_t retval; | 2798 | irqreturn_t retval; |
2814 | u32 intr; | 2799 | u32 intr; |
2815 | 2800 | ||
2816 | trace(); | 2801 | trace(udc ? udc->dev : NULL, ""); |
2817 | 2802 | ||
2818 | if (udc == NULL) { | 2803 | if (udc == NULL) { |
2819 | pr_err("ENODEV\n"); | 2804 | dev_err(udc->dev, "ENODEV"); |
2820 | return IRQ_HANDLED; | 2805 | return IRQ_HANDLED; |
2821 | } | 2806 | } |
2822 | 2807 | ||
@@ -2885,10 +2870,7 @@ static irqreturn_t udc_irq(int irq, void *data) | |||
2885 | */ | 2870 | */ |
2886 | static void udc_release(struct device *dev) | 2871 | static void udc_release(struct device *dev) |
2887 | { | 2872 | { |
2888 | trace("%p", dev); | 2873 | trace(dev->parent, "%p", dev); |
2889 | |||
2890 | if (dev == NULL) | ||
2891 | pr_err("EINVAL\n"); | ||
2892 | } | 2874 | } |
2893 | 2875 | ||
2894 | /** | 2876 | /** |
@@ -2907,7 +2889,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, | |||
2907 | struct ci13xxx *udc; | 2889 | struct ci13xxx *udc; |
2908 | int retval = 0; | 2890 | int retval = 0; |
2909 | 2891 | ||
2910 | trace("%p, %p, %p", dev, regs, driver->name); | 2892 | trace(dev, "%p, %p, %p", dev, regs, driver->name); |
2911 | 2893 | ||
2912 | if (dev == NULL || regs == NULL || driver == NULL || | 2894 | if (dev == NULL || regs == NULL || driver == NULL || |
2913 | driver->name == NULL) | 2895 | driver->name == NULL) |
@@ -2936,6 +2918,8 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, | |||
2936 | udc->gadget.dev.parent = dev; | 2918 | udc->gadget.dev.parent = dev; |
2937 | udc->gadget.dev.release = udc_release; | 2919 | udc->gadget.dev.release = udc_release; |
2938 | 2920 | ||
2921 | udc->dev = dev; | ||
2922 | |||
2939 | retval = hw_device_init(udc, regs, driver->capoffset); | 2923 | retval = hw_device_init(udc, regs, driver->capoffset); |
2940 | if (retval < 0) | 2924 | if (retval < 0) |
2941 | goto free_udc; | 2925 | goto free_udc; |
@@ -3015,10 +2999,9 @@ static void udc_remove(void) | |||
3015 | { | 2999 | { |
3016 | struct ci13xxx *udc = _udc; | 3000 | struct ci13xxx *udc = _udc; |
3017 | 3001 | ||
3018 | if (udc == NULL) { | 3002 | if (udc == NULL) |
3019 | pr_err("EINVAL\n"); | ||
3020 | return; | 3003 | return; |
3021 | } | 3004 | |
3022 | usb_del_gadget_udc(&udc->gadget); | 3005 | usb_del_gadget_udc(&udc->gadget); |
3023 | 3006 | ||
3024 | if (udc->transceiver) { | 3007 | if (udc->transceiver) { |
diff --git a/drivers/usb/gadget/ci13xxx_udc.h b/drivers/usb/gadget/ci13xxx_udc.h index f605090777ce..a12fa569315f 100644 --- a/drivers/usb/gadget/ci13xxx_udc.h +++ b/drivers/usb/gadget/ci13xxx_udc.h | |||
@@ -134,6 +134,7 @@ struct ci13xxx { | |||
134 | struct dma_pool *td_pool; /* DMA pool for transfer descs */ | 134 | struct dma_pool *td_pool; /* DMA pool for transfer descs */ |
135 | struct usb_request *status; /* ep0 status request */ | 135 | struct usb_request *status; /* ep0 status request */ |
136 | 136 | ||
137 | struct device *dev; | ||
137 | struct usb_gadget gadget; /* USB slave device */ | 138 | struct usb_gadget gadget; /* USB slave device */ |
138 | struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */ | 139 | struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */ |
139 | u32 ep0_dir; /* ep0 direction */ | 140 | u32 ep0_dir; /* ep0 direction */ |
@@ -245,24 +246,18 @@ enum ci13xxx_regs { | |||
245 | /****************************************************************************** | 246 | /****************************************************************************** |
246 | * LOGGING | 247 | * LOGGING |
247 | *****************************************************************************/ | 248 | *****************************************************************************/ |
248 | #define ci13xxx_printk(level, format, args...) \ | ||
249 | do { \ | ||
250 | if (_udc == NULL) \ | ||
251 | printk(level "[%s] " format "\n", __func__, ## args); \ | ||
252 | else \ | ||
253 | dev_printk(level, _udc->gadget.dev.parent, \ | ||
254 | "[%s] " format "\n", __func__, ## args); \ | ||
255 | } while (0) | ||
256 | |||
257 | #define warn(format, args...) ci13xxx_printk(KERN_WARNING, format, ## args) | ||
258 | #define info(format, args...) ci13xxx_printk(KERN_INFO, format, ## args) | ||
259 | |||
260 | #ifdef TRACE | 249 | #ifdef TRACE |
261 | #define trace(format, args...) ci13xxx_printk(KERN_DEBUG, format, ## args) | 250 | #define trace(dev, format, args...) \ |
262 | #define dbg_trace(format, args...) dev_dbg(dev, format, ##args) | 251 | do { \ |
252 | if (dev == NULL) \ | ||
253 | pr_debug("[%s] " format "\n", __func__, \ | ||
254 | ## args); \ | ||
255 | else \ | ||
256 | dev_printk(KERN_DEBUG, dev, "[%s] " format "\n", \ | ||
257 | __func__, ## args); \ | ||
258 | } while (0) | ||
263 | #else | 259 | #else |
264 | #define trace(format, args...) do {} while (0) | 260 | #define trace(dev, format, args...) do {} while (0) |
265 | #define dbg_trace(format, args...) do {} while (0) | ||
266 | #endif | 261 | #endif |
267 | 262 | ||
268 | #endif /* _CI13XXX_h_ */ | 263 | #endif /* _CI13XXX_h_ */ |