From: Marco Felsch <m.felsch@pengutronix.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Fabio Estevam <festevam@gmail.com>,
Matthias Kaehlcke <mka@chromium.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, kernel@pengutronix.de,
Marco Felsch <m.felsch@pengutronix.de>
Subject: [PATCH v3 1/4] usb: port: track the disabled state
Date: Thu, 21 Aug 2025 18:31:55 +0200 [thread overview]
Message-ID: <20250821-v6-16-topic-usb-onboard-dev-v3-1-6d2b38a5d818@pengutronix.de> (raw)
In-Reply-To: <20250821-v6-16-topic-usb-onboard-dev-v3-0-6d2b38a5d818@pengutronix.de>
The disable state isn't tracked at the moment, instead the state is
directly passed to the hub driver. Change this behavior to only trigger
the hub if a state change happened. Exit early in case of no state
changes but don't return an error.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
drivers/usb/core/hub.h | 2 ++
drivers/usb/core/port.c | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 9ebc5ef54a325d63e01b0deb59a1853d2b13c8d5..297adf2c6078809ca582104f228e5222c464f999 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -97,6 +97,7 @@ struct usb_hub {
* @usb3_lpm_u2_permit: whether USB3 U2 LPM is permitted.
* @early_stop: whether port initialization will be stopped earlier.
* @ignore_event: whether events of the port are ignored.
+ * @disabled: whether the port is disabled
*/
struct usb_port {
struct usb_device *child;
@@ -118,6 +119,7 @@ struct usb_port {
unsigned int is_superspeed:1;
unsigned int usb3_lpm_u1_permit:1;
unsigned int usb3_lpm_u2_permit:1;
+ unsigned int disabled:1;
};
#define to_usb_port(_dev) \
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index f54198171b6a3fb49c5f74f4a8a303b422d099eb..cae08a9a71e65c42fb9a8f5369060bd82b8daebb 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -117,6 +117,10 @@ static ssize_t disable_store(struct device *dev, struct device_attribute *attr,
if (rc)
return rc;
+ /* Early quit if no change was detected */
+ if (port_dev->disabled == disabled)
+ return count;
+
hub_get(hub);
rc = usb_autopm_get_interface(intf);
if (rc < 0)
@@ -148,6 +152,8 @@ static ssize_t disable_store(struct device *dev, struct device_attribute *attr,
usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_ENABLE);
}
+ port_dev->disabled = disabled;
+
if (!rc)
rc = count;
--
2.39.5
next prev parent reply other threads:[~2025-08-21 16:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 16:31 [PATCH v3 0/4] Add ext. port vbus handling for onboard-dev Marco Felsch
2025-08-21 16:31 ` Marco Felsch [this message]
2025-08-21 16:31 ` [PATCH v3 2/4] usb: hub: add infrastructure to pass onboard_dev port features Marco Felsch
2025-08-21 16:31 ` [PATCH v3 3/4] dt-bindings: usb: microchip,usb2514: add support for port vbus-supply Marco Felsch
2025-08-22 8:23 ` Krzysztof Kozlowski
2025-08-22 10:30 ` Marco Felsch
2025-08-22 20:05 ` Rob Herring
2025-09-03 22:57 ` Marco Felsch
2025-08-24 9:03 ` Krzysztof Kozlowski
2025-09-03 23:10 ` Marco Felsch
2025-08-21 16:31 ` [PATCH v3 4/4] usb: misc: onboard_dev: add ext-vbus-supply handling Marco Felsch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250821-v6-16-topic-usb-onboard-dev-v3-1-6d2b38a5d818@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mka@chromium.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).