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

Configure Feed

Select the types of activity you want to include in your feed.

usb: xhci: rename 'wIndex' parameters to 'portnum'

Several helper functions take a parameter named 'wIndex', but the
value they receive is not the raw USB request wIndex field. The only
function that actually processes the USB hub request parameter is
xhci_hub_control(), which extracts the relevant port number (and other
upper-byte fields) before passing them down.

To avoid confusion between the USB request parameter and the derived
0-based port index, rename all such function parameters from 'wIndex'
to 'portnum'. This improves readability and makes the call intentions
clearer.

When a function accept struct 'xhci_port' pointer, use its port number
instead.

Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20260402131342.2628648-15-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Niklas Neronin and committed by
Greg Kroah-Hartman
ec5521a7 1e6138c0

+27 -33
+27 -33
drivers/usb/host/xhci-hub.c
··· 577 577 hcd->self.busnum, port->hcd_portnum + 1, portsc); 578 578 } 579 579 580 - static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, 581 - u16 wIndex, struct xhci_port *port, u32 port_status) 580 + static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, struct xhci_port *port, 581 + u32 port_status) 582 582 { 583 583 char *port_change_bit; 584 584 u32 status; ··· 625 625 port_status = xhci_portsc_readl(port); 626 626 627 627 xhci_dbg(xhci, "clear port%d %s change, portsc: 0x%x\n", 628 - wIndex + 1, port_change_bit, port_status); 628 + port->hcd_portnum + 1, port_change_bit, port_status); 629 629 } 630 630 631 631 struct xhci_hub *xhci_get_rhub(struct usb_hcd *hcd) ··· 675 675 spin_lock_irqsave(&xhci->lock, *flags); 676 676 } 677 677 678 - static void xhci_port_set_test_mode(struct xhci_hcd *xhci, 679 - u16 test_mode, u16 wIndex) 678 + static void xhci_port_set_test_mode(struct xhci_hcd *xhci, u16 test_mode, int portnum) 680 679 { 681 680 u32 temp; 682 681 struct xhci_port *port; 683 682 684 683 /* xhci only supports test mode for usb2 ports */ 685 - port = xhci->usb2_rhub.ports[wIndex]; 684 + port = xhci->usb2_rhub.ports[portnum]; 686 685 temp = readl(&port->port_reg->portpmsc); 687 686 temp |= test_mode << PORT_TEST_MODE_SHIFT; 688 687 writel(temp, &port->port_reg->portpmsc); ··· 690 691 xhci_start(xhci); 691 692 } 692 693 693 - static int xhci_enter_test_mode(struct xhci_hcd *xhci, 694 - u16 test_mode, u16 wIndex, unsigned long *flags) 694 + static int xhci_enter_test_mode(struct xhci_hcd *xhci, u16 test_mode, int portnum, 695 + unsigned long *flags) 695 696 __must_hold(&xhci->lock) 696 697 { 697 698 int i, retval; ··· 725 726 /* Disable runtime PM for test mode */ 726 727 pm_runtime_forbid(xhci_to_hcd(xhci)->self.controller); 727 728 /* Set PORTPMSC.PTC field to enter selected test mode */ 728 - /* Port is selected by wIndex. port_id = wIndex + 1 */ 729 - xhci_dbg(xhci, "Enter Test Mode: %d, Port_id=%d\n", 730 - test_mode, wIndex + 1); 731 - xhci_port_set_test_mode(xhci, test_mode, wIndex); 729 + xhci_dbg(xhci, "Enter Test Mode: %u, Port_id=%d\n", test_mode, portnum + 1); 730 + xhci_port_set_test_mode(xhci, test_mode, portnum); 732 731 return retval; 733 732 } 734 733 ··· 910 913 * the compliance mode timer is deleted. A port won't enter 911 914 * compliance mode if it has previously entered U0. 912 915 */ 913 - static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status, 914 - u16 wIndex) 916 + static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status, int portnum) 915 917 { 916 918 u32 all_ports_seen_u0 = ((1 << xhci->usb3_rhub.num_ports) - 1); 917 919 bool port_in_u0 = ((status & PORT_PLS_MASK) == XDEV_U0); ··· 919 923 return; 920 924 921 925 if ((xhci->port_status_u0 != all_ports_seen_u0) && port_in_u0) { 922 - xhci->port_status_u0 |= 1 << wIndex; 926 + xhci->port_status_u0 |= 1 << portnum; 923 927 if (xhci->port_status_u0 == all_ports_seen_u0) { 924 928 timer_delete_sync(&xhci->comp_mode_recovery_timer); 925 929 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, ··· 937 941 struct xhci_bus_state *bus_state; 938 942 struct xhci_hcd *xhci; 939 943 struct usb_hcd *hcd; 940 - u32 wIndex; 944 + int portnum; 941 945 942 946 hcd = port->rhub->hcd; 943 947 bus_state = &port->rhub->bus_state; 944 948 xhci = hcd_to_xhci(hcd); 945 - wIndex = port->hcd_portnum; 949 + portnum = port->hcd_portnum; 946 950 947 951 if ((portsc & PORT_RESET) || !(portsc & PORT_PE)) { 948 952 return -EINVAL; ··· 950 954 /* did port event handler already start resume timing? */ 951 955 if (!port->resume_timestamp) { 952 956 /* If not, maybe we are in a host initiated resume? */ 953 - if (test_bit(wIndex, &bus_state->resuming_ports)) { 957 + if (test_bit(portnum, &bus_state->resuming_ports)) { 954 958 /* Host initiated resume doesn't time the resume 955 959 * signalling using resume_done[]. 956 960 * It manually sets RESUME state, sleeps 20ms ··· 964 968 unsigned long timeout = jiffies + 965 969 msecs_to_jiffies(USB_RESUME_TIMEOUT); 966 970 967 - set_bit(wIndex, &bus_state->resuming_ports); 971 + set_bit(portnum, &bus_state->resuming_ports); 968 972 port->resume_timestamp = timeout; 969 973 mod_timer(&hcd->rh_timer, timeout); 970 - usb_hcd_start_port_resume(&hcd->self, wIndex); 974 + usb_hcd_start_port_resume(&hcd->self, portnum); 971 975 } 972 976 /* Has resume been signalled for USB_RESUME_TIME yet? */ 973 977 } else if (time_after_eq(jiffies, port->resume_timestamp)) { 974 978 int time_left; 975 979 976 980 xhci_dbg(xhci, "resume USB2 port %d-%d\n", 977 - hcd->self.busnum, wIndex + 1); 981 + hcd->self.busnum, portnum + 1); 978 982 979 983 port->resume_timestamp = 0; 980 - clear_bit(wIndex, &bus_state->resuming_ports); 984 + clear_bit(portnum, &bus_state->resuming_ports); 981 985 982 986 reinit_completion(&port->rexit_done); 983 987 port->rexit_active = true; ··· 1001 1005 int port_status = xhci_portsc_readl(port); 1002 1006 1003 1007 xhci_warn(xhci, "Port resume timed out, port %d-%d: 0x%x\n", 1004 - hcd->self.busnum, wIndex + 1, port_status); 1008 + hcd->self.busnum, portnum + 1, port_status); 1005 1009 /* 1006 1010 * keep rexit_active set if U0 transition failed so we 1007 1011 * know to report PORT_STAT_SUSPEND status back to ··· 1010 1014 */ 1011 1015 } 1012 1016 1013 - usb_hcd_end_port_resume(&hcd->self, wIndex); 1014 - bus_state->port_c_suspend |= 1 << wIndex; 1015 - bus_state->suspended_ports &= ~(1 << wIndex); 1017 + usb_hcd_end_port_resume(&hcd->self, portnum); 1018 + bus_state->port_c_suspend |= 1 << portnum; 1019 + bus_state->suspended_ports &= ~(1 << portnum); 1016 1020 } 1017 1021 1018 1022 return 0; ··· 1149 1153 * - Stop the Synopsys redriver Compliance Mode polling. 1150 1154 * - Drop and reacquire the xHCI lock, in order to wait for port resume. 1151 1155 */ 1152 - static u32 xhci_get_port_status(struct usb_hcd *hcd, 1153 - struct xhci_bus_state *bus_state, 1154 - u16 wIndex, u32 raw_port_status, 1155 - unsigned long *flags) 1156 + static u32 xhci_get_port_status(struct usb_hcd *hcd, struct xhci_bus_state *bus_state, 1157 + int portnum, u32 raw_port_status, unsigned long *flags) 1156 1158 __releases(&xhci->lock) 1157 1159 __acquires(&xhci->lock) 1158 1160 { ··· 1159 1165 struct xhci_port *port; 1160 1166 1161 1167 rhub = xhci_get_rhub(hcd); 1162 - port = rhub->ports[wIndex]; 1168 + port = rhub->ports[portnum]; 1163 1169 1164 1170 /* common wPortChange bits */ 1165 1171 if (raw_port_status & PORT_CSC) ··· 1190 1196 xhci_get_usb2_port_status(port, &status, raw_port_status, 1191 1197 flags); 1192 1198 1193 - if (bus_state->port_c_suspend & (1 << wIndex)) 1199 + if (bus_state->port_c_suspend & (1 << portnum)) 1194 1200 status |= USB_PORT_STAT_C_SUSPEND << 16; 1195 1201 1196 1202 return status; ··· 1592 1598 case USB_PORT_FEAT_C_ENABLE: 1593 1599 case USB_PORT_FEAT_C_PORT_LINK_STATE: 1594 1600 case USB_PORT_FEAT_C_PORT_CONFIG_ERROR: 1595 - xhci_clear_port_change_bit(xhci, wValue, portnum, port, temp); 1601 + xhci_clear_port_change_bit(xhci, wValue, port, temp); 1596 1602 break; 1597 1603 case USB_PORT_FEAT_ENABLE: 1598 1604 xhci_disable_port(xhci, port);