summaryrefslogtreecommitdiff
path: root/drivers/soundwire/sysfs_slave.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/soundwire/sysfs_slave.c')
-rw-r--r--drivers/soundwire/sysfs_slave.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/drivers/soundwire/sysfs_slave.c b/drivers/soundwire/sysfs_slave.c
index 3210359cd944..f4259710dd0f 100644
--- a/drivers/soundwire/sysfs_slave.c
+++ b/drivers/soundwire/sysfs_slave.c
@@ -105,7 +105,10 @@ static struct attribute *slave_attrs[] = {
&dev_attr_modalias.attr,
NULL,
};
-ATTRIBUTE_GROUPS(slave);
+
+static const struct attribute_group slave_attr_group = {
+ .attrs = slave_attrs,
+};
static struct attribute *slave_dev_attrs[] = {
&dev_attr_mipi_revision.attr,
@@ -126,10 +129,6 @@ static struct attribute *slave_dev_attrs[] = {
NULL,
};
-/*
- * we don't use ATTRIBUTES_GROUP here since we want to add a subdirectory
- * for device-level properties
- */
static const struct attribute_group sdw_slave_dev_attr_group = {
.attrs = slave_dev_attrs,
.name = "dev-properties",
@@ -181,41 +180,38 @@ static struct attribute *dp0_attrs[] = {
NULL,
};
-/*
- * we don't use ATTRIBUTES_GROUP here since we want to add a subdirectory
- * for dp0-level properties
- */
-static const struct attribute_group dp0_group = {
- .attrs = dp0_attrs,
- .name = "dp0",
-};
-
-int sdw_slave_sysfs_init(struct sdw_slave *slave)
+static umode_t dp0_attr_visible(struct kobject *kobj, struct attribute *attr,
+ int n)
{
- int ret;
+ struct sdw_slave *slave = dev_to_sdw_dev(kobj_to_dev(kobj));
- ret = devm_device_add_groups(&slave->dev, slave_groups);
- if (ret < 0)
- return ret;
+ if (slave->prop.dp0_prop)
+ return attr->mode;
+ return 0;
+}
- ret = devm_device_add_group(&slave->dev, &sdw_slave_dev_attr_group);
- if (ret < 0)
- return ret;
+static bool dp0_group_visible(struct kobject *kobj)
+{
+ struct sdw_slave *slave = dev_to_sdw_dev(kobj_to_dev(kobj));
- if (slave->prop.dp0_prop) {
- ret = devm_device_add_group(&slave->dev, &dp0_group);
- if (ret < 0)
- return ret;
- }
+ if (slave->prop.dp0_prop)
+ return true;
+ return false;
+}
+DEFINE_SYSFS_GROUP_VISIBLE(dp0);
- if (slave->prop.source_ports || slave->prop.sink_ports) {
- ret = sdw_slave_sysfs_dpn_init(slave);
- if (ret < 0)
- return ret;
- }
+static const struct attribute_group dp0_group = {
+ .attrs = dp0_attrs,
+ .is_visible = SYSFS_GROUP_VISIBLE(dp0),
+ .name = "dp0",
+};
- return 0;
-}
+const struct attribute_group *sdw_attr_groups[] = {
+ &slave_attr_group,
+ &sdw_slave_dev_attr_group,
+ &dp0_group,
+ NULL,
+};
/*
* the status is shown in capital letters for UNATTACHED and RESERVED