[PATCH v3 06/13] usb: hub: Pass |struct usb_port*| to usb_port_is_power_on()
From: Chen-Yu Tsai <wenst@chromium.org>
Date: 2026-07-03 11:04:05
Also in:
driver-core, linux-acpi, linux-devicetree, linux-mediatek, linux-pm, linux-usb, lkml
Subsystem:
the rest, usb subsystem · Maintainers:
Linus Torvalds, Greg Kroah-Hartman
usb_port_is_power_on() currently takes |struct usb_hub*|, but only needs
it to tell if the hub/port is SuperSpeed or not.
In a subsequent change, usb_port_is_power_on() needs access to a pwrseq
state tracking field in |struct usb_port|. Either structure can be used
to identify whether a port/hub is SuperSpeed or not, as the field in
|struct usb_port| is inherited from the hub:
port->is_superspeed = hub_is_superspeed(hub)
Replace usb_port_is_power_on()'s |struct usb_hub*| parameter with
|struct usb_port*| so a subsequent change can use it.
Reviewed-by: Bartosz Golaszewski <redacted>
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---
drivers/usb/core/hub.c | 11 ++++++-----
drivers/usb/core/hub.h | 2 +-
drivers/usb/core/port.c | 2 +-
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index fe10d72ef39d..da0a4cc8e15a 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c@@ -3240,11 +3240,11 @@ static bool hub_port_stop_enumerate(struct usb_hub *hub, int port1, int retries) } /* Check if a port is power on */ -int usb_port_is_power_on(struct usb_hub *hub, unsigned int portstatus) +int usb_port_is_power_on(struct usb_port *port, unsigned int portstatus) { int ret = 0; - if (hub_is_superspeed(hub->hdev)) { + if (port->is_superspeed) { if (portstatus & USB_SS_PORT_STAT_POWER) ret = 1; } else {
@@ -3306,7 +3306,7 @@ static int check_port_resume_type(struct usb_device *udev, } /* Is the device still present? */ else if (status || port_is_suspended(hub, portstatus) || - !usb_port_is_power_on(hub, portstatus)) { + !usb_port_is_power_on(port_dev, portstatus)) { if (status >= 0) status = -ENODEV; } else if (!(portstatus & USB_PORT_STAT_CONNECTION)) {
@@ -3748,12 +3748,13 @@ static int wait_for_connected(struct usb_device *udev, struct usb_hub *hub, int port1, u16 *portchange, u16 *portstatus) { + struct usb_port *port_dev = hub->ports[port1 - 1]; int status = 0, delay_ms = 0; while (delay_ms < 2000) { if (status || *portstatus & USB_PORT_STAT_CONNECTION) break; - if (!usb_port_is_power_on(hub, *portstatus)) { + if (!usb_port_is_power_on(port_dev, *portstatus)) { status = -ENODEV; break; }
@@ -5449,7 +5450,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, * but only if the port isn't owned by someone else. */ if (hub_is_port_power_switchable(hub) - && !usb_port_is_power_on(hub, portstatus) + && !usb_port_is_power_on(port_dev, portstatus) && !port_dev->port_owner) set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 9ebc5ef54a32..b65d9192379d 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h@@ -138,7 +138,7 @@ extern int usb_clear_port_feature(struct usb_device *hdev, int port1, int feature); extern int usb_hub_port_status(struct usb_hub *hub, int port1, u16 *status, u16 *change); -extern int usb_port_is_power_on(struct usb_hub *hub, unsigned int portstatus); +extern int usb_port_is_power_on(struct usb_port *port, unsigned int portstatus); static inline bool hub_is_port_power_switchable(struct usb_hub *hub) {
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 1088776ef750..77dbf51f1760 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c@@ -98,7 +98,7 @@ static ssize_t disable_show(struct device *dev, } usb_hub_port_status(hub, port1, &portstatus, &unused); - disabled = !usb_port_is_power_on(hub, portstatus); + disabled = !usb_port_is_power_on(port_dev, portstatus); out_hdev_lock: usb_unlock_device(hdev);
--
2.55.0.rc0.799.gd6f94ed593-goog