aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorArvid Brodin <arvid.brodin@enea.com>2011-02-26 16:06:37 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-02-28 22:23:38 -0500
commit6bda21bc0941c11f07cbf436ff6ca85e7e6e47f0 (patch)
treef0a871bace736393a9bbdd03dcfac80fe4ab601a /drivers/usb/host
parentbbaa387674b65a2f784631cc4c87c77ec9d3374e (diff)
usb/isp1760: Consolidate printouts and remove unused code
Consolidate printouts to use dev_XXX functions instead of an assortment of printks and driver specific macros. Remove some unused code snippets and struct members. Remove some unused function parameters and #defines. Change the "queue_entry" variable name which has different but related meanings in different places and use "slot" only. Signed-off-by: Arvid Brodin <arvid.brodin@enea.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/isp1760-hcd.c397
-rw-r--r--drivers/usb/host/isp1760-hcd.h11
2 files changed, 190 insertions, 218 deletions
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index e0d9704b2039..0f5b48946739 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -48,10 +48,6 @@ static inline struct isp1760_hcd *hcd_to_priv(struct usb_hcd *hcd)
48{ 48{
49 return (struct isp1760_hcd *) (hcd->hcd_priv); 49 return (struct isp1760_hcd *) (hcd->hcd_priv);
50} 50}
51static inline struct usb_hcd *priv_to_hcd(struct isp1760_hcd *priv)
52{
53 return container_of((void *) priv, struct usb_hcd, hcd_priv);
54}
55 51
56/* Section 2.2 Host Controller Capability Registers */ 52/* Section 2.2 Host Controller Capability Registers */
57#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */ 53#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */
@@ -100,18 +96,14 @@ struct isp1760_qtd {
100struct isp1760_qh { 96struct isp1760_qh {
101 /* first part defined by EHCI spec */ 97 /* first part defined by EHCI spec */
102 struct list_head qtd_list; 98 struct list_head qtd_list;
103 struct isp1760_hcd *priv;
104 99
105 /* periodic schedule info */ 100 /* periodic schedule info */
106 unsigned short period; /* polling interval */ 101 unsigned short period; /* polling interval */
107 struct usb_device *dev;
108 102
109 u32 toggle; 103 u32 toggle;
110 u32 ping; 104 u32 ping;
111}; 105};
112 106
113#define ehci_port_speed(priv, portsc) USB_PORT_STAT_HIGH_SPEED
114
115/* 107/*
116 * Access functions for isp176x registers (addresses 0..0x03FF). 108 * Access functions for isp176x registers (addresses 0..0x03FF).
117 */ 109 */
@@ -288,8 +280,9 @@ static void init_memory(struct isp1760_hcd *priv)
288 BUG_ON(payload_addr - priv->memory_pool[0].start > PAYLOAD_AREA_SIZE); 280 BUG_ON(payload_addr - priv->memory_pool[0].start > PAYLOAD_AREA_SIZE);
289} 281}
290 282
291static void alloc_mem(struct isp1760_hcd *priv, struct isp1760_qtd *qtd) 283static void alloc_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd)
292{ 284{
285 struct isp1760_hcd *priv = hcd_to_priv(hcd);
293 int i; 286 int i;
294 287
295 BUG_ON(qtd->payload_addr); 288 BUG_ON(qtd->payload_addr);
@@ -306,11 +299,12 @@ static void alloc_mem(struct isp1760_hcd *priv, struct isp1760_qtd *qtd)
306 } 299 }
307 } 300 }
308 301
309 printk(KERN_ERR "ISP1760 MEM: can not allocate %lu bytes of memory\n", 302 dev_err(hcd->self.controller,
310 qtd->length); 303 "%s: Can not allocate %lu bytes of memory\n"
311 printk(KERN_ERR "Current memory map:\n"); 304 "Current memory map:\n",
305 __func__, qtd->length);
312 for (i = 0; i < BLOCKS; i++) { 306 for (i = 0; i < BLOCKS; i++) {
313 printk(KERN_ERR "Pool %2d size %4d status: %d\n", 307 dev_err(hcd->self.controller, "Pool %2d size %4d status: %d\n",
314 i, priv->memory_pool[i].size, 308 i, priv->memory_pool[i].size,
315 priv->memory_pool[i].free); 309 priv->memory_pool[i].free);
316 } 310 }
@@ -319,8 +313,9 @@ static void alloc_mem(struct isp1760_hcd *priv, struct isp1760_qtd *qtd)
319 return; 313 return;
320} 314}
321 315
322static void free_mem(struct isp1760_hcd *priv, struct isp1760_qtd *qtd) 316static void free_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd)
323{ 317{
318 struct isp1760_hcd *priv = hcd_to_priv(hcd);
324 int i; 319 int i;
325 320
326 if (!qtd->payload_addr) 321 if (!qtd->payload_addr)
@@ -335,8 +330,8 @@ static void free_mem(struct isp1760_hcd *priv, struct isp1760_qtd *qtd)
335 } 330 }
336 } 331 }
337 332
338 printk(KERN_ERR "%s: Invalid pointer: %08x\n", __func__, 333 dev_err(hcd->self.controller, "%s: Invalid pointer: %08x\n",
339 qtd->payload_addr); 334 __func__, qtd->payload_addr);
340 BUG(); 335 BUG();
341} 336}
342 337
@@ -371,10 +366,11 @@ static int handshake(struct usb_hcd *hcd, u32 reg,
371} 366}
372 367
373/* reset a non-running (STS_HALT == 1) controller */ 368/* reset a non-running (STS_HALT == 1) controller */
374static int ehci_reset(struct isp1760_hcd *priv) 369static int ehci_reset(struct usb_hcd *hcd)
375{ 370{
376 int retval; 371 int retval;
377 struct usb_hcd *hcd = priv_to_hcd(priv); 372 struct isp1760_hcd *priv = hcd_to_priv(hcd);
373
378 u32 command = reg_read32(hcd->regs, HC_USBCMD); 374 u32 command = reg_read32(hcd->regs, HC_USBCMD);
379 375
380 command |= CMD_RESET; 376 command |= CMD_RESET;
@@ -392,8 +388,7 @@ static void qh_destroy(struct isp1760_qh *qh)
392 kmem_cache_free(qh_cachep, qh); 388 kmem_cache_free(qh_cachep, qh);
393} 389}
394 390
395static struct isp1760_qh *isp1760_qh_alloc(struct isp1760_hcd *priv, 391static struct isp1760_qh *isp1760_qh_alloc(gfp_t flags)
396 gfp_t flags)
397{ 392{
398 struct isp1760_qh *qh; 393 struct isp1760_qh *qh;
399 394
@@ -402,7 +397,6 @@ static struct isp1760_qh *isp1760_qh_alloc(struct isp1760_hcd *priv,
402 return qh; 397 return qh;
403 398
404 INIT_LIST_HEAD(&qh->qtd_list); 399 INIT_LIST_HEAD(&qh->qtd_list);
405 qh->priv = priv;
406 return qh; 400 return qh;
407} 401}
408 402
@@ -474,7 +468,7 @@ static int isp1760_hc_setup(struct usb_hcd *hcd)
474 scratch = reg_read32(hcd->regs, HC_CHIP_ID_REG); 468 scratch = reg_read32(hcd->regs, HC_CHIP_ID_REG);
475 scratch = reg_read32(hcd->regs, HC_SCRATCH_REG); 469 scratch = reg_read32(hcd->regs, HC_SCRATCH_REG);
476 if (scratch != 0xdeadbabe) { 470 if (scratch != 0xdeadbabe) {
477 printk(KERN_ERR "ISP1760: Scratch test failed.\n"); 471 dev_err(hcd->self.controller, "Scratch test failed.\n");
478 return -ENODEV; 472 return -ENODEV;
479 } 473 }
480 474
@@ -488,13 +482,13 @@ static int isp1760_hc_setup(struct usb_hcd *hcd)
488 reg_write32(hcd->regs, HC_RESET_REG, SW_RESET_RESET_HC); 482 reg_write32(hcd->regs, HC_RESET_REG, SW_RESET_RESET_HC);
489 mdelay(100); 483 mdelay(100);
490 484
491 result = ehci_reset(priv); 485 result = ehci_reset(hcd);
492 if (result) 486 if (result)
493 return result; 487 return result;
494 488
495 /* Step 11 passed */ 489 /* Step 11 passed */
496 490
497 isp1760_info(priv, "bus width: %d, oc: %s\n", 491 dev_info(hcd->self.controller, "bus width: %d, oc: %s\n",
498 (priv->devflags & ISP1760_FLAG_BUS_WIDTH_16) ? 492 (priv->devflags & ISP1760_FLAG_BUS_WIDTH_16) ?
499 16 : 32, (priv->devflags & ISP1760_FLAG_ANALOG_OC) ? 493 16 : 32, (priv->devflags & ISP1760_FLAG_ANALOG_OC) ?
500 "analog" : "digital"); 494 "analog" : "digital");
@@ -542,7 +536,6 @@ static void isp1760_enable_interrupts(struct usb_hcd *hcd)
542 536
543static int isp1760_run(struct usb_hcd *hcd) 537static int isp1760_run(struct usb_hcd *hcd)
544{ 538{
545 struct isp1760_hcd *priv = hcd_to_priv(hcd);
546 int retval; 539 int retval;
547 u32 temp; 540 u32 temp;
548 u32 command; 541 u32 command;
@@ -579,8 +572,8 @@ static int isp1760_run(struct usb_hcd *hcd)
579 return retval; 572 return retval;
580 573
581 chipid = reg_read32(hcd->regs, HC_CHIP_ID_REG); 574 chipid = reg_read32(hcd->regs, HC_CHIP_ID_REG);
582 isp1760_info(priv, "USB ISP %04x HW rev. %d started\n", chipid & 0xffff, 575 dev_info(hcd->self.controller, "USB ISP %04x HW rev. %d started\n",
583 chipid >> 16); 576 chipid & 0xffff, chipid >> 16);
584 577
585 /* PTD Register Init Part 2, Step 28 */ 578 /* PTD Register Init Part 2, Step 28 */
586 /* enable INTs */ 579 /* enable INTs */
@@ -598,7 +591,7 @@ static u32 base_to_chip(u32 base)
598 return ((base - 0x400) >> 3); 591 return ((base - 0x400) >> 3);
599} 592}
600 593
601static void transform_into_atl(struct isp1760_hcd *priv, struct isp1760_qh *qh, 594static void transform_into_atl(struct isp1760_qh *qh,
602 struct isp1760_qtd *qtd, struct ptd *ptd) 595 struct isp1760_qtd *qtd, struct ptd *ptd)
603{ 596{
604 u32 maxpacket; 597 u32 maxpacket;
@@ -677,7 +670,7 @@ static void transform_into_atl(struct isp1760_hcd *priv, struct isp1760_qh *qh,
677 ptd->dw3 |= PTD_CERR(ERR_COUNTER); 670 ptd->dw3 |= PTD_CERR(ERR_COUNTER);
678} 671}
679 672
680static void transform_add_int(struct isp1760_hcd *priv, struct isp1760_qh *qh, 673static void transform_add_int(struct isp1760_qh *qh,
681 struct isp1760_qtd *qtd, struct ptd *ptd) 674 struct isp1760_qtd *qtd, struct ptd *ptd)
682{ 675{
683 u32 maxpacket; 676 u32 maxpacket;
@@ -738,11 +731,11 @@ static void transform_add_int(struct isp1760_hcd *priv, struct isp1760_qh *qh,
738 ptd->dw4 = usof; 731 ptd->dw4 = usof;
739} 732}
740 733
741static void transform_into_int(struct isp1760_hcd *priv, struct isp1760_qh *qh, 734static void transform_into_int(struct isp1760_qh *qh,
742 struct isp1760_qtd *qtd, struct ptd *ptd) 735 struct isp1760_qtd *qtd, struct ptd *ptd)
743{ 736{
744 transform_into_atl(priv, qh, qtd, ptd); 737 transform_into_atl(qh, qtd, ptd);
745 transform_add_int(priv, qh, qtd, ptd); 738 transform_add_int(qh, qtd, ptd);
746} 739}
747 740
748static int qtd_fill(struct isp1760_qtd *qtd, void *databuffer, size_t len, 741static int qtd_fill(struct isp1760_qtd *qtd, void *databuffer, size_t len,
@@ -763,7 +756,7 @@ static int qtd_fill(struct isp1760_qtd *qtd, void *databuffer, size_t len,
763 return count; 756 return count;
764} 757}
765 758
766static int check_error(struct ptd *ptd) 759static int check_error(struct usb_hcd *hcd, struct ptd *ptd)
767{ 760{
768 int error = 0; 761 int error = 0;
769 762
@@ -775,15 +768,15 @@ static int check_error(struct ptd *ptd)
775 } 768 }
776 769
777 if (ptd->dw3 & DW3_QTD_ACTIVE) { 770 if (ptd->dw3 & DW3_QTD_ACTIVE) {
778 printk(KERN_ERR "transfer active bit is set DW3\n"); 771 dev_err(hcd->self.controller, "Transfer active bit is set DW3\n"
779 printk(KERN_ERR "nak counter: %d, rl: %d\n", 772 "nak counter: %d, rl: %d\n",
780 (ptd->dw3 >> 19) & 0xf, (ptd->dw2 >> 25) & 0xf); 773 (ptd->dw3 >> 19) & 0xf, (ptd->dw2 >> 25) & 0xf);
781 } 774 }
782 775
783 return error; 776 return error;
784} 777}
785 778
786static void check_int_err_status(u32 dw4) 779static void check_int_err_status(struct usb_hcd *hcd, u32 dw4)
787{ 780{
788 u32 i; 781 u32 i;
789 782
@@ -792,25 +785,24 @@ static void check_int_err_status(u32 dw4)
792 for (i = 0; i < 8; i++) { 785 for (i = 0; i < 8; i++) {
793 switch (dw4 & 0x7) { 786 switch (dw4 & 0x7) {
794 case INT_UNDERRUN: 787 case INT_UNDERRUN:
795 printk(KERN_ERR "ERROR: under run , %d\n", i); 788 dev_err(hcd->self.controller, "Underrun (%d)\n", i);
796 break; 789 break;
797 790
798 case INT_EXACT: 791 case INT_EXACT:
799 printk(KERN_ERR "ERROR: transaction error, %d\n", i); 792 dev_err(hcd->self.controller,
793 "Transaction error (%d)\n", i);
800 break; 794 break;
801 795
802 case INT_BABBLE: 796 case INT_BABBLE:
803 printk(KERN_ERR "ERROR: babble error, %d\n", i); 797 dev_err(hcd->self.controller, "Babble error (%d)\n", i);
804 break; 798 break;
805 } 799 }
806 dw4 >>= 3; 800 dw4 >>= 3;
807 } 801 }
808} 802}
809 803
810static void enqueue_one_qtd(struct isp1760_qtd *qtd, struct isp1760_hcd *priv) 804static void enqueue_one_qtd(struct usb_hcd *hcd, struct isp1760_qtd *qtd)
811{ 805{
812 struct usb_hcd *hcd = priv_to_hcd(priv);
813
814 if (qtd->length && (qtd->length <= MAX_PAYLOAD_SIZE)) { 806 if (qtd->length && (qtd->length <= MAX_PAYLOAD_SIZE)) {
815 switch (qtd->packet_type) { 807 switch (qtd->packet_type) {
816 case IN_PID: 808 case IN_PID:
@@ -823,17 +815,16 @@ static void enqueue_one_qtd(struct isp1760_qtd *qtd, struct isp1760_hcd *priv)
823 } 815 }
824} 816}
825 817
826static void enqueue_one_atl_qtd(struct isp1760_hcd *priv, 818static void enqueue_one_atl_qtd(struct usb_hcd *hcd, struct isp1760_qh *qh,
827 struct isp1760_qh *qh, u32 slot, 819 u32 slot, struct isp1760_qtd *qtd)
828 struct isp1760_qtd *qtd)
829{ 820{
821 struct isp1760_hcd *priv = hcd_to_priv(hcd);
830 struct ptd ptd; 822 struct ptd ptd;
831 struct usb_hcd *hcd = priv_to_hcd(priv);
832 823
833 alloc_mem(priv, qtd); 824 alloc_mem(hcd, qtd);
834 transform_into_atl(priv, qh, qtd, &ptd); 825 transform_into_atl(qh, qtd, &ptd);
835 ptd_write(hcd->regs, ATL_PTD_OFFSET, slot, &ptd); 826 ptd_write(hcd->regs, ATL_PTD_OFFSET, slot, &ptd);
836 enqueue_one_qtd(qtd, priv); 827 enqueue_one_qtd(hcd, qtd);
837 828
838 priv->atl_ints[slot].qh = qh; 829 priv->atl_ints[slot].qh = qh;
839 priv->atl_ints[slot].qtd = qtd; 830 priv->atl_ints[slot].qtd = qtd;
@@ -841,17 +832,16 @@ static void enqueue_one_atl_qtd(struct isp1760_hcd *priv,
841 qtd->status |= slot << 16; 832 qtd->status |= slot << 16;
842} 833}
843 834
844static void enqueue_one_int_qtd(struct isp1760_hcd *priv, 835static void enqueue_one_int_qtd(struct usb_hcd *hcd, struct isp1760_qh *qh,
845 struct isp1760_qh *qh, u32 slot, 836 u32 slot, struct isp1760_qtd *qtd)
846 struct isp1760_qtd *qtd)
847{ 837{
838 struct isp1760_hcd *priv = hcd_to_priv(hcd);
848 struct ptd ptd; 839 struct ptd ptd;
849 struct usb_hcd *hcd = priv_to_hcd(priv);
850 840
851 alloc_mem(priv, qtd); 841 alloc_mem(hcd, qtd);
852 transform_into_int(priv, qh, qtd, &ptd); 842 transform_into_int(qh, qtd, &ptd);
853 ptd_write(hcd->regs, INT_PTD_OFFSET, slot, &ptd); 843 ptd_write(hcd->regs, INT_PTD_OFFSET, slot, &ptd);
854 enqueue_one_qtd(qtd, priv); 844 enqueue_one_qtd(hcd, qtd);
855 845
856 priv->int_ints[slot].qh = qh; 846 priv->int_ints[slot].qh = qh;
857 priv->int_ints[slot].qtd = qtd; 847 priv->int_ints[slot].qtd = qtd;
@@ -864,7 +854,6 @@ static void enqueue_an_ATL_packet(struct usb_hcd *hcd, struct isp1760_qh *qh,
864{ 854{
865 struct isp1760_hcd *priv = hcd_to_priv(hcd); 855 struct isp1760_hcd *priv = hcd_to_priv(hcd);
866 u32 skip_map, or_map; 856 u32 skip_map, or_map;
867 u32 queue_entry;
868 u32 slot; 857 u32 slot;
869 u32 buffstatus; 858 u32 buffstatus;
870 859
@@ -880,15 +869,14 @@ static void enqueue_an_ATL_packet(struct usb_hcd *hcd, struct isp1760_qh *qh,
880 869
881 BUG_ON(!skip_map); 870 BUG_ON(!skip_map);
882 slot = __ffs(skip_map); 871 slot = __ffs(skip_map);
883 queue_entry = 1 << slot;
884 872
885 enqueue_one_atl_qtd(priv, qh, slot, qtd); 873 enqueue_one_atl_qtd(hcd, qh, slot, qtd);
886 874
887 or_map = reg_read32(hcd->regs, HC_ATL_IRQ_MASK_OR_REG); 875 or_map = reg_read32(hcd->regs, HC_ATL_IRQ_MASK_OR_REG);
888 or_map |= queue_entry; 876 or_map |= (1 << slot);
889 reg_write32(hcd->regs, HC_ATL_IRQ_MASK_OR_REG, or_map); 877 reg_write32(hcd->regs, HC_ATL_IRQ_MASK_OR_REG, or_map);
890 878
891 skip_map &= ~queue_entry; 879 skip_map &= ~(1 << slot);
892 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map); 880 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map);
893 881
894 priv->atl_queued++; 882 priv->atl_queued++;
@@ -904,9 +892,7 @@ static void enqueue_an_ATL_packet(struct usb_hcd *hcd, struct isp1760_qh *qh,
904static void enqueue_an_INT_packet(struct usb_hcd *hcd, struct isp1760_qh *qh, 892static void enqueue_an_INT_packet(struct usb_hcd *hcd, struct isp1760_qh *qh,
905 struct isp1760_qtd *qtd) 893 struct isp1760_qtd *qtd)
906{ 894{
907 struct isp1760_hcd *priv = hcd_to_priv(hcd);
908 u32 skip_map, or_map; 895 u32 skip_map, or_map;
909 u32 queue_entry;
910 u32 slot; 896 u32 slot;
911 u32 buffstatus; 897 u32 buffstatus;
912 898
@@ -922,15 +908,14 @@ static void enqueue_an_INT_packet(struct usb_hcd *hcd, struct isp1760_qh *qh,
922 908
923 BUG_ON(!skip_map); 909 BUG_ON(!skip_map);
924 slot = __ffs(skip_map); 910 slot = __ffs(skip_map);
925 queue_entry = 1 << slot;
926 911
927 enqueue_one_int_qtd(priv, qh, slot, qtd); 912 enqueue_one_int_qtd(hcd, qh, slot, qtd);
928 913
929 or_map = reg_read32(hcd->regs, HC_INT_IRQ_MASK_OR_REG); 914 or_map = reg_read32(hcd->regs, HC_INT_IRQ_MASK_OR_REG);
930 or_map |= queue_entry; 915 or_map |= (1 << slot);
931 reg_write32(hcd->regs, HC_INT_IRQ_MASK_OR_REG, or_map); 916 reg_write32(hcd->regs, HC_INT_IRQ_MASK_OR_REG, or_map);
932 917
933 skip_map &= ~queue_entry; 918 skip_map &= ~(1 << slot);
934 reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, skip_map); 919 reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, skip_map);
935 920
936 buffstatus = reg_read32(hcd->regs, HC_BUFFER_STATUS_REG); 921 buffstatus = reg_read32(hcd->regs, HC_BUFFER_STATUS_REG);
@@ -938,14 +923,15 @@ static void enqueue_an_INT_packet(struct usb_hcd *hcd, struct isp1760_qh *qh,
938 reg_write32(hcd->regs, HC_BUFFER_STATUS_REG, buffstatus); 923 reg_write32(hcd->regs, HC_BUFFER_STATUS_REG, buffstatus);
939} 924}
940 925
941static void isp1760_urb_done(struct isp1760_hcd *priv, struct urb *urb, 926static void isp1760_urb_done(struct usb_hcd *hcd, struct urb *urb)
942 int status)
943__releases(priv->lock) 927__releases(priv->lock)
944__acquires(priv->lock) 928__acquires(priv->lock)
945{ 929{
930 struct isp1760_hcd *priv = hcd_to_priv(hcd);
931
946 if (!urb->unlinked) { 932 if (!urb->unlinked) {
947 if (status == -EINPROGRESS) 933 if (urb->status == -EINPROGRESS)
948 status = 0; 934 urb->status = 0;
949 } 935 }
950 936
951 if (usb_pipein(urb->pipe) && usb_pipetype(urb->pipe) != PIPE_CONTROL) { 937 if (usb_pipein(urb->pipe) && usb_pipetype(urb->pipe) != PIPE_CONTROL) {
@@ -957,9 +943,9 @@ __acquires(priv->lock)
957 } 943 }
958 944
959 /* complete() can reenter this HCD */ 945 /* complete() can reenter this HCD */
960 usb_hcd_unlink_urb_from_ep(priv_to_hcd(priv), urb); 946 usb_hcd_unlink_urb_from_ep(hcd, urb);
961 spin_unlock(&priv->lock); 947 spin_unlock(&priv->lock);
962 usb_hcd_giveback_urb(priv_to_hcd(priv), urb, status); 948 usb_hcd_giveback_urb(hcd, urb, urb->status);
963 spin_lock(&priv->lock); 949 spin_lock(&priv->lock);
964} 950}
965 951
@@ -1019,8 +1005,8 @@ static void do_atl_int(struct usb_hcd *hcd)
1019 struct isp1760_hcd *priv = hcd_to_priv(hcd); 1005 struct isp1760_hcd *priv = hcd_to_priv(hcd);
1020 u32 done_map, skip_map; 1006 u32 done_map, skip_map;
1021 struct ptd ptd; 1007 struct ptd ptd;
1022 struct urb *urb = NULL; 1008 struct urb *urb;
1023 u32 queue_entry; 1009 u32 slot;
1024 u32 length; 1010 u32 length;
1025 u32 or_map; 1011 u32 or_map;
1026 u32 status = -EINVAL; 1012 u32 status = -EINVAL;
@@ -1041,19 +1027,18 @@ static void do_atl_int(struct usb_hcd *hcd)
1041 status = 0; 1027 status = 0;
1042 priv->atl_queued--; 1028 priv->atl_queued--;
1043 1029
1044 queue_entry = __ffs(done_map); 1030 slot = __ffs(done_map);
1045 done_map &= ~(1 << queue_entry); 1031 done_map &= ~(1 << slot);
1046 skip_map |= 1 << queue_entry; 1032 skip_map |= (1 << slot);
1047 1033
1048 qtd = priv->atl_ints[queue_entry].qtd; 1034 qtd = priv->atl_ints[slot].qtd;
1049 urb = qtd->urb; 1035 qh = priv->atl_ints[slot].qh;
1050 qh = priv->atl_ints[queue_entry].qh;
1051 1036
1052 if (!qh) { 1037 if (!qh) {
1053 printk(KERN_ERR "qh is 0\n"); 1038 dev_err(hcd->self.controller, "qh is 0\n");
1054 continue; 1039 continue;
1055 } 1040 }
1056 ptd_read(hcd->regs, ATL_PTD_OFFSET, queue_entry, &ptd); 1041 ptd_read(hcd->regs, ATL_PTD_OFFSET, slot, &ptd);
1057 1042
1058 rl = (ptd.dw2 >> 25) & 0x0f; 1043 rl = (ptd.dw2 >> 25) & 0x0f;
1059 nakcount = (ptd.dw3 >> 19) & 0xf; 1044 nakcount = (ptd.dw3 >> 19) & 0xf;
@@ -1070,7 +1055,8 @@ static void do_atl_int(struct usb_hcd *hcd)
1070 */ 1055 */
1071 1056
1072 length = PTD_XFERRED_LENGTH(ptd.dw3); 1057 length = PTD_XFERRED_LENGTH(ptd.dw3);
1073 printk(KERN_ERR "Should reload now.... transfered %d " 1058 dev_err(hcd->self.controller,
1059 "Should reload now... transferred %d "
1074 "of %zu\n", length, qtd->length); 1060 "of %zu\n", length, qtd->length);
1075 BUG(); 1061 BUG();
1076 } 1062 }
@@ -1095,13 +1081,13 @@ static void do_atl_int(struct usb_hcd *hcd)
1095 * is unchanged. Just make sure that this entry is 1081 * is unchanged. Just make sure that this entry is
1096 * unskipped once it gets written to the HW. 1082 * unskipped once it gets written to the HW.
1097 */ 1083 */
1098 skip_map &= ~(1 << queue_entry); 1084 skip_map &= ~(1 << slot);
1099 or_map = reg_read32(hcd->regs, HC_ATL_IRQ_MASK_OR_REG); 1085 or_map = reg_read32(hcd->regs, HC_ATL_IRQ_MASK_OR_REG);
1100 or_map |= 1 << queue_entry; 1086 or_map |= 1 << slot;
1101 reg_write32(hcd->regs, HC_ATL_IRQ_MASK_OR_REG, or_map); 1087 reg_write32(hcd->regs, HC_ATL_IRQ_MASK_OR_REG, or_map);
1102 1088
1103 ptd.dw0 |= PTD_VALID; 1089 ptd.dw0 |= PTD_VALID;
1104 ptd_write(hcd->regs, ATL_PTD_OFFSET, queue_entry, &ptd); 1090 ptd_write(hcd->regs, ATL_PTD_OFFSET, slot, &ptd);
1105 1091
1106 priv->atl_queued++; 1092 priv->atl_queued++;
1107 if (priv->atl_queued == 2) 1093 if (priv->atl_queued == 2)
@@ -1116,12 +1102,12 @@ static void do_atl_int(struct usb_hcd *hcd)
1116 continue; 1102 continue;
1117 } 1103 }
1118 1104
1119 error = check_error(&ptd); 1105 error = check_error(hcd, &ptd);
1120 if (error) { 1106 if (error) {
1121 status = error; 1107 status = error;
1122 priv->atl_ints[queue_entry].qh->toggle = 0; 1108 priv->atl_ints[slot].qh->toggle = 0;
1123 priv->atl_ints[queue_entry].qh->ping = 0; 1109 priv->atl_ints[slot].qh->ping = 0;
1124 urb->status = -EPIPE; 1110 qtd->urb->status = -EPIPE;
1125 1111
1126#if 0 1112#if 0
1127 printk(KERN_ERR "Error in %s().\n", __func__); 1113 printk(KERN_ERR "Error in %s().\n", __func__);
@@ -1132,10 +1118,10 @@ static void do_atl_int(struct usb_hcd *hcd)
1132 ptd.dw4, ptd.dw5, ptd.dw6, ptd.dw7); 1118 ptd.dw4, ptd.dw5, ptd.dw6, ptd.dw7);
1133#endif 1119#endif
1134 } else { 1120 } else {
1135 if (usb_pipetype(urb->pipe) == PIPE_BULK) { 1121 if (usb_pipetype(qtd->urb->pipe) == PIPE_BULK) {
1136 priv->atl_ints[queue_entry].qh->toggle = 1122 priv->atl_ints[slot].qh->toggle =
1137 ptd.dw3 & (1 << 25); 1123 ptd.dw3 & (1 << 25);
1138 priv->atl_ints[queue_entry].qh->ping = 1124 priv->atl_ints[slot].qh->ping =
1139 ptd.dw3 & (1 << 26); 1125 ptd.dw3 & (1 << 26);
1140 } 1126 }
1141 } 1127 }
@@ -1149,51 +1135,55 @@ static void do_atl_int(struct usb_hcd *hcd)
1149 1135
1150 case OUT_PID: 1136 case OUT_PID:
1151 1137
1152 urb->actual_length += length; 1138 qtd->urb->actual_length += length;
1153 1139
1154 case SETUP_PID: 1140 case SETUP_PID:
1155 break; 1141 break;
1156 } 1142 }
1157 } 1143 }
1158 1144
1159 priv->atl_ints[queue_entry].qtd = NULL; 1145 priv->atl_ints[slot].qtd = NULL;
1160 priv->atl_ints[queue_entry].qh = NULL; 1146 priv->atl_ints[slot].qh = NULL;
1161 1147
1162 free_mem(priv, qtd); 1148 free_mem(hcd, qtd);
1163 1149
1164 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map); 1150 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map);
1165 1151
1166 if (urb->status == -EPIPE) { 1152 if (qtd->urb->status == -EPIPE) {
1167 /* HALT was received */ 1153 /* HALT was received */
1168 1154
1155 urb = qtd->urb;
1169 qtd = clean_up_qtdlist(qtd, qh); 1156 qtd = clean_up_qtdlist(qtd, qh);
1170 isp1760_urb_done(priv, urb, urb->status); 1157 isp1760_urb_done(hcd, urb);
1171 1158
1172 } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) { 1159 } else if (usb_pipebulk(qtd->urb->pipe) &&
1160 (length < qtd->length)) {
1173 /* short BULK received */ 1161 /* short BULK received */
1174 1162
1175 if (urb->transfer_flags & URB_SHORT_NOT_OK) { 1163 if (qtd->urb->transfer_flags & URB_SHORT_NOT_OK) {
1176 urb->status = -EREMOTEIO; 1164 qtd->urb->status = -EREMOTEIO;
1177 isp1760_dbg(priv, "short bulk, %d instead %zu " 1165 dev_dbg(hcd->self.controller,
1178 "with URB_SHORT_NOT_OK flag.\n", 1166 "short bulk, %d instead %zu "
1179 length, qtd->length); 1167 "with URB_SHORT_NOT_OK flag.\n",
1168 length, qtd->length);
1180 } 1169 }
1181 1170
1182 if (urb->status == -EINPROGRESS) 1171 if (qtd->urb->status == -EINPROGRESS)
1183 urb->status = 0; 1172 qtd->urb->status = 0;
1184 1173
1174 urb = qtd->urb;
1185 qtd = clean_up_qtdlist(qtd, qh); 1175 qtd = clean_up_qtdlist(qtd, qh);
1186 1176 isp1760_urb_done(hcd, urb);
1187 isp1760_urb_done(priv, urb, urb->status);
1188 1177
1189 } else if (last_qtd_of_urb(qtd, qh)) { 1178 } else if (last_qtd_of_urb(qtd, qh)) {
1190 /* that was the last qtd of that URB */ 1179 /* that was the last qtd of that URB */
1191 1180
1192 if (urb->status == -EINPROGRESS) 1181 if (qtd->urb->status == -EINPROGRESS)
1193 urb->status = 0; 1182 qtd->urb->status = 0;
1194 1183
1195 qtd = clean_this_qtd(qtd, qh); 1184 urb = qtd->urb;
1196 isp1760_urb_done(priv, urb, urb->status); 1185 qtd = clean_up_qtdlist(qtd, qh);
1186 isp1760_urb_done(hcd, urb);
1197 1187
1198 } else { 1188 } else {
1199 /* next QTD of this URB */ 1189 /* next QTD of this URB */
@@ -1217,11 +1207,11 @@ static void do_intl_int(struct usb_hcd *hcd)
1217 struct isp1760_hcd *priv = hcd_to_priv(hcd); 1207 struct isp1760_hcd *priv = hcd_to_priv(hcd);
1218 u32 done_map, skip_map; 1208 u32 done_map, skip_map;
1219 struct ptd ptd; 1209 struct ptd ptd;
1220 struct urb *urb = NULL; 1210 struct urb *urb;
1221 u32 length; 1211 u32 length;
1222 u32 or_map; 1212 u32 or_map;
1223 int error; 1213 int error;
1224 u32 queue_entry; 1214 u32 slot;
1225 struct isp1760_qtd *qtd; 1215 struct isp1760_qtd *qtd;
1226 struct isp1760_qh *qh; 1216 struct isp1760_qh *qh;
1227 1217
@@ -1233,23 +1223,22 @@ static void do_intl_int(struct usb_hcd *hcd)
1233 reg_write32(hcd->regs, HC_INT_IRQ_MASK_OR_REG, or_map); 1223 reg_write32(hcd->regs, HC_INT_IRQ_MASK_OR_REG, or_map);
1234 1224
1235 while (done_map) { 1225 while (done_map) {
1236 queue_entry = __ffs(done_map); 1226 slot = __ffs(done_map);
1237 done_map &= ~(1 << queue_entry); 1227 done_map &= ~(1 << slot);
1238 skip_map |= 1 << queue_entry; 1228 skip_map |= (1 << slot);
1239 1229
1240 qtd = priv->int_ints[queue_entry].qtd; 1230 qtd = priv->int_ints[slot].qtd;
1241 urb = qtd->urb; 1231 qh = priv->int_ints[slot].qh;
1242 qh = priv->int_ints[queue_entry].qh;
1243 1232
1244 if (!qh) { 1233 if (!qh) {
1245 printk(KERN_ERR "(INT) qh is 0\n"); 1234 dev_err(hcd->self.controller, "(INT) qh is 0\n");
1246 continue; 1235 continue;
1247 } 1236 }
1248 1237
1249 ptd_read(hcd->regs, INT_PTD_OFFSET, queue_entry, &ptd); 1238 ptd_read(hcd->regs, INT_PTD_OFFSET, slot, &ptd);
1250 check_int_err_status(ptd.dw4); 1239 check_int_err_status(hcd, ptd.dw4);
1251 1240
1252 error = check_error(&ptd); 1241 error = check_error(hcd, &ptd);
1253 if (error) { 1242 if (error) {
1254#if 0 1243#if 0
1255 printk(KERN_ERR "Error in %s().\n", __func__); 1244 printk(KERN_ERR "Error in %s().\n", __func__);
@@ -1259,18 +1248,16 @@ static void do_intl_int(struct usb_hcd *hcd)
1259 ptd.dw0, ptd.dw1, ptd.dw2, ptd.dw3, 1248 ptd.dw0, ptd.dw1, ptd.dw2, ptd.dw3,
1260 ptd.dw4, ptd.dw5, ptd.dw6, ptd.dw7); 1249 ptd.dw4, ptd.dw5, ptd.dw6, ptd.dw7);
1261#endif 1250#endif
1262 urb->status = -EPIPE; 1251 qtd->urb->status = -EPIPE;
1263 priv->int_ints[queue_entry].qh->toggle = 0; 1252 priv->int_ints[slot].qh->toggle = 0;
1264 priv->int_ints[queue_entry].qh->ping = 0; 1253 priv->int_ints[slot].qh->ping = 0;
1265 1254
1266 } else { 1255 } else {
1267 priv->int_ints[queue_entry].qh->toggle = 1256 priv->int_ints[slot].qh->toggle = ptd.dw3 & (1 << 25);
1268 ptd.dw3 & (1 << 25); 1257 priv->int_ints[slot].qh->ping = ptd.dw3 & (1 << 26);
1269 priv->int_ints[queue_entry].qh->ping =
1270 ptd.dw3 & (1 << 26);
1271 } 1258 }
1272 1259
1273 if (urb->dev->speed != USB_SPEED_HIGH) 1260 if (qtd->urb->dev->speed != USB_SPEED_HIGH)
1274 length = PTD_XFERRED_LENGTH_LO(ptd.dw3); 1261 length = PTD_XFERRED_LENGTH_LO(ptd.dw3);
1275 else 1262 else
1276 length = PTD_XFERRED_LENGTH(ptd.dw3); 1263 length = PTD_XFERRED_LENGTH(ptd.dw3);
@@ -1282,32 +1269,34 @@ static void do_intl_int(struct usb_hcd *hcd)
1282 qtd->data_buffer, length); 1269 qtd->data_buffer, length);
1283 case OUT_PID: 1270 case OUT_PID:
1284 1271
1285 urb->actual_length += length; 1272 qtd->urb->actual_length += length;
1286 1273
1287 case SETUP_PID: 1274 case SETUP_PID:
1288 break; 1275 break;
1289 } 1276 }
1290 } 1277 }
1291 1278
1292 priv->int_ints[queue_entry].qtd = NULL; 1279 priv->int_ints[slot].qtd = NULL;
1293 priv->int_ints[queue_entry].qh = NULL; 1280 priv->int_ints[slot].qh = NULL;
1294 1281
1295 reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, skip_map); 1282 reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, skip_map);
1296 free_mem(priv, qtd); 1283 free_mem(hcd, qtd);
1297 1284
1298 if (urb->status == -EPIPE) { 1285 if (qtd->urb->status == -EPIPE) {
1299 /* HALT received */ 1286 /* HALT received */
1300 1287
1301 qtd = clean_up_qtdlist(qtd, qh); 1288 urb = qtd->urb;
1302 isp1760_urb_done(priv, urb, urb->status); 1289 qtd = clean_up_qtdlist(qtd, qh);
1290 isp1760_urb_done(hcd, urb);
1303 1291
1304 } else if (last_qtd_of_urb(qtd, qh)) { 1292 } else if (last_qtd_of_urb(qtd, qh)) {
1305 1293
1306 if (urb->status == -EINPROGRESS) 1294 if (qtd->urb->status == -EINPROGRESS)
1307 urb->status = 0; 1295 qtd->urb->status = 0;
1308 1296
1309 qtd = clean_this_qtd(qtd, qh); 1297 urb = qtd->urb;
1310 isp1760_urb_done(priv, urb, urb->status); 1298 qtd = clean_up_qtdlist(qtd, qh);
1299 isp1760_urb_done(hcd, urb);
1311 1300
1312 } else { 1301 } else {
1313 /* next QTD of this URB */ 1302 /* next QTD of this URB */
@@ -1323,14 +1312,13 @@ static void do_intl_int(struct usb_hcd *hcd)
1323 } 1312 }
1324} 1313}
1325 1314
1326#define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff) 1315static struct isp1760_qh *qh_make(struct usb_hcd *hcd, struct urb *urb,
1327static struct isp1760_qh *qh_make(struct isp1760_hcd *priv, struct urb *urb,
1328 gfp_t flags) 1316 gfp_t flags)
1329{ 1317{
1330 struct isp1760_qh *qh; 1318 struct isp1760_qh *qh;
1331 int is_input, type; 1319 int is_input, type;
1332 1320
1333 qh = isp1760_qh_alloc(priv, flags); 1321 qh = isp1760_qh_alloc(flags);
1334 if (!qh) 1322 if (!qh)
1335 return qh; 1323 return qh;
1336 1324
@@ -1350,7 +1338,7 @@ static struct isp1760_qh *qh_make(struct isp1760_hcd *priv, struct urb *urb,
1350 * But interval 1 scheduling is simpler, and 1338 * But interval 1 scheduling is simpler, and
1351 * includes high bandwidth. 1339 * includes high bandwidth.
1352 */ 1340 */
1353 printk(KERN_ERR "intr period %d uframes, NYET!", 1341 dev_err(hcd->self.controller, "intr period %d uframes, NYET!",
1354 urb->interval); 1342 urb->interval);
1355 qh_destroy(qh); 1343 qh_destroy(qh);
1356 return NULL; 1344 return NULL;
@@ -1360,9 +1348,6 @@ static struct isp1760_qh *qh_make(struct isp1760_hcd *priv, struct urb *urb,
1360 } 1348 }
1361 } 1349 }
1362 1350
1363 /* support for tt scheduling, and access to toggles */
1364 qh->dev = urb->dev;
1365
1366 if (!usb_pipecontrol(urb->pipe)) 1351 if (!usb_pipecontrol(urb->pipe))
1367 usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), !is_input, 1352 usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), !is_input,
1368 1); 1353 1);
@@ -1375,7 +1360,7 @@ static struct isp1760_qh *qh_make(struct isp1760_hcd *priv, struct urb *urb,
1375 * Returns null if it can't allocate a QH it needs to. 1360 * Returns null if it can't allocate a QH it needs to.
1376 * If the QH has TDs (urbs) already, that's great. 1361 * If the QH has TDs (urbs) already, that's great.
1377 */ 1362 */
1378static struct isp1760_qh *qh_append_tds(struct isp1760_hcd *priv, 1363static struct isp1760_qh *qh_append_tds(struct usb_hcd *hcd,
1379 struct urb *urb, struct list_head *qtd_list, int epnum, 1364 struct urb *urb, struct list_head *qtd_list, int epnum,
1380 void **ptr) 1365 void **ptr)
1381{ 1366{
@@ -1384,7 +1369,7 @@ static struct isp1760_qh *qh_append_tds(struct isp1760_hcd *priv,
1384 qh = (struct isp1760_qh *)*ptr; 1369 qh = (struct isp1760_qh *)*ptr;
1385 if (!qh) { 1370 if (!qh) {
1386 /* can't sleep here, we have priv->lock... */ 1371 /* can't sleep here, we have priv->lock... */
1387 qh = qh_make(priv, urb, GFP_ATOMIC); 1372 qh = qh_make(hcd, urb, GFP_ATOMIC);
1388 if (!qh) 1373 if (!qh)
1389 return qh; 1374 return qh;
1390 *ptr = qh; 1375 *ptr = qh;
@@ -1395,8 +1380,7 @@ static struct isp1760_qh *qh_append_tds(struct isp1760_hcd *priv,
1395 return qh; 1380 return qh;
1396} 1381}
1397 1382
1398static void qtd_list_free(struct isp1760_hcd *priv, struct urb *urb, 1383static void qtd_list_free(struct urb *urb, struct list_head *qtd_list)
1399 struct list_head *qtd_list)
1400{ 1384{
1401 struct list_head *entry, *temp; 1385 struct list_head *entry, *temp;
1402 1386
@@ -1409,9 +1393,10 @@ static void qtd_list_free(struct isp1760_hcd *priv, struct urb *urb,
1409 } 1393 }
1410} 1394}
1411 1395
1412static int isp1760_prepare_enqueue(struct isp1760_hcd *priv, struct urb *urb, 1396static int isp1760_prepare_enqueue(struct usb_hcd *hcd, struct urb *urb,
1413 struct list_head *qtd_list, gfp_t mem_flags, packet_enqueue *p) 1397 struct list_head *qtd_list, gfp_t mem_flags, packet_enqueue *p)
1414{ 1398{
1399 struct isp1760_hcd *priv = hcd_to_priv(hcd);
1415 struct isp1760_qtd *qtd; 1400 struct isp1760_qtd *qtd;
1416 int epnum; 1401 int epnum;
1417 unsigned long flags; 1402 unsigned long flags;
@@ -1423,11 +1408,11 @@ static int isp1760_prepare_enqueue(struct isp1760_hcd *priv, struct urb *urb,
1423 epnum = urb->ep->desc.bEndpointAddress; 1408 epnum = urb->ep->desc.bEndpointAddress;
1424 1409
1425 spin_lock_irqsave(&priv->lock, flags); 1410 spin_lock_irqsave(&priv->lock, flags);
1426 if (!HCD_HW_ACCESSIBLE(priv_to_hcd(priv))) { 1411 if (!HCD_HW_ACCESSIBLE(hcd)) {
1427 rc = -ESHUTDOWN; 1412 rc = -ESHUTDOWN;
1428 goto done; 1413 goto done;
1429 } 1414 }
1430 rc = usb_hcd_link_urb_to_ep(priv_to_hcd(priv), urb); 1415 rc = usb_hcd_link_urb_to_ep(hcd, urb);
1431 if (rc) 1416 if (rc)
1432 goto done; 1417 goto done;
1433 1418
@@ -1437,25 +1422,24 @@ static int isp1760_prepare_enqueue(struct isp1760_hcd *priv, struct urb *urb,
1437 else 1422 else
1438 qh_busy = 0; 1423 qh_busy = 0;
1439 1424
1440 qh = qh_append_tds(priv, urb, qtd_list, epnum, &urb->ep->hcpriv); 1425 qh = qh_append_tds(hcd, urb, qtd_list, epnum, &urb->ep->hcpriv);
1441 if (!qh) { 1426 if (!qh) {
1442 usb_hcd_unlink_urb_from_ep(priv_to_hcd(priv), urb); 1427 usb_hcd_unlink_urb_from_ep(hcd, urb);
1443 rc = -ENOMEM; 1428 rc = -ENOMEM;
1444 goto done; 1429 goto done;
1445 } 1430 }
1446 1431
1447 if (!qh_busy) 1432 if (!qh_busy)
1448 p(priv_to_hcd(priv), qh, qtd); 1433 p(hcd, qh, qtd);
1449 1434
1450done: 1435done:
1451 spin_unlock_irqrestore(&priv->lock, flags); 1436 spin_unlock_irqrestore(&priv->lock, flags);
1452 if (!qh) 1437 if (!qh)
1453 qtd_list_free(priv, urb, qtd_list); 1438 qtd_list_free(urb, qtd_list);
1454 return rc; 1439 return rc;
1455} 1440}
1456 1441
1457static struct isp1760_qtd *isp1760_qtd_alloc(struct isp1760_hcd *priv, 1442static struct isp1760_qtd *isp1760_qtd_alloc(gfp_t flags)
1458 gfp_t flags)
1459{ 1443{
1460 struct isp1760_qtd *qtd; 1444 struct isp1760_qtd *qtd;
1461 1445
@@ -1469,7 +1453,8 @@ static struct isp1760_qtd *isp1760_qtd_alloc(struct isp1760_hcd *priv,
1469/* 1453/*
1470 * create a list of filled qtds for this URB; won't link into qh. 1454 * create a list of filled qtds for this URB; won't link into qh.
1471 */ 1455 */
1472static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv, 1456#define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)
1457static struct list_head *qh_urb_transaction(struct usb_hcd *hcd,
1473 struct urb *urb, struct list_head *head, gfp_t flags) 1458 struct urb *urb, struct list_head *head, gfp_t flags)
1474{ 1459{
1475 struct isp1760_qtd *qtd; 1460 struct isp1760_qtd *qtd;
@@ -1481,7 +1466,7 @@ static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv,
1481 /* 1466 /*
1482 * URBs map to sequences of QTDs: one logical transaction 1467 * URBs map to sequences of QTDs: one logical transaction
1483 */ 1468 */
1484 qtd = isp1760_qtd_alloc(priv, flags); 1469 qtd = isp1760_qtd_alloc(flags);
1485 if (!qtd) 1470 if (!qtd)
1486 return NULL; 1471 return NULL;
1487 1472
@@ -1502,7 +1487,7 @@ static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv,
1502 1487
1503 /* ... and always at least one more pid */ 1488 /* ... and always at least one more pid */
1504 token ^= DATA_TOGGLE; 1489 token ^= DATA_TOGGLE;
1505 qtd = isp1760_qtd_alloc(priv, flags); 1490 qtd = isp1760_qtd_alloc(flags);
1506 if (!qtd) 1491 if (!qtd)
1507 goto cleanup; 1492 goto cleanup;
1508 qtd->urb = urb; 1493 qtd->urb = urb;
@@ -1535,7 +1520,7 @@ static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv,
1535 1520
1536 if (!buf && len) { 1521 if (!buf && len) {
1537 /* XXX This looks like usb storage / SCSI bug */ 1522 /* XXX This looks like usb storage / SCSI bug */
1538 printk(KERN_ERR "buf is null, dma is %08lx len is %d\n", 1523 dev_err(hcd->self.controller, "buf is null, dma is %08lx len is %d\n",
1539 (long unsigned)urb->transfer_dma, len); 1524 (long unsigned)urb->transfer_dma, len);
1540 WARN_ON(1); 1525 WARN_ON(1);
1541 } 1526 }
@@ -1551,7 +1536,7 @@ static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv,
1551 if (len <= 0) 1536 if (len <= 0)
1552 break; 1537 break;
1553 1538
1554 qtd = isp1760_qtd_alloc(priv, flags); 1539 qtd = isp1760_qtd_alloc(flags);
1555 if (!qtd) 1540 if (!qtd)
1556 goto cleanup; 1541 goto cleanup;
1557 qtd->urb = urb; 1542 qtd->urb = urb;
@@ -1577,7 +1562,7 @@ static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv,
1577 one_more = 1; 1562 one_more = 1;
1578 } 1563 }
1579 if (one_more) { 1564 if (one_more) {
1580 qtd = isp1760_qtd_alloc(priv, flags); 1565 qtd = isp1760_qtd_alloc(flags);
1581 if (!qtd) 1566 if (!qtd)
1582 goto cleanup; 1567 goto cleanup;
1583 qtd->urb = urb; 1568 qtd->urb = urb;
@@ -1592,14 +1577,13 @@ static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv,
1592 return head; 1577 return head;
1593 1578
1594cleanup: 1579cleanup:
1595 qtd_list_free(priv, urb, head); 1580 qtd_list_free(urb, head);
1596 return NULL; 1581 return NULL;
1597} 1582}
1598 1583
1599static int isp1760_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, 1584static int isp1760_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
1600 gfp_t mem_flags) 1585 gfp_t mem_flags)
1601{ 1586{
1602 struct isp1760_hcd *priv = hcd_to_priv(hcd);
1603 struct list_head qtd_list; 1587 struct list_head qtd_list;
1604 packet_enqueue *pe; 1588 packet_enqueue *pe;
1605 1589
@@ -1608,29 +1592,27 @@ static int isp1760_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
1608 switch (usb_pipetype(urb->pipe)) { 1592 switch (usb_pipetype(urb->pipe)) {
1609 case PIPE_CONTROL: 1593 case PIPE_CONTROL:
1610 case PIPE_BULK: 1594 case PIPE_BULK:
1611 1595 if (!qh_urb_transaction(hcd, urb, &qtd_list, mem_flags))
1612 if (!qh_urb_transaction(priv, urb, &qtd_list, mem_flags))
1613 return -ENOMEM; 1596 return -ENOMEM;
1614 pe = enqueue_an_ATL_packet; 1597 pe = enqueue_an_ATL_packet;
1615 break; 1598 break;
1616 1599
1617 case PIPE_INTERRUPT: 1600 case PIPE_INTERRUPT:
1618 if (!qh_urb_transaction(priv, urb, &qtd_list, mem_flags)) 1601 if (!qh_urb_transaction(hcd, urb, &qtd_list, mem_flags))
1619 return -ENOMEM; 1602 return -ENOMEM;
1620 pe = enqueue_an_INT_packet; 1603 pe = enqueue_an_INT_packet;
1621 break; 1604 break;
1622 1605
1623 case PIPE_ISOCHRONOUS: 1606 case PIPE_ISOCHRONOUS:
1624 printk(KERN_ERR "PIPE_ISOCHRONOUS ain't supported\n"); 1607 dev_err(hcd->self.controller, "PIPE_ISOCHRONOUS ain't supported\n");
1625 default: 1608 default:
1626 return -EPIPE; 1609 return -EPIPE;
1627 } 1610 }
1628 1611
1629 return isp1760_prepare_enqueue(priv, urb, &qtd_list, mem_flags, pe); 1612 return isp1760_prepare_enqueue(hcd, urb, &qtd_list, mem_flags, pe);
1630} 1613}
1631 1614
1632static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, 1615static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
1633 int status)
1634{ 1616{
1635 struct isp1760_hcd *priv = hcd_to_priv(hcd); 1617 struct isp1760_hcd *priv = hcd_to_priv(hcd);
1636 struct inter_packet_info *ints; 1618 struct inter_packet_info *ints;
@@ -1689,13 +1671,13 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
1689 qtd = ints->qtd; 1671 qtd = ints->qtd;
1690 qh = ints[i].qh; 1672 qh = ints[i].qh;
1691 1673
1692 free_mem(priv, qtd); 1674 free_mem(hcd, qtd);
1693 qtd = clean_up_qtdlist(qtd, qh); 1675 qtd = clean_up_qtdlist(qtd, qh);
1694 1676
1695 ints->qh = NULL; 1677 ints->qh = NULL;
1696 ints->qtd = NULL; 1678 ints->qtd = NULL;
1697 1679
1698 isp1760_urb_done(priv, urb, status); 1680 isp1760_urb_done(hcd, urb);
1699 if (qtd) 1681 if (qtd)
1700 pe(hcd, qh, qtd); 1682 pe(hcd, qh, qtd);
1701 break; 1683 break;
@@ -1707,7 +1689,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
1707 qtd_list) { 1689 qtd_list) {
1708 if (qtd->urb == urb) { 1690 if (qtd->urb == urb) {
1709 clean_up_qtdlist(qtd, ints[i].qh); 1691 clean_up_qtdlist(qtd, ints[i].qh);
1710 isp1760_urb_done(priv, urb, status); 1692 isp1760_urb_done(hcd, urb);
1711 qtd = NULL; 1693 qtd = NULL;
1712 break; 1694 break;
1713 } 1695 }
@@ -1724,27 +1706,27 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
1724 return 0; 1706 return 0;
1725} 1707}
1726 1708
1727static irqreturn_t isp1760_irq(struct usb_hcd *usb_hcd) 1709static irqreturn_t isp1760_irq(struct usb_hcd *hcd)
1728{ 1710{
1729 struct isp1760_hcd *priv = hcd_to_priv(usb_hcd); 1711 struct isp1760_hcd *priv = hcd_to_priv(hcd);
1730 u32 imask; 1712 u32 imask;
1731 irqreturn_t irqret = IRQ_NONE; 1713 irqreturn_t irqret = IRQ_NONE;
1732 1714
1733 spin_lock(&priv->lock); 1715 spin_lock(&priv->lock);
1734 1716
1735 if (!(usb_hcd->state & HC_STATE_RUNNING)) 1717 if (!(hcd->state & HC_STATE_RUNNING))
1736 goto leave; 1718 goto leave;
1737 1719
1738 imask = reg_read32(usb_hcd->regs, HC_INTERRUPT_REG); 1720 imask = reg_read32(hcd->regs, HC_INTERRUPT_REG);
1739 if (unlikely(!imask)) 1721 if (unlikely(!imask))
1740 goto leave; 1722 goto leave;
1741 1723
1742 reg_write32(usb_hcd->regs, HC_INTERRUPT_REG, imask); 1724 reg_write32(hcd->regs, HC_INTERRUPT_REG, imask);
1743 if (imask & (HC_ATL_INT | HC_SOT_INT)) 1725 if (imask & (HC_ATL_INT | HC_SOT_INT))
1744 do_atl_int(usb_hcd); 1726 do_atl_int(hcd);
1745 1727
1746 if (imask & HC_INTL_INT) 1728 if (imask & HC_INTL_INT)
1747 do_intl_int(usb_hcd); 1729 do_intl_int(hcd);
1748 1730
1749 irqret = IRQ_HANDLED; 1731 irqret = IRQ_HANDLED;
1750leave: 1732leave:
@@ -1840,15 +1822,17 @@ static int check_reset_complete(struct usb_hcd *hcd, int index,
1840 /* if reset finished and it's still not enabled -- handoff */ 1822 /* if reset finished and it's still not enabled -- handoff */
1841 if (!(port_status & PORT_PE)) { 1823 if (!(port_status & PORT_PE)) {
1842 1824
1843 printk(KERN_ERR "port %d full speed --> companion\n", 1825 dev_err(hcd->self.controller,
1844 index + 1); 1826 "port %d full speed --> companion\n",
1827 index + 1);
1845 1828
1846 port_status |= PORT_OWNER; 1829 port_status |= PORT_OWNER;
1847 port_status &= ~PORT_RWC_BITS; 1830 port_status &= ~PORT_RWC_BITS;
1848 reg_write32(hcd->regs, HC_PORTSC1, port_status); 1831 reg_write32(hcd->regs, HC_PORTSC1, port_status);
1849 1832
1850 } else 1833 } else
1851 printk(KERN_ERR "port %d high speed\n", index + 1); 1834 dev_err(hcd->self.controller, "port %d high speed\n",
1835 index + 1);
1852 1836
1853 return port_status; 1837 return port_status;
1854} 1838}
@@ -1961,7 +1945,7 @@ static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq,
1961 1945
1962 /* whoever resumes must GetPortStatus to complete it!! */ 1946 /* whoever resumes must GetPortStatus to complete it!! */
1963 if (temp & PORT_RESUME) { 1947 if (temp & PORT_RESUME) {
1964 printk(KERN_ERR "Port resume should be skipped.\n"); 1948 dev_err(hcd->self.controller, "Port resume should be skipped.\n");
1965 1949
1966 /* Remote Wakeup received? */ 1950 /* Remote Wakeup received? */
1967 if (!priv->reset_done) { 1951 if (!priv->reset_done) {
@@ -1969,8 +1953,7 @@ static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq,
1969 priv->reset_done = jiffies 1953 priv->reset_done = jiffies
1970 + msecs_to_jiffies(20); 1954 + msecs_to_jiffies(20);
1971 /* check the port again */ 1955 /* check the port again */
1972 mod_timer(&priv_to_hcd(priv)->rh_timer, 1956 mod_timer(&hcd->rh_timer, priv->reset_done);
1973 priv->reset_done);
1974 } 1957 }
1975 1958
1976 /* resume completed? */ 1959 /* resume completed? */
@@ -1986,7 +1969,7 @@ static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq,
1986 retval = handshake(hcd, HC_PORTSC1, 1969 retval = handshake(hcd, HC_PORTSC1,
1987 PORT_RESUME, 0, 2000 /* 2msec */); 1970 PORT_RESUME, 0, 2000 /* 2msec */);
1988 if (retval != 0) { 1971 if (retval != 0) {
1989 isp1760_err(priv, 1972 dev_err(hcd->self.controller,
1990 "port %d resume error %d\n", 1973 "port %d resume error %d\n",
1991 wIndex + 1, retval); 1974 wIndex + 1, retval);
1992 goto error; 1975 goto error;
@@ -2010,7 +1993,7 @@ static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq,
2010 retval = handshake(hcd, HC_PORTSC1, 1993 retval = handshake(hcd, HC_PORTSC1,
2011 PORT_RESET, 0, 750); 1994 PORT_RESET, 0, 750);
2012 if (retval != 0) { 1995 if (retval != 0) {
2013 isp1760_err(priv, "port %d reset error %d\n", 1996 dev_err(hcd->self.controller, "port %d reset error %d\n",
2014 wIndex + 1, retval); 1997 wIndex + 1, retval);
2015 goto error; 1998 goto error;
2016 } 1999 }
@@ -2026,12 +2009,12 @@ static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq,
2026 */ 2009 */
2027 2010
2028 if (temp & PORT_OWNER) 2011 if (temp & PORT_OWNER)
2029 printk(KERN_ERR "Warning: PORT_OWNER is set\n"); 2012 dev_err(hcd->self.controller, "PORT_OWNER is set\n");
2030 2013
2031 if (temp & PORT_CONNECT) { 2014 if (temp & PORT_CONNECT) {
2032 status |= USB_PORT_STAT_CONNECTION; 2015 status |= USB_PORT_STAT_CONNECTION;
2033 /* status may be from integrated TT */ 2016 /* status may be from integrated TT */
2034 status |= ehci_port_speed(priv, temp); 2017 status |= USB_PORT_STAT_HIGH_SPEED;
2035 } 2018 }
2036 if (temp & PORT_PE) 2019 if (temp & PORT_PE)
2037 status |= USB_PORT_STAT_ENABLE; 2020 status |= USB_PORT_STAT_ENABLE;
@@ -2120,10 +2103,10 @@ error:
2120 return retval; 2103 return retval;
2121} 2104}
2122 2105
2123static void isp1760_endpoint_disable(struct usb_hcd *usb_hcd, 2106static void isp1760_endpoint_disable(struct usb_hcd *hcd,
2124 struct usb_host_endpoint *ep) 2107 struct usb_host_endpoint *ep)
2125{ 2108{
2126 struct isp1760_hcd *priv = hcd_to_priv(usb_hcd); 2109 struct isp1760_hcd *priv = hcd_to_priv(hcd);
2127 struct isp1760_qh *qh; 2110 struct isp1760_qh *qh;
2128 struct isp1760_qtd *qtd; 2111 struct isp1760_qtd *qtd;
2129 unsigned long flags; 2112 unsigned long flags;
@@ -2143,16 +2126,16 @@ static void isp1760_endpoint_disable(struct usb_hcd *usb_hcd,
2143 qtd_list); 2126 qtd_list);
2144 2127
2145 if (qtd->status & URB_ENQUEUED) { 2128 if (qtd->status & URB_ENQUEUED) {
2146
2147 spin_unlock_irqrestore(&priv->lock, flags); 2129 spin_unlock_irqrestore(&priv->lock, flags);
2148 isp1760_urb_dequeue(usb_hcd, qtd->urb, -ECONNRESET); 2130 isp1760_urb_dequeue(hcd, qtd->urb, -ECONNRESET);
2149 spin_lock_irqsave(&priv->lock, flags); 2131 spin_lock_irqsave(&priv->lock, flags);
2150 } else { 2132 } else {
2151 struct urb *urb; 2133 struct urb *urb;
2152 2134
2153 urb = qtd->urb; 2135 urb = qtd->urb;
2154 clean_up_qtdlist(qtd, qh); 2136 clean_up_qtdlist(qtd, qh);
2155 isp1760_urb_done(priv, urb, -ECONNRESET); 2137 urb->status = -ECONNRESET;
2138 isp1760_urb_done(hcd, urb);
2156 } 2139 }
2157 } while (1); 2140 } while (1);
2158 2141
@@ -2184,7 +2167,7 @@ static void isp1760_stop(struct usb_hcd *hcd)
2184 mdelay(20); 2167 mdelay(20);
2185 2168
2186 spin_lock_irq(&priv->lock); 2169 spin_lock_irq(&priv->lock);
2187 ehci_reset(priv); 2170 ehci_reset(hcd);
2188 /* Disable IRQ */ 2171 /* Disable IRQ */
2189 temp = reg_read32(hcd->regs, HC_HW_MODE_CTRL); 2172 temp = reg_read32(hcd->regs, HC_HW_MODE_CTRL);
2190 reg_write32(hcd->regs, HC_HW_MODE_CTRL, temp &= ~HW_GLOBAL_INTR_EN); 2173 reg_write32(hcd->regs, HC_HW_MODE_CTRL, temp &= ~HW_GLOBAL_INTR_EN);
diff --git a/drivers/usb/host/isp1760-hcd.h b/drivers/usb/host/isp1760-hcd.h
index aadd77bc271c..870507690607 100644
--- a/drivers/usb/host/isp1760-hcd.h
+++ b/drivers/usb/host/isp1760-hcd.h
@@ -107,8 +107,6 @@ struct ptd {
107#define PAYLOAD_OFFSET 0x1000 107#define PAYLOAD_OFFSET 0x1000
108 108
109struct inter_packet_info { 109struct inter_packet_info {
110#define PTD_FIRE_NEXT (1 << 0)
111#define PTD_URB_FINISHED (1 << 1)
112 struct isp1760_qh *qh; 110 struct isp1760_qh *qh;
113 struct isp1760_qtd *qtd; 111 struct isp1760_qtd *qtd;
114}; 112};
@@ -117,15 +115,6 @@ struct inter_packet_info {
117typedef void (packet_enqueue)(struct usb_hcd *hcd, struct isp1760_qh *qh, 115typedef void (packet_enqueue)(struct usb_hcd *hcd, struct isp1760_qh *qh,
118 struct isp1760_qtd *qtd); 116 struct isp1760_qtd *qtd);
119 117
120#define isp1760_dbg(priv, fmt, args...) \
121 dev_dbg(priv_to_hcd(priv)->self.controller, fmt, ##args)
122
123#define isp1760_info(priv, fmt, args...) \
124 dev_info(priv_to_hcd(priv)->self.controller, fmt, ##args)
125
126#define isp1760_err(priv, fmt, args...) \
127 dev_err(priv_to_hcd(priv)->self.controller, fmt, ##args)
128
129/* 118/*
130 * Device flags that can vary from board to board. All of these 119 * Device flags that can vary from board to board. All of these
131 * indicate the most "atypical" case, so that a devflags of 0 is 120 * indicate the most "atypical" case, so that a devflags of 0 is