aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/usb/typec
diff options
context:
space:
mode:
authorMario Limonciello <mario.limonciello@amd.com>2025-02-20 23:40:04 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-03-03 10:24:24 +0100
commit403849c8edc1551d1a489b1b942f68d75758e98a (patch)
tree2f579b8cd7b256c32938e09efef1d0ddfac75fd8 /drivers/usb/typec
parentucsi_ccg: Don't show failed to get FW build information error (diff)
downloadwireguard-linux-403849c8edc1551d1a489b1b942f68d75758e98a.tar.xz
wireguard-linux-403849c8edc1551d1a489b1b942f68d75758e98a.zip
ucsi_ccg: Don't show non-functional attributes
If no fw_build is recognized for the controller there is no point to exposing the `do_flash` attribute. Add an is_visible callback to the attribute group and check for that fw_build member to hide when not applicable. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20250221054137.1631765-3-superm1@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/typec')
-rw-r--r--drivers/usb/typec/ucsi/ucsi_ccg.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
index 3c4dcc3fa7cf..802b1d73ca12 100644
--- a/drivers/usb/typec/ucsi/ucsi_ccg.c
+++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
@@ -1387,22 +1387,35 @@ static ssize_t do_flash_store(struct device *dev,
if (!flash)
return n;
- if (uc->fw_build == 0x0) {
- dev_err(dev, "fail to flash FW due to missing FW build info\n");
- return -EINVAL;
- }
-
schedule_work(&uc->work);
return n;
}
+static umode_t ucsi_ccg_attrs_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
+{
+ struct device *dev = kobj_to_dev(kobj);
+ struct ucsi_ccg *uc = i2c_get_clientdata(to_i2c_client(dev));
+
+ if (!uc->fw_build)
+ return 0;
+
+ return attr->mode;
+}
+
static DEVICE_ATTR_WO(do_flash);
static struct attribute *ucsi_ccg_attrs[] = {
&dev_attr_do_flash.attr,
NULL,
};
-ATTRIBUTE_GROUPS(ucsi_ccg);
+static struct attribute_group ucsi_ccg_attr_group = {
+ .attrs = ucsi_ccg_attrs,
+ .is_visible = ucsi_ccg_attrs_is_visible,
+};
+static const struct attribute_group *ucsi_ccg_groups[] = {
+ &ucsi_ccg_attr_group,
+ NULL,
+};
static int ucsi_ccg_probe(struct i2c_client *client)
{