summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Gromm <christian.gromm@microchip.com>2018-08-13 15:02:29 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-08-27 19:51:49 +0200
commit4ad866231e4c73af02c89c337c2b655793088bb8 (patch)
treec547f86f12547e9c5c3c88e94b84623520383a45
parentf0b4a22a48481824e124f633bbe5d3e884fc8e36 (diff)
staging: most: do not make interface dependent attrs default for all channels
The channel attribute dbr_size is only relevant for the DIM2 interface. so is the packets_per_xact for USB. This patch cleans up the driver's ABI by not showing all attributes by default for each channel, but only on those they belong to. Signed-off-by: Christian Gromm <christian.gromm@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/most/core.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index b59e4711b62f..dabe180ae432 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -442,6 +442,24 @@ static ssize_t set_dbr_size_store(struct device *dev,
return count;
}
+#define to_dev_attr(a) container_of(a, struct device_attribute, attr)
+static umode_t channel_attr_is_visible(struct kobject *kobj,
+ struct attribute *attr, int index)
+{
+ struct device_attribute *dev_attr = to_dev_attr(attr);
+ struct device *dev = kobj_to_dev(kobj);
+ struct most_channel *c = to_channel(dev);
+
+ if (!strcmp(dev_attr->attr.name, "set_dbr_size") &&
+ (c->iface->interface != ITYPE_MEDIALB_DIM2))
+ return 0;
+ if (!strcmp(dev_attr->attr.name, "set_packets_per_xact") &&
+ (c->iface->interface != ITYPE_USB))
+ return 0;
+
+ return attr->mode;
+}
+
#define DEV_ATTR(_name) (&dev_attr_##_name.attr)
static DEVICE_ATTR_RO(available_directions);
@@ -479,6 +497,7 @@ static struct attribute *channel_attrs[] = {
static struct attribute_group channel_attr_group = {
.attrs = channel_attrs,
+ .is_visible = channel_attr_is_visible,
};
static const struct attribute_group *channel_attr_groups[] = {