diff options
Diffstat (limited to 'drivers/usb/dwc2/hcd_queue.c')
-rw-r--r-- | drivers/usb/dwc2/hcd_queue.c | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c index 5713f03a4e56..3ae8b1bbaa55 100644 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c | |||
@@ -76,14 +76,13 @@ static int dwc2_periodic_channel_available(struct dwc2_hsotg *hsotg) | |||
76 | int num_channels; | 76 | int num_channels; |
77 | 77 | ||
78 | num_channels = hsotg->params.host_channels; | 78 | num_channels = hsotg->params.host_channels; |
79 | if (hsotg->periodic_channels + hsotg->non_periodic_channels < | 79 | if ((hsotg->periodic_channels + hsotg->non_periodic_channels < |
80 | num_channels | 80 | num_channels) && (hsotg->periodic_channels < num_channels - 1)) { |
81 | && hsotg->periodic_channels < num_channels - 1) { | ||
82 | status = 0; | 81 | status = 0; |
83 | } else { | 82 | } else { |
84 | dev_dbg(hsotg->dev, | 83 | dev_dbg(hsotg->dev, |
85 | "%s: Total channels: %d, Periodic: %d, " | 84 | "%s: Total channels: %d, Periodic: %d, Non-periodic: %d\n", |
86 | "Non-periodic: %d\n", __func__, num_channels, | 85 | __func__, num_channels, |
87 | hsotg->periodic_channels, hsotg->non_periodic_channels); | 86 | hsotg->periodic_channels, hsotg->non_periodic_channels); |
88 | status = -ENOSPC; | 87 | status = -ENOSPC; |
89 | } | 88 | } |
@@ -485,7 +484,6 @@ static void pmap_print(unsigned long *map, int bits_per_period, | |||
485 | } | 484 | } |
486 | } | 485 | } |
487 | 486 | ||
488 | |||
489 | struct dwc2_qh_print_data { | 487 | struct dwc2_qh_print_data { |
490 | struct dwc2_hsotg *hsotg; | 488 | struct dwc2_hsotg *hsotg; |
491 | struct dwc2_qh *qh; | 489 | struct dwc2_qh *qh; |
@@ -558,7 +556,6 @@ static void dwc2_qh_schedule_print(struct dwc2_hsotg *hsotg, | |||
558 | DWC2_HS_SCHEDULE_UFRAMES, "uFrame", "us", | 556 | DWC2_HS_SCHEDULE_UFRAMES, "uFrame", "us", |
559 | dwc2_qh_print, &print_data); | 557 | dwc2_qh_print, &print_data); |
560 | } | 558 | } |
561 | return; | ||
562 | } | 559 | } |
563 | #else | 560 | #else |
564 | static inline void dwc2_qh_schedule_print(struct dwc2_hsotg *hsotg, | 561 | static inline void dwc2_qh_schedule_print(struct dwc2_hsotg *hsotg, |
@@ -587,7 +584,7 @@ static int dwc2_ls_pmap_schedule(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, | |||
587 | unsigned long *map = dwc2_get_ls_map(hsotg, qh); | 584 | unsigned long *map = dwc2_get_ls_map(hsotg, qh); |
588 | int slice; | 585 | int slice; |
589 | 586 | ||
590 | if (map == NULL) | 587 | if (!map) |
591 | return -EINVAL; | 588 | return -EINVAL; |
592 | 589 | ||
593 | /* | 590 | /* |
@@ -626,7 +623,7 @@ static void dwc2_ls_pmap_unschedule(struct dwc2_hsotg *hsotg, | |||
626 | unsigned long *map = dwc2_get_ls_map(hsotg, qh); | 623 | unsigned long *map = dwc2_get_ls_map(hsotg, qh); |
627 | 624 | ||
628 | /* Schedule should have failed, so no worries about no error code */ | 625 | /* Schedule should have failed, so no worries about no error code */ |
629 | if (map == NULL) | 626 | if (!map) |
630 | return; | 627 | return; |
631 | 628 | ||
632 | pmap_unschedule(map, DWC2_LS_PERIODIC_SLICES_PER_FRAME, | 629 | pmap_unschedule(map, DWC2_LS_PERIODIC_SLICES_PER_FRAME, |
@@ -1107,7 +1104,7 @@ static void dwc2_pick_first_frame(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | |||
1107 | next_active_frame = earliest_frame; | 1104 | next_active_frame = earliest_frame; |
1108 | 1105 | ||
1109 | /* Get the "no microframe schduler" out of the way... */ | 1106 | /* Get the "no microframe schduler" out of the way... */ |
1110 | if (hsotg->params.uframe_sched <= 0) { | 1107 | if (!hsotg->params.uframe_sched) { |
1111 | if (qh->do_split) | 1108 | if (qh->do_split) |
1112 | /* Splits are active at microframe 0 minus 1 */ | 1109 | /* Splits are active at microframe 0 minus 1 */ |
1113 | next_active_frame |= 0x7; | 1110 | next_active_frame |= 0x7; |
@@ -1182,7 +1179,7 @@ exit: | |||
1182 | qh->start_active_frame = next_active_frame; | 1179 | qh->start_active_frame = next_active_frame; |
1183 | 1180 | ||
1184 | dwc2_sch_vdbg(hsotg, "QH=%p First fn=%04x nxt=%04x\n", | 1181 | dwc2_sch_vdbg(hsotg, "QH=%p First fn=%04x nxt=%04x\n", |
1185 | qh, frame_number, qh->next_active_frame); | 1182 | qh, frame_number, qh->next_active_frame); |
1186 | } | 1183 | } |
1187 | 1184 | ||
1188 | /** | 1185 | /** |
@@ -1200,7 +1197,7 @@ static int dwc2_do_reserve(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | |||
1200 | { | 1197 | { |
1201 | int status; | 1198 | int status; |
1202 | 1199 | ||
1203 | if (hsotg->params.uframe_sched > 0) { | 1200 | if (hsotg->params.uframe_sched) { |
1204 | status = dwc2_uframe_schedule(hsotg, qh); | 1201 | status = dwc2_uframe_schedule(hsotg, qh); |
1205 | } else { | 1202 | } else { |
1206 | status = dwc2_periodic_channel_available(hsotg); | 1203 | status = dwc2_periodic_channel_available(hsotg); |
@@ -1221,7 +1218,7 @@ static int dwc2_do_reserve(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | |||
1221 | return status; | 1218 | return status; |
1222 | } | 1219 | } |
1223 | 1220 | ||
1224 | if (hsotg->params.uframe_sched <= 0) | 1221 | if (!hsotg->params.uframe_sched) |
1225 | /* Reserve periodic channel */ | 1222 | /* Reserve periodic channel */ |
1226 | hsotg->periodic_channels++; | 1223 | hsotg->periodic_channels++; |
1227 | 1224 | ||
@@ -1257,7 +1254,7 @@ static void dwc2_do_unreserve(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | |||
1257 | /* Update claimed usecs per (micro)frame */ | 1254 | /* Update claimed usecs per (micro)frame */ |
1258 | hsotg->periodic_usecs -= qh->host_us; | 1255 | hsotg->periodic_usecs -= qh->host_us; |
1259 | 1256 | ||
1260 | if (hsotg->params.uframe_sched > 0) { | 1257 | if (hsotg->params.uframe_sched) { |
1261 | dwc2_uframe_unschedule(hsotg, qh); | 1258 | dwc2_uframe_unschedule(hsotg, qh); |
1262 | } else { | 1259 | } else { |
1263 | /* Release periodic channel reservation */ | 1260 | /* Release periodic channel reservation */ |
@@ -1394,7 +1391,7 @@ static int dwc2_schedule_periodic(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | |||
1394 | 1391 | ||
1395 | qh->unreserve_pending = 0; | 1392 | qh->unreserve_pending = 0; |
1396 | 1393 | ||
1397 | if (hsotg->params.dma_desc_enable > 0) | 1394 | if (hsotg->params.dma_desc_enable) |
1398 | /* Don't rely on SOF and start in ready schedule */ | 1395 | /* Don't rely on SOF and start in ready schedule */ |
1399 | list_add_tail(&qh->qh_list_entry, &hsotg->periodic_sched_ready); | 1396 | list_add_tail(&qh->qh_list_entry, &hsotg->periodic_sched_ready); |
1400 | else | 1397 | else |
@@ -1501,7 +1498,6 @@ static void dwc2_qh_init(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, | |||
1501 | device_ns += dwc_tt->usb_tt->think_time; | 1498 | device_ns += dwc_tt->usb_tt->think_time; |
1502 | qh->device_us = NS_TO_US(device_ns); | 1499 | qh->device_us = NS_TO_US(device_ns); |
1503 | 1500 | ||
1504 | |||
1505 | qh->device_interval = urb->interval; | 1501 | qh->device_interval = urb->interval; |
1506 | qh->host_interval = urb->interval * (do_split ? 8 : 1); | 1502 | qh->host_interval = urb->interval * (do_split ? 8 : 1); |
1507 | 1503 | ||
@@ -1587,7 +1583,7 @@ static void dwc2_qh_init(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, | |||
1587 | * Return: Pointer to the newly allocated QH, or NULL on error | 1583 | * Return: Pointer to the newly allocated QH, or NULL on error |
1588 | */ | 1584 | */ |
1589 | struct dwc2_qh *dwc2_hcd_qh_create(struct dwc2_hsotg *hsotg, | 1585 | struct dwc2_qh *dwc2_hcd_qh_create(struct dwc2_hsotg *hsotg, |
1590 | struct dwc2_hcd_urb *urb, | 1586 | struct dwc2_hcd_urb *urb, |
1591 | gfp_t mem_flags) | 1587 | gfp_t mem_flags) |
1592 | { | 1588 | { |
1593 | struct dwc2_qh *qh; | 1589 | struct dwc2_qh *qh; |
@@ -1602,7 +1598,7 @@ struct dwc2_qh *dwc2_hcd_qh_create(struct dwc2_hsotg *hsotg, | |||
1602 | 1598 | ||
1603 | dwc2_qh_init(hsotg, qh, urb, mem_flags); | 1599 | dwc2_qh_init(hsotg, qh, urb, mem_flags); |
1604 | 1600 | ||
1605 | if (hsotg->params.dma_desc_enable > 0 && | 1601 | if (hsotg->params.dma_desc_enable && |
1606 | dwc2_hcd_qh_init_ddma(hsotg, qh, mem_flags) < 0) { | 1602 | dwc2_hcd_qh_init_ddma(hsotg, qh, mem_flags) < 0) { |
1607 | dwc2_hcd_qh_free(hsotg, qh); | 1603 | dwc2_hcd_qh_free(hsotg, qh); |
1608 | return NULL; | 1604 | return NULL; |
@@ -1714,7 +1710,7 @@ void dwc2_hcd_qh_unlink(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | |||
1714 | dwc2_deschedule_periodic(hsotg, qh); | 1710 | dwc2_deschedule_periodic(hsotg, qh); |
1715 | hsotg->periodic_qh_count--; | 1711 | hsotg->periodic_qh_count--; |
1716 | if (!hsotg->periodic_qh_count && | 1712 | if (!hsotg->periodic_qh_count && |
1717 | hsotg->params.dma_desc_enable <= 0) { | 1713 | !hsotg->params.dma_desc_enable) { |
1718 | intr_mask = dwc2_readl(hsotg->regs + GINTMSK); | 1714 | intr_mask = dwc2_readl(hsotg->regs + GINTMSK); |
1719 | intr_mask &= ~GINTSTS_SOF; | 1715 | intr_mask &= ~GINTSTS_SOF; |
1720 | dwc2_writel(intr_mask, hsotg->regs + GINTMSK); | 1716 | dwc2_writel(intr_mask, hsotg->regs + GINTMSK); |
@@ -1741,7 +1737,7 @@ void dwc2_hcd_qh_unlink(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | |||
1741 | * Return: number missed by (or 0 if we didn't miss). | 1737 | * Return: number missed by (or 0 if we didn't miss). |
1742 | */ | 1738 | */ |
1743 | static int dwc2_next_for_periodic_split(struct dwc2_hsotg *hsotg, | 1739 | static int dwc2_next_for_periodic_split(struct dwc2_hsotg *hsotg, |
1744 | struct dwc2_qh *qh, u16 frame_number) | 1740 | struct dwc2_qh *qh, u16 frame_number) |
1745 | { | 1741 | { |
1746 | u16 old_frame = qh->next_active_frame; | 1742 | u16 old_frame = qh->next_active_frame; |
1747 | u16 prev_frame_number = dwc2_frame_num_dec(frame_number, 1); | 1743 | u16 prev_frame_number = dwc2_frame_num_dec(frame_number, 1); |
@@ -1804,7 +1800,7 @@ static int dwc2_next_for_periodic_split(struct dwc2_hsotg *hsotg, | |||
1804 | * Return: number missed by (or 0 if we didn't miss). | 1800 | * Return: number missed by (or 0 if we didn't miss). |
1805 | */ | 1801 | */ |
1806 | static int dwc2_next_periodic_start(struct dwc2_hsotg *hsotg, | 1802 | static int dwc2_next_periodic_start(struct dwc2_hsotg *hsotg, |
1807 | struct dwc2_qh *qh, u16 frame_number) | 1803 | struct dwc2_qh *qh, u16 frame_number) |
1808 | { | 1804 | { |
1809 | int missed = 0; | 1805 | int missed = 0; |
1810 | u16 interval = qh->host_interval; | 1806 | u16 interval = qh->host_interval; |
@@ -1926,7 +1922,7 @@ void dwc2_hcd_qh_deactivate(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, | |||
1926 | missed = dwc2_next_periodic_start(hsotg, qh, frame_number); | 1922 | missed = dwc2_next_periodic_start(hsotg, qh, frame_number); |
1927 | 1923 | ||
1928 | dwc2_sch_vdbg(hsotg, | 1924 | dwc2_sch_vdbg(hsotg, |
1929 | "QH=%p next(%d) fn=%04x, sch=%04x=>%04x (%+d) miss=%d %s\n", | 1925 | "QH=%p next(%d) fn=%04x, sch=%04x=>%04x (%+d) miss=%d %s\n", |
1930 | qh, sched_next_periodic_split, frame_number, old_frame, | 1926 | qh, sched_next_periodic_split, frame_number, old_frame, |
1931 | qh->next_active_frame, | 1927 | qh->next_active_frame, |
1932 | dwc2_frame_num_dec(qh->next_active_frame, old_frame), | 1928 | dwc2_frame_num_dec(qh->next_active_frame, old_frame), |