aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/isp1760-hcd.c
diff options
context:
space:
mode:
authorArvid Brodin <arvid.brodin@enea.com>2011-02-26 16:03:49 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-02-28 22:23:36 -0500
commitfd436aee97d157ff6441e7aaff2a2dc802765b5b (patch)
tree84f6b909856181d463db97b309bc1974580ad916 /drivers/usb/host/isp1760-hcd.c
parentbedc0c31ac3db828e6ade7a8c5cb708688f0a7e1 (diff)
usb/isp1760: Remove redundant variables and defines
Removes the redundant hw_next list pointer from struct isp1760_qtd, removes some unused #defines, removes redundant "urb" member from struct inter_packet_info. Signed-off-by: Arvid Brodin <arvid.brodin@enea.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/isp1760-hcd.c')
-rw-r--r--drivers/usb/host/isp1760-hcd.c126
1 files changed, 58 insertions, 68 deletions
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index 47ce0373a3c9..2342f11d0f30 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -81,7 +81,6 @@ static inline struct usb_hcd *priv_to_hcd(struct isp1760_hcd *priv)
81#define PORT_RWC_BITS (PORT_CSC) 81#define PORT_RWC_BITS (PORT_CSC)
82 82
83struct isp1760_qtd { 83struct isp1760_qtd {
84 struct isp1760_qtd *hw_next;
85 u8 packet_type; 84 u8 packet_type;
86 u8 toggle; 85 u8 toggle;
87 86
@@ -93,10 +92,7 @@ struct isp1760_qtd {
93 92
94 /* isp special*/ 93 /* isp special*/
95 u32 status; 94 u32 status;
96#define URB_COMPLETE_NOTIFY (1 << 0)
97#define URB_ENQUEUED (1 << 1) 95#define URB_ENQUEUED (1 << 1)
98#define URB_TYPE_ATL (1 << 2)
99#define URB_TYPE_INT (1 << 3)
100}; 96};
101 97
102struct isp1760_qh { 98struct isp1760_qh {
@@ -839,12 +835,11 @@ static void enqueue_one_atl_qtd(u32 payload,
839 ptd_write(hcd->regs, ATL_PTD_OFFSET, slot, &ptd); 835 ptd_write(hcd->regs, ATL_PTD_OFFSET, slot, &ptd);
840 enqueue_one_qtd(qtd, priv, payload); 836 enqueue_one_qtd(qtd, priv, payload);
841 837
842 priv->atl_ints[slot].urb = urb;
843 priv->atl_ints[slot].qh = qh; 838 priv->atl_ints[slot].qh = qh;
844 priv->atl_ints[slot].qtd = qtd; 839 priv->atl_ints[slot].qtd = qtd;
845 priv->atl_ints[slot].data_buffer = qtd->data_buffer; 840 priv->atl_ints[slot].data_buffer = qtd->data_buffer;
846 priv->atl_ints[slot].payload = payload; 841 priv->atl_ints[slot].payload = payload;
847 qtd->status |= URB_ENQUEUED | URB_TYPE_ATL; 842 qtd->status |= URB_ENQUEUED;
848 qtd->status |= slot << 16; 843 qtd->status |= slot << 16;
849} 844}
850 845
@@ -859,12 +854,11 @@ static void enqueue_one_int_qtd(u32 payload,
859 ptd_write(hcd->regs, INT_PTD_OFFSET, slot, &ptd); 854 ptd_write(hcd->regs, INT_PTD_OFFSET, slot, &ptd);
860 enqueue_one_qtd(qtd, priv, payload); 855 enqueue_one_qtd(qtd, priv, payload);
861 856
862 priv->int_ints[slot].urb = urb;
863 priv->int_ints[slot].qh = qh; 857 priv->int_ints[slot].qh = qh;
864 priv->int_ints[slot].qtd = qtd; 858 priv->int_ints[slot].qtd = qtd;
865 priv->int_ints[slot].data_buffer = qtd->data_buffer; 859 priv->int_ints[slot].data_buffer = qtd->data_buffer;
866 priv->int_ints[slot].payload = payload; 860 priv->int_ints[slot].payload = payload;
867 qtd->status |= URB_ENQUEUED | URB_TYPE_INT; 861 qtd->status |= URB_ENQUEUED;
868 qtd->status |= slot << 16; 862 qtd->status |= slot << 16;
869} 863}
870 864
@@ -983,11 +977,16 @@ static void isp1760_qtd_free(struct isp1760_qtd *qtd)
983 kmem_cache_free(qtd_cachep, qtd); 977 kmem_cache_free(qtd_cachep, qtd);
984} 978}
985 979
986static struct isp1760_qtd *clean_this_qtd(struct isp1760_qtd *qtd) 980static struct isp1760_qtd *clean_this_qtd(struct isp1760_qtd *qtd,
981 struct isp1760_qh *qh)
987{ 982{
988 struct isp1760_qtd *tmp_qtd; 983 struct isp1760_qtd *tmp_qtd;
989 984
990 tmp_qtd = qtd->hw_next; 985 if (list_is_last(&qtd->qtd_list, &qh->qtd_list))
986 tmp_qtd = NULL;
987 else
988 tmp_qtd = list_entry(qtd->qtd_list.next, struct isp1760_qtd,
989 qtd_list);
991 list_del(&qtd->qtd_list); 990 list_del(&qtd->qtd_list);
992 isp1760_qtd_free(qtd); 991 isp1760_qtd_free(qtd);
993 return tmp_qtd; 992 return tmp_qtd;
@@ -998,22 +997,31 @@ static struct isp1760_qtd *clean_this_qtd(struct isp1760_qtd *qtd)
998 * isn't the last one than remove also his successor(s). 997 * isn't the last one than remove also his successor(s).
999 * Returns the QTD which is part of an new URB and should be enqueued. 998 * Returns the QTD which is part of an new URB and should be enqueued.
1000 */ 999 */
1001static struct isp1760_qtd *clean_up_qtdlist(struct isp1760_qtd *qtd) 1000static struct isp1760_qtd *clean_up_qtdlist(struct isp1760_qtd *qtd,
1001 struct isp1760_qh *qh)
1002{ 1002{
1003 struct isp1760_qtd *tmp_qtd; 1003 struct urb *urb;
1004 int last_one;
1005 1004
1005 urb = qtd->urb;
1006 do { 1006 do {
1007 tmp_qtd = qtd->hw_next; 1007 qtd = clean_this_qtd(qtd, qh);
1008 last_one = qtd->status & URB_COMPLETE_NOTIFY; 1008 } while (qtd && (qtd->urb == urb));
1009 list_del(&qtd->qtd_list);
1010 isp1760_qtd_free(qtd);
1011 qtd = tmp_qtd;
1012 } while (!last_one && qtd);
1013 1009
1014 return qtd; 1010 return qtd;
1015} 1011}
1016 1012
1013static int last_qtd_of_urb(struct isp1760_qtd *qtd, struct isp1760_qh *qh)
1014{
1015 struct urb *urb;
1016
1017 if (list_is_last(&qtd->qtd_list, &qh->qtd_list))
1018 return 1;
1019
1020 urb = qtd->urb;
1021 qtd = list_entry(qtd->qtd_list.next, typeof(*qtd), qtd_list);
1022 return (qtd->urb != urb);
1023}
1024
1017static void do_atl_int(struct usb_hcd *hcd) 1025static void do_atl_int(struct usb_hcd *hcd)
1018{ 1026{
1019 struct isp1760_hcd *priv = hcd_to_priv(hcd); 1027 struct isp1760_hcd *priv = hcd_to_priv(hcd);
@@ -1046,8 +1054,8 @@ static void do_atl_int(struct usb_hcd *hcd)
1046 done_map &= ~(1 << queue_entry); 1054 done_map &= ~(1 << queue_entry);
1047 skip_map |= 1 << queue_entry; 1055 skip_map |= 1 << queue_entry;
1048 1056
1049 urb = priv->atl_ints[queue_entry].urb;
1050 qtd = priv->atl_ints[queue_entry].qtd; 1057 qtd = priv->atl_ints[queue_entry].qtd;
1058 urb = qtd->urb;
1051 qh = priv->atl_ints[queue_entry].qh; 1059 qh = priv->atl_ints[queue_entry].qh;
1052 payload = priv->atl_ints[queue_entry].payload; 1060 payload = priv->atl_ints[queue_entry].payload;
1053 1061
@@ -1160,7 +1168,6 @@ static void do_atl_int(struct usb_hcd *hcd)
1160 } 1168 }
1161 1169
1162 priv->atl_ints[queue_entry].data_buffer = NULL; 1170 priv->atl_ints[queue_entry].data_buffer = NULL;
1163 priv->atl_ints[queue_entry].urb = NULL;
1164 priv->atl_ints[queue_entry].qtd = NULL; 1171 priv->atl_ints[queue_entry].qtd = NULL;
1165 priv->atl_ints[queue_entry].qh = NULL; 1172 priv->atl_ints[queue_entry].qh = NULL;
1166 1173
@@ -1171,7 +1178,7 @@ static void do_atl_int(struct usb_hcd *hcd)
1171 if (urb->status == -EPIPE) { 1178 if (urb->status == -EPIPE) {
1172 /* HALT was received */ 1179 /* HALT was received */
1173 1180
1174 qtd = clean_up_qtdlist(qtd); 1181 qtd = clean_up_qtdlist(qtd, qh);
1175 isp1760_urb_done(priv, urb, urb->status); 1182 isp1760_urb_done(priv, urb, urb->status);
1176 1183
1177 } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) { 1184 } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) {
@@ -1187,23 +1194,23 @@ static void do_atl_int(struct usb_hcd *hcd)
1187 if (urb->status == -EINPROGRESS) 1194 if (urb->status == -EINPROGRESS)
1188 urb->status = 0; 1195 urb->status = 0;
1189 1196
1190 qtd = clean_up_qtdlist(qtd); 1197 qtd = clean_up_qtdlist(qtd, qh);
1191 1198
1192 isp1760_urb_done(priv, urb, urb->status); 1199 isp1760_urb_done(priv, urb, urb->status);
1193 1200
1194 } else if (qtd->status & URB_COMPLETE_NOTIFY) { 1201 } else if (last_qtd_of_urb(qtd, qh)) {
1195 /* that was the last qtd of that URB */ 1202 /* that was the last qtd of that URB */
1196 1203
1197 if (urb->status == -EINPROGRESS) 1204 if (urb->status == -EINPROGRESS)
1198 urb->status = 0; 1205 urb->status = 0;
1199 1206
1200 qtd = clean_this_qtd(qtd); 1207 qtd = clean_this_qtd(qtd, qh);
1201 isp1760_urb_done(priv, urb, urb->status); 1208 isp1760_urb_done(priv, urb, urb->status);
1202 1209
1203 } else { 1210 } else {
1204 /* next QTD of this URB */ 1211 /* next QTD of this URB */
1205 1212
1206 qtd = clean_this_qtd(qtd); 1213 qtd = clean_this_qtd(qtd, qh);
1207 BUG_ON(!qtd); 1214 BUG_ON(!qtd);
1208 } 1215 }
1209 1216
@@ -1243,8 +1250,8 @@ static void do_intl_int(struct usb_hcd *hcd)
1243 done_map &= ~(1 << queue_entry); 1250 done_map &= ~(1 << queue_entry);
1244 skip_map |= 1 << queue_entry; 1251 skip_map |= 1 << queue_entry;
1245 1252
1246 urb = priv->int_ints[queue_entry].urb;
1247 qtd = priv->int_ints[queue_entry].qtd; 1253 qtd = priv->int_ints[queue_entry].qtd;
1254 urb = qtd->urb;
1248 qh = priv->int_ints[queue_entry].qh; 1255 qh = priv->int_ints[queue_entry].qh;
1249 payload = priv->int_ints[queue_entry].payload; 1256 payload = priv->int_ints[queue_entry].payload;
1250 1257
@@ -1298,7 +1305,6 @@ static void do_intl_int(struct usb_hcd *hcd)
1298 } 1305 }
1299 1306
1300 priv->int_ints[queue_entry].data_buffer = NULL; 1307 priv->int_ints[queue_entry].data_buffer = NULL;
1301 priv->int_ints[queue_entry].urb = NULL;
1302 priv->int_ints[queue_entry].qtd = NULL; 1308 priv->int_ints[queue_entry].qtd = NULL;
1303 priv->int_ints[queue_entry].qh = NULL; 1309 priv->int_ints[queue_entry].qh = NULL;
1304 1310
@@ -1308,21 +1314,21 @@ static void do_intl_int(struct usb_hcd *hcd)
1308 if (urb->status == -EPIPE) { 1314 if (urb->status == -EPIPE) {
1309 /* HALT received */ 1315 /* HALT received */
1310 1316
1311 qtd = clean_up_qtdlist(qtd); 1317 qtd = clean_up_qtdlist(qtd, qh);
1312 isp1760_urb_done(priv, urb, urb->status); 1318 isp1760_urb_done(priv, urb, urb->status);
1313 1319
1314 } else if (qtd->status & URB_COMPLETE_NOTIFY) { 1320 } else if (last_qtd_of_urb(qtd, qh)) {
1315 1321
1316 if (urb->status == -EINPROGRESS) 1322 if (urb->status == -EINPROGRESS)
1317 urb->status = 0; 1323 urb->status = 0;
1318 1324
1319 qtd = clean_this_qtd(qtd); 1325 qtd = clean_this_qtd(qtd, qh);
1320 isp1760_urb_done(priv, urb, urb->status); 1326 isp1760_urb_done(priv, urb, urb->status);
1321 1327
1322 } else { 1328 } else {
1323 /* next QTD of this URB */ 1329 /* next QTD of this URB */
1324 1330
1325 qtd = clean_this_qtd(qtd); 1331 qtd = clean_this_qtd(qtd, qh);
1326 BUG_ON(!qtd); 1332 BUG_ON(!qtd);
1327 } 1333 }
1328 1334
@@ -1390,8 +1396,6 @@ static struct isp1760_qh *qh_append_tds(struct isp1760_hcd *priv,
1390 void **ptr) 1396 void **ptr)
1391{ 1397{
1392 struct isp1760_qh *qh; 1398 struct isp1760_qh *qh;
1393 struct isp1760_qtd *qtd;
1394 struct isp1760_qtd *prev_qtd;
1395 1399
1396 qh = (struct isp1760_qh *)*ptr; 1400 qh = (struct isp1760_qh *)*ptr;
1397 if (!qh) { 1401 if (!qh) {
@@ -1402,21 +1406,8 @@ static struct isp1760_qh *qh_append_tds(struct isp1760_hcd *priv,
1402 *ptr = qh; 1406 *ptr = qh;
1403 } 1407 }
1404 1408
1405 qtd = list_entry(qtd_list->next, struct isp1760_qtd,
1406 qtd_list);
1407 if (!list_empty(&qh->qtd_list))
1408 prev_qtd = list_entry(qh->qtd_list.prev,
1409 struct isp1760_qtd, qtd_list);
1410 else
1411 prev_qtd = NULL;
1412
1413 list_splice(qtd_list, qh->qtd_list.prev); 1409 list_splice(qtd_list, qh->qtd_list.prev);
1414 if (prev_qtd) {
1415 BUG_ON(prev_qtd->hw_next);
1416 prev_qtd->hw_next = qtd;
1417 }
1418 1410
1419 urb->hcpriv = qh;
1420 return qh; 1411 return qh;
1421} 1412}
1422 1413
@@ -1497,7 +1488,7 @@ static struct isp1760_qtd *isp1760_qtd_alloc(struct isp1760_hcd *priv,
1497static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv, 1488static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv,
1498 struct urb *urb, struct list_head *head, gfp_t flags) 1489 struct urb *urb, struct list_head *head, gfp_t flags)
1499{ 1490{
1500 struct isp1760_qtd *qtd, *qtd_prev; 1491 struct isp1760_qtd *qtd;
1501 void *buf; 1492 void *buf;
1502 int len, maxpacket; 1493 int len, maxpacket;
1503 int is_input; 1494 int is_input;
@@ -1527,12 +1518,10 @@ static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv,
1527 1518
1528 /* ... and always at least one more pid */ 1519 /* ... and always at least one more pid */
1529 token ^= DATA_TOGGLE; 1520 token ^= DATA_TOGGLE;
1530 qtd_prev = qtd;
1531 qtd = isp1760_qtd_alloc(priv, flags); 1521 qtd = isp1760_qtd_alloc(priv, flags);
1532 if (!qtd) 1522 if (!qtd)
1533 goto cleanup; 1523 goto cleanup;
1534 qtd->urb = urb; 1524 qtd->urb = urb;
1535 qtd_prev->hw_next = qtd;
1536 list_add_tail(&qtd->qtd_list, head); 1525 list_add_tail(&qtd->qtd_list, head);
1537 1526
1538 /* for zero length DATA stages, STATUS is always IN */ 1527 /* for zero length DATA stages, STATUS is always IN */
@@ -1578,12 +1567,10 @@ static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv,
1578 if (len <= 0) 1567 if (len <= 0)
1579 break; 1568 break;
1580 1569
1581 qtd_prev = qtd;
1582 qtd = isp1760_qtd_alloc(priv, flags); 1570 qtd = isp1760_qtd_alloc(priv, flags);
1583 if (!qtd) 1571 if (!qtd)
1584 goto cleanup; 1572 goto cleanup;
1585 qtd->urb = urb; 1573 qtd->urb = urb;
1586 qtd_prev->hw_next = qtd;
1587 list_add_tail(&qtd->qtd_list, head); 1574 list_add_tail(&qtd->qtd_list, head);
1588 } 1575 }
1589 1576
@@ -1606,12 +1593,10 @@ static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv,
1606 one_more = 1; 1593 one_more = 1;
1607 } 1594 }
1608 if (one_more) { 1595 if (one_more) {
1609 qtd_prev = qtd;
1610 qtd = isp1760_qtd_alloc(priv, flags); 1596 qtd = isp1760_qtd_alloc(priv, flags);
1611 if (!qtd) 1597 if (!qtd)
1612 goto cleanup; 1598 goto cleanup;
1613 qtd->urb = urb; 1599 qtd->urb = urb;
1614 qtd_prev->hw_next = qtd;
1615 list_add_tail(&qtd->qtd_list, head); 1600 list_add_tail(&qtd->qtd_list, head);
1616 1601
1617 /* never any data in such packets */ 1602 /* never any data in such packets */
@@ -1619,7 +1604,7 @@ static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv,
1619 } 1604 }
1620 } 1605 }
1621 1606
1622 qtd->status = URB_COMPLETE_NOTIFY; 1607 qtd->status = 0;
1623 return head; 1608 return head;
1624 1609
1625cleanup: 1610cleanup:
@@ -1697,11 +1682,15 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
1697 spin_lock_irqsave(&priv->lock, flags); 1682 spin_lock_irqsave(&priv->lock, flags);
1698 1683
1699 for (i = 0; i < 32; i++) { 1684 for (i = 0; i < 32; i++) {
1700 if (ints->urb == urb) { 1685 if (!ints[i].qh)
1686 continue;
1687 BUG_ON(!ints[i].qtd);
1688
1689 if (ints[i].qtd->urb == urb) {
1701 u32 skip_map; 1690 u32 skip_map;
1702 u32 or_map; 1691 u32 or_map;
1703 struct isp1760_qtd *qtd; 1692 struct isp1760_qtd *qtd;
1704 struct isp1760_qh *qh = ints->qh; 1693 struct isp1760_qh *qh;
1705 1694
1706 skip_map = reg_read32(hcd->regs, skip_reg); 1695 skip_map = reg_read32(hcd->regs, skip_reg);
1707 skip_map |= 1 << i; 1696 skip_map |= 1 << i;
@@ -1714,11 +1703,11 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
1714 ptd_write(hcd->regs, reg_base, i, &ptd); 1703 ptd_write(hcd->regs, reg_base, i, &ptd);
1715 1704
1716 qtd = ints->qtd; 1705 qtd = ints->qtd;
1717 qtd = clean_up_qtdlist(qtd); 1706 qh = ints[i].qh;
1707 qtd = clean_up_qtdlist(qtd, qh);
1718 1708
1719 free_mem(priv, ints->payload); 1709 free_mem(priv, ints->payload);
1720 1710
1721 ints->urb = NULL;
1722 ints->qh = NULL; 1711 ints->qh = NULL;
1723 ints->qtd = NULL; 1712 ints->qtd = NULL;
1724 ints->data_buffer = NULL; 1713 ints->data_buffer = NULL;
@@ -1729,20 +1718,21 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
1729 pe(hcd, qh, qtd); 1718 pe(hcd, qh, qtd);
1730 break; 1719 break;
1731 1720
1732 } else if (ints->qtd) { 1721 } else {
1733 struct isp1760_qtd *qtd, *prev_qtd = ints->qtd; 1722 struct isp1760_qtd *qtd;
1734 1723
1735 for (qtd = ints->qtd->hw_next; qtd; qtd = qtd->hw_next) { 1724 list_for_each_entry(qtd, &ints[i].qtd->qtd_list,
1725 qtd_list) {
1736 if (qtd->urb == urb) { 1726 if (qtd->urb == urb) {
1737 prev_qtd->hw_next = 1727 clean_up_qtdlist(qtd, ints[i].qh);
1738 clean_up_qtdlist(qtd);
1739 isp1760_urb_done(priv, urb, status); 1728 isp1760_urb_done(priv, urb, status);
1729 qtd = NULL;
1740 break; 1730 break;
1741 } 1731 }
1742 prev_qtd = qtd;
1743 } 1732 }
1744 /* we found the urb before the end of the list */ 1733
1745 if (qtd) 1734 /* We found the urb before the last slot */
1735 if (!qtd)
1746 break; 1736 break;
1747 } 1737 }
1748 ints++; 1738 ints++;
@@ -2179,7 +2169,7 @@ static void isp1760_endpoint_disable(struct usb_hcd *usb_hcd,
2179 struct urb *urb; 2169 struct urb *urb;
2180 2170
2181 urb = qtd->urb; 2171 urb = qtd->urb;
2182 clean_up_qtdlist(qtd); 2172 clean_up_qtdlist(qtd, qh);
2183 isp1760_urb_done(priv, urb, -ECONNRESET); 2173 isp1760_urb_done(priv, urb, -ECONNRESET);
2184 } 2174 }
2185 } while (1); 2175 } while (1);