提交 6d75db30 编写于 作者: S Sean Young 提交者: Mauro Carvalho Chehab

[media] media: rc: if protocols can't be changed, don't be writable

If the protocols of an rc device cannot be changed, ensure the sysfs
file is not writable.

This makes it possible to detect this from userspace, so ir-keytable
can deal with case without giving an error.
Signed-off-by: NSean Young <sean@mess.org>
Signed-off-by: NMauro Carvalho Chehab <mchehab@osg.samsung.com>
上级 3c03726a
...@@ -1487,7 +1487,10 @@ static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env) ...@@ -1487,7 +1487,10 @@ static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env)
/* /*
* Static device attribute struct with the sysfs attributes for IR's * Static device attribute struct with the sysfs attributes for IR's
*/ */
static DEVICE_ATTR(protocols, 0644, show_protocols, store_protocols); static struct device_attribute dev_attr_ro_protocols =
__ATTR(protocols, 0444, show_protocols, NULL);
static struct device_attribute dev_attr_rw_protocols =
__ATTR(protocols, 0644, show_protocols, store_protocols);
static DEVICE_ATTR(wakeup_protocols, 0644, show_wakeup_protocols, static DEVICE_ATTR(wakeup_protocols, 0644, show_wakeup_protocols,
store_wakeup_protocols); store_wakeup_protocols);
static RC_FILTER_ATTR(filter, S_IRUGO|S_IWUSR, static RC_FILTER_ATTR(filter, S_IRUGO|S_IWUSR,
...@@ -1499,13 +1502,22 @@ static RC_FILTER_ATTR(wakeup_filter, S_IRUGO|S_IWUSR, ...@@ -1499,13 +1502,22 @@ static RC_FILTER_ATTR(wakeup_filter, S_IRUGO|S_IWUSR,
static RC_FILTER_ATTR(wakeup_filter_mask, S_IRUGO|S_IWUSR, static RC_FILTER_ATTR(wakeup_filter_mask, S_IRUGO|S_IWUSR,
show_filter, store_filter, RC_FILTER_WAKEUP, true); show_filter, store_filter, RC_FILTER_WAKEUP, true);
static struct attribute *rc_dev_protocol_attrs[] = { static struct attribute *rc_dev_rw_protocol_attrs[] = {
&dev_attr_protocols.attr, &dev_attr_rw_protocols.attr,
NULL, NULL,
}; };
static const struct attribute_group rc_dev_protocol_attr_grp = { static const struct attribute_group rc_dev_rw_protocol_attr_grp = {
.attrs = rc_dev_protocol_attrs, .attrs = rc_dev_rw_protocol_attrs,
};
static struct attribute *rc_dev_ro_protocol_attrs[] = {
&dev_attr_ro_protocols.attr,
NULL,
};
static const struct attribute_group rc_dev_ro_protocol_attr_grp = {
.attrs = rc_dev_ro_protocol_attrs,
}; };
static struct attribute *rc_dev_filter_attrs[] = { static struct attribute *rc_dev_filter_attrs[] = {
...@@ -1732,8 +1744,10 @@ int rc_register_device(struct rc_dev *dev) ...@@ -1732,8 +1744,10 @@ int rc_register_device(struct rc_dev *dev)
dev_set_drvdata(&dev->dev, dev); dev_set_drvdata(&dev->dev, dev);
dev->dev.groups = dev->sysfs_groups; dev->dev.groups = dev->sysfs_groups;
if (dev->driver_type != RC_DRIVER_IR_RAW_TX) if (dev->driver_type == RC_DRIVER_SCANCODE && !dev->change_protocol)
dev->sysfs_groups[attr++] = &rc_dev_protocol_attr_grp; dev->sysfs_groups[attr++] = &rc_dev_ro_protocol_attr_grp;
else if (dev->driver_type != RC_DRIVER_IR_RAW_TX)
dev->sysfs_groups[attr++] = &rc_dev_rw_protocol_attr_grp;
if (dev->s_filter) if (dev->s_filter)
dev->sysfs_groups[attr++] = &rc_dev_filter_attr_grp; dev->sysfs_groups[attr++] = &rc_dev_filter_attr_grp;
if (dev->s_wakeup_filter) if (dev->s_wakeup_filter)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册