Skip to content

Commit

Permalink
[media] rc-core: remove protocol arrays
Browse files Browse the repository at this point in the history
The basic API of rc-core used to be:

	dev = rc_allocate_device();
	dev->x = a;
	dev->y = b;
	dev->z = c;
	rc_register_device();

which is a pretty common pattern in the kernel, after the introduction of
protocol arrays the API looks something like:

	dev = rc_allocate_device();
	dev->x = a;
	rc_set_allowed_protocols(dev, RC_BIT_X);
	dev->z = c;
	rc_register_device();

There's no real need for the protocols to be an array, so change it
back to be consistent (and in preparation for the following patches).

[m.chehab@samsung.com: added missing changes at some files]
Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
  • Loading branch information
David Härdeman authored and Mauro Carvalho Chehab committed Jul 25, 2014
1 parent da6e162 commit c5540fb
Show file tree
Hide file tree
Showing 39 changed files with 86 additions and 119 deletions.
2 changes: 1 addition & 1 deletion drivers/hid/hid-picolcd_cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ int picolcd_init_cir(struct picolcd_data *data, struct hid_report *report)

rdev->priv = data;
rdev->driver_type = RC_DRIVER_IR_RAW;
rc_set_allowed_protocols(rdev, RC_BIT_ALL);
rdev->allowed_protocols = RC_BIT_ALL;
rdev->open = picolcd_cir_open;
rdev->close = picolcd_cir_close;
rdev->input_name = data->hdev->name;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/common/siano/smsir.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int sms_ir_init(struct smscore_device_t *coredev)

dev->priv = coredev;
dev->driver_type = RC_DRIVER_IR_RAW;
rc_set_allowed_protocols(dev, RC_BIT_ALL);
dev->allowed_protocols = RC_BIT_ALL;
dev->map_name = sms_get_board(board_id)->rc_codes;
dev->driver_name = MODULE_NAME;

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/i2c/ir-kbd-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
* Initialize the other fields of rc_dev
*/
rc->map_name = ir->ir_codes;
rc_set_allowed_protocols(rc, rc_type);
rc_set_enabled_protocols(rc, rc_type);
rc->allowed_protocols = rc_type;
rc->enabled_protocols = rc_type;
if (!rc->driver_name)
rc->driver_name = MODULE_NAME;

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/cx23885/cx23885-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
}
rc->dev.parent = &dev->pci->dev;
rc->driver_type = driver_type;
rc_set_allowed_protocols(rc, allowed_protos);
rc->allowed_protocols = allowed_protos;
rc->priv = kernel_ir;
rc->open = cx23885_input_ir_open;
rc->close = cx23885_input_ir_close;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/cx88/cx88-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
dev->timeout = 10 * 1000 * 1000; /* 10 ms */
} else {
dev->driver_type = RC_DRIVER_SCANCODE;
rc_set_allowed_protocols(dev, rc_type);
dev->allowed_protocols = rc_type;
}

ir->core = core;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/ati_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ static void ati_remote_rc_init(struct ati_remote *ati_remote)

rdev->priv = ati_remote;
rdev->driver_type = RC_DRIVER_SCANCODE;
rc_set_allowed_protocols(rdev, RC_BIT_OTHER);
rdev->allowed_protocols = RC_BIT_OTHER;
rdev->driver_name = "ati_remote";

rdev->open = ati_remote_rc_open;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/ene_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
learning_mode_force = false;

