aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2014-02-28 18:17:03 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-03-11 12:24:39 -0400
commit1a1934fab0c920f0d3bceeb60c9fe2dae8a56be9 (patch)
tree9ce4f9817f35063ac8a4543dc5e0908805dc4e93
parentb8c7d915087c97a21fa415fa0e860e59739da202 (diff)
[media] rc: abstract access to allowed/enabled protocols
The allowed and enabled protocol masks need to be expanded to be per filter type in order to support wakeup filter protocol selection. To ease that process abstract access to the rc_dev::allowed_protos and rc_dev::enabled_protocols members with inline functions. Signed-off-by: James Hogan <james.hogan@imgtec.com> Reviewed-by: Antti Seppälä <a.seppala@gmail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/hid/hid-picolcd_cir.c2
-rw-r--r--drivers/media/common/siano/smsir.c2
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c4
-rw-r--r--drivers/media/pci/cx23885/cx23885-input.c2
-rw-r--r--drivers/media/pci/cx88/cx88-input.c2
-rw-r--r--drivers/media/rc/ati_remote.c2
-rw-r--r--drivers/media/rc/ene_ir.c2
-rw-r--r--drivers/media/rc/fintek-cir.c2
-rw-r--r--drivers/media/rc/gpio-ir-recv.c4
-rw-r--r--drivers/media/rc/iguanair.c2
-rw-r--r--drivers/media/rc/imon.c7
-rw-r--r--drivers/media/rc/ir-jvc-decoder.c2
-rw-r--r--drivers/media/rc/ir-lirc-codec.c2
-rw-r--r--drivers/media/rc/ir-mce_kbd-decoder.c2
-rw-r--r--drivers/media/rc/ir-nec-decoder.c2
-rw-r--r--drivers/media/rc/ir-raw.c2
-rw-r--r--drivers/media/rc/ir-rc5-decoder.c6
-rw-r--r--drivers/media/rc/ir-rc5-sz-decoder.c2
-rw-r--r--drivers/media/rc/ir-rc6-decoder.c6
-rw-r--r--drivers/media/rc/ir-sanyo-decoder.c2
-rw-r--r--drivers/media/rc/ir-sharp-decoder.c2
-rw-r--r--drivers/media/rc/ir-sony-decoder.c10
-rw-r--r--drivers/media/rc/ite-cir.c2
-rw-r--r--drivers/media/rc/mceusb.c2
-rw-r--r--drivers/media/rc/nuvoton-cir.c2
-rw-r--r--drivers/media/rc/rc-loopback.c2
-rw-r--r--drivers/media/rc/redrat3.c2
-rw-r--r--drivers/media/rc/st_rc.c2
-rw-r--r--drivers/media/rc/streamzap.c2
-rw-r--r--drivers/media/rc/ttusbir.c2
-rw-r--r--drivers/media/rc/winbond-cir.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb_core.c2
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-remote.c2
-rw-r--r--drivers/media/usb/em28xx/em28xx-input.c8
-rw-r--r--drivers/media/usb/tm6000/tm6000-input.c2
-rw-r--r--include/media/rc-core.h22
36 files changed, 73 insertions, 50 deletions
diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
index 59d5eb1e742c..cf1a9f1c1217 100644
--- a/drivers/hid/hid-picolcd_cir.c
+++ b/drivers/hid/hid-picolcd_cir.c
@@ -114,7 +114,7 @@ int picolcd_init_cir(struct picolcd_data *data, struct hid_report *report)
114 114
115 rdev->priv = data; 115 rdev->priv = data;
116 rdev->driver_type = RC_DRIVER_IR_RAW; 116 rdev->driver_type = RC_DRIVER_IR_RAW;
117 rdev->allowed_protos = RC_BIT_ALL; 117 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
118 rdev->open = picolcd_cir_open; 118 rdev->open = picolcd_cir_open;
119 rdev->close = picolcd_cir_close; 119 rdev->close = picolcd_cir_close;
120 rdev->input_name = data->hdev->name; 120 rdev->input_name = data->hdev->name;
diff --git a/drivers/media/common/siano/smsir.c b/drivers/media/common/siano/smsir.c
index b8c5cad78537..6d7c0c858bd0 100644
--- a/drivers/media/common/siano/smsir.c
+++ b/drivers/media/common/siano/smsir.c
@@ -88,7 +88,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
88 88
89 dev->priv = coredev; 89 dev->priv = coredev;
90 dev->driver_type = RC_DRIVER_IR_RAW; 90 dev->driver_type = RC_DRIVER_IR_RAW;
91 dev->allowed_protos = RC_BIT_ALL; 91 rc_set_allowed_protocols(dev, RC_BIT_ALL);
92 dev->map_name = sms_get_board(board_id)->rc_codes; 92 dev->map_name = sms_get_board(board_id)->rc_codes;
93 dev->driver_name = MODULE_NAME; 93 dev->driver_name = MODULE_NAME;
94 94
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 99ee456700f4..c8fe1358ec9e 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -431,8 +431,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
431 * Initialize the other fields of rc_dev 431 * Initialize the other fields of rc_dev
432 */ 432 */
433 rc->map_name = ir->ir_codes; 433 rc->map_name = ir->ir_codes;
434 rc->allowed_protos = rc_type; 434 rc_set_allowed_protocols(rc, rc_type);
435 rc->enabled_protocols = rc_type; 435 rc_set_enabled_protocols(rc, rc_type);
436 if (!rc->driver_name) 436 if (!rc->driver_name)
437 rc->driver_name = MODULE_NAME; 437 rc->driver_name = MODULE_NAME;
438 438
diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c
index 8a49e7c9eddd..097d0a0b5f57 100644
--- a/drivers/media/pci/cx23885/cx23885-input.c
+++ b/drivers/media/pci/cx23885/cx23885-input.c
@@ -346,7 +346,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
346 } 346 }
347 rc->dev.parent = &dev->pci->dev; 347 rc->dev.parent = &dev->pci->dev;
348 rc->driver_type = driver_type; 348 rc->driver_type = driver_type;
349 rc->allowed_protos = allowed_protos; 349 rc_set_allowed_protocols(rc, allowed_protos);
350 rc->priv = kernel_ir; 350 rc->priv = kernel_ir;
351 rc->open = cx23885_input_ir_open; 351 rc->open = cx23885_input_ir_open;
352 rc->close = cx23885_input_ir_close; 352 rc->close = cx23885_input_ir_close;
diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c
index f29e18c72f44..f991696a6c59 100644
--- a/drivers/media/pci/cx88/cx88-input.c
+++ b/drivers/media/pci/cx88/cx88-input.c
@@ -469,7 +469,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
469 dev->timeout = 10 * 1000 * 1000; /* 10 ms */ 469 dev->timeout = 10 * 1000 * 1000; /* 10 ms */
470 } else { 470 } else {
471 dev->driver_type = RC_DRIVER_SCANCODE; 471 dev->driver_type = RC_DRIVER_SCANCODE;
472 dev->allowed_protos = rc_type; 472 rc_set_allowed_protocols(dev, rc_type);
473 } 473 }
474 474
475 ir->core = core; 475 ir->core = core;
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index 4d6a63fe6c5e..2df7c5516013 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -784,7 +784,7 @@ static void ati_remote_rc_init(struct ati_remote *ati_remote)
784 784
785 rdev->priv = ati_remote; 785 rdev->priv = ati_remote;
786 rdev->driver_type = RC_DRIVER_SCANCODE; 786 rdev->driver_type = RC_DRIVER_SCANCODE;
787 rdev->allowed_protos = RC_BIT_OTHER; 787 rc_set_allowed_protocols(rdev, RC_BIT_OTHER);
788 rdev->driver_name = "ati_remote"; 788 rdev->driver_name = "ati_remote";
789 789
790 rdev->open = ati_remote_rc_open; 790 rdev->open = ati_remote_rc_open;
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index c1444f84717d..fc9d23f2ed3f 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -1059,7 +1059,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1059 learning_mode_force = false; 1059 learning_mode_force = false;
1060 1060
1061 rdev->driver_type = RC_DRIVER_IR_RAW; 1061 rdev->driver_type = RC_DRIVER_IR_RAW;
1062 rdev->allowed_protos = RC_BIT_ALL; 1062 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
1063 rdev->priv = dev; 1063 rdev->priv = dev;
1064 rdev->open = ene_open; 1064 rdev->open = ene_open;
1065 rdev->close = ene_close; 1065 rdev->close = ene_close;
diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
index d6fa441655d2..46b66e59438f 100644
--- a/drivers/media/rc/fintek-cir.c
+++ b/drivers/media/rc/fintek-cir.c
@@ -541,7 +541,7 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
541 /* Set up the rc device */ 541 /* Set up the rc device */
542 rdev->priv = fintek; 542 rdev->priv = fintek;
543 rdev->driver_type = RC_DRIVER_IR_RAW; 543 rdev->driver_type = RC_DRIVER_IR_RAW;
544 rdev->allowed_protos = RC_BIT_ALL; 544 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
545 rdev->open = fintek_open; 545 rdev->open = fintek_open;
546 rdev->close = fintek_close; 546 rdev->close = fintek_close;
547 rdev->input_name = FINTEK_DESCRIPTION; 547 rdev->input_name = FINTEK_DESCRIPTION;
diff --git a/drivers/media/rc/gpio-ir-recv.c b/drivers/media/rc/gpio-ir-recv.c
index 80c611c2e8c2..29b5f89813b4 100644
--- a/drivers/media/rc/gpio-ir-recv.c
+++ b/drivers/media/rc/gpio-ir-recv.c
@@ -145,9 +145,9 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
145 rcdev->dev.parent = &pdev->dev; 145 rcdev->dev.parent = &pdev->dev;
146 rcdev->driver_name = GPIO_IR_DRIVER_NAME; 146 rcdev->driver_name = GPIO_IR_DRIVER_NAME;
147 if (pdata->allowed_protos) 147 if (pdata->allowed_protos)
148 rcdev->allowed_protos = pdata->allowed_protos; 148 rc_set_allowed_protocols(rcdev, pdata->allowed_protos);
149 else 149 else
150 rcdev->allowed_protos = RC_BIT_ALL; 150 rc_set_allowed_protocols(rcdev, RC_BIT_ALL);
151 rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY; 151 rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY;
152 152
153 gpio_dev->rcdev = rcdev; 153 gpio_dev->rcdev = rcdev;
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index a83519a6a158..627ddfd61980 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -495,7 +495,7 @@ static int iguanair_probe(struct usb_interface *intf,
495 usb_to_input_id(ir->udev, &rc->input_id); 495 usb_to_input_id(ir->udev, &rc->input_id);
496 rc->dev.parent = &intf->dev; 496 rc->dev.parent = &intf->dev;
497 rc->driver_type = RC_DRIVER_IR_RAW; 497 rc->driver_type = RC_DRIVER_IR_RAW;
498 rc->allowed_protos = RC_BIT_ALL; 498 rc_set_allowed_protocols(rc, RC_BIT_ALL);
499 rc->priv = ir; 499 rc->priv = ir;
500 rc->open = iguanair_open; 500 rc->open = iguanair_open;
501 rc->close = iguanair_close; 501 rc->close = iguanair_close;
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 822b9f47ca72..6f24e77b1488 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -1017,7 +1017,7 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 *rc_type)
1017 unsigned char ir_proto_packet[] = { 1017 unsigned char ir_proto_packet[] = {
1018 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 }; 1018 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 };
1019 1019
1020 if (*rc_type && !(*rc_type & rc->allowed_protos)) 1020 if (*rc_type && !rc_protocols_allowed(rc, *rc_type))
1021 dev_warn(dev, "Looks like you're trying to use an IR protocol " 1021 dev_warn(dev, "Looks like you're trying to use an IR protocol "
1022 "this device does not support\n"); 1022 "this device does not support\n");
1023 1023
@@ -1867,7 +1867,8 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1867 1867
1868 rdev->priv = ictx; 1868 rdev->priv = ictx;
1869 rdev->driver_type = RC_DRIVER_SCANCODE; 1869 rdev->driver_type = RC_DRIVER_SCANCODE;
1870 rdev->allowed_protos = RC_BIT_OTHER | RC_BIT_RC6_MCE; /* iMON PAD or MCE */ 1870 /* iMON PAD or MCE */
1871 rc_set_allowed_protocols(rdev, RC_BIT_OTHER | RC_BIT_RC6_MCE);
1871 rdev->change_protocol = imon_ir_change_protocol; 1872 rdev->change_protocol = imon_ir_change_protocol;
1872 rdev->driver_name = MOD_NAME; 1873 rdev->driver_name = MOD_NAME;
1873 1874
@@ -1880,7 +1881,7 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1880 1881
1881 if (ictx->product == 0xffdc) { 1882 if (ictx->product == 0xffdc) {
1882 imon_get_ffdc_type(ictx); 1883 imon_get_ffdc_type(ictx);
1883 rdev->allowed_protos = ictx->rc_type; 1884 rc_set_allowed_protocols(rdev, ictx->rc_type);
1884 } 1885 }
1885 1886
1886 imon_set_display_type(ictx); 1887 imon_set_display_type(ictx);
diff --git a/drivers/media/rc/ir-jvc-decoder.c b/drivers/media/rc/ir-jvc-decoder.c
index 3948138ca870..4ea62a1dcfda 100644
--- a/drivers/media/rc/ir-jvc-decoder.c
+++ b/drivers/media/rc/ir-jvc-decoder.c
@@ -47,7 +47,7 @@ static int ir_jvc_decode(struct rc_dev *dev, struct ir_raw_event ev)
47{ 47{
48 struct jvc_dec *data = &dev->raw->jvc; 48 struct jvc_dec *data = &dev->raw->jvc;
49 49
50 if (!(dev->enabled_protocols & RC_BIT_JVC)) 50 if (!rc_protocols_enabled(dev, RC_BIT_JVC))
51 return 0; 51 return 0;
52 52
53 if (!is_timing_event(ev)) { 53 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index ed2c8a1ed8ca..d731da6c414d 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -35,7 +35,7 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev)
35 struct lirc_codec *lirc = &dev->raw->lirc; 35 struct lirc_codec *lirc = &dev->raw->lirc;
36 int sample; 36 int sample;
37 37
38 if (!(dev->enabled_protocols & RC_BIT_LIRC)) 38 if (!rc_protocols_enabled(dev, RC_BIT_LIRC))
39 return 0; 39 return 0;
40 40
41 if (!dev->raw->lirc.drv || !dev->raw->lirc.drv->rbuf) 41 if (!dev->raw->lirc.drv || !dev->raw->lirc.drv->rbuf)
diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c
index 9f3c9b59f30c..0c55f794c8cf 100644
--- a/drivers/media/rc/ir-mce_kbd-decoder.c
+++ b/drivers/media/rc/ir-mce_kbd-decoder.c
@@ -216,7 +216,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev)
216 u32 scancode; 216 u32 scancode;
217 unsigned long delay; 217 unsigned long delay;
218 218
219 if (!(dev->enabled_protocols & RC_BIT_MCE_KBD)) 219 if (!rc_protocols_enabled(dev, RC_BIT_MCE_KBD))
220 return 0; 220 return 0;
221 221
222 if (!is_timing_event(ev)) { 222 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c
index e687a4247052..9de1791d2494 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -52,7 +52,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
52 u8 address, not_address, command, not_command; 52 u8 address, not_address, command, not_command;
53 bool send_32bits = false; 53 bool send_32bits = false;
54 54
55 if (!(dev->enabled_protocols & RC_BIT_NEC)) 55 if (!rc_protocols_enabled(dev, RC_BIT_NEC))
56 return 0; 56 return 0;
57 57
58 if (!is_timing_event(ev)) { 58 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index f0656fa1a01a..763c9d131d0f 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -256,7 +256,7 @@ int ir_raw_event_register(struct rc_dev *dev)
256 return -ENOMEM; 256 return -ENOMEM;
257 257
258 dev->raw->dev = dev; 258 dev->raw->dev = dev;
259 dev->enabled_protocols = ~0; 259 rc_set_enabled_protocols(dev, ~0);
260 rc = kfifo_alloc(&dev->raw->kfifo, 260 rc = kfifo_alloc(&dev->raw->kfifo,
261 sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE, 261 sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE,
262 GFP_KERNEL); 262 GFP_KERNEL);
diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c
index 1085e173270a..4295d9b250c8 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -52,7 +52,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
52 u8 toggle; 52 u8 toggle;
53 u32 scancode; 53 u32 scancode;
54 54
55 if (!(dev->enabled_protocols & (RC_BIT_RC5 | RC_BIT_RC5X))) 55 if (!rc_protocols_enabled(dev, RC_BIT_RC5 | RC_BIT_RC5X))
56 return 0; 56 return 0;
57 57
58 if (!is_timing_event(ev)) { 58 if (!is_timing_event(ev)) {
@@ -128,7 +128,7 @@ again:
128 if (data->wanted_bits == RC5X_NBITS) { 128 if (data->wanted_bits == RC5X_NBITS) {
129 /* RC5X */ 129 /* RC5X */
130 u8 xdata, command, system; 130 u8 xdata, command, system;
131 if (!(dev->enabled_protocols & RC_BIT_RC5X)) { 131 if (!rc_protocols_enabled(dev, RC_BIT_RC5X)) {
132 data->state = STATE_INACTIVE; 132 data->state = STATE_INACTIVE;
133 return 0; 133 return 0;
134 } 134 }
@@ -145,7 +145,7 @@ again:
145 } else { 145 } else {
146 /* RC5 */ 146 /* RC5 */
147 u8 command, system; 147 u8 command, system;
148 if (!(dev->enabled_protocols & RC_BIT_RC5)) { 148 if (!rc_protocols_enabled(dev, RC_BIT_RC5)) {
149 data->state = STATE_INACTIVE; 149 data->state = STATE_INACTIVE;
150 return 0; 150 return 0;
151 } 151 }
diff --git a/drivers/media/rc/ir-rc5-sz-decoder.c b/drivers/media/rc/ir-rc5-sz-decoder.c
index 984e5b9f5bc3..dc18b7434db8 100644
--- a/drivers/media/rc/ir-rc5-sz-decoder.c
+++ b/drivers/media/rc/ir-rc5-sz-decoder.c
@@ -48,7 +48,7 @@ static int ir_rc5_sz_decode(struct rc_dev *dev, struct ir_raw_event ev)
48 u8 toggle, command, system; 48 u8 toggle, command, system;
49 u32 scancode; 49 u32 scancode;
50 50
51 if (!(dev->enabled_protocols & RC_BIT_RC5_SZ)) 51 if (!rc_protocols_enabled(dev, RC_BIT_RC5_SZ))
52 return 0; 52 return 0;
53 53
54 if (!is_timing_event(ev)) { 54 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c
index 7cba7d33a3fa..cfbd64e3999c 100644
--- a/drivers/media/rc/ir-rc6-decoder.c
+++ b/drivers/media/rc/ir-rc6-decoder.c
@@ -89,9 +89,9 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
89 u32 scancode; 89 u32 scancode;
90 u8 toggle; 90 u8 toggle;
91 91
92 if (!(dev->enabled_protocols & 92 if (!rc_protocols_enabled(dev, RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 |
93 (RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | 93 RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 |
94 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE))) 94 RC_BIT_RC6_MCE))
95 return 0; 95 return 0;
96 96
97 if (!is_timing_event(ev)) { 97 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-sanyo-decoder.c b/drivers/media/rc/ir-sanyo-decoder.c
index e1351ed61629..eb715f04dc27 100644
--- a/drivers/media/rc/ir-sanyo-decoder.c
+++ b/drivers/media/rc/ir-sanyo-decoder.c
@@ -58,7 +58,7 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev)
58 u32 scancode; 58 u32 scancode;
59 u8 address, command, not_command; 59 u8 address, command, not_command;
60 60
61 if (!(dev->enabled_protocols & RC_BIT_SANYO)) 61 if (!rc_protocols_enabled(dev, RC_BIT_SANYO))
62 return 0; 62 return 0;
63 63
64 if (!is_timing_event(ev)) { 64 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-sharp-decoder.c b/drivers/media/rc/ir-sharp-decoder.c
index 4895bc752f97..66d20394ceaa 100644
--- a/drivers/media/rc/ir-sharp-decoder.c
+++ b/drivers/media/rc/ir-sharp-decoder.c
@@ -48,7 +48,7 @@ static int ir_sharp_decode(struct rc_dev *dev, struct ir_raw_event ev)
48 struct sharp_dec *data = &dev->raw->sharp; 48 struct sharp_dec *data = &dev->raw->sharp;
49 u32 msg, echo, address, command, scancode; 49 u32 msg, echo, address, command, scancode;
50 50
51 if (!(dev->enabled_protocols & RC_BIT_SHARP)) 51 if (!rc_protocols_enabled(dev, RC_BIT_SHARP))
52 return 0; 52 return 0;
53 53
54 if (!is_timing_event(ev)) { 54 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-sony-decoder.c b/drivers/media/rc/ir-sony-decoder.c
index 29ab9c2db060..599c19a73360 100644
--- a/drivers/media/rc/ir-sony-decoder.c
+++ b/drivers/media/rc/ir-sony-decoder.c
@@ -45,8 +45,8 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
45 u32 scancode; 45 u32 scancode;
46 u8 device, subdevice, function; 46 u8 device, subdevice, function;
47 47
48 if (!(dev->enabled_protocols & 48 if (!rc_protocols_enabled(dev, RC_BIT_SONY12 | RC_BIT_SONY15 |
49 (RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20))) 49 RC_BIT_SONY20))
50 return 0; 50 return 0;
51 51
52 if (!is_timing_event(ev)) { 52 if (!is_timing_event(ev)) {
@@ -124,7 +124,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
124 124
125 switch (data->count) { 125 switch (data->count) {
126 case 12: 126 case 12:
127 if (!(dev->enabled_protocols & RC_BIT_SONY12)) { 127 if (!rc_protocols_enabled(dev, RC_BIT_SONY12)) {
128 data->state = STATE_INACTIVE; 128 data->state = STATE_INACTIVE;
129 return 0; 129 return 0;
130 } 130 }
@@ -133,7 +133,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
133 function = bitrev8((data->bits >> 4) & 0xFE); 133 function = bitrev8((data->bits >> 4) & 0xFE);
134 break; 134 break;
135 case 15: 135 case 15:
136 if (!(dev->enabled_protocols & RC_BIT_SONY15)) { 136 if (!rc_protocols_enabled(dev, RC_BIT_SONY15)) {
137 data->state = STATE_INACTIVE; 137 data->state = STATE_INACTIVE;
138 return 0; 138 return 0;
139 } 139 }
@@ -142,7 +142,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
142 function = bitrev8((data->bits >> 7) & 0xFE); 142 function = bitrev8((data->bits >> 7) & 0xFE);
143 break; 143 break;
144 case 20: 144 case 20:
145 if (!(dev->enabled_protocols & RC_BIT_SONY20)) { 145 if (!rc_protocols_enabled(dev, RC_BIT_SONY20)) {
146 data->state = STATE_INACTIVE; 146 data->state = STATE_INACTIVE;
147 return 0; 147 return 0;
148 } 148 }
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
index 63b42252166a..ab24cc6d3655 100644
--- a/drivers/media/rc/ite-cir.c
+++ b/drivers/media/rc/ite-cir.c
@@ -1563,7 +1563,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1563 /* set up ir-core props */ 1563 /* set up ir-core props */
1564 rdev->priv = itdev; 1564 rdev->priv = itdev;
1565 rdev->driver_type = RC_DRIVER_IR_RAW; 1565 rdev->driver_type = RC_DRIVER_IR_RAW;
1566 rdev->allowed_protos = RC_BIT_ALL; 1566 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
1567 rdev->open = ite_open; 1567 rdev->open = ite_open;
1568 rdev->close = ite_close; 1568 rdev->close = ite_close;
1569 rdev->s_idle = ite_s_idle; 1569 rdev->s_idle = ite_s_idle;
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index c01b4c1f64ca..5d8f3d40d820 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -1211,7 +1211,7 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
1211 rc->dev.parent = dev; 1211 rc->dev.parent = dev;
1212 rc->priv = ir; 1212 rc->priv = ir;
1213 rc->driver_type = RC_DRIVER_IR_RAW; 1213 rc->driver_type = RC_DRIVER_IR_RAW;
1214 rc->allowed_protos = RC_BIT_ALL; 1214 rc_set_allowed_protocols(rc, RC_BIT_ALL);
1215 rc->timeout = MS_TO_NS(100); 1215 rc->timeout = MS_TO_NS(100);
1216 if (!ir->flags.no_tx) { 1216 if (!ir->flags.no_tx) {
1217 rc->s_tx_mask = mceusb_set_tx_mask; 1217 rc->s_tx_mask = mceusb_set_tx_mask;
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index b81325d7948f..d244e1a83f43 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -1044,7 +1044,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1044 /* Set up the rc device */ 1044 /* Set up the rc device */
1045 rdev->priv = nvt; 1045 rdev->priv = nvt;
1046 rdev->driver_type = RC_DRIVER_IR_RAW; 1046 rdev->driver_type = RC_DRIVER_IR_RAW;
1047 rdev->allowed_protos = RC_BIT_ALL; 1047 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
1048 rdev->open = nvt_open; 1048 rdev->open = nvt_open;
1049 rdev->close = nvt_close; 1049 rdev->close = nvt_close;
1050 rdev->tx_ir = nvt_tx_ir; 1050 rdev->tx_ir = nvt_tx_ir;
diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
index 53d02827a472..0a88e0cf964f 100644
--- a/drivers/media/rc/rc-loopback.c
+++ b/drivers/media/rc/rc-loopback.c
@@ -195,7 +195,7 @@ static int __init loop_init(void)
195 rc->map_name = RC_MAP_EMPTY; 195 rc->map_name = RC_MAP_EMPTY;
196 rc->priv = &loopdev; 196 rc->priv = &loopdev;
197 rc->driver_type = RC_DRIVER_IR_RAW; 197 rc->driver_type = RC_DRIVER_IR_RAW;
198 rc->allowed_protos = RC_BIT_ALL; 198 rc_set_allowed_protocols(rc, RC_BIT_ALL);
199 rc->timeout = 100 * 1000 * 1000; /* 100 ms */ 199 rc->timeout = 100 * 1000 * 1000; /* 100 ms */
200 rc->min_timeout = 1; 200 rc->min_timeout = 1;
201 rc->max_timeout = UINT_MAX; 201 rc->max_timeout = UINT_MAX;
diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index a5d4f883d053..47cd373e2295 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -922,7 +922,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
922 rc->dev.parent = dev; 922 rc->dev.parent = dev;
923 rc->priv = rr3; 923 rc->priv = rr3;
924 rc->driver_type = RC_DRIVER_IR_RAW; 924 rc->driver_type = RC_DRIVER_IR_RAW;
925 rc->allowed_protos = RC_BIT_ALL; 925 rc_set_allowed_protocols(rc, RC_BIT_ALL);
926 rc->timeout = US_TO_NS(2750); 926 rc->timeout = US_TO_NS(2750);
927 rc->tx_ir = redrat3_transmit_ir; 927 rc->tx_ir = redrat3_transmit_ir;
928 rc->s_tx_carrier = redrat3_set_tx_carrier; 928 rc->s_tx_carrier = redrat3_set_tx_carrier;
diff --git a/drivers/media/rc/st_rc.c b/drivers/media/rc/st_rc.c
index 8f0cddb9e8f2..22e4c1f28ab4 100644
--- a/drivers/media/rc/st_rc.c
+++ b/drivers/media/rc/st_rc.c
@@ -287,7 +287,7 @@ static int st_rc_probe(struct platform_device *pdev)
287 st_rc_hardware_init(rc_dev); 287 st_rc_hardware_init(rc_dev);
288 288
289 rdev->driver_type = RC_DRIVER_IR_RAW; 289 rdev->driver_type = RC_DRIVER_IR_RAW;
290 rdev->allowed_protos = RC_BIT_ALL; 290 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
291 /* rx sampling rate is 10Mhz */ 291 /* rx sampling rate is 10Mhz */
292 rdev->rx_resolution = 100; 292 rdev->rx_resolution = 100;
293 rdev->timeout = US_TO_NS(MAX_SYMB_TIME); 293 rdev->timeout = US_TO_NS(MAX_SYMB_TIME);
diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
index d7b11e6a9982..f4e0bc3d382c 100644
--- a/drivers/media/rc/streamzap.c
+++ b/drivers/media/rc/streamzap.c
@@ -322,7 +322,7 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)
322 rdev->dev.parent = dev; 322 rdev->dev.parent = dev;
323 rdev->priv = sz; 323 rdev->priv = sz;
324 rdev->driver_type = RC_DRIVER_IR_RAW; 324 rdev->driver_type = RC_DRIVER_IR_RAW;
325 rdev->allowed_protos = RC_BIT_ALL; 325 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
326 rdev->driver_name = DRIVER_NAME; 326 rdev->driver_name = DRIVER_NAME;
327 rdev->map_name = RC_MAP_STREAMZAP; 327 rdev->map_name = RC_MAP_STREAMZAP;
328 328
diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
index d8de2056a4f6..c5be38e2a2fe 100644
--- a/drivers/media/rc/ttusbir.c
+++ b/drivers/media/rc/ttusbir.c
@@ -318,7 +318,7 @@ static int ttusbir_probe(struct usb_interface *intf,
318 usb_to_input_id(tt->udev, &rc->input_id); 318 usb_to_input_id(tt->udev, &rc->input_id);
319 rc->dev.parent = &intf->dev; 319 rc->dev.parent = &intf->dev;
320 rc->driver_type = RC_DRIVER_IR_RAW; 320 rc->driver_type = RC_DRIVER_IR_RAW;
321 rc->allowed_protos = RC_BIT_ALL; 321 rc_set_allowed_protocols(rc, RC_BIT_ALL);
322 rc->priv = tt; 322 rc->priv = tt;
323 rc->driver_name = DRIVER_NAME; 323 rc->driver_name = DRIVER_NAME;
324 rc->map_name = RC_MAP_TT_1500; 324 rc->map_name = RC_MAP_TT_1500;
diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 904baf4eec28..a8b981f5ce2e 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -1082,7 +1082,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1082 data->dev->dev.parent = &device->dev; 1082 data->dev->dev.parent = &device->dev;
1083 data->dev->timeout = MS_TO_NS(100); 1083 data->dev->timeout = MS_TO_NS(100);
1084 data->dev->rx_resolution = US_TO_NS(2); 1084 data->dev->rx_resolution = US_TO_NS(2);
1085 data->dev->allowed_protos = RC_BIT_ALL; 1085 rc_set_allowed_protocols(data->dev, RC_BIT_ALL);
1086 1086
1087 err = rc_register_device(data->dev); 1087 err = rc_register_device(data->dev);
1088 if (err) 1088 if (err)
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
index 8a054d66e708..de02db802ace 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -164,7 +164,7 @@ static int dvb_usbv2_remote_init(struct dvb_usb_device *d)
164 dev->driver_name = (char *) d->props->driver_name; 164 dev->driver_name = (char *) d->props->driver_name;
165 dev->map_name = d->rc.map_name; 165 dev->map_name = d->rc.map_name;
166 dev->driver_type = d->rc.driver_type; 166 dev->driver_type = d->rc.driver_type;
167 dev->allowed_protos = d->rc.allowed_protos; 167 rc_set_allowed_protocols(dev, d->rc.allowed_protos);
168 dev->change_protocol = d->rc.change_protocol; 168 dev->change_protocol = d->rc.change_protocol;
169 dev->priv = d; 169 dev->priv = d;
170 170
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-remote.c b/drivers/media/usb/dvb-usb/dvb-usb-remote.c
index 41bacff24960..4058aea9272f 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-remote.c
@@ -272,7 +272,7 @@ static int rc_core_dvb_usb_remote_init(struct dvb_usb_device *d)
272 dev->driver_name = d->props.rc.core.module_name; 272 dev->driver_name = d->props.rc.core.module_name;
273 dev->map_name = d->props.rc.core.rc_codes; 273 dev->map_name = d->props.rc.core.rc_codes;
274 dev->change_protocol = d->props.rc.core.change_protocol; 274 dev->change_protocol = d->props.rc.core.change_protocol;
275 dev->allowed_protos = d->props.rc.core.allowed_protos; 275 rc_set_allowed_protocols(dev, d->props.rc.core.allowed_protos);
276 dev->driver_type = d->props.rc.core.driver_type; 276 dev->driver_type = d->props.rc.core.driver_type;
277 usb_to_input_id(d->udev, &dev->input_id); 277 usb_to_input_id(d->udev, &dev->input_id);
278 dev->input_name = "IR-receiver inside an USB DVB receiver"; 278 dev->input_name = "IR-receiver inside an USB DVB receiver";
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index 2a9bf667f208..56ef49df4f8d 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -727,7 +727,7 @@ static int em28xx_ir_init(struct em28xx *dev)
727 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2: 727 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
728 rc->map_name = RC_MAP_HAUPPAUGE; 728 rc->map_name = RC_MAP_HAUPPAUGE;
729 ir->get_key_i2c = em28xx_get_key_em_haup; 729 ir->get_key_i2c = em28xx_get_key_em_haup;
730 rc->allowed_protos = RC_BIT_RC5; 730 rc_set_allowed_protocols(rc, RC_BIT_RC5);
731 break; 731 break;
732 case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE: 732 case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE:
733 rc->map_name = RC_MAP_WINFAST_USBII_DELUXE; 733 rc->map_name = RC_MAP_WINFAST_USBII_DELUXE;
@@ -743,7 +743,7 @@ static int em28xx_ir_init(struct em28xx *dev)
743 switch (dev->chip_id) { 743 switch (dev->chip_id) {
744 case CHIP_ID_EM2860: 744 case CHIP_ID_EM2860:
745 case CHIP_ID_EM2883: 745 case CHIP_ID_EM2883:
746 rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC; 746 rc_set_allowed_protocols(rc, RC_BIT_RC5 | RC_BIT_NEC);
747 ir->get_key = default_polling_getkey; 747 ir->get_key = default_polling_getkey;
748 break; 748 break;
749 case CHIP_ID_EM2884: 749 case CHIP_ID_EM2884:
@@ -751,8 +751,8 @@ static int em28xx_ir_init(struct em28xx *dev)
751 case CHIP_ID_EM28174: 751 case CHIP_ID_EM28174:
752 case CHIP_ID_EM28178: 752 case CHIP_ID_EM28178:
753 ir->get_key = em2874_polling_getkey; 753 ir->get_key = em2874_polling_getkey;
754 rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC | 754 rc_set_allowed_protocols(rc, RC_BIT_RC5 | RC_BIT_NEC |
755 RC_BIT_RC6_0; 755 RC_BIT_RC6_0);
756 break; 756 break;
757 default: 757 default:
758 err = -ENODEV; 758 err = -ENODEV;
diff --git a/drivers/media/usb/tm6000/tm6000-input.c b/drivers/media/usb/tm6000/tm6000-input.c
index 8a6bbf1d80e1..d1af5438c168 100644
--- a/drivers/media/usb/tm6000/tm6000-input.c
+++ b/drivers/media/usb/tm6000/tm6000-input.c
@@ -422,7 +422,7 @@ int tm6000_ir_init(struct tm6000_core *dev)
422 ir->rc = rc; 422 ir->rc = rc;
423 423
424 /* input setup */ 424 /* input setup */
425 rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC; 425 rc_set_allowed_protocols(rc, RC_BIT_RC5 | RC_BIT_NEC);
426 /* Neded, in order to support NEC remotes with 24 or 32 bits */ 426 /* Neded, in order to support NEC remotes with 24 or 32 bits */
427 rc->scanmask = 0xffff; 427 rc->scanmask = 0xffff;
428 rc->priv = ir; 428 rc->priv = ir;
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 5e7197e40c14..6f3c3d977c81 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -160,6 +160,28 @@ struct rc_dev {
160 160
161#define to_rc_dev(d) container_of(d, struct rc_dev, dev) 161#define to_rc_dev(d) container_of(d, struct rc_dev, dev)
162 162
163static inline bool rc_protocols_allowed(struct rc_dev *rdev, u64 protos)
164{
165 return rdev->allowed_protos & protos;
166}
167
168/* should be called prior to registration or with mutex held */
169static inline void rc_set_allowed_protocols(struct rc_dev *rdev, u64 protos)
170{
171 rdev->allowed_protos = protos;
172}
173
174static inline bool rc_protocols_enabled(struct rc_dev *rdev, u64 protos)
175{
176 return rdev->enabled_protocols & protos;
177}
178
179/* should be called prior to registration or with mutex held */
180static inline void rc_set_enabled_protocols(struct rc_dev *rdev, u64 protos)
181{
182 rdev->enabled_protocols = protos;
183}
184
163/* 185/*
164 * From rc-main.c 186 * From rc-main.c
165 * Those functions can be used on any type of Remote Controller. They 187 * Those functions can be used on any type of Remote Controller. They