mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: shayderrr <darknessshayder@gmail.com>
To: andreas.noever@gmail.com, mika.westerberg@linux.intel.com,
	yehezkel.bernat@gmail.com
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Pranav Bajjuri <darknessshayder@gmail.com>
Subject: [PATCH] thunderbolt: usb4-port: fix error path and sysfs alignment
Date: Sun, 17 May 2026 09:29:23 -0500	[thread overview]
Message-ID: <20260517142923.80585-1-darknessshayder@gmail.com> (raw)

From: Pranav Bajjuri <darknessshayder@gmail.com>

Add missing return ERR_PTR(ret) after component_add() failure so PM
setup is not reached on error, and fix argument alignment on
offline_show(), offline_store(), and rescan_store().

Signed-off-by: Pranav Bajjuri <darknessshayder@gmail.com>
---
 drivers/thunderbolt/usb4_port.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/thunderbolt/usb4_port.c b/drivers/thunderbolt/usb4_port.c
index c32d3516e780..2282e1ad0c45 100644
--- a/drivers/thunderbolt/usb4_port.c
+++ b/drivers/thunderbolt/usb4_port.c
@@ -34,8 +34,8 @@ static void connector_unbind(struct device *dev, struct device *connector, void
 }
 
 static const struct component_ops connector_ops = {
-	.bind = connector_bind,
-	.unbind = connector_unbind,
+	.bind	= connector_bind,
+	.unbind	= connector_unbind,
 };
 
 static ssize_t link_show(struct device *dev, struct device_attribute *attr,
@@ -137,7 +137,6 @@ bool usb4_usb3_port_match(struct device *usb4_port_dev,
 	if (IS_ERR(nhi_fwnode))
 		return false;
 
-	/* Check if USB3 fwnode references same NHI where USB4 port resides */
 	if (!device_match_fwnode(&nhi->pdev->dev, nhi_fwnode))
 		return false;
 
@@ -179,7 +178,6 @@ static ssize_t offline_store(struct device *dev,
 	if (val == usb4->offline)
 		goto out_unlock;
 
-	/* Offline mode works only for ports that are not connected */
 	if (tb_port_has_remote(port)) {
 		ret = -EBUSY;
 		goto out_unlock;
@@ -230,7 +228,6 @@ static ssize_t rescan_store(struct device *dev,
 		goto out_rpm;
 	}
 
-	/* Must be in offline mode already */
 	if (!usb4->offline) {
 		ret = -EINVAL;
 		goto out_unlock;
@@ -261,16 +258,12 @@ static umode_t service_attr_is_visible(struct kobject *kobj,
 	struct device *dev = kobj_to_dev(kobj);
 	struct usb4_port *usb4 = tb_to_usb4_port_device(dev);
 
-	/*
-	 * Always need some platform help to cycle the modes so that
-	 * retimers can be accessed through the sideband.
-	 */
 	return usb4->can_offline ? attr->mode : 0;
 }
 
 static const struct attribute_group service_group = {
-	.attrs = service_attrs,
-	.is_visible = service_attr_is_visible,
+	.attrs		= service_attrs,
+	.is_visible	= service_attr_is_visible,
 };
 
 static const struct attribute_group *usb4_port_device_groups[] = {
@@ -282,14 +275,13 @@ static const struct attribute_group *usb4_port_device_groups[] = {
 static void usb4_port_device_release(struct device *dev)
 {
 	struct usb4_port *usb4 = container_of(dev, struct usb4_port, dev);
-
 	kfree(usb4);
 }
 
 const struct device_type usb4_port_device_type = {
-	.name = "usb4_port",
-	.groups = usb4_port_device_groups,
-	.release = usb4_port_device_release,
+	.name		= "usb4_port",
+	.groups		= usb4_port_device_groups,
+	.release	= usb4_port_device_release,
 };
 
 /**
@@ -324,6 +316,7 @@ struct usb4_port *usb4_port_device_add(struct tb_port *port)
 	if (ret) {
 		dev_err(&usb4->dev, "failed to add component\n");
 		device_unregister(&usb4->dev);
+		return ERR_PTR(ret);
 	}
 
 	if (!tb_is_upstream_port(port))
-- 
2.50.1 (Apple Git-155)


             reply	other threads:[~2026-05-17 14:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-17 14:29 shayderrr [this message]
2026-05-18  4:55 ` Mika Westerberg

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=20260517142923.80585-1-darknessshayder@gmail.com \
    --to=darknessshayder@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=yehezkel.bernat@gmail.com \
    /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

all inboxes | Powered by JetHome®