diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-06-28 11:58:48 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-08-02 13:54:56 -0400 |
commit | 5f1247972e0fcce6dd4bce94459a9f3db09ae61d (patch) | |
tree | 8f9e2d7b1c617d9699614c1af7db5b23d3480eef /drivers/media/IR | |
parent | a9e55ea9774cc87434b386a7fba63d96af32792d (diff) |
V4L/DVB: ir-core: Add support for disabling all protocols
Writing "none" to /dev/class/rc/rc*/protocols will disable all protocols.
This allows an easier setup, from userspace, as userspace applications don't
need to disable protocol per protocol, before enabling a different set of
protocols.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/IR')
-rw-r--r-- | drivers/media/IR/ir-sysfs.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c index c0c4dc250599..e84f9783b8c2 100644 --- a/drivers/media/IR/ir-sysfs.c +++ b/drivers/media/IR/ir-sysfs.c | |||
@@ -45,6 +45,8 @@ static struct { | |||
45 | { IR_TYPE_SONY, "sony" }, | 45 | { IR_TYPE_SONY, "sony" }, |
46 | }; | 46 | }; |
47 | 47 | ||
48 | #define PROTO_NONE "none" | ||
49 | |||
48 | /** | 50 | /** |
49 | * show_protocols() - shows the current IR protocol(s) | 51 | * show_protocols() - shows the current IR protocol(s) |
50 | * @d: the device descriptor | 52 | * @d: the device descriptor |
@@ -101,6 +103,7 @@ static ssize_t show_protocols(struct device *d, | |||
101 | * Writing "+proto" will add a protocol to the list of enabled protocols. | 103 | * Writing "+proto" will add a protocol to the list of enabled protocols. |
102 | * Writing "-proto" will remove a protocol from the list of enabled protocols. | 104 | * Writing "-proto" will remove a protocol from the list of enabled protocols. |
103 | * Writing "proto" will enable only "proto". | 105 | * Writing "proto" will enable only "proto". |
106 | * Writing "none" will disable all protocols. | ||
104 | * Returns -EINVAL if an invalid protocol combination or unknown protocol name | 107 | * Returns -EINVAL if an invalid protocol combination or unknown protocol name |
105 | * is used, otherwise @len. | 108 | * is used, otherwise @len. |
106 | */ | 109 | */ |
@@ -134,16 +137,22 @@ static ssize_t store_protocols(struct device *d, | |||
134 | disable = false; | 137 | disable = false; |
135 | } | 138 | } |
136 | 139 | ||
137 | for (i = 0; i < ARRAY_SIZE(proto_names); i++) { | 140 | |
138 | if (!strncasecmp(tmp, proto_names[i].name, strlen(proto_names[i].name))) { | 141 | if (!enable && !disable && !strncasecmp(tmp, PROTO_NONE, sizeof(PROTO_NONE))) { |
139 | tmp += strlen(proto_names[i].name); | 142 | mask = 0; |
140 | mask = proto_names[i].type; | 143 | tmp += sizeof(PROTO_NONE); |
141 | break; | 144 | } else { |
145 | for (i = 0; i < ARRAY_SIZE(proto_names); i++) { | ||
146 | if (!strncasecmp(tmp, proto_names[i].name, strlen(proto_names[i].name))) { | ||
147 | tmp += strlen(proto_names[i].name); | ||
148 | mask = proto_names[i].type; | ||
149 | break; | ||
150 | } | ||
151 | } | ||
152 | if (i == ARRAY_SIZE(proto_names)) { | ||
153 | IR_dprintk(1, "Unknown protocol\n"); | ||
154 | return -EINVAL; | ||
142 | } | 155 | } |
143 | } | ||
144 | if (i == ARRAY_SIZE(proto_names)) { | ||
145 | IR_dprintk(1, "Unknown protocol\n"); | ||
146 | return -EINVAL; | ||
147 | } | 156 | } |
148 | 157 | ||
149 | tmp = skip_spaces(tmp); | 158 | tmp = skip_spaces(tmp); |