aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/most/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/most/core.c')
-rw-r--r--drivers/staging/most/core.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index f4c464625a67..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[] = {
@@ -1439,10 +1458,6 @@ int most_register_interface(struct most_interface *iface)
c->dev.parent = &iface->dev;
c->dev.groups = channel_attr_groups;
c->dev.release = release_channel;
- if (device_register(&c->dev)) {
- pr_err("registering c->dev failed\n");
- goto free_instance_nodev;
- }
iface->p->channel[i] = c;
c->is_starving = 0;
c->iface = iface;
@@ -1465,6 +1480,10 @@ int most_register_interface(struct most_interface *iface)
mutex_init(&c->start_mutex);
mutex_init(&c->nq_mutex);
list_add_tail(&c->list, &iface->p->channel_list);
+ if (device_register(&c->dev)) {
+ pr_err("registering c->dev failed\n");
+ goto free_instance_nodev;
+ }
}
pr_info("registered new device mdev%d (%s)\n",
id, iface->description);