linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: linux-media@vger.kernel.org
Cc: Ralf Schmidt <rds2@gmx.de>
Subject: [PATCH v4l-utils] keytable: "-p all" should not attempt BPF decodes that don't exist
Date: Sat, 16 May 2020 14:09:59 +0100	[thread overview]
Message-ID: <20200516130959.2593-1-sean@mess.org> (raw)

Currently we only have a BPF decoder for xbox_dvd. Other decoders
should not be attempted.

Reported-by: Ralf Schmidt <rds2@gmx.de>
Signed-off-by: Sean Young <sean@mess.org>
---
 utils/keytable/keytable.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c
index 4db91267..3df5fcf2 100644
--- a/utils/keytable/keytable.c
+++ b/utils/keytable/keytable.c
@@ -945,12 +945,21 @@ static struct sysfs_names *find_device(char *name)
 	return names;
 }
 
+/*
+ * If an rcdev does not have a decoder for a protocol, try to load a bpf
+ * replacement.
+ */
 static enum sysfs_protocols load_bpf_for_unsupported(enum sysfs_protocols protocols, enum sysfs_protocols supported)
 {
 	const struct protocol_map_entry *pme;
 	struct bpf_protocol *b;
 
 	for (pme = protocol_map; pme->name; pme++) {
+		// So far, we only have a replacement for the xbox_dvd
+		// protocol
+		if (pme->sysfs_protocol != SYSFS_XBOX_DVD)
+			continue;
+
 		if (!(protocols & pme->sysfs_protocol) ||
 		    (supported & pme->sysfs_protocol))
 			continue;
@@ -1156,7 +1165,7 @@ static int v2_set_protocols(struct rc_device *rc_dev)
 
 	if (!stat(name, &st) && !(st.st_mode & 0222)) {
 		fprintf(stderr, _("Protocols for device can not be changed\n"));
-		return 0;
+		return EINVAL;
 	}
 
 	fp = fopen(name, "w");
@@ -1323,8 +1332,7 @@ static int set_proto(struct rc_device *rc_dev)
 	int rc = 0;
 
 	if (rc_dev->version == VERSION_2) {
-		rc = v2_set_protocols(rc_dev);
-		return rc;
+		return v2_set_protocols(rc_dev);
 	}
 
 	rc_dev->current &= rc_dev->supported;
@@ -2151,9 +2159,7 @@ int main(int argc, char *argv[])
 
 		rc_dev.current = load_bpf_for_unsupported(ch_proto, rc_dev.supported);
 
-		if (set_proto(&rc_dev))
-			fprintf(stderr, _("Couldn't change the IR protocols\n"));
-		else {
+		if (!set_proto(&rc_dev)) {
 			fprintf(stderr, _("Protocols changed to "));
 			write_sysfs_protocols(rc_dev.current, stderr, "%s ");
 			fprintf(stderr, "\n");
-- 
2.26.2


                 reply	other threads:[~2020-05-16 13:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200516130959.2593-1-sean@mess.org \
    --to=sean@mess.org \
    --cc=linux-media@vger.kernel.org \
    --cc=rds2@gmx.de \
    /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;
as well as URLs for NNTP newsgroup(s).