rdev->driver_type = RC_DRIVER_IR_RAW;
rc_set_allowed_protocols(rdev, RC_BIT_ALL);
rdev->allowed_protocols = RC_BIT_ALL;
rdev->priv = dev;
rdev->open = ene_open;
rdev->close = ene_close;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/fintek-cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
/* Set up the rc device */
rdev->priv = fintek;
rdev->driver_type = RC_DRIVER_IR_RAW;
rc_set_allowed_protocols(rdev, RC_BIT_ALL);
rdev->allowed_protocols = RC_BIT_ALL;
rdev->open = fintek_open;
rdev->close = fintek_close;
rdev->input_name = FINTEK_DESCRIPTION;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/rc/gpio-ir-recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
rcdev->dev.parent = &pdev->dev;
rcdev->driver_name = GPIO_IR_DRIVER_NAME;
if (pdata->allowed_protos)
rc_set_allowed_protocols(rcdev, pdata->allowed_protos);
rcdev->allowed_protocols = pdata->allowed_protos;
else
rc_set_allowed_protocols(rcdev, RC_BIT_ALL);
rcdev->allowed_protocols = RC_BIT_ALL;
rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY;

gpio_dev->rcdev = rcdev;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/iguanair.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ static int iguanair_probe(struct usb_interface *intf,
usb_to_input_id(ir->udev, &rc->input_id);
rc->dev.parent = &intf->dev;
rc->driver_type = RC_DRIVER_IR_RAW;
rc_set_allowed_protocols(rc, RC_BIT_ALL);
rc->allowed_protocols = RC_BIT_ALL;
rc->priv = ir;
rc->open = iguanair_open;
rc->close = iguanair_close;
Expand Down
16 changes: 8 additions & 8 deletions drivers/media/rc/img-ir/img-ir-hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,8 @@ static void img_ir_set_decoder(struct img_ir_priv *priv,
hw->mode = IMG_IR_M_NORMAL;

/* clear the wakeup scancode filter */
rdev->scancode_filters[RC_FILTER_WAKEUP].data = 0;
rdev->scancode_filters[RC_FILTER_WAKEUP].mask = 0;
rdev->scancode_wakeup_filter.data = 0;
rdev->scancode_wakeup_filter.mask = 0;

/* clear raw filters */
_img_ir_set_filter(priv, NULL);
Expand Down Expand Up @@ -661,8 +661,8 @@ static int img_ir_change_protocol(struct rc_dev *dev, u64 *ir_type)
wakeup_protocols = *ir_type;
if (!hw->decoder || !hw->decoder->filter)
wakeup_protocols = 0;
rc_set_allowed_wakeup_protocols(rdev, wakeup_protocols);
rc_set_enabled_wakeup_protocols(rdev, wakeup_protocols);
rdev->allowed_wakeup_protocols = wakeup_protocols;
rdev->enabled_wakeup_protocols = wakeup_protocols;
return 0;
}

Expand All @@ -676,9 +676,9 @@ static void img_ir_set_protocol(struct img_ir_priv *priv, u64 proto)
spin_unlock_irq(&rdev->rc_map.lock);

mutex_lock(&rdev->lock);
rc_set_enabled_protocols(rdev, proto);
rc_set_allowed_wakeup_protocols(rdev, proto);
rc_set_enabled_wakeup_protocols(rdev, proto);
rdev->enabled_protocols = proto;
rdev->allowed_wakeup_protocols = proto;
rdev->enabled_wakeup_protocols = proto;
mutex_unlock(&rdev->lock);
}

Expand Down Expand Up @@ -1003,7 +1003,7 @@ int img_ir_probe_hw(struct img_ir_priv *priv)
}
rdev->priv = priv;
rdev->map_name = RC_MAP_EMPTY;
rc_set_allowed_protocols(rdev, img_ir_allowed_protos(priv));
rdev->allowed_protocols = img_ir_allowed_protos(priv);
rdev->input_name = "IMG Infrared Decoder";
rdev->s_filter = img_ir_set_normal_filter;
rdev->s_wakeup_filter = img_ir_set_wakeup_filter;
Expand Down
7 changes: 3 additions & 4 deletions drivers/media/rc/imon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 *rc_type)
unsigned char ir_proto_packet[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 };

if (*rc_type && !rc_protocols_allowed(rc, *rc_type))
if (*rc_type && !(*rc_type & rc->allowed_protocols))
dev_warn(dev, "Looks like you're trying to use an IR protocol "
"this device does not support\n");

Expand Down Expand Up @@ -1870,8 +1870,7 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)

