From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: unlisted-recipients:; (no To-header on input)@bombadil.infradead.org
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: [PATCH 3/4] ir-core: Add support for disabling all protocols
Date: Mon, 28 Jun 2010 13:59:58 -0300 [thread overview]
Message-ID: <20100628135958.3b36a6bf@pedra> (raw)
In-Reply-To: <cover.1277744236.git.mchehab@redhat.com>
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>
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index 9a464a3..db8c7f4 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -45,6 +45,8 @@ static struct {
{ IR_TYPE_SONY, "sony" },
};
+#define PROTO_NONE "none"
+
/**
* show_protocols() - shows the current IR protocol(s)
* @d: the device descriptor
@@ -101,6 +103,7 @@ static ssize_t show_protocols(struct device *d,
* Writing "+proto" will add a protocol to the list of enabled protocols.
* Writing "-proto" will remove a protocol from the list of enabled protocols.
* Writing "proto" will enable only "proto".
+ * Writing "none" will disable all protocols.
* Returns -EINVAL if an invalid protocol combination or unknown protocol name
* is used, otherwise @len.
*/
@@ -134,16 +137,22 @@ static ssize_t store_protocols(struct device *d,
disable = false;
}
- for (i = 0; i < ARRAY_SIZE(proto_names); i++) {
- if (!strncasecmp(tmp, proto_names[i].name, strlen(proto_names[i].name))) {
- tmp += strlen(proto_names[i].name);
- mask = proto_names[i].type;
- break;
+
+ if (!enable && !disable && !strncasecmp(tmp, PROTO_NONE, sizeof(PROTO_NONE))) {
+ mask = 0;
+ tmp += sizeof(PROTO_NONE);
+ } else {
+ for (i = 0; i < ARRAY_SIZE(proto_names); i++) {
+ if (!strncasecmp(tmp, proto_names[i].name, strlen(proto_names[i].name))) {
+ tmp += strlen(proto_names[i].name);
+ mask = proto_names[i].type;
+ break;
+ }
+ }
+ if (i == ARRAY_SIZE(proto_names)) {
+ IR_dprintk(1, "Unknown protocol\n");
+ return -EINVAL;
}
- }
- if (i == ARRAY_SIZE(proto_names)) {
- IR_dprintk(1, "Unknown protocol\n");
- return -EINVAL;
}
tmp = skip_spaces(tmp);
--
1.7.1
next prev parent reply other threads:[~2010-06-28 17:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1277744236.git.mchehab@redhat.com>
2010-06-28 16:59 ` [PATCH 4/4] ir-core: allow specifying multiple protocols at one open/write Mauro Carvalho Chehab
2010-06-28 16:59 ` Mauro Carvalho Chehab [this message]
2010-06-28 16:59 ` [PATCH 2/4] ir-core: Rename sysfs protocols nomenclature to rc-5 and rc-6 Mauro Carvalho Chehab
2010-06-28 17:00 ` [PATCH 1/4] ir-core: Remove magic numbers at the sysfs logic Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100628135958.3b36a6bf@pedra \
--to=mchehab@redhat.com \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox