Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: remove third argument of usb_maxpacket()

The third argument of usb_maxpacket(): in_out has been deprecated
because it could be derived from the second argument (e.g. using
usb_pipeout(pipe)).

N.B. function usb_maxpacket() was made variadic to accommodate the
transition from the old prototype with three arguments to the new one
with only two arguments (so that no renaming is needed). The variadic
argument is to be removed once all users of usb_maxpacket() get
migrated.

CC: Duncan Sands <duncan.sands@free.fr>
CC: Alan Stern <stern@rowland.harvard.edu>
CC: Olav Kongas <ok@artecdesign.ee>
CC: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/r/20220317035514.6378-7-mailhol.vincent@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Vincent Mailhol and committed by
Greg Kroah-Hartman
dcd2e49b e13adbfa

+33 -44
+1 -1
drivers/usb/atm/usbatm.c
··· 1091 1091 snd_buf_bytes - (snd_buf_bytes % instance->tx_channel.stride)); 1092 1092 1093 1093 /* rx buffer size must be a positive multiple of the endpoint maxpacket */ 1094 - maxpacket = usb_maxpacket(usb_dev, instance->rx_channel.endpoint, 0); 1094 + maxpacket = usb_maxpacket(usb_dev, instance->rx_channel.endpoint); 1095 1095 1096 1096 if ((maxpacket < 1) || (maxpacket > UDSL_MAX_BUF_SIZE)) { 1097 1097 dev_err(dev, "%s: invalid endpoint %02x!\n", __func__,
+2 -2
drivers/usb/c67x00/c67x00-sched.c
··· 655 655 usb_pipeout(urb->pipe)); 656 656 remaining = urb->transfer_buffer_length - urb->actual_length; 657 657 658 - maxps = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)); 658 + maxps = usb_maxpacket(urb->dev, urb->pipe); 659 659 660 660 need_empty = (urb->transfer_flags & URB_ZERO_PACKET) && 661 661 usb_pipeout(urb->pipe) && !(remaining % maxps); ··· 866 866 if (unlikely(!act_bytes)) 867 867 return 1; /* This was an empty packet */ 868 868 869 - maxps = usb_maxpacket(td_udev(td), td->pipe, usb_pipeout(td->pipe)); 869 + maxps = usb_maxpacket(td_udev(td), td->pipe); 870 870 871 871 if (unlikely(act_bytes < maxps)) 872 872 return 1; /* Smaller then full packet */
+1 -1
drivers/usb/core/hub.c
··· 1635 1635 * maxpktsize is defined in hcd.c's fake endpoint descriptors 1636 1636 * to be big enough for at least USB_MAXCHILDREN ports. */ 1637 1637 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); 1638 - maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); 1638 + maxp = usb_maxpacket(hdev, pipe); 1639 1639 1640 1640 if (maxp > sizeof(*hub->buffer)) 1641 1641 maxp = sizeof(*hub->buffer);
+2 -2
drivers/usb/host/ehci-q.c
··· 645 645 token |= (1 /* "in" */ << 8); 646 646 /* else it's already initted to "out" pid (0 << 8) */ 647 647 648 - maxpacket = usb_maxpacket(urb->dev, urb->pipe, !is_input); 648 + maxpacket = usb_maxpacket(urb->dev, urb->pipe); 649 649 650 650 /* 651 651 * buffer gets wrapped in one or more qtds; ··· 1218 1218 1219 1219 token |= (1 /* "in" */ << 8); /*This is IN stage*/ 1220 1220 1221 - maxpacket = usb_maxpacket(urb->dev, urb->pipe, 0); 1221 + maxpacket = usb_maxpacket(urb->dev, urb->pipe); 1222 1222 1223 1223 qtd_fill(ehci, qtd, buf, len, token, maxpacket); 1224 1224
+1 -2
drivers/usb/host/fhci-hcd.c
··· 408 408 size++; 409 409 else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 410 410 && (urb->transfer_buffer_length 411 - % usb_maxpacket(urb->dev, pipe, 412 - usb_pipeout(pipe))) != 0) 411 + % usb_maxpacket(urb->dev, pipe)) != 0) 413 412 size++; 414 413 break; 415 414 case PIPE_ISOCHRONOUS:
+1 -1
drivers/usb/host/fotg210-hcd.c
··· 2596 2596 token |= (1 /* "in" */ << 8); 2597 2597 /* else it's already initted to "out" pid (0 << 8) */ 2598 2598 2599 - maxpacket = usb_maxpacket(urb->dev, urb->pipe, !is_input); 2599 + maxpacket = usb_maxpacket(urb->dev, urb->pipe); 2600 2600 2601 2601 /* 2602 2602 * buffer gets wrapped in one or more qtds;
+2 -3
drivers/usb/host/isp116x-hcd.c
··· 726 726 INIT_LIST_HEAD(&ep->schedule); 727 727 ep->udev = udev; 728 728 ep->epnum = epnum; 729 - ep->maxpacket = usb_maxpacket(udev, urb->pipe, is_out); 729 + ep->maxpacket = usb_maxpacket(udev, urb->pipe); 730 730 usb_settoggle(udev, epnum, is_out, 0); 731 731 732 732 if (type == PIPE_CONTROL) { ··· 757 757 ep->load = usb_calc_bus_time(udev->speed, 758 758 !is_out, 759 759 (type == PIPE_ISOCHRONOUS), 760 - usb_maxpacket(udev, pipe, 761 - is_out)) / 760 + usb_maxpacket(udev, pipe)) / 762 761 1000; 763 762 } 764 763 hep->hcpriv = ep;
+3 -3
drivers/usb/host/isp1362-hcd.c
··· 1279 1279 ep->udev = usb_get_dev(udev); 1280 1280 ep->hep = hep; 1281 1281 ep->epnum = epnum; 1282 - ep->maxpacket = usb_maxpacket(udev, urb->pipe, is_out); 1282 + ep->maxpacket = usb_maxpacket(udev, urb->pipe); 1283 1283 ep->ptd_offset = -EINVAL; 1284 1284 ep->ptd_index = -EINVAL; 1285 1285 usb_settoggle(udev, epnum, is_out, 0); ··· 1299 1299 ep->interval = urb->interval; 1300 1300 ep->branch = PERIODIC_SIZE; 1301 1301 ep->load = usb_calc_bus_time(udev->speed, !is_out, 1302 - (type == PIPE_ISOCHRONOUS), 1303 - usb_maxpacket(udev, pipe, is_out)) / 1000; 1302 + type == PIPE_ISOCHRONOUS, 1303 + usb_maxpacket(udev, pipe)) / 1000; 1304 1304 break; 1305 1305 } 1306 1306 hep->hcpriv = ep;
+3 -3
drivers/usb/host/max3421-hcd.c
··· 546 546 return MAX3421_HXFR_BULK_OUT(epnum); 547 547 } 548 548 549 - max_packet = usb_maxpacket(urb->dev, urb->pipe, 1); 549 + max_packet = usb_maxpacket(urb->dev, urb->pipe); 550 550 551 551 if (max_packet > MAX3421_FIFO_SIZE) { 552 552 /* ··· 952 952 * USB 2.0 Section 5.3.2 Pipes: packets must be full size 953 953 * except for last one. 954 954 */ 955 - max_packet = usb_maxpacket(urb->dev, urb->pipe, 0); 955 + max_packet = usb_maxpacket(urb->dev, urb->pipe); 956 956 if (max_packet > MAX3421_FIFO_SIZE) { 957 957 /* 958 958 * We do not support isochronous transfers at this ··· 998 998 * max_packet as an indicator that the end of the 999 999 * packet has been reached). 1000 1000 */ 1001 - u32 max_packet = usb_maxpacket(urb->dev, urb->pipe, 1); 1001 + u32 max_packet = usb_maxpacket(urb->dev, urb->pipe); 1002 1002 1003 1003 if (max3421_hcd->curr_len == max_packet) 1004 1004 return 0;
+1 -2
drivers/usb/host/ohci-hcd.c
··· 181 181 size++; 182 182 else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 183 183 && (urb->transfer_buffer_length 184 - % usb_maxpacket (urb->dev, pipe, 185 - usb_pipeout (pipe))) == 0) 184 + % usb_maxpacket(urb->dev, pipe)) == 0) 186 185 size++; 187 186 break; 188 187 case PIPE_ISOCHRONOUS: /* number of packets from URB */
+2 -2
drivers/usb/host/oxu210hp-hcd.c
··· 1685 1685 token |= (1 /* "in" */ << 8); 1686 1686 /* else it's already initted to "out" pid (0 << 8) */ 1687 1687 1688 - maxpacket = usb_maxpacket(urb->dev, urb->pipe, !is_input); 1688 + maxpacket = usb_maxpacket(urb->dev, urb->pipe); 1689 1689 1690 1690 /* 1691 1691 * buffer gets wrapped in one or more qtds; ··· 1796 1796 1797 1797 is_input = usb_pipein(urb->pipe); 1798 1798 type = usb_pipetype(urb->pipe); 1799 - maxp = usb_maxpacket(urb->dev, urb->pipe, !is_input); 1799 + maxp = usb_maxpacket(urb->dev, urb->pipe); 1800 1800 1801 1801 /* Compute interrupt scheduling parameters just once, and save. 1802 1802 * - allowing for high bandwidth, how many nsec/uframe are used?
+1 -2
drivers/usb/host/r8a66597-hcd.c
··· 1867 1867 td->pipe = hep->hcpriv; 1868 1868 td->urb = urb; 1869 1869 td->address = get_urb_to_r8a66597_addr(r8a66597, urb); 1870 - td->maxpacket = usb_maxpacket(urb->dev, urb->pipe, 1871 - !usb_pipein(urb->pipe)); 1870 + td->maxpacket = usb_maxpacket(urb->dev, urb->pipe); 1872 1871 if (usb_pipecontrol(urb->pipe)) 1873 1872 td->type = USB_PID_SETUP; 1874 1873 else if (usb_pipein(urb->pipe))
+3 -3
drivers/usb/host/sl811-hcd.c
··· 842 842 INIT_LIST_HEAD(&ep->schedule); 843 843 ep->udev = udev; 844 844 ep->epnum = epnum; 845 - ep->maxpacket = usb_maxpacket(udev, urb->pipe, is_out); 845 + ep->maxpacket = usb_maxpacket(udev, urb->pipe); 846 846 ep->defctrl = SL11H_HCTLMASK_ARM | SL11H_HCTLMASK_ENABLE; 847 847 usb_settoggle(udev, epnum, is_out, 0); 848 848 ··· 878 878 if (type == PIPE_ISOCHRONOUS) 879 879 ep->defctrl |= SL11H_HCTLMASK_ISOCH; 880 880 ep->load = usb_calc_bus_time(udev->speed, !is_out, 881 - (type == PIPE_ISOCHRONOUS), 882 - usb_maxpacket(udev, pipe, is_out)) 881 + type == PIPE_ISOCHRONOUS, 882 + usb_maxpacket(udev, pipe)) 883 883 / 1000; 884 884 break; 885 885 }
+2 -4
drivers/usb/isp1760/isp1760-hcd.c
··· 825 825 memset(ptd, 0, sizeof(*ptd)); 826 826 827 827 /* according to 3.6.2, max packet len can not be > 0x400 */ 828 - maxpacket = usb_maxpacket(qtd->urb->dev, qtd->urb->pipe, 829 - usb_pipeout(qtd->urb->pipe)); 828 + maxpacket = usb_maxpacket(qtd->urb->dev, qtd->urb->pipe); 830 829 multi = 1 + ((maxpacket >> 11) & 0x3); 831 830 maxpacket &= 0x7ff; 832 831 ··· 1807 1808 packet_type = IN_PID; 1808 1809 } 1809 1810 1810 - maxpacketsize = usb_maxpacket(urb->dev, urb->pipe, 1811 - usb_pipeout(urb->pipe)); 1811 + maxpacketsize = usb_maxpacket(urb->dev, urb->pipe); 1812 1812 1813 1813 /* 1814 1814 * buffer gets wrapped in one or more qtds;
+5 -10
drivers/usb/misc/ftdi-elan.c
··· 1449 1449 command->length = 0x8007; 1450 1450 command->address = (toggle_bits << 6) | (ep_number << 2) 1451 1451 | (address << 0); 1452 - command->width = usb_maxpacket(urb->dev, urb->pipe, 1453 - usb_pipeout(urb->pipe)); 1452 + command->width = usb_maxpacket(urb->dev, urb->pipe); 1454 1453 command->follows = 8; 1455 1454 command->value = 0; 1456 1455 command->buffer = urb->setup_packet; ··· 1513 1514 1); 1514 1515 command->address = (toggle_bits << 6) | (ep_number << 2) 1515 1516 | (address << 0); 1516 - command->width = usb_maxpacket(urb->dev, urb->pipe, 1517 - usb_pipeout(urb->pipe)); 1517 + command->width = usb_maxpacket(urb->dev, urb->pipe); 1518 1518 command->follows = 0; 1519 1519 command->value = 0; 1520 1520 command->buffer = NULL; ··· 1569 1571 command->length = 0x0000; 1570 1572 command->address = (toggle_bits << 6) | (ep_number << 2) 1571 1573 | (address << 0); 1572 - command->width = usb_maxpacket(urb->dev, urb->pipe, 1573 - usb_pipeout(urb->pipe)); 1574 + command->width = usb_maxpacket(urb->dev, urb->pipe); 1574 1575 command->follows = 0; 1575 1576 command->value = 0; 1576 1577 command->buffer = NULL; ··· 1631 1634 command->header = 0x81 | (ed << 5); 1632 1635 command->address = (toggle_bits << 6) | (ep_number << 2) 1633 1636 | (address << 0); 1634 - command->width = usb_maxpacket(urb->dev, urb->pipe, 1635 - usb_pipeout(urb->pipe)); 1637 + command->width = usb_maxpacket(urb->dev, urb->pipe); 1636 1638 command->follows = min_t(u32, 1024, 1637 1639 urb->transfer_buffer_length - 1638 1640 urb->actual_length); ··· 1711 1715 1); 1712 1716 command->address = (toggle_bits << 6) | (ep_number << 2) 1713 1717 | (address << 0); 1714 - command->width = usb_maxpacket(urb->dev, urb->pipe, 1715 - usb_pipeout(urb->pipe)); 1718 + command->width = usb_maxpacket(urb->dev, urb->pipe); 1716 1719 command->follows = 0; 1717 1720 command->value = 0; 1718 1721 command->buffer = NULL;
+1 -1
drivers/usb/misc/lvstest.c
··· 437 437 INIT_WORK(&lvs->rh_work, lvs_rh_work); 438 438 439 439 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); 440 - maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); 440 + maxp = usb_maxpacket(hdev, pipe); 441 441 usb_fill_int_urb(lvs->urb, hdev, pipe, &lvs->buffer[0], maxp, 442 442 lvs_rh_irq, lvs, endpoint->bInterval); 443 443
+1 -1
drivers/usb/storage/onetouch.c
··· 180 180 return -ENODEV; 181 181 182 182 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 183 - maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 183 + maxp = usb_maxpacket(udev, pipe); 184 184 maxp = min(maxp, ONETOUCH_PKT_LEN); 185 185 186 186 onetouch = kzalloc(sizeof(struct usb_onetouch), GFP_KERNEL);
+1 -1
drivers/usb/storage/transport.c
··· 363 363 usb_stor_dbg(us, "xfer %u bytes\n", length); 364 364 365 365 /* calculate the max packet size */ 366 - maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe)); 366 + maxp = usb_maxpacket(us->pusb_dev, pipe); 367 367 if (maxp > length) 368 368 maxp = length; 369 369