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 1/7] V4L/DVB: Partially revert commit da7251dd0bca6c17571be2bd4434b9779dea72d8
Date: Sat, 31 Jul 2010 23:54:02 -0300 [thread overview]
Message-ID: <20100731235402.52f4c0e2@pedra> (raw)
In-Reply-To: <cover.1280630041.git.mchehab@redhat.com>
By mistake, changeset da7251dd0bca6c17571be2bd4434b9779dea72d8
reverted the following commits:
commit 6795f9a1ac9e85deb96a49e46b29c809214bf5ea
commit d69861a25a54ef1cd6ee92f5ceb6ff2c01d84803
commit 1ba30538e2d125ce821622ac1f5e7ef31d856077
This patch partially reverts the original commit, to return the
code to its original state.
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 a841e51..c533d8b 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -33,6 +33,21 @@ static struct class ir_input_class = {
.devnode = ir_devnode,
};
+static struct {
+ u64 type;
+ char *name;
+} proto_names[] = {
+ { IR_TYPE_UNKNOWN, "unknown" },
+ { IR_TYPE_RC5, "rc-5" },
+ { IR_TYPE_NEC, "nec" },
+ { IR_TYPE_RC6, "rc-6" },
+ { IR_TYPE_JVC, "jvc" },
+ { IR_TYPE_SONY, "sony" },
+ { IR_TYPE_LIRC, "lirc" },
+};
+
+#define PROTO_NONE "none"
+
/**
* show_protocols() - shows the current IR protocol(s)
* @d: the device descriptor
@@ -50,6 +65,7 @@ static ssize_t show_protocols(struct device *d,
struct ir_input_dev *ir_dev = dev_get_drvdata(d);
u64 allowed, enabled;
char *tmp = buf;
+ int i;
if (ir_dev->props->driver_type == RC_DRIVER_SCANCODE) {
enabled = ir_dev->rc_tab.ir_type;
@@ -63,35 +79,12 @@ static ssize_t show_protocols(struct device *d,
(long long)allowed,
(long long)enabled);
- if (allowed & enabled & IR_TYPE_UNKNOWN)
- tmp += sprintf(tmp, "[unknown] ");
- else if (allowed & IR_TYPE_UNKNOWN)
- tmp += sprintf(tmp, "unknown ");
-
- if (allowed & enabled & IR_TYPE_RC5)
- tmp += sprintf(tmp, "[rc5] ");
- else if (allowed & IR_TYPE_RC5)
- tmp += sprintf(tmp, "rc5 ");
-
- if (allowed & enabled & IR_TYPE_NEC)
- tmp += sprintf(tmp, "[nec] ");
- else if (allowed & IR_TYPE_NEC)
- tmp += sprintf(tmp, "nec ");
-
- if (allowed & enabled & IR_TYPE_RC6)
- tmp += sprintf(tmp, "[rc6] ");
- else if (allowed & IR_TYPE_RC6)
- tmp += sprintf(tmp, "rc6 ");
-
- if (allowed & enabled & IR_TYPE_JVC)
- tmp += sprintf(tmp, "[jvc] ");
- else if (allowed & IR_TYPE_JVC)
- tmp += sprintf(tmp, "jvc ");
-
- if (allowed & enabled & IR_TYPE_SONY)
- tmp += sprintf(tmp, "[sony] ");
- else if (allowed & IR_TYPE_SONY)
- tmp += sprintf(tmp, "sony ");
+ for (i = 0; i < ARRAY_SIZE(proto_names); i++) {
+ if (allowed & enabled & proto_names[i].type)
+ tmp += sprintf(tmp, "[%s] ", proto_names[i].name);
+ else if (allowed & proto_names[i].type)
+ tmp += sprintf(tmp, "%s ", proto_names[i].name);
+ }
if (allowed & enabled & IR_TYPE_LIRC)
tmp += sprintf(tmp, "[lirc] ");
@@ -116,6 +109,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.
*/
@@ -129,67 +123,62 @@ static ssize_t store_protocols(struct device *d,
const char *tmp;
u64 type;
u64 mask;
- int rc;
+ int rc, i, count = 0;
unsigned long flags;
- tmp = skip_spaces(data);
-
- if (*tmp == '+') {
- enable = true;
- disable = false;
- tmp++;
- } else if (*tmp == '-') {
- enable = false;
- disable = true;
- tmp++;
- } else {
- enable = false;
- disable = false;
- }
-
- if (!strncasecmp(tmp, "unknown", 7)) {
- tmp += 7;
- mask = IR_TYPE_UNKNOWN;
- } else if (!strncasecmp(tmp, "rc5", 3)) {
- tmp += 3;
- mask = IR_TYPE_RC5;
- } else if (!strncasecmp(tmp, "nec", 3)) {
- tmp += 3;
- mask = IR_TYPE_NEC;
- } else if (!strncasecmp(tmp, "rc6", 3)) {
- tmp += 3;
- mask = IR_TYPE_RC6;
- } else if (!strncasecmp(tmp, "jvc", 3)) {
- tmp += 3;
- mask = IR_TYPE_JVC;
- } else if (!strncasecmp(tmp, "sony", 4)) {
- tmp += 4;
- mask = IR_TYPE_SONY;
- } else if (!strncasecmp(tmp, "lirc", 4)) {
- tmp += 4;
- mask = IR_TYPE_LIRC;
- } else {
- IR_dprintk(1, "Unknown protocol\n");
- return -EINVAL;
- }
-
- tmp = skip_spaces(tmp);
- if (*tmp != '\0') {
- IR_dprintk(1, "Invalid trailing characters\n");
- return -EINVAL;
- }
-
if (ir_dev->props->driver_type == RC_DRIVER_SCANCODE)
type = ir_dev->rc_tab.ir_type;
else
type = ir_dev->raw->enabled_protocols;
- if (enable)
- type |= mask;
- else if (disable)
- type &= ~mask;
- else
- type = mask;
+ while ((tmp = strsep((char **) &data, " \n")) != NULL) {
+ if (!*tmp)
+ break;
+
+ if (*tmp == '+') {
+ enable = true;
+ disable = false;
+ tmp++;
+ } else if (*tmp == '-') {
+ enable = false;
+ disable = true;
+ tmp++;
+ } else {
+ enable = false;
+ disable = false;
+ }
+
+ if (!enable && !disable && !strncasecmp(tmp, PROTO_NONE, sizeof(PROTO_NONE))) {
+ tmp += sizeof(PROTO_NONE);
+ mask = 0;
+ count++;
+ } 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: '%s'\n", tmp);
+ return -EINVAL;
+ }
+ count++;
+ }
+
+ if (enable)
+ type |= mask;
+ else if (disable)
+ type &= ~mask;
+ else
+ type = mask;
+ }
+
+ if (!count) {
+ IR_dprintk(1, "Protocol not specified\n");
+ return -EINVAL;
+ }
if (ir_dev->props && ir_dev->props->change_protocol) {
rc = ir_dev->props->change_protocol(ir_dev->props->priv,
--
1.7.1
next parent reply other threads:[~2010-08-01 2:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1280630041.git.mchehab@redhat.com>
2010-08-01 2:54 ` Mauro Carvalho Chehab [this message]
2010-08-01 2:54 ` [PATCH 2/7] V4L/DVB: dvb-usb: get rid of struct dvb_usb_rc_key Mauro Carvalho Chehab
2010-08-02 19:41 ` Jarod Wilson
2010-08-01 2:54 ` [PATCH 3/7] V4L/DVB: dvb-usb: prepare drivers for using rc-core Mauro Carvalho Chehab
2010-08-02 19:46 ` Jarod Wilson
2010-08-01 2:54 ` [PATCH 4/7] V4L/DVB: dvb-usb: add support for rc-core mode Mauro Carvalho Chehab
2010-08-01 2:54 ` [PATCH 5/7] V4L/DVB: Add a keymap file with dib0700 table Mauro Carvalho Chehab
2010-08-01 2:54 ` [PATCH 6/7] V4L/DVB: Port dib0700 to rc-core Mauro Carvalho Chehab
2010-08-01 2:54 ` [PATCH 7/7] V4L/DVB: dib0700: avoid bad repeat 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=20100731235402.52f4c0e2@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.