linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thunderbolt: Don't display retimers unless nvm was initialized
@ 2024-12-06 18:33 Mario Limonciello
  2024-12-09  6:24 ` Mika Westerberg
  0 siblings, 1 reply; 6+ messages in thread
From: Mario Limonciello @ 2024-12-06 18:33 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: open list:THUNDERBOLT DRIVER, linux-kernel, Andreas Noever,
	Michael Jamet, Yehezkel Bernat, Mario Limonciello, Richard Hughes

From: Mario Limonciello <mario.limonciello@amd.com>

The read will never succeed if nvm wasn't initialized.

Reported-by: Richard Hughes <hughsient@gmail.com>
Closes: https://github.com/fwupd/fwupd/issues/8200
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/thunderbolt/retimer.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/thunderbolt/retimer.c b/drivers/thunderbolt/retimer.c
index 89d2919d0193e..7be435aee7217 100644
--- a/drivers/thunderbolt/retimer.c
+++ b/drivers/thunderbolt/retimer.c
@@ -321,9 +321,7 @@ static ssize_t nvm_version_show(struct device *dev,
 	if (!mutex_trylock(&rt->tb->lock))
 		return restart_syscall();
 
-	if (!rt->nvm)
-		ret = -EAGAIN;
-	else if (rt->no_nvm_upgrade)
+	if (rt->no_nvm_upgrade)
 		ret = -EOPNOTSUPP;
 	else
 		ret = sysfs_emit(buf, "%x.%x\n", rt->nvm->major, rt->nvm->minor);
@@ -342,6 +340,18 @@ static ssize_t vendor_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(vendor);
 
+static umode_t retimer_is_visible(struct kobject *kobj,
+				      struct attribute *attr, int n)
+{
+	struct device *dev = kobj_to_dev(kobj);
+	struct tb_retimer *rt = tb_to_retimer(dev);
+
+	if (!rt->nvm)
+		return 0;
+	return attr->mode;
+
+}
+
 static struct attribute *retimer_attrs[] = {
 	&dev_attr_device.attr,
 	&dev_attr_nvm_authenticate.attr,
@@ -351,6 +361,7 @@ static struct attribute *retimer_attrs[] = {
 };
 
 static const struct attribute_group retimer_group = {
+	.is_visible = retimer_is_visible,
 	.attrs = retimer_attrs,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-12-09 15:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-06 18:33 [PATCH] thunderbolt: Don't display retimers unless nvm was initialized Mario Limonciello
2024-12-09  6:24 ` Mika Westerberg
2024-12-09 14:15   ` Mario Limonciello
2024-12-09 15:40     ` Mika Westerberg
2024-12-09 15:44       ` Mario Limonciello
2024-12-09 15:47         ` Mika Westerberg

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).