Skip to content

Commit e34f171

Browse files
superm1westeri
authored andcommitted
thunderbolt: Don't display nvm_version unless upgrade supported
The read will never succeed if NVM wasn't initialized due to an unknown format. Add a new callback for visibility to only show when supported. Cc: [email protected] Fixes: aef9c69 ("thunderbolt: Move vendor specific NVM handling into nvm.c") Reported-by: Richard Hughes <[email protected]> Closes: fwupd/fwupd#8200 Signed-off-by: Mario Limonciello <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
1 parent 8644b48 commit e34f171

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

drivers/thunderbolt/retimer.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static int tb_retimer_nvm_add(struct tb_retimer *rt)
103103

104104
err_nvm:
105105
dev_dbg(&rt->dev, "NVM upgrade disabled\n");
106+
rt->no_nvm_upgrade = true;
106107
if (!IS_ERR(nvm))
107108
tb_nvm_free(nvm);
108109

@@ -182,8 +183,6 @@ static ssize_t nvm_authenticate_show(struct device *dev,
182183

183184
if (!rt->nvm)
184185
ret = -EAGAIN;
185-
else if (rt->no_nvm_upgrade)
186-
ret = -EOPNOTSUPP;
187186
else
188187
ret = sysfs_emit(buf, "%#x\n", rt->auth_status);
189188

@@ -323,8 +322,6 @@ static ssize_t nvm_version_show(struct device *dev,
323322

324323
if (!rt->nvm)
325324
ret = -EAGAIN;
326-
else if (rt->no_nvm_upgrade)
327-
ret = -EOPNOTSUPP;
328325
else
329326
ret = sysfs_emit(buf, "%x.%x\n", rt->nvm->major, rt->nvm->minor);
330327

@@ -342,6 +339,19 @@ static ssize_t vendor_show(struct device *dev, struct device_attribute *attr,
342339
}
343340
static DEVICE_ATTR_RO(vendor);
344341

342+
static umode_t retimer_is_visible(struct kobject *kobj, struct attribute *attr,
343+
int n)
344+
{
345+
struct device *dev = kobj_to_dev(kobj);
346+
struct tb_retimer *rt = tb_to_retimer(dev);
347+
348+
if (attr == &dev_attr_nvm_authenticate.attr ||
349+
attr == &dev_attr_nvm_version.attr)
350+
return rt->no_nvm_upgrade ? 0 : attr->mode;
351+
352+
return attr->mode;
353+
}
354+
345355
static struct attribute *retimer_attrs[] = {
346356
&dev_attr_device.attr,
347357
&dev_attr_nvm_authenticate.attr,
@@ -351,6 +361,7 @@ static struct attribute *retimer_attrs[] = {
351361
};
352362

353363
static const struct attribute_group retimer_group = {
364+
.is_visible = retimer_is_visible,
354365
.attrs = retimer_attrs,
355366
};
356367

0 commit comments

Comments
 (0)