rdev->priv = ictx;
rdev->driver_type = RC_DRIVER_SCANCODE;
/* iMON PAD or MCE */
rc_set_allowed_protocols(rdev, RC_BIT_OTHER | RC_BIT_RC6_MCE);
rdev->allowed_protocols = RC_BIT_OTHER | RC_BIT_RC6_MCE; /* iMON PAD or MCE */
rdev->change_protocol = imon_ir_change_protocol;
rdev->driver_name = MOD_NAME;

Expand All @@ -1884,7 +1883,7 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)

if (ictx->product == 0xffdc) {
imon_get_ffdc_type(ictx);
rc_set_allowed_protocols(rdev, ictx->rc_type);
rdev->allowed_protocols = ictx->rc_type;
}

imon_set_display_type(ictx);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/ir-jvc-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int ir_jvc_decode(struct rc_dev *dev, struct ir_raw_event ev)
{
struct jvc_dec *data = &dev->raw->jvc;

if (!rc_protocols_enabled(dev, RC_BIT_JVC))
if (!(dev->enabled_protocols & RC_BIT_JVC))
return 0;

if (!is_timing_event(ev)) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/ir-lirc-codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev)
struct lirc_codec *lirc = &dev->raw->lirc;
int sample;

if (!rc_protocols_enabled(dev, RC_BIT_LIRC))
if (!(dev->enabled_protocols & RC_BIT_LIRC))
return 0;

if (!dev->raw->lirc.drv || !dev->raw->lirc.drv->rbuf)
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/ir-mce_kbd-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev)
u32 scancode;
unsigned long delay;

if (!rc_protocols_enabled(dev, RC_BIT_MCE_KBD))
if (!(dev->enabled_protocols & RC_BIT_MCE_KBD))
return 0;

if (!is_timing_event(ev)) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/ir-nec-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
u8 address, not_address, command, not_command;
bool send_32bits = false;

if (!rc_protocols_enabled(dev, RC_BIT_NEC))
if (!(dev->enabled_protocols & RC_BIT_NEC))
return 0;

if (!is_timing_event(ev)) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/ir-raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ int ir_raw_event_register(struct rc_dev *dev)
return -ENOMEM;

