aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/Kconfig7
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.c268
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.h9
-rw-r--r--drivers/usb/gadget/composite.c5
-rw-r--r--drivers/usb/gadget/pch_udc.c127
-rw-r--r--drivers/usb/gadget/printer.c19
6 files changed, 237 insertions, 198 deletions
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 1dc9739277b4..06bb9d4587e9 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -509,7 +509,7 @@ config USB_LANGWELL
509 select USB_GADGET_SELECTED 509 select USB_GADGET_SELECTED
510 510
511config USB_GADGET_EG20T 511config USB_GADGET_EG20T
512 boolean "Intel EG20T(Topcliff) USB Device controller" 512 boolean "Intel EG20T PCH/OKI SEMICONDUCTOR ML7213 IOH UDC"
513 depends on PCI 513 depends on PCI
514 select USB_GADGET_DUALSPEED 514 select USB_GADGET_DUALSPEED
515 help 515 help
@@ -525,6 +525,11 @@ config USB_GADGET_EG20T
525 This driver dose not support interrupt transfer or isochronous 525 This driver dose not support interrupt transfer or isochronous
526 transfer modes. 526 transfer modes.
527 527
528 This driver also can be used for OKI SEMICONDUCTOR's ML7213 which is
529 for IVI(In-Vehicle Infotainment) use.
530 ML7213 is companion chip for Intel Atom E6xx series.
531 ML7213 is completely compatible for Intel EG20T PCH.
532
528config USB_EG20T 533config USB_EG20T
529 tristate 534 tristate
530 depends on USB_GADGET_EG20T 535 depends on USB_GADGET_EG20T
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index 31656a2b4ab4..a1c67ae1572a 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -76,10 +76,21 @@ static DEFINE_SPINLOCK(udc_lock);
76 76
77/* control endpoint description */ 77/* control endpoint description */
78static const struct usb_endpoint_descriptor 78static const struct usb_endpoint_descriptor
79ctrl_endpt_desc = { 79ctrl_endpt_out_desc = {
80 .bLength = USB_DT_ENDPOINT_SIZE, 80 .bLength = USB_DT_ENDPOINT_SIZE,
81 .bDescriptorType = USB_DT_ENDPOINT, 81 .bDescriptorType = USB_DT_ENDPOINT,
82 82
83 .bEndpointAddress = USB_DIR_OUT,
84 .bmAttributes = USB_ENDPOINT_XFER_CONTROL,
85 .wMaxPacketSize = cpu_to_le16(CTRL_PAYLOAD_MAX),
86};
87
88static const struct usb_endpoint_descriptor
89ctrl_endpt_in_desc = {
90 .bLength = USB_DT_ENDPOINT_SIZE,
91 .bDescriptorType = USB_DT_ENDPOINT,
92
93 .bEndpointAddress = USB_DIR_IN,
83 .bmAttributes = USB_ENDPOINT_XFER_CONTROL, 94 .bmAttributes = USB_ENDPOINT_XFER_CONTROL,
84 .wMaxPacketSize = cpu_to_le16(CTRL_PAYLOAD_MAX), 95 .wMaxPacketSize = cpu_to_le16(CTRL_PAYLOAD_MAX),
85}; 96};
@@ -265,10 +276,10 @@ static int hw_device_init(void __iomem *base)
265 hw_bank.size /= sizeof(u32); 276 hw_bank.size /= sizeof(u32);
266 277
267 reg = hw_aread(ABS_DCCPARAMS, DCCPARAMS_DEN) >> ffs_nr(DCCPARAMS_DEN); 278 reg = hw_aread(ABS_DCCPARAMS, DCCPARAMS_DEN) >> ffs_nr(DCCPARAMS_DEN);
268 if (reg == 0 || reg > ENDPT_MAX) 279 hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */
269 return -ENODEV;
270 280
271 hw_ep_max = reg; /* cache hw ENDPT_MAX */ 281 if (hw_ep_max == 0 || hw_ep_max > ENDPT_MAX)
282 return -ENODEV;
272 283
273 /* setup lock mode ? */ 284 /* setup lock mode ? */
274 285
@@ -1197,16 +1208,17 @@ static ssize_t show_qheads(struct device *dev, struct device_attribute *attr,
1197 } 1208 }
1198 1209
1199 spin_lock_irqsave(udc->lock, flags); 1210 spin_lock_irqsave(udc->lock, flags);
1200 for (i = 0; i < hw_ep_max; i++) { 1211 for (i = 0; i < hw_ep_max/2; i++) {
1201 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i]; 1212 struct ci13xxx_ep *mEpRx = &udc->ci13xxx_ep[i];
1213 struct ci13xxx_ep *mEpTx = &udc->ci13xxx_ep[i + hw_ep_max/2];
1202 n += scnprintf(buf + n, PAGE_SIZE - n, 1214 n += scnprintf(buf + n, PAGE_SIZE - n,
1203 "EP=%02i: RX=%08X TX=%08X\n", 1215 "EP=%02i: RX=%08X TX=%08X\n",
1204 i, (u32)mEp->qh[RX].dma, (u32)mEp->qh[TX].dma); 1216 i, (u32)mEpRx->qh.dma, (u32)mEpTx->qh.dma);
1205 for (j = 0; j < (sizeof(struct ci13xxx_qh)/sizeof(u32)); j++) { 1217 for (j = 0; j < (sizeof(struct ci13xxx_qh)/sizeof(u32)); j++) {
1206 n += scnprintf(buf + n, PAGE_SIZE - n, 1218 n += scnprintf(buf + n, PAGE_SIZE - n,
1207 " %04X: %08X %08X\n", j, 1219 " %04X: %08X %08X\n", j,
1208 *((u32 *)mEp->qh[RX].ptr + j), 1220 *((u32 *)mEpRx->qh.ptr + j),
1209 *((u32 *)mEp->qh[TX].ptr + j)); 1221 *((u32 *)mEpTx->qh.ptr + j));
1210 } 1222 }
1211 } 1223 }
1212 spin_unlock_irqrestore(udc->lock, flags); 1224 spin_unlock_irqrestore(udc->lock, flags);
@@ -1293,7 +1305,7 @@ static ssize_t show_requests(struct device *dev, struct device_attribute *attr,
1293 unsigned long flags; 1305 unsigned long flags;
1294 struct list_head *ptr = NULL; 1306 struct list_head *ptr = NULL;
1295 struct ci13xxx_req *req = NULL; 1307 struct ci13xxx_req *req = NULL;
1296 unsigned i, j, k, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32); 1308 unsigned i, j, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32);
1297 1309
1298 dbg_trace("[%s] %p\n", __func__, buf); 1310 dbg_trace("[%s] %p\n", __func__, buf);
1299 if (attr == NULL || buf == NULL) { 1311 if (attr == NULL || buf == NULL) {
@@ -1303,22 +1315,20 @@ static ssize_t show_requests(struct device *dev, struct device_attribute *attr,
1303 1315
1304 spin_lock_irqsave(udc->lock, flags); 1316 spin_lock_irqsave(udc->lock, flags);
1305 for (i = 0; i < hw_ep_max; i++) 1317 for (i = 0; i < hw_ep_max; i++)
1306 for (k = RX; k <= TX; k++) 1318 list_for_each(ptr, &udc->ci13xxx_ep[i].qh.queue)
1307 list_for_each(ptr, &udc->ci13xxx_ep[i].qh[k].queue) 1319 {
1308 { 1320 req = list_entry(ptr, struct ci13xxx_req, queue);
1309 req = list_entry(ptr, 1321
1310 struct ci13xxx_req, queue); 1322 n += scnprintf(buf + n, PAGE_SIZE - n,
1323 "EP=%02i: TD=%08X %s\n",
1324 i % hw_ep_max/2, (u32)req->dma,
1325 ((i < hw_ep_max/2) ? "RX" : "TX"));
1311 1326
1327 for (j = 0; j < qSize; j++)
1312 n += scnprintf(buf + n, PAGE_SIZE - n, 1328 n += scnprintf(buf + n, PAGE_SIZE - n,
1313 "EP=%02i: TD=%08X %s\n", 1329 " %04X: %08X\n", j,
1314 i, (u32)req->dma, 1330 *((u32 *)req->ptr + j));
1315 ((k == RX) ? "RX" : "TX")); 1331 }
1316
1317 for (j = 0; j < qSize; j++)
1318 n += scnprintf(buf + n, PAGE_SIZE - n,
1319 " %04X: %08X\n", j,
1320 *((u32 *)req->ptr + j));
1321 }
1322 spin_unlock_irqrestore(udc->lock, flags); 1332 spin_unlock_irqrestore(udc->lock, flags);
1323 1333
1324 return n; 1334 return n;
@@ -1467,12 +1477,12 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
1467 * At this point it's guaranteed exclusive access to qhead 1477 * At this point it's guaranteed exclusive access to qhead
1468 * (endpt is not primed) so it's no need to use tripwire 1478 * (endpt is not primed) so it's no need to use tripwire
1469 */ 1479 */
1470 mEp->qh[mEp->dir].ptr->td.next = mReq->dma; /* TERMINATE = 0 */ 1480 mEp->qh.ptr->td.next = mReq->dma; /* TERMINATE = 0 */
1471 mEp->qh[mEp->dir].ptr->td.token &= ~TD_STATUS; /* clear status */ 1481 mEp->qh.ptr->td.token &= ~TD_STATUS; /* clear status */
1472 if (mReq->req.zero == 0) 1482 if (mReq->req.zero == 0)
1473 mEp->qh[mEp->dir].ptr->cap |= QH_ZLT; 1483 mEp->qh.ptr->cap |= QH_ZLT;
1474 else 1484 else
1475 mEp->qh[mEp->dir].ptr->cap &= ~QH_ZLT; 1485 mEp->qh.ptr->cap &= ~QH_ZLT;
1476 1486
1477 wmb(); /* synchronize before ep prime */ 1487 wmb(); /* synchronize before ep prime */
1478 1488
@@ -1542,11 +1552,11 @@ __acquires(mEp->lock)
1542 1552
1543 hw_ep_flush(mEp->num, mEp->dir); 1553 hw_ep_flush(mEp->num, mEp->dir);
1544 1554
1545 while (!list_empty(&mEp->qh[mEp->dir].queue)) { 1555 while (!list_empty(&mEp->qh.queue)) {
1546 1556
1547 /* pop oldest request */ 1557 /* pop oldest request */
1548 struct ci13xxx_req *mReq = \ 1558 struct ci13xxx_req *mReq = \
1549 list_entry(mEp->qh[mEp->dir].queue.next, 1559 list_entry(mEp->qh.queue.next,
1550 struct ci13xxx_req, queue); 1560 struct ci13xxx_req, queue);
1551 list_del_init(&mReq->queue); 1561 list_del_init(&mReq->queue);
1552 mReq->req.status = -ESHUTDOWN; 1562 mReq->req.status = -ESHUTDOWN;
@@ -1571,8 +1581,6 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
1571{ 1581{
1572 struct usb_ep *ep; 1582 struct usb_ep *ep;
1573 struct ci13xxx *udc = container_of(gadget, struct ci13xxx, gadget); 1583 struct ci13xxx *udc = container_of(gadget, struct ci13xxx, gadget);
1574 struct ci13xxx_ep *mEp = container_of(gadget->ep0,
1575 struct ci13xxx_ep, ep);
1576 1584
1577 trace("%p", gadget); 1585 trace("%p", gadget);
1578 1586
@@ -1583,7 +1591,8 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
1583 gadget_for_each_ep(ep, gadget) { 1591 gadget_for_each_ep(ep, gadget) {
1584 usb_ep_fifo_flush(ep); 1592 usb_ep_fifo_flush(ep);
1585 } 1593 }
1586 usb_ep_fifo_flush(gadget->ep0); 1594 usb_ep_fifo_flush(&udc->ep0out.ep);
1595 usb_ep_fifo_flush(&udc->ep0in.ep);
1587 1596
1588 udc->driver->disconnect(gadget); 1597 udc->driver->disconnect(gadget);
1589 1598
@@ -1591,11 +1600,12 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
1591 gadget_for_each_ep(ep, gadget) { 1600 gadget_for_each_ep(ep, gadget) {
1592 usb_ep_disable(ep); 1601 usb_ep_disable(ep);
1593 } 1602 }
1594 usb_ep_disable(gadget->ep0); 1603 usb_ep_disable(&udc->ep0out.ep);
1604 usb_ep_disable(&udc->ep0in.ep);
1595 1605
1596 if (mEp->status != NULL) { 1606 if (udc->status != NULL) {
1597 usb_ep_free_request(gadget->ep0, mEp->status); 1607 usb_ep_free_request(&udc->ep0in.ep, udc->status);
1598 mEp->status = NULL; 1608 udc->status = NULL;
1599 } 1609 }
1600 1610
1601 return 0; 1611 return 0;
@@ -1614,7 +1624,6 @@ static void isr_reset_handler(struct ci13xxx *udc)
1614__releases(udc->lock) 1624__releases(udc->lock)
1615__acquires(udc->lock) 1625__acquires(udc->lock)
1616{ 1626{
1617 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[0];
1618 int retval; 1627 int retval;
1619 1628
1620 trace("%p", udc); 1629 trace("%p", udc);
@@ -1635,11 +1644,15 @@ __acquires(udc->lock)
1635 if (retval) 1644 if (retval)
1636 goto done; 1645 goto done;
1637 1646
1638 retval = usb_ep_enable(&mEp->ep, &ctrl_endpt_desc); 1647 retval = usb_ep_enable(&udc->ep0out.ep, &ctrl_endpt_out_desc);
1648 if (retval)
1649 goto done;
1650
1651 retval = usb_ep_enable(&udc->ep0in.ep, &ctrl_endpt_in_desc);
1639 if (!retval) { 1652 if (!retval) {
1640 mEp->status = usb_ep_alloc_request(&mEp->ep, GFP_ATOMIC); 1653 udc->status = usb_ep_alloc_request(&udc->ep0in.ep, GFP_ATOMIC);
1641 if (mEp->status == NULL) { 1654 if (udc->status == NULL) {
1642 usb_ep_disable(&mEp->ep); 1655 usb_ep_disable(&udc->ep0out.ep);
1643 retval = -ENOMEM; 1656 retval = -ENOMEM;
1644 } 1657 }
1645 } 1658 }
@@ -1672,16 +1685,17 @@ static void isr_get_status_complete(struct usb_ep *ep, struct usb_request *req)
1672 1685
1673/** 1686/**
1674 * isr_get_status_response: get_status request response 1687 * isr_get_status_response: get_status request response
1675 * @ep: endpoint 1688 * @udc: udc struct
1676 * @setup: setup request packet 1689 * @setup: setup request packet
1677 * 1690 *
1678 * This function returns an error code 1691 * This function returns an error code
1679 */ 1692 */
1680static int isr_get_status_response(struct ci13xxx_ep *mEp, 1693static int isr_get_status_response(struct ci13xxx *udc,
1681 struct usb_ctrlrequest *setup) 1694 struct usb_ctrlrequest *setup)
1682__releases(mEp->lock) 1695__releases(mEp->lock)
1683__acquires(mEp->lock) 1696__acquires(mEp->lock)
1684{ 1697{
1698 struct ci13xxx_ep *mEp = &udc->ep0in;
1685 struct usb_request *req = NULL; 1699 struct usb_request *req = NULL;
1686 gfp_t gfp_flags = GFP_ATOMIC; 1700 gfp_t gfp_flags = GFP_ATOMIC;
1687 int dir, num, retval; 1701 int dir, num, retval;
@@ -1736,27 +1750,23 @@ __acquires(mEp->lock)
1736 1750
1737/** 1751/**
1738 * isr_setup_status_phase: queues the status phase of a setup transation 1752 * isr_setup_status_phase: queues the status phase of a setup transation
1739 * @mEp: endpoint 1753 * @udc: udc struct
1740 * 1754 *
1741 * This function returns an error code 1755 * This function returns an error code
1742 */ 1756 */
1743static int isr_setup_status_phase(struct ci13xxx_ep *mEp) 1757static int isr_setup_status_phase(struct ci13xxx *udc)
1744__releases(mEp->lock) 1758__releases(mEp->lock)
1745__acquires(mEp->lock) 1759__acquires(mEp->lock)
1746{ 1760{
1747 int retval; 1761 int retval;
1762 struct ci13xxx_ep *mEp;
1748 1763
1749 trace("%p", mEp); 1764 trace("%p", udc);
1750
1751 /* mEp is always valid & configured */
1752
1753 if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
1754 mEp->dir = (mEp->dir == TX) ? RX : TX;
1755 1765
1756 mEp->status->no_interrupt = 1; 1766 mEp = (udc->ep0_dir == TX) ? &udc->ep0out : &udc->ep0in;
1757 1767
1758 spin_unlock(mEp->lock); 1768 spin_unlock(mEp->lock);
1759 retval = usb_ep_queue(&mEp->ep, mEp->status, GFP_ATOMIC); 1769 retval = usb_ep_queue(&mEp->ep, udc->status, GFP_ATOMIC);
1760 spin_lock(mEp->lock); 1770 spin_lock(mEp->lock);
1761 1771
1762 return retval; 1772 return retval;
@@ -1778,11 +1788,11 @@ __acquires(mEp->lock)
1778 1788
1779 trace("%p", mEp); 1789 trace("%p", mEp);
1780 1790
1781 if (list_empty(&mEp->qh[mEp->dir].queue)) 1791 if (list_empty(&mEp->qh.queue))
1782 return -EINVAL; 1792 return -EINVAL;
1783 1793
1784 /* pop oldest request */ 1794 /* pop oldest request */
1785 mReq = list_entry(mEp->qh[mEp->dir].queue.next, 1795 mReq = list_entry(mEp->qh.queue.next,
1786 struct ci13xxx_req, queue); 1796 struct ci13xxx_req, queue);
1787 list_del_init(&mReq->queue); 1797 list_del_init(&mReq->queue);
1788 1798
@@ -1794,10 +1804,10 @@ __acquires(mEp->lock)
1794 1804
1795 dbg_done(_usb_addr(mEp), mReq->ptr->token, retval); 1805 dbg_done(_usb_addr(mEp), mReq->ptr->token, retval);
1796 1806
1797 if (!list_empty(&mEp->qh[mEp->dir].queue)) { 1807 if (!list_empty(&mEp->qh.queue)) {
1798 struct ci13xxx_req* mReqEnq; 1808 struct ci13xxx_req* mReqEnq;
1799 1809
1800 mReqEnq = list_entry(mEp->qh[mEp->dir].queue.next, 1810 mReqEnq = list_entry(mEp->qh.queue.next,
1801 struct ci13xxx_req, queue); 1811 struct ci13xxx_req, queue);
1802 _hardware_enqueue(mEp, mReqEnq); 1812 _hardware_enqueue(mEp, mReqEnq);
1803 } 1813 }
@@ -1836,16 +1846,14 @@ __acquires(udc->lock)
1836 int type, num, err = -EINVAL; 1846 int type, num, err = -EINVAL;
1837 struct usb_ctrlrequest req; 1847 struct usb_ctrlrequest req;
1838 1848
1839
1840 if (mEp->desc == NULL) 1849 if (mEp->desc == NULL)
1841 continue; /* not configured */ 1850 continue; /* not configured */
1842 1851
1843 if ((mEp->dir == RX && hw_test_and_clear_complete(i)) || 1852 if (hw_test_and_clear_complete(i)) {
1844 (mEp->dir == TX && hw_test_and_clear_complete(i + 16))) {
1845 err = isr_tr_complete_low(mEp); 1853 err = isr_tr_complete_low(mEp);
1846 if (mEp->type == USB_ENDPOINT_XFER_CONTROL) { 1854 if (mEp->type == USB_ENDPOINT_XFER_CONTROL) {
1847 if (err > 0) /* needs status phase */ 1855 if (err > 0) /* needs status phase */
1848 err = isr_setup_status_phase(mEp); 1856 err = isr_setup_status_phase(udc);
1849 if (err < 0) { 1857 if (err < 0) {
1850 dbg_event(_usb_addr(mEp), 1858 dbg_event(_usb_addr(mEp),
1851 "ERROR", err); 1859 "ERROR", err);
@@ -1866,15 +1874,22 @@ __acquires(udc->lock)
1866 continue; 1874 continue;
1867 } 1875 }
1868 1876
1877 /*
1878 * Flush data and handshake transactions of previous
1879 * setup packet.
1880 */
1881 _ep_nuke(&udc->ep0out);
1882 _ep_nuke(&udc->ep0in);
1883
1869 /* read_setup_packet */ 1884 /* read_setup_packet */
1870 do { 1885 do {
1871 hw_test_and_set_setup_guard(); 1886 hw_test_and_set_setup_guard();
1872 memcpy(&req, &mEp->qh[RX].ptr->setup, sizeof(req)); 1887 memcpy(&req, &mEp->qh.ptr->setup, sizeof(req));
1873 } while (!hw_test_and_clear_setup_guard()); 1888 } while (!hw_test_and_clear_setup_guard());
1874 1889
1875 type = req.bRequestType; 1890 type = req.bRequestType;
1876 1891
1877 mEp->dir = (type & USB_DIR_IN) ? TX : RX; 1892 udc->ep0_dir = (type & USB_DIR_IN) ? TX : RX;
1878 1893
1879 dbg_setup(_usb_addr(mEp), &req); 1894 dbg_setup(_usb_addr(mEp), &req);
1880 1895
@@ -1895,7 +1910,7 @@ __acquires(udc->lock)
1895 if (err) 1910 if (err)
1896 break; 1911 break;
1897 } 1912 }
1898 err = isr_setup_status_phase(mEp); 1913 err = isr_setup_status_phase(udc);
1899 break; 1914 break;
1900 case USB_REQ_GET_STATUS: 1915 case USB_REQ_GET_STATUS:
1901 if (type != (USB_DIR_IN|USB_RECIP_DEVICE) && 1916 if (type != (USB_DIR_IN|USB_RECIP_DEVICE) &&
@@ -1905,7 +1920,7 @@ __acquires(udc->lock)
1905 if (le16_to_cpu(req.wLength) != 2 || 1920 if (le16_to_cpu(req.wLength) != 2 ||
1906 le16_to_cpu(req.wValue) != 0) 1921 le16_to_cpu(req.wValue) != 0)
1907 break; 1922 break;
1908 err = isr_get_status_response(mEp, &req); 1923 err = isr_get_status_response(udc, &req);
1909 break; 1924 break;
1910 case USB_REQ_SET_ADDRESS: 1925 case USB_REQ_SET_ADDRESS:
1911 if (type != (USB_DIR_OUT|USB_RECIP_DEVICE)) 1926 if (type != (USB_DIR_OUT|USB_RECIP_DEVICE))
@@ -1916,7 +1931,7 @@ __acquires(udc->lock)
1916 err = hw_usb_set_address((u8)le16_to_cpu(req.wValue)); 1931 err = hw_usb_set_address((u8)le16_to_cpu(req.wValue));
1917 if (err) 1932 if (err)
1918 break; 1933 break;
1919 err = isr_setup_status_phase(mEp); 1934 err = isr_setup_status_phase(udc);
1920 break; 1935 break;
1921 case USB_REQ_SET_FEATURE: 1936 case USB_REQ_SET_FEATURE:
1922 if (type != (USB_DIR_OUT|USB_RECIP_ENDPOINT) && 1937 if (type != (USB_DIR_OUT|USB_RECIP_ENDPOINT) &&
@@ -1932,12 +1947,12 @@ __acquires(udc->lock)
1932 spin_lock(udc->lock); 1947 spin_lock(udc->lock);
1933 if (err) 1948 if (err)
1934 break; 1949 break;
1935 err = isr_setup_status_phase(mEp); 1950 err = isr_setup_status_phase(udc);
1936 break; 1951 break;
1937 default: 1952 default:
1938delegate: 1953delegate:
1939 if (req.wLength == 0) /* no data phase */ 1954 if (req.wLength == 0) /* no data phase */
1940 mEp->dir = TX; 1955 udc->ep0_dir = TX;
1941 1956
1942 spin_unlock(udc->lock); 1957 spin_unlock(udc->lock);
1943 err = udc->driver->setup(&udc->gadget, &req); 1958 err = udc->driver->setup(&udc->gadget, &req);
@@ -1968,7 +1983,7 @@ static int ep_enable(struct usb_ep *ep,
1968 const struct usb_endpoint_descriptor *desc) 1983 const struct usb_endpoint_descriptor *desc)
1969{ 1984{
1970 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep); 1985 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
1971 int direction, retval = 0; 1986 int retval = 0;
1972 unsigned long flags; 1987 unsigned long flags;
1973 1988
1974 trace("%p, %p", ep, desc); 1989 trace("%p, %p", ep, desc);
@@ -1982,7 +1997,7 @@ static int ep_enable(struct usb_ep *ep,
1982 1997
1983 mEp->desc = desc; 1998 mEp->desc = desc;
1984 1999
1985 if (!list_empty(&mEp->qh[mEp->dir].queue)) 2000 if (!list_empty(&mEp->qh.queue))
1986 warn("enabling a non-empty endpoint!"); 2001 warn("enabling a non-empty endpoint!");
1987 2002
1988 mEp->dir = usb_endpoint_dir_in(desc) ? TX : RX; 2003 mEp->dir = usb_endpoint_dir_in(desc) ? TX : RX;
@@ -1991,29 +2006,22 @@ static int ep_enable(struct usb_ep *ep,
1991 2006
1992 mEp->ep.maxpacket = __constant_le16_to_cpu(desc->wMaxPacketSize); 2007 mEp->ep.maxpacket = __constant_le16_to_cpu(desc->wMaxPacketSize);
1993 2008
1994 direction = mEp->dir; 2009 dbg_event(_usb_addr(mEp), "ENABLE", 0);
1995 do {
1996 dbg_event(_usb_addr(mEp), "ENABLE", 0);
1997 2010
1998 mEp->qh[mEp->dir].ptr->cap = 0; 2011 mEp->qh.ptr->cap = 0;
1999 2012
2000 if (mEp->type == USB_ENDPOINT_XFER_CONTROL) 2013 if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
2001 mEp->qh[mEp->dir].ptr->cap |= QH_IOS; 2014 mEp->qh.ptr->cap |= QH_IOS;
2002 else if (mEp->type == USB_ENDPOINT_XFER_ISOC) 2015 else if (mEp->type == USB_ENDPOINT_XFER_ISOC)
2003 mEp->qh[mEp->dir].ptr->cap &= ~QH_MULT; 2016 mEp->qh.ptr->cap &= ~QH_MULT;
2004 else 2017 else
2005 mEp->qh[mEp->dir].ptr->cap &= ~QH_ZLT; 2018 mEp->qh.ptr->cap &= ~QH_ZLT;
2006
2007 mEp->qh[mEp->dir].ptr->cap |=
2008 (mEp->ep.maxpacket << ffs_nr(QH_MAX_PKT)) & QH_MAX_PKT;
2009 mEp->qh[mEp->dir].ptr->td.next |= TD_TERMINATE; /* needed? */
2010
2011 retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);
2012 2019
2013 if (mEp->type == USB_ENDPOINT_XFER_CONTROL) 2020 mEp->qh.ptr->cap |=
2014 mEp->dir = (mEp->dir == TX) ? RX : TX; 2021 (mEp->ep.maxpacket << ffs_nr(QH_MAX_PKT)) & QH_MAX_PKT;
2022 mEp->qh.ptr->td.next |= TD_TERMINATE; /* needed? */
2015 2023
2016 } while (mEp->dir != direction); 2024 retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);
2017 2025
2018 spin_unlock_irqrestore(mEp->lock, flags); 2026 spin_unlock_irqrestore(mEp->lock, flags);
2019 return retval; 2027 return retval;
@@ -2146,7 +2154,7 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req,
2146 spin_lock_irqsave(mEp->lock, flags); 2154 spin_lock_irqsave(mEp->lock, flags);
2147 2155
2148 if (mEp->type == USB_ENDPOINT_XFER_CONTROL && 2156 if (mEp->type == USB_ENDPOINT_XFER_CONTROL &&
2149 !list_empty(&mEp->qh[mEp->dir].queue)) { 2157 !list_empty(&mEp->qh.queue)) {
2150 _ep_nuke(mEp); 2158 _ep_nuke(mEp);
2151 retval = -EOVERFLOW; 2159 retval = -EOVERFLOW;
2152 warn("endpoint ctrl %X nuked", _usb_addr(mEp)); 2160 warn("endpoint ctrl %X nuked", _usb_addr(mEp));
@@ -2170,9 +2178,9 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req,
2170 /* push request */ 2178 /* push request */
2171 mReq->req.status = -EINPROGRESS; 2179 mReq->req.status = -EINPROGRESS;
2172 mReq->req.actual = 0; 2180 mReq->req.actual = 0;
2173 list_add_tail(&mReq->queue, &mEp->qh[mEp->dir].queue); 2181 list_add_tail(&mReq->queue, &mEp->qh.queue);
2174 2182
2175 if (list_is_singular(&mEp->qh[mEp->dir].queue)) 2183 if (list_is_singular(&mEp->qh.queue))
2176 retval = _hardware_enqueue(mEp, mReq); 2184 retval = _hardware_enqueue(mEp, mReq);
2177 2185
2178 if (retval == -EALREADY) { 2186 if (retval == -EALREADY) {
@@ -2199,7 +2207,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
2199 trace("%p, %p", ep, req); 2207 trace("%p, %p", ep, req);
2200 2208
2201 if (ep == NULL || req == NULL || mEp->desc == NULL || 2209 if (ep == NULL || req == NULL || mEp->desc == NULL ||
2202 list_empty(&mReq->queue) || list_empty(&mEp->qh[mEp->dir].queue)) 2210 list_empty(&mReq->queue) || list_empty(&mEp->qh.queue))
2203 return -EINVAL; 2211 return -EINVAL;
2204 2212
2205 spin_lock_irqsave(mEp->lock, flags); 2213 spin_lock_irqsave(mEp->lock, flags);
@@ -2244,7 +2252,7 @@ static int ep_set_halt(struct usb_ep *ep, int value)
2244#ifndef STALL_IN 2252#ifndef STALL_IN
2245 /* g_file_storage MS compliant but g_zero fails chapter 9 compliance */ 2253 /* g_file_storage MS compliant but g_zero fails chapter 9 compliance */
2246 if (value && mEp->type == USB_ENDPOINT_XFER_BULK && mEp->dir == TX && 2254 if (value && mEp->type == USB_ENDPOINT_XFER_BULK && mEp->dir == TX &&
2247 !list_empty(&mEp->qh[mEp->dir].queue)) { 2255 !list_empty(&mEp->qh.queue)) {
2248 spin_unlock_irqrestore(mEp->lock, flags); 2256 spin_unlock_irqrestore(mEp->lock, flags);
2249 return -EAGAIN; 2257 return -EAGAIN;
2250 } 2258 }
@@ -2355,7 +2363,7 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active)
2355 if (is_active) { 2363 if (is_active) {
2356 pm_runtime_get_sync(&_gadget->dev); 2364 pm_runtime_get_sync(&_gadget->dev);
2357 hw_device_reset(udc); 2365 hw_device_reset(udc);
2358 hw_device_state(udc->ci13xxx_ep[0].qh[RX].dma); 2366 hw_device_state(udc->ep0out.qh.dma);
2359 } else { 2367 } else {
2360 hw_device_state(0); 2368 hw_device_state(0);
2361 if (udc->udc_driver->notify_event) 2369 if (udc->udc_driver->notify_event)
@@ -2390,7 +2398,8 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2390 int (*bind)(struct usb_gadget *)) 2398 int (*bind)(struct usb_gadget *))
2391{ 2399{
2392 struct ci13xxx *udc = _udc; 2400 struct ci13xxx *udc = _udc;
2393 unsigned long i, k, flags; 2401 unsigned long flags;
2402 int i, j;
2394 int retval = -ENOMEM; 2403 int retval = -ENOMEM;
2395 2404
2396 trace("%p", driver); 2405 trace("%p", driver);
@@ -2427,45 +2436,46 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2427 2436
2428 info("hw_ep_max = %d", hw_ep_max); 2437 info("hw_ep_max = %d", hw_ep_max);
2429 2438
2430 udc->driver = driver;
2431 udc->gadget.dev.driver = NULL; 2439 udc->gadget.dev.driver = NULL;
2432 2440
2433 retval = 0; 2441 retval = 0;
2434 for (i = 0; i < hw_ep_max; i++) { 2442 for (i = 0; i < hw_ep_max/2; i++) {
2435 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i]; 2443 for (j = RX; j <= TX; j++) {
2444 int k = i + j * hw_ep_max/2;
2445 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[k];
2436 2446
2437 scnprintf(mEp->name, sizeof(mEp->name), "ep%i", (int)i); 2447 scnprintf(mEp->name, sizeof(mEp->name), "ep%i%s", i,
2448 (j == TX) ? "in" : "out");
2438 2449
2439 mEp->lock = udc->lock; 2450 mEp->lock = udc->lock;
2440 mEp->device = &udc->gadget.dev; 2451 mEp->device = &udc->gadget.dev;
2441 mEp->td_pool = udc->td_pool; 2452 mEp->td_pool = udc->td_pool;
2442 2453
2443 mEp->ep.name = mEp->name; 2454 mEp->ep.name = mEp->name;
2444 mEp->ep.ops = &usb_ep_ops; 2455 mEp->ep.ops = &usb_ep_ops;
2445 mEp->ep.maxpacket = CTRL_PAYLOAD_MAX; 2456 mEp->ep.maxpacket = CTRL_PAYLOAD_MAX;
2446 2457
2447 /* this allocation cannot be random */ 2458 INIT_LIST_HEAD(&mEp->qh.queue);
2448 for (k = RX; k <= TX; k++) {
2449 INIT_LIST_HEAD(&mEp->qh[k].queue);
2450 spin_unlock_irqrestore(udc->lock, flags); 2459 spin_unlock_irqrestore(udc->lock, flags);
2451 mEp->qh[k].ptr = dma_pool_alloc(udc->qh_pool, 2460 mEp->qh.ptr = dma_pool_alloc(udc->qh_pool, GFP_KERNEL,
2452 GFP_KERNEL, 2461 &mEp->qh.dma);
2453 &mEp->qh[k].dma);
2454 spin_lock_irqsave(udc->lock, flags); 2462 spin_lock_irqsave(udc->lock, flags);
2455 if (mEp->qh[k].ptr == NULL) 2463 if (mEp->qh.ptr == NULL)
2456 retval = -ENOMEM; 2464 retval = -ENOMEM;
2457 else 2465 else
2458 memset(mEp->qh[k].ptr, 0, 2466 memset(mEp->qh.ptr, 0, sizeof(*mEp->qh.ptr));
2459 sizeof(*mEp->qh[k].ptr)); 2467
2460 } 2468 /* skip ep0 out and in endpoints */
2461 if (i == 0) 2469 if (i == 0)
2462 udc->gadget.ep0 = &mEp->ep; 2470 continue;
2463 else 2471
2464 list_add_tail(&mEp->ep.ep_list, &udc->gadget.ep_list); 2472 list_add_tail(&mEp->ep.ep_list, &udc->gadget.ep_list);
2473 }
2465 } 2474 }
2466 if (retval) 2475 if (retval)
2467 goto done; 2476 goto done;
2468 2477
2478 udc->gadget.ep0 = &udc->ep0in.ep;
2469 /* bind gadget */ 2479 /* bind gadget */
2470 driver->driver.bus = NULL; 2480 driver->driver.bus = NULL;
2471 udc->gadget.dev.driver = &driver->driver; 2481 udc->gadget.dev.driver = &driver->driver;
@@ -2479,6 +2489,7 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2479 goto done; 2489 goto done;
2480 } 2490 }
2481 2491
2492 udc->driver = driver;
2482 pm_runtime_get_sync(&udc->gadget.dev); 2493 pm_runtime_get_sync(&udc->gadget.dev);
2483 if (udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS) { 2494 if (udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS) {
2484 if (udc->vbus_active) { 2495 if (udc->vbus_active) {
@@ -2490,14 +2501,12 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2490 } 2501 }
2491 } 2502 }
2492 2503
2493 retval = hw_device_state(udc->ci13xxx_ep[0].qh[RX].dma); 2504 retval = hw_device_state(udc->ep0out.qh.dma);
2494 if (retval) 2505 if (retval)
2495 pm_runtime_put_sync(&udc->gadget.dev); 2506 pm_runtime_put_sync(&udc->gadget.dev);
2496 2507
2497 done: 2508 done:
2498 spin_unlock_irqrestore(udc->lock, flags); 2509 spin_unlock_irqrestore(udc->lock, flags);
2499 if (retval)
2500 usb_gadget_unregister_driver(driver);
2501 return retval; 2510 return retval;
2502} 2511}
2503EXPORT_SYMBOL(usb_gadget_probe_driver); 2512EXPORT_SYMBOL(usb_gadget_probe_driver);
@@ -2510,7 +2519,7 @@ EXPORT_SYMBOL(usb_gadget_probe_driver);
2510int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) 2519int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
2511{ 2520{
2512 struct ci13xxx *udc = _udc; 2521 struct ci13xxx *udc = _udc;
2513 unsigned long i, k, flags; 2522 unsigned long i, flags;
2514 2523
2515 trace("%p", driver); 2524 trace("%p", driver);
2516 2525
@@ -2546,17 +2555,14 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
2546 for (i = 0; i < hw_ep_max; i++) { 2555 for (i = 0; i < hw_ep_max; i++) {
2547 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i]; 2556 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];
2548 2557
2549 if (i == 0) 2558 if (!list_empty(&mEp->ep.ep_list))
2550 udc->gadget.ep0 = NULL;
2551 else if (!list_empty(&mEp->ep.ep_list))
2552 list_del_init(&mEp->ep.ep_list); 2559 list_del_init(&mEp->ep.ep_list);
2553 2560
2554 for (k = RX; k <= TX; k++) 2561 if (mEp->qh.ptr != NULL)
2555 if (mEp->qh[k].ptr != NULL) 2562 dma_pool_free(udc->qh_pool, mEp->qh.ptr, mEp->qh.dma);
2556 dma_pool_free(udc->qh_pool,
2557 mEp->qh[k].ptr, mEp->qh[k].dma);
2558 } 2563 }
2559 2564
2565 udc->gadget.ep0 = NULL;
2560 udc->driver = NULL; 2566 udc->driver = NULL;
2561 2567
2562 spin_unlock_irqrestore(udc->lock, flags); 2568 spin_unlock_irqrestore(udc->lock, flags);
diff --git a/drivers/usb/gadget/ci13xxx_udc.h b/drivers/usb/gadget/ci13xxx_udc.h
index f61fed07f76b..a2492b65f98c 100644
--- a/drivers/usb/gadget/ci13xxx_udc.h
+++ b/drivers/usb/gadget/ci13xxx_udc.h
@@ -20,7 +20,7 @@
20 * DEFINE 20 * DEFINE
21 *****************************************************************************/ 21 *****************************************************************************/
22#define CI13XXX_PAGE_SIZE 4096ul /* page size for TD's */ 22#define CI13XXX_PAGE_SIZE 4096ul /* page size for TD's */
23#define ENDPT_MAX (16) 23#define ENDPT_MAX (32)
24#define CTRL_PAYLOAD_MAX (64) 24#define CTRL_PAYLOAD_MAX (64)
25#define RX (0) /* similar to USB_DIR_OUT but can be used as an index */ 25#define RX (0) /* similar to USB_DIR_OUT but can be used as an index */
26#define TX (1) /* similar to USB_DIR_IN but can be used as an index */ 26#define TX (1) /* similar to USB_DIR_IN but can be used as an index */
@@ -88,8 +88,7 @@ struct ci13xxx_ep {
88 struct list_head queue; 88 struct list_head queue;
89 struct ci13xxx_qh *ptr; 89 struct ci13xxx_qh *ptr;
90 dma_addr_t dma; 90 dma_addr_t dma;
91 } qh[2]; 91 } qh;
92 struct usb_request *status;
93 int wedge; 92 int wedge;
94 93
95 /* global resources */ 94 /* global resources */
@@ -119,9 +118,13 @@ struct ci13xxx {
119 118
120 struct dma_pool *qh_pool; /* DMA pool for queue heads */ 119 struct dma_pool *qh_pool; /* DMA pool for queue heads */
121 struct dma_pool *td_pool; /* DMA pool for transfer descs */ 120 struct dma_pool *td_pool; /* DMA pool for transfer descs */
121 struct usb_request *status; /* ep0 status request */
122 122
123 struct usb_gadget gadget; /* USB slave device */ 123 struct usb_gadget gadget; /* USB slave device */
124 struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */ 124 struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */
125 u32 ep0_dir; /* ep0 direction */
126#define ep0out ci13xxx_ep[0]
127#define ep0in ci13xxx_ep[16]
125 128
126 struct usb_gadget_driver *driver; /* 3rd party gadget driver */ 129 struct usb_gadget_driver *driver; /* 3rd party gadget driver */
127 struct ci13xxx_udc_driver *udc_driver; /* device controller driver */ 130 struct ci13xxx_udc_driver *udc_driver; /* device controller driver */
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index f6ff8456d52d..1ba4befe336b 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -928,8 +928,9 @@ unknown:
928 */ 928 */
929 switch (ctrl->bRequestType & USB_RECIP_MASK) { 929 switch (ctrl->bRequestType & USB_RECIP_MASK) {
930 case USB_RECIP_INTERFACE: 930 case USB_RECIP_INTERFACE:
931 if (cdev->config) 931 if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES)
932 f = cdev->config->interface[intf]; 932 break;
933 f = cdev->config->interface[intf];
933 break; 934 break;
934 935
935 case USB_RECIP_ENDPOINT: 936 case USB_RECIP_ENDPOINT:
diff --git a/drivers/usb/gadget/pch_udc.c b/drivers/usb/gadget/pch_udc.c
index 0c8dd81dddca..b120dbb64d0f 100644
--- a/drivers/usb/gadget/pch_udc.c
+++ b/drivers/usb/gadget/pch_udc.c
@@ -198,10 +198,10 @@
198#define PCH_UDC_BRLEN 0x0F /* Burst length */ 198#define PCH_UDC_BRLEN 0x0F /* Burst length */
199#define PCH_UDC_THLEN 0x1F /* Threshold length */ 199#define PCH_UDC_THLEN 0x1F /* Threshold length */
200/* Value of EP Buffer Size */ 200/* Value of EP Buffer Size */
201#define UDC_EP0IN_BUFF_SIZE 64 201#define UDC_EP0IN_BUFF_SIZE 16
202#define UDC_EPIN_BUFF_SIZE 512 202#define UDC_EPIN_BUFF_SIZE 256
203#define UDC_EP0OUT_BUFF_SIZE 64 203#define UDC_EP0OUT_BUFF_SIZE 16
204#define UDC_EPOUT_BUFF_SIZE 512 204#define UDC_EPOUT_BUFF_SIZE 256
205/* Value of EP maximum packet size */ 205/* Value of EP maximum packet size */
206#define UDC_EP0IN_MAX_PKT_SIZE 64 206#define UDC_EP0IN_MAX_PKT_SIZE 64
207#define UDC_EP0OUT_MAX_PKT_SIZE 64 207#define UDC_EP0OUT_MAX_PKT_SIZE 64
@@ -351,7 +351,7 @@ struct pch_udc_dev {
351 struct pci_pool *data_requests; 351 struct pci_pool *data_requests;
352 struct pci_pool *stp_requests; 352 struct pci_pool *stp_requests;
353 dma_addr_t dma_addr; 353 dma_addr_t dma_addr;
354 unsigned long ep0out_buf[64]; 354 void *ep0out_buf;
355 struct usb_ctrlrequest setup_data; 355 struct usb_ctrlrequest setup_data;
356 unsigned long phys_addr; 356 unsigned long phys_addr;
357 void __iomem *base_addr; 357 void __iomem *base_addr;
@@ -361,6 +361,8 @@ struct pch_udc_dev {
361 361
362#define PCH_UDC_PCI_BAR 1 362#define PCH_UDC_PCI_BAR 1
363#define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808 363#define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808
364#define PCI_VENDOR_ID_ROHM 0x10DB
365#define PCI_DEVICE_ID_ML7213_IOH_UDC 0x801D
364 366
365static const char ep0_string[] = "ep0in"; 367static const char ep0_string[] = "ep0in";
366static DEFINE_SPINLOCK(udc_stall_spinlock); /* stall spin lock */ 368static DEFINE_SPINLOCK(udc_stall_spinlock); /* stall spin lock */
@@ -1219,11 +1221,11 @@ static void complete_req(struct pch_udc_ep *ep, struct pch_udc_request *req,
1219 dev = ep->dev; 1221 dev = ep->dev;
1220 if (req->dma_mapped) { 1222 if (req->dma_mapped) {
1221 if (ep->in) 1223 if (ep->in)
1222 pci_unmap_single(dev->pdev, req->req.dma, 1224 dma_unmap_single(&dev->pdev->dev, req->req.dma,
1223 req->req.length, PCI_DMA_TODEVICE); 1225 req->req.length, DMA_TO_DEVICE);
1224 else 1226 else
1225 pci_unmap_single(dev->pdev, req->req.dma, 1227 dma_unmap_single(&dev->pdev->dev, req->req.dma,
1226 req->req.length, PCI_DMA_FROMDEVICE); 1228 req->req.length, DMA_FROM_DEVICE);
1227 req->dma_mapped = 0; 1229 req->dma_mapped = 0;
1228 req->req.dma = DMA_ADDR_INVALID; 1230 req->req.dma = DMA_ADDR_INVALID;
1229 } 1231 }
@@ -1414,7 +1416,6 @@ static void pch_udc_start_rxrequest(struct pch_udc_ep *ep,
1414 1416
1415 pch_udc_clear_dma(ep->dev, DMA_DIR_RX); 1417 pch_udc_clear_dma(ep->dev, DMA_DIR_RX);
1416 td_data = req->td_data; 1418 td_data = req->td_data;
1417 ep->td_data = req->td_data;
1418 /* Set the status bits for all descriptors */ 1419 /* Set the status bits for all descriptors */
1419 while (1) { 1420 while (1) {
1420 td_data->status = (td_data->status & ~PCH_UDC_BUFF_STS) | 1421 td_data->status = (td_data->status & ~PCH_UDC_BUFF_STS) |
@@ -1613,15 +1614,19 @@ static int pch_udc_pcd_queue(struct usb_ep *usbep, struct usb_request *usbreq,
1613 if (usbreq->length && 1614 if (usbreq->length &&
1614 ((usbreq->dma == DMA_ADDR_INVALID) || !usbreq->dma)) { 1615 ((usbreq->dma == DMA_ADDR_INVALID) || !usbreq->dma)) {
1615 if (ep->in) 1616 if (ep->in)
1616 usbreq->dma = pci_map_single(dev->pdev, usbreq->buf, 1617 usbreq->dma = dma_map_single(&dev->pdev->dev,
1617 usbreq->length, PCI_DMA_TODEVICE); 1618 usbreq->buf,
1619 usbreq->length,
1620 DMA_TO_DEVICE);
1618 else 1621 else
1619 usbreq->dma = pci_map_single(dev->pdev, usbreq->buf, 1622 usbreq->dma = dma_map_single(&dev->pdev->dev,
1620 usbreq->length, PCI_DMA_FROMDEVICE); 1623 usbreq->buf,
1624 usbreq->length,
1625 DMA_FROM_DEVICE);
1621 req->dma_mapped = 1; 1626 req->dma_mapped = 1;
1622 } 1627 }
1623 if (usbreq->length > 0) { 1628 if (usbreq->length > 0) {
1624 retval = prepare_dma(ep, req, gfp); 1629 retval = prepare_dma(ep, req, GFP_ATOMIC);
1625 if (retval) 1630 if (retval)
1626 goto probe_end; 1631 goto probe_end;
1627 } 1632 }
@@ -1646,7 +1651,6 @@ static int pch_udc_pcd_queue(struct usb_ep *usbep, struct usb_request *usbreq,
1646 pch_udc_wait_ep_stall(ep); 1651 pch_udc_wait_ep_stall(ep);
1647 pch_udc_ep_clear_nak(ep); 1652 pch_udc_ep_clear_nak(ep);
1648 pch_udc_enable_ep_interrupts(ep->dev, (1 << ep->num)); 1653 pch_udc_enable_ep_interrupts(ep->dev, (1 << ep->num));
1649 pch_udc_set_dma(dev, DMA_DIR_TX);
1650 } 1654 }
1651 } 1655 }
1652 /* Now add this request to the ep's pending requests */ 1656 /* Now add this request to the ep's pending requests */
@@ -1926,6 +1930,7 @@ static void pch_udc_complete_receiver(struct pch_udc_ep *ep)
1926 PCH_UDC_BS_DMA_DONE) 1930 PCH_UDC_BS_DMA_DONE)
1927 return; 1931 return;
1928 pch_udc_clear_dma(ep->dev, DMA_DIR_RX); 1932 pch_udc_clear_dma(ep->dev, DMA_DIR_RX);
1933 pch_udc_ep_set_ddptr(ep, 0);
1929 if ((req->td_data_last->status & PCH_UDC_RXTX_STS) != 1934 if ((req->td_data_last->status & PCH_UDC_RXTX_STS) !=
1930 PCH_UDC_RTS_SUCC) { 1935 PCH_UDC_RTS_SUCC) {
1931 dev_err(&dev->pdev->dev, "Invalid RXTX status (0x%08x) " 1936 dev_err(&dev->pdev->dev, "Invalid RXTX status (0x%08x) "
@@ -1963,7 +1968,7 @@ static void pch_udc_svc_data_in(struct pch_udc_dev *dev, int ep_num)
1963 u32 epsts; 1968 u32 epsts;
1964 struct pch_udc_ep *ep; 1969 struct pch_udc_ep *ep;
1965 1970
1966 ep = &dev->ep[2*ep_num]; 1971 ep = &dev->ep[UDC_EPIN_IDX(ep_num)];
1967 epsts = ep->epsts; 1972 epsts = ep->epsts;
1968 ep->epsts = 0; 1973 ep->epsts = 0;
1969 1974
@@ -2008,7 +2013,7 @@ static void pch_udc_svc_data_out(struct pch_udc_dev *dev, int ep_num)
2008 struct pch_udc_ep *ep; 2013 struct pch_udc_ep *ep;
2009 struct pch_udc_request *req = NULL; 2014 struct pch_udc_request *req = NULL;
2010 2015
2011 ep = &dev->ep[2*ep_num + 1]; 2016 ep = &dev->ep[UDC_EPOUT_IDX(ep_num)];
2012 epsts = ep->epsts; 2017 epsts = ep->epsts;
2013 ep->epsts = 0; 2018 ep->epsts = 0;
2014 2019
@@ -2025,10 +2030,11 @@ static void pch_udc_svc_data_out(struct pch_udc_dev *dev, int ep_num)
2025 } 2030 }
2026 if (epsts & UDC_EPSTS_HE) 2031 if (epsts & UDC_EPSTS_HE)
2027 return; 2032 return;
2028 if (epsts & UDC_EPSTS_RSS) 2033 if (epsts & UDC_EPSTS_RSS) {
2029 pch_udc_ep_set_stall(ep); 2034 pch_udc_ep_set_stall(ep);
2030 pch_udc_enable_ep_interrupts(ep->dev, 2035 pch_udc_enable_ep_interrupts(ep->dev,
2031 PCH_UDC_EPINT(ep->in, ep->num)); 2036 PCH_UDC_EPINT(ep->in, ep->num));
2037 }
2032 if (epsts & UDC_EPSTS_RCS) { 2038 if (epsts & UDC_EPSTS_RCS) {
2033 if (!dev->prot_stall) { 2039 if (!dev->prot_stall) {
2034 pch_udc_ep_clear_stall(ep); 2040 pch_udc_ep_clear_stall(ep);
@@ -2060,8 +2066,10 @@ static void pch_udc_svc_control_in(struct pch_udc_dev *dev)
2060{ 2066{
2061 u32 epsts; 2067 u32 epsts;
2062 struct pch_udc_ep *ep; 2068 struct pch_udc_ep *ep;
2069 struct pch_udc_ep *ep_out;
2063 2070
2064 ep = &dev->ep[UDC_EP0IN_IDX]; 2071 ep = &dev->ep[UDC_EP0IN_IDX];
2072 ep_out = &dev->ep[UDC_EP0OUT_IDX];
2065 epsts = ep->epsts; 2073 epsts = ep->epsts;
2066 ep->epsts = 0; 2074 ep->epsts = 0;
2067 2075
@@ -2073,8 +2081,16 @@ static void pch_udc_svc_control_in(struct pch_udc_dev *dev)
2073 return; 2081 return;
2074 if (epsts & UDC_EPSTS_HE) 2082 if (epsts & UDC_EPSTS_HE)
2075 return; 2083 return;
2076 if ((epsts & UDC_EPSTS_TDC) && (!dev->stall)) 2084 if ((epsts & UDC_EPSTS_TDC) && (!dev->stall)) {
2077 pch_udc_complete_transfer(ep); 2085 pch_udc_complete_transfer(ep);
2086 pch_udc_clear_dma(dev, DMA_DIR_RX);
2087 ep_out->td_data->status = (ep_out->td_data->status &
2088 ~PCH_UDC_BUFF_STS) |
2089 PCH_UDC_BS_HST_RDY;
2090 pch_udc_ep_clear_nak(ep_out);
2091 pch_udc_set_dma(dev, DMA_DIR_RX);
2092 pch_udc_ep_set_rrdy(ep_out);
2093 }
2078 /* On IN interrupt, provide data if we have any */ 2094 /* On IN interrupt, provide data if we have any */
2079 if ((epsts & UDC_EPSTS_IN) && !(epsts & UDC_EPSTS_TDC) && 2095 if ((epsts & UDC_EPSTS_IN) && !(epsts & UDC_EPSTS_TDC) &&
2080 !(epsts & UDC_EPSTS_TXEMPTY)) 2096 !(epsts & UDC_EPSTS_TXEMPTY))
@@ -2102,11 +2118,9 @@ static void pch_udc_svc_control_out(struct pch_udc_dev *dev)
2102 dev->stall = 0; 2118 dev->stall = 0;
2103 dev->ep[UDC_EP0IN_IDX].halted = 0; 2119 dev->ep[UDC_EP0IN_IDX].halted = 0;
2104 dev->ep[UDC_EP0OUT_IDX].halted = 0; 2120 dev->ep[UDC_EP0OUT_IDX].halted = 0;
2105 /* In data not ready */
2106 pch_udc_ep_set_nak(&(dev->ep[UDC_EP0IN_IDX]));
2107 dev->setup_data = ep->td_stp->request; 2121 dev->setup_data = ep->td_stp->request;
2108 pch_udc_init_setup_buff(ep->td_stp); 2122 pch_udc_init_setup_buff(ep->td_stp);
2109 pch_udc_clear_dma(dev, DMA_DIR_TX); 2123 pch_udc_clear_dma(dev, DMA_DIR_RX);
2110 pch_udc_ep_fifo_flush(&(dev->ep[UDC_EP0IN_IDX]), 2124 pch_udc_ep_fifo_flush(&(dev->ep[UDC_EP0IN_IDX]),
2111 dev->ep[UDC_EP0IN_IDX].in); 2125 dev->ep[UDC_EP0IN_IDX].in);
2112 if ((dev->setup_data.bRequestType & USB_DIR_IN)) 2126 if ((dev->setup_data.bRequestType & USB_DIR_IN))
@@ -2122,14 +2136,23 @@ static void pch_udc_svc_control_out(struct pch_udc_dev *dev)
2122 setup_supported = dev->driver->setup(&dev->gadget, 2136 setup_supported = dev->driver->setup(&dev->gadget,
2123 &dev->setup_data); 2137 &dev->setup_data);
2124 spin_lock(&dev->lock); 2138 spin_lock(&dev->lock);
2139
2140 if (dev->setup_data.bRequestType & USB_DIR_IN) {
2141 ep->td_data->status = (ep->td_data->status &
2142 ~PCH_UDC_BUFF_STS) |
2143 PCH_UDC_BS_HST_RDY;
2144 pch_udc_ep_set_ddptr(ep, ep->td_data_phys);
2145 }
2125 /* ep0 in returns data on IN phase */ 2146 /* ep0 in returns data on IN phase */
2126 if (setup_supported >= 0 && setup_supported < 2147 if (setup_supported >= 0 && setup_supported <
2127 UDC_EP0IN_MAX_PKT_SIZE) { 2148 UDC_EP0IN_MAX_PKT_SIZE) {
2128 pch_udc_ep_clear_nak(&(dev->ep[UDC_EP0IN_IDX])); 2149 pch_udc_ep_clear_nak(&(dev->ep[UDC_EP0IN_IDX]));
2129 /* Gadget would have queued a request when 2150 /* Gadget would have queued a request when
2130 * we called the setup */ 2151 * we called the setup */
2131 pch_udc_set_dma(dev, DMA_DIR_RX); 2152 if (!(dev->setup_data.bRequestType & USB_DIR_IN)) {
2132 pch_udc_ep_clear_nak(ep); 2153 pch_udc_set_dma(dev, DMA_DIR_RX);
2154 pch_udc_ep_clear_nak(ep);
2155 }
2133 } else if (setup_supported < 0) { 2156 } else if (setup_supported < 0) {
2134 /* if unsupported request, then stall */ 2157 /* if unsupported request, then stall */
2135 pch_udc_ep_set_stall(&(dev->ep[UDC_EP0IN_IDX])); 2158 pch_udc_ep_set_stall(&(dev->ep[UDC_EP0IN_IDX]));
@@ -2142,22 +2165,13 @@ static void pch_udc_svc_control_out(struct pch_udc_dev *dev)
2142 } 2165 }
2143 } else if ((((stat & UDC_EPSTS_OUT_MASK) >> UDC_EPSTS_OUT_SHIFT) == 2166 } else if ((((stat & UDC_EPSTS_OUT_MASK) >> UDC_EPSTS_OUT_SHIFT) ==
2144 UDC_EPSTS_OUT_DATA) && !dev->stall) { 2167 UDC_EPSTS_OUT_DATA) && !dev->stall) {
2145 if (list_empty(&ep->queue)) { 2168 pch_udc_clear_dma(dev, DMA_DIR_RX);
2146 dev_err(&dev->pdev->dev, "%s: No request\n", __func__); 2169 pch_udc_ep_set_ddptr(ep, 0);
2147 ep->td_data->status = (ep->td_data->status & 2170 if (!list_empty(&ep->queue)) {
2148 ~PCH_UDC_BUFF_STS) |
2149 PCH_UDC_BS_HST_RDY;
2150 pch_udc_set_dma(dev, DMA_DIR_RX);
2151 } else {
2152 /* control write */
2153 /* next function will pickuo an clear the status */
2154 ep->epsts = stat; 2171 ep->epsts = stat;
2155 2172 pch_udc_svc_data_out(dev, PCH_UDC_EP0);
2156 pch_udc_svc_data_out(dev, 0);
2157 /* re-program desc. pointer for possible ZLPs */
2158 pch_udc_ep_set_ddptr(ep, ep->td_data_phys);
2159 pch_udc_set_dma(dev, DMA_DIR_RX);
2160 } 2173 }
2174 pch_udc_set_dma(dev, DMA_DIR_RX);
2161 } 2175 }
2162 pch_udc_ep_set_rrdy(ep); 2176 pch_udc_ep_set_rrdy(ep);
2163} 2177}
@@ -2174,7 +2188,7 @@ static void pch_udc_postsvc_epinters(struct pch_udc_dev *dev, int ep_num)
2174 struct pch_udc_ep *ep; 2188 struct pch_udc_ep *ep;
2175 struct pch_udc_request *req; 2189 struct pch_udc_request *req;
2176 2190
2177 ep = &dev->ep[2*ep_num]; 2191 ep = &dev->ep[UDC_EPIN_IDX(ep_num)];
2178 if (!list_empty(&ep->queue)) { 2192 if (!list_empty(&ep->queue)) {
2179 req = list_entry(ep->queue.next, struct pch_udc_request, queue); 2193 req = list_entry(ep->queue.next, struct pch_udc_request, queue);
2180 pch_udc_enable_ep_interrupts(ep->dev, 2194 pch_udc_enable_ep_interrupts(ep->dev,
@@ -2196,13 +2210,13 @@ static void pch_udc_read_all_epstatus(struct pch_udc_dev *dev, u32 ep_intr)
2196 for (i = 0; i < PCH_UDC_USED_EP_NUM; i++) { 2210 for (i = 0; i < PCH_UDC_USED_EP_NUM; i++) {
2197 /* IN */ 2211 /* IN */
2198 if (ep_intr & (0x1 << i)) { 2212 if (ep_intr & (0x1 << i)) {
2199 ep = &dev->ep[2*i]; 2213 ep = &dev->ep[UDC_EPIN_IDX(i)];
2200 ep->epsts = pch_udc_read_ep_status(ep); 2214 ep->epsts = pch_udc_read_ep_status(ep);
2201 pch_udc_clear_ep_status(ep, ep->epsts); 2215 pch_udc_clear_ep_status(ep, ep->epsts);
2202 } 2216 }
2203 /* OUT */ 2217 /* OUT */
2204 if (ep_intr & (0x10000 << i)) { 2218 if (ep_intr & (0x10000 << i)) {
2205 ep = &dev->ep[2*i+1]; 2219 ep = &dev->ep[UDC_EPOUT_IDX(i)];
2206 ep->epsts = pch_udc_read_ep_status(ep); 2220 ep->epsts = pch_udc_read_ep_status(ep);
2207 pch_udc_clear_ep_status(ep, ep->epsts); 2221 pch_udc_clear_ep_status(ep, ep->epsts);
2208 } 2222 }
@@ -2563,9 +2577,6 @@ static void pch_udc_pcd_reinit(struct pch_udc_dev *dev)
2563 dev->ep[UDC_EP0IN_IDX].ep.maxpacket = UDC_EP0IN_MAX_PKT_SIZE; 2577 dev->ep[UDC_EP0IN_IDX].ep.maxpacket = UDC_EP0IN_MAX_PKT_SIZE;
2564 dev->ep[UDC_EP0OUT_IDX].ep.maxpacket = UDC_EP0OUT_MAX_PKT_SIZE; 2578 dev->ep[UDC_EP0OUT_IDX].ep.maxpacket = UDC_EP0OUT_MAX_PKT_SIZE;
2565 2579
2566 dev->dma_addr = pci_map_single(dev->pdev, dev->ep0out_buf, 256,
2567 PCI_DMA_FROMDEVICE);
2568
2569 /* remove ep0 in and out from the list. They have own pointer */ 2580 /* remove ep0 in and out from the list. They have own pointer */
2570 list_del_init(&dev->ep[UDC_EP0IN_IDX].ep.ep_list); 2581 list_del_init(&dev->ep[UDC_EP0IN_IDX].ep.ep_list);
2571 list_del_init(&dev->ep[UDC_EP0OUT_IDX].ep.ep_list); 2582 list_del_init(&dev->ep[UDC_EP0OUT_IDX].ep.ep_list);
@@ -2637,6 +2648,13 @@ static int init_dma_pools(struct pch_udc_dev *dev)
2637 dev->ep[UDC_EP0IN_IDX].td_stp_phys = 0; 2648 dev->ep[UDC_EP0IN_IDX].td_stp_phys = 0;
2638 dev->ep[UDC_EP0IN_IDX].td_data = NULL; 2649 dev->ep[UDC_EP0IN_IDX].td_data = NULL;
2639 dev->ep[UDC_EP0IN_IDX].td_data_phys = 0; 2650 dev->ep[UDC_EP0IN_IDX].td_data_phys = 0;
2651
2652 dev->ep0out_buf = kzalloc(UDC_EP0OUT_BUFF_SIZE * 4, GFP_KERNEL);
2653 if (!dev->ep0out_buf)
2654 return -ENOMEM;
2655 dev->dma_addr = dma_map_single(&dev->pdev->dev, dev->ep0out_buf,
2656 UDC_EP0OUT_BUFF_SIZE * 4,
2657 DMA_FROM_DEVICE);
2640 return 0; 2658 return 0;
2641} 2659}
2642 2660
@@ -2700,7 +2718,8 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
2700 2718
2701 pch_udc_disable_interrupts(dev, UDC_DEVINT_MSK); 2719 pch_udc_disable_interrupts(dev, UDC_DEVINT_MSK);
2702 2720
2703 /* Assues that there are no pending requets with this driver */ 2721 /* Assures that there are no pending requests with this driver */
2722 driver->disconnect(&dev->gadget);
2704 driver->unbind(&dev->gadget); 2723 driver->unbind(&dev->gadget);
2705 dev->gadget.dev.driver = NULL; 2724 dev->gadget.dev.driver = NULL;
2706 dev->driver = NULL; 2725 dev->driver = NULL;
@@ -2750,6 +2769,11 @@ static void pch_udc_remove(struct pci_dev *pdev)
2750 pci_pool_destroy(dev->stp_requests); 2769 pci_pool_destroy(dev->stp_requests);
2751 } 2770 }
2752 2771
2772 if (dev->dma_addr)
2773 dma_unmap_single(&dev->pdev->dev, dev->dma_addr,
2774 UDC_EP0OUT_BUFF_SIZE * 4, DMA_FROM_DEVICE);
2775 kfree(dev->ep0out_buf);
2776
2753 pch_udc_exit(dev); 2777 pch_udc_exit(dev);
2754 2778
2755 if (dev->irq_registered) 2779 if (dev->irq_registered)
@@ -2792,11 +2816,7 @@ static int pch_udc_resume(struct pci_dev *pdev)
2792 int ret; 2816 int ret;
2793 2817
2794 pci_set_power_state(pdev, PCI_D0); 2818 pci_set_power_state(pdev, PCI_D0);
2795 ret = pci_restore_state(pdev); 2819 pci_restore_state(pdev);
2796 if (ret) {
2797 dev_err(&pdev->dev, "%s: pci_restore_state failed\n", __func__);
2798 return ret;
2799 }
2800 ret = pci_enable_device(pdev); 2820 ret = pci_enable_device(pdev);
2801 if (ret) { 2821 if (ret) {
2802 dev_err(&pdev->dev, "%s: pci_enable_device failed\n", __func__); 2822 dev_err(&pdev->dev, "%s: pci_enable_device failed\n", __func__);
@@ -2914,6 +2934,11 @@ static DEFINE_PCI_DEVICE_TABLE(pch_udc_pcidev_id) = {
2914 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe, 2934 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,
2915 .class_mask = 0xffffffff, 2935 .class_mask = 0xffffffff,
2916 }, 2936 },
2937 {
2938 PCI_DEVICE(PCI_VENDOR_ID_ROHM, PCI_DEVICE_ID_ML7213_IOH_UDC),
2939 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,
2940 .class_mask = 0xffffffff,
2941 },
2917 { 0 }, 2942 { 0 },
2918}; 2943};
2919 2944
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index 2fc8636316c5..12ff6cffedc9 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -131,31 +131,31 @@ static struct printer_dev usb_printer_gadget;
131 * parameters are in UTF-8 (superset of ASCII's 7 bit characters). 131 * parameters are in UTF-8 (superset of ASCII's 7 bit characters).
132 */ 132 */
133 133
134static ushort __initdata idVendor; 134static ushort idVendor;
135module_param(idVendor, ushort, S_IRUGO); 135module_param(idVendor, ushort, S_IRUGO);
136MODULE_PARM_DESC(idVendor, "USB Vendor ID"); 136MODULE_PARM_DESC(idVendor, "USB Vendor ID");
137 137
138static ushort __initdata idProduct; 138static ushort idProduct;
139module_param(idProduct, ushort, S_IRUGO); 139module_param(idProduct, ushort, S_IRUGO);
140MODULE_PARM_DESC(idProduct, "USB Product ID"); 140MODULE_PARM_DESC(idProduct, "USB Product ID");
141 141
142static ushort __initdata bcdDevice; 142static ushort bcdDevice;
143module_param(bcdDevice, ushort, S_IRUGO); 143module_param(bcdDevice, ushort, S_IRUGO);
144MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); 144MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)");
145 145
146static char *__initdata iManufacturer; 146static char *iManufacturer;
147module_param(iManufacturer, charp, S_IRUGO); 147module_param(iManufacturer, charp, S_IRUGO);
148MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); 148MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string");
149 149
150static char *__initdata iProduct; 150static char *iProduct;
151module_param(iProduct, charp, S_IRUGO); 151module_param(iProduct, charp, S_IRUGO);
152MODULE_PARM_DESC(iProduct, "USB Product string"); 152MODULE_PARM_DESC(iProduct, "USB Product string");
153 153
154static char *__initdata iSerialNum; 154static char *iSerialNum;
155module_param(iSerialNum, charp, S_IRUGO); 155module_param(iSerialNum, charp, S_IRUGO);
156MODULE_PARM_DESC(iSerialNum, "1"); 156MODULE_PARM_DESC(iSerialNum, "1");
157 157
158static char *__initdata iPNPstring; 158static char *iPNPstring;
159module_param(iPNPstring, charp, S_IRUGO); 159module_param(iPNPstring, charp, S_IRUGO);
160MODULE_PARM_DESC(iPNPstring, "MFG:linux;MDL:g_printer;CLS:PRINTER;SN:1;"); 160MODULE_PARM_DESC(iPNPstring, "MFG:linux;MDL:g_printer;CLS:PRINTER;SN:1;");
161 161
@@ -1596,13 +1596,12 @@ cleanup(void)
1596 int status; 1596 int status;
1597 1597
1598 mutex_lock(&usb_printer_gadget.lock_printer_io); 1598 mutex_lock(&usb_printer_gadget.lock_printer_io);
1599 class_destroy(usb_gadget_class);
1600 unregister_chrdev_region(g_printer_devno, 2);
1601
1602 status = usb_gadget_unregister_driver(&printer_driver); 1599 status = usb_gadget_unregister_driver(&printer_driver);
1603 if (status) 1600 if (status)
1604 ERROR(dev, "usb_gadget_unregister_driver %x\n", status); 1601 ERROR(dev, "usb_gadget_unregister_driver %x\n", status);
1605 1602
1603 unregister_chrdev_region(g_printer_devno, 2);
1604 class_destroy(usb_gadget_class);
1606 mutex_unlock(&usb_printer_gadget.lock_printer_io); 1605 mutex_unlock(&usb_printer_gadget.lock_printer_io);
1607} 1606}
1608module_exit(cleanup); 1607module_exit(cleanup);