keytable: Mask selected protocols with the supported ones
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Sat, 26 Jul 2014 02:02:00 +0000 (23:02 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Sat, 26 Jul 2014 02:02:00 +0000 (23:02 -0300)
It should never try to enable a protocol not supported, as
the Kernel will give an error and reset to none.

That's a problem when -p all option is used. So, mask the
protocols to make this option to work.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
utils/keytable/keytable.c

index 6a8deee..1a91fba 100644 (file)
@@ -1174,6 +1174,12 @@ static int set_proto(struct rc_device *rc_dev)
 {
        int rc = 0;
 
+       rc_dev->current &= rc_dev->supported;
+       if (!rc_dev->current) {
+               fprintf(stderr, "Invalid protocols selected\n");
+               return EINVAL;
+       }
+
        if (rc_dev->version == VERSION_2) {
                rc = v2_set_protocols(rc_dev);
                return rc;