dev->raw->dev = dev;
rc_set_enabled_protocols(dev, ~0);
dev->enabled_protocols = ~0;
dev->change_protocol = change_protocol;
rc = kfifo_alloc(&dev->raw->kfifo,
sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE,
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/rc/ir-rc5-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
u32 scancode;
enum rc_type protocol;

if (!rc_protocols_enabled(dev, RC_BIT_RC5 | RC_BIT_RC5X))
if (!(dev->enabled_protocols & (RC_BIT_RC5 | RC_BIT_RC5X)))
return 0;

if (!is_timing_event(ev)) {
Expand Down Expand Up @@ -129,7 +129,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
if (data->wanted_bits == RC5X_NBITS) {
/* RC5X */
u8 xdata, command, system;
if (!rc_protocols_enabled(dev, RC_BIT_RC5X)) {
if (!(dev->enabled_protocols & RC_BIT_RC5X)) {
data->state = STATE_INACTIVE;
return 0;
}
Expand All @@ -147,7 +147,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
} else {
/* RC5 */
u8 command, system;
if (!rc_protocols_enabled(dev, RC_BIT_RC5)) {
if (!(dev->enabled_protocols & RC_BIT_RC5)) {
data->state = STATE_INACTIVE;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/ir-rc5-sz-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static int ir_rc5_sz_decode(struct rc_dev *dev, struct ir_raw_event ev)
u8 toggle, command, system;
u32 scancode;

if (!rc_protocols_enabled(dev, RC_BIT_RC5_SZ))
if (!(dev->enabled_protocols & RC_BIT_RC5_SZ))
return 0;

if (!is_timing_event(ev)) {
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/rc/ir-rc6-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
u8 toggle;
enum rc_type protocol;

if (!rc_protocols_enabled(dev, RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 |
RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 |
RC_BIT_RC6_MCE))
if (!(dev->enabled_protocols &
(RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 |
RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE)))
return 0;

if (!is_timing_event(ev)) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/ir-sanyo-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev)
u32 scancode;
u8 address, command, not_command;

if (!rc_protocols_enabled(dev, RC_BIT_SANYO))
if (!(dev->enabled_protocols & RC_BIT_SANYO))
return 0;

if (!is_timing_event(ev)) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/ir-sharp-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static int ir_sharp_decode(struct rc_dev *dev, struct ir_raw_event ev)
struct sharp_dec *data = &dev->raw->sharp;
u32 msg, echo, address, command, scancode;

if (!rc_protocols_enabled(dev, RC_BIT_SHARP))
if (!(dev->enabled_protocols & RC_BIT_SHARP))
return 0;

if (!is_timing_event(ev)) {
Expand Down
10 changes: 5 additions & 5 deletions drivers/media/rc/ir-sony-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
u32 scancode;
u8 device, subdevice, function;

if (!rc_protocols_enabled(dev, RC_BIT_SONY12 | RC_BIT_SONY15 |
RC_BIT_SONY20))
if (!(dev->enabled_protocols &
(RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20)))
return 0;

if (!is_timing_event(ev)) {
Expand Down Expand Up @@ -125,7 +125,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)

switch (data->count) {
case 12:
if (!rc_protocols_enabled(dev, RC_BIT_SONY12)) {
if (!(dev->enabled_protocols & RC_BIT_SONY12)) {
data->state = STATE_INACTIVE;
return 0;
}
Expand All @@ -135,7 +135,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
protocol = RC_TYPE_SONY12;
break;
case 15:
if (!rc_protocols_enabled(dev, RC_BIT_SONY15)) {
if (!(dev->enabled_protocols & RC_BIT_SONY15)) {
data->state = STATE_INACTIVE;
return 0;
}
Expand All @@ -145,7 +145,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
protocol = RC_TYPE_SONY15;
break;
case 20:
if (!rc_protocols_enabled(dev, RC_BIT_SONY20)) {
if (!(dev->enabled_protocols & RC_BIT_SONY20)) {
data->state = STATE_INACTIVE;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/ite-cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
/* set up ir-core props */
rdev->priv = itdev;
rdev->driver_type = RC_DRIVER_IR_RAW;
rc_set_allowed_protocols(rdev, RC_BIT_ALL);
rdev->allowed_protocols = RC_BIT_ALL;
rdev->open = ite_open;
rdev->close = ite_close;
rdev->s_idle = ite_s_idle;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/mceusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
rc->dev.parent = dev;
rc->priv = ir;
rc->driver_type = RC_DRIVER_IR_RAW;
rc_set_allowed_protocols(rc, RC_BIT_ALL);
rc->allowed_protocols = RC_BIT_ALL;
rc->timeout = MS_TO_NS(100);
if (!ir->flags.no_tx) {
rc->s_tx_mask = mceusb_set_tx_mask;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/nuvoton-cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
/* Set up the rc device */
rdev->priv = nvt;
rdev->driver_type = RC_DRIVER_IR_RAW;
rc_set_allowed_protocols(rdev, RC_BIT_ALL);
rdev->allowed_protocols = RC_BIT_ALL;
rdev->open = nvt_open;
rdev->close = nvt_close;
rdev->tx_ir = nvt_tx_ir;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/rc-loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static int __init loop_init(void)
rc->map_name = RC_MAP_EMPTY;
rc->priv = &loopdev;
rc->driver_type = RC_DRIVER_IR_RAW;
rc_set_allowed_protocols(rc, RC_BIT_ALL);
rc->allowed_protocols = RC_BIT_ALL;
rc->timeout = 100 * 1000 * 1000; /* 100 ms */
rc->min_timeout = 1;
rc->max_timeout = UINT_MAX;
Expand Down
Loading

0 comments on commit c5540fb

Please sign in to comment.