Skip to content

Commit

Permalink
[media] rc-main: assign driver type during allocation
Browse files Browse the repository at this point in the history
The driver type can be assigned immediately when an RC device
requests to the framework to allocate the device.

This is an 'enum rc_driver_type' data type and specifies whether
the device is a raw receiver or scancode receiver. The type will
be given as parameter to the rc_allocate_device device.

Change accordingly all the drivers calling rc_allocate_device()
so that the device type is specified during the rc device
allocation. Whenever the device type is not specified, it will be
set as RC_DRIVER_SCANCODE which was the default '0' value.

Suggested-by: Sean Young <sean@mess.org>
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
  • Loading branch information
Andi Shyti authored and Mauro Carvalho Chehab committed Jan 30, 2017
1 parent 97c1297 commit 0f7499f
Show file tree
Hide file tree
Showing 42 changed files with 50 additions and 85 deletions.
3 changes: 1 addition & 2 deletions drivers/hid/hid-picolcd_cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,11 @@ int picolcd_init_cir(struct picolcd_data *data, struct hid_report *report)
struct rc_dev *rdev;
int ret = 0;

rdev = rc_allocate_device();
rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rdev)
return -ENOMEM;

rdev->priv = data;
rdev->driver_type = RC_DRIVER_IR_RAW;
rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rdev->open = picolcd_cir_open;
rdev->close = picolcd_cir_close;
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/cec/cec-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,

#if IS_REACHABLE(CONFIG_RC_CORE)
/* Prepare the RC input device */
adap->rc = rc_allocate_device();
adap->rc = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!adap->rc) {
pr_err("cec-%s: failed to allocate memory for rc_dev\n",
name);
Expand All @@ -259,7 +259,6 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
adap->rc->input_id.vendor = 0;
adap->rc->input_id.product = 0;
adap->rc->input_id.version = 1;
adap->rc->driver_type = RC_DRIVER_SCANCODE;
adap->rc->driver_name = CEC_NAME;
adap->rc->allowed_protocols = RC_BIT_CEC;
adap->rc->priv = adap;
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/common/siano/smsir.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
struct rc_dev *dev;

pr_debug("Allocating rc device\n");
dev = rc_allocate_device();
dev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!dev)
return -ENOMEM;

Expand Down Expand Up @@ -86,7 +86,6 @@ int sms_ir_init(struct smscore_device_t *coredev)
#endif

dev->priv = coredev;
dev->driver_type = RC_DRIVER_IR_RAW;
dev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
dev->map_name = sms_get_board(board_id)->rc_codes;
dev->driver_name = MODULE_NAME;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/i2c/ir-kbd-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
* If platform_data doesn't specify rc_dev, initialize it
* internally
*/
rc = rc_allocate_device();
rc = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!rc)
return -ENOMEM;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/bt8xx/bttv-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ int bttv_input_init(struct bttv *btv)
return -ENODEV;

ir = kzalloc(sizeof(*ir),GFP_KERNEL);
rc = rc_allocate_device();
rc = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!ir || !rc)
goto err_out_free;

Expand Down
11 changes: 1 addition & 10 deletions drivers/media/pci/cx23885/cx23885-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ int cx23885_input_init(struct cx23885_dev *dev)
struct cx23885_kernel_ir *kernel_ir;
struct rc_dev *rc;
char *rc_map;
enum rc_driver_type driver_type;
u64 allowed_protos;

int ret;
Expand All @@ -285,36 +284,31 @@ int cx23885_input_init(struct cx23885_dev *dev)
case CX23885_BOARD_HAUPPAUGE_HVR1290:
case CX23885_BOARD_HAUPPAUGE_HVR1250:
/* Integrated CX2388[58] IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
/* The grey Hauppauge RC-5 remote */
rc_map = RC_MAP_HAUPPAUGE;
break;
case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
/* The grey Terratec remote with orange buttons */
rc_map = RC_MAP_NEC_TERRATEC_CINERGY_XS;
break;
case CX23885_BOARD_TEVII_S470:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
/* A guess at the remote */
rc_map = RC_MAP_TEVII_NEC;
break;
case CX23885_BOARD_MYGICA_X8507:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
/* A guess at the remote */
rc_map = RC_MAP_TOTAL_MEDIA_IN_HAND_02;
break;
case CX23885_BOARD_TBS_6980:
case CX23885_BOARD_TBS_6981:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
/* A guess at the remote */
rc_map = RC_MAP_TBS_NEC;
Expand All @@ -326,13 +320,11 @@ int cx23885_input_init(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_S952:
case CX23885_BOARD_DVBSKY_T982:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
rc_map = RC_MAP_DVBSKY;
break;
case CX23885_BOARD_TT_CT2_4500_CI:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
rc_map = RC_MAP_TT_1500;
break;
Expand All @@ -352,7 +344,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
pci_name(dev->pci));

/* input device */
rc = rc_allocate_device();
rc = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rc) {
ret = -ENOMEM;
goto err_out_free;
Expand All @@ -371,7 +363,6 @@ int cx23885_input_init(struct cx23885_dev *dev)
rc->input_id.product = dev->pci->device;
}
rc->dev.parent = &dev->pci->dev;
rc->driver_type = driver_type;
rc->allowed_protocols = allowed_protos;
rc->priv = kernel_ir;
rc->open = cx23885_input_ir_open;
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/pci/cx88/cx88-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
*/

ir = kzalloc(sizeof(*ir), GFP_KERNEL);
dev = rc_allocate_device();
dev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!ir || !dev)
goto err_out_free;

Expand Down Expand Up @@ -484,7 +484,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
dev->scancode_mask = hardware_mask;

if (ir->sampling) {
dev->driver_type = RC_DRIVER_IR_RAW;
dev->timeout = 10 * 1000 * 1000; /* 10 ms */
} else {
dev->driver_type = RC_DRIVER_SCANCODE;
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/pci/dm1105/dm1105.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ static int dm1105_ir_init(struct dm1105_dev *dm1105)
struct rc_dev *dev;
int err = -ENOMEM;

dev = rc_allocate_device();
dev = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!dev)
return -ENOMEM;

Expand All @@ -748,7 +748,6 @@ static int dm1105_ir_init(struct dm1105_dev *dm1105)

dev->driver_name = MODULE_NAME;
dev->map_name = RC_MAP_DM1105_NEC;
dev->driver_type = RC_DRIVER_SCANCODE;
dev->input_name = "DVB on-card IR receiver";
dev->input_phys = dm1105->ir.input_phys;
dev->input_id.bustype = BUS_PCI;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/mantis/mantis_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int mantis_input_init(struct mantis_pci *mantis)
struct rc_dev *dev;
int err;

dev = rc_allocate_device();
dev = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!dev) {
dprintk(MANTIS_ERROR, 1, "Remote device allocation failed");
err = -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/saa7134/saa7134-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
}

ir = kzalloc(sizeof(*ir), GFP_KERNEL);
rc = rc_allocate_device();
rc = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!ir || !rc) {
err = -ENOMEM;
goto err_out_free;
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/pci/smipcie/smipcie-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int smi_ir_init(struct smi_dev *dev)
struct rc_dev *rc_dev;
struct smi_rc *ir = &dev->ir;

rc_dev = rc_allocate_device();
rc_dev = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!rc_dev)
return -ENOMEM;

Expand All @@ -202,7 +202,6 @@ int smi_ir_init(struct smi_dev *dev)
rc_dev->input_id.product = dev->pci_dev->subsystem_device;
rc_dev->dev.parent = &dev->pci_dev->dev;

rc_dev->driver_type = RC_DRIVER_SCANCODE;
rc_dev->map_name = dev->info->rc_map;

ir->rc_dev = rc_dev;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/ttpci/budget-ci.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
struct rc_dev *dev;
int error;

dev = rc_allocate_device();
dev = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!dev) {
printk(KERN_ERR "budget_ci: IR interface initialisation failed\n");
return -ENOMEM;
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/rc/ati_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,6 @@ static void ati_remote_rc_init(struct ati_remote *ati_remote)
struct rc_dev *rdev = ati_remote->rdev;

rdev->priv = ati_remote;
rdev->driver_type = RC_DRIVER_SCANCODE;
rdev->allowed_protocols = RC_BIT_OTHER;
rdev->driver_name = "ati_remote";

Expand Down Expand Up @@ -847,7 +846,7 @@ static int ati_remote_probe(struct usb_interface *interface,
}

ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL);
rc_dev = rc_allocate_device();
rc_dev = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!ati_remote || !rc_dev)
goto exit_free_dev_rdev;

Expand Down
3 changes: 1 addition & 2 deletions drivers/media/rc/ene_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)

/* allocate memory */
dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL);
rdev = rc_allocate_device();
rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!dev || !rdev)
goto exit_free_dev_rdev;

Expand Down Expand Up @@ -1053,7 +1053,6 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
if (!dev->hw_learning_and_tx_capable)
learning_mode_force = false;

rdev->driver_type = RC_DRIVER_IR_RAW;
rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rdev->priv = dev;
rdev->open = ene_open;
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/rc/fintek-cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
return ret;

/* input device for IR remote (and tx) */
rdev = rc_allocate_device();
rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rdev)
goto exit_free_dev_rdev;

Expand Down Expand Up @@ -529,7 +529,6 @@ 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;
rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rdev->open = fintek_open;
rdev->close = fintek_close;
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/rc/gpio-ir-recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,13 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
if (!gpio_dev)
return -ENOMEM;

rcdev = rc_allocate_device();
rcdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rcdev) {
rc = -ENOMEM;
goto err_allocate_device;
}

rcdev->priv = gpio_dev;
rcdev->driver_type = RC_DRIVER_IR_RAW;
rcdev->input_name = GPIO_IR_DEVICE_NAME;
rcdev->input_phys = GPIO_IR_DEVICE_NAME "/input0";
rcdev->input_id.bustype = BUS_HOST;
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/rc/igorplugusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,14 @@ static int igorplugusb_probe(struct usb_interface *intf,

usb_make_path(udev, ir->phys, sizeof(ir->phys));

rc = rc_allocate_device();
rc = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rc)
goto fail;

rc->input_name = DRIVER_DESC;
rc->input_phys = ir->phys;
usb_to_input_id(udev, &rc->input_id);
rc->dev.parent = &intf->dev;
rc->driver_type = RC_DRIVER_IR_RAW;
/*
* This device can only store 36 pulses + spaces, which is not enough
* for the NEC protocol and many others.
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/rc/iguanair.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ static int iguanair_probe(struct usb_interface *intf,
struct usb_host_interface *idesc;

ir = kzalloc(sizeof(*ir), GFP_KERNEL);
rc = rc_allocate_device();
rc = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!ir || !rc) {
ret = -ENOMEM;
goto out;
Expand Down Expand Up @@ -490,7 +490,6 @@ static int iguanair_probe(struct usb_interface *intf,
rc->input_phys = ir->phys;
usb_to_input_id(ir->udev, &rc->input_id);
rc->dev.parent = &intf->dev;
rc->driver_type = RC_DRIVER_IR_RAW;
rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rc->priv = ir;
rc->open = iguanair_open;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/img-ir/img-ir-hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ int img_ir_probe_hw(struct img_ir_priv *priv)
}

/* Allocate hardware decoder */
hw->rdev = rdev = rc_allocate_device();
hw->rdev = rdev = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!rdev) {
dev_err(priv->dev, "cannot allocate input device\n");
error = -ENOMEM;
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/rc/img-ir/img-ir-raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,14 @@ int img_ir_probe_raw(struct img_ir_priv *priv)
setup_timer(&raw->timer, img_ir_echo_timer, (unsigned long)priv);

/* Allocate raw decoder */
raw->rdev = rdev = rc_allocate_device();
raw->rdev = rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rdev) {
dev_err(priv->dev, "cannot allocate raw input device\n");
return -ENOMEM;
}
rdev->priv = priv;
rdev->map_name = RC_MAP_EMPTY;
rdev->input_name = "IMG Infrared Decoder Raw";
rdev->driver_type = RC_DRIVER_IR_RAW;

/* Register raw decoder */
error = rc_register_device(rdev);
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/rc/imon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,7 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
const unsigned char fp_packet[] = { 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x88 };

rdev = rc_allocate_device();
rdev = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!rdev) {
dev_err(ictx->dev, "remote control dev allocation failed\n");
goto out;
Expand All @@ -1953,7 +1953,6 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
rdev->dev.parent = ictx->dev;

rdev->priv = ictx;
rdev->driver_type = RC_DRIVER_SCANCODE;
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 Down
3 changes: 1 addition & 2 deletions drivers/media/rc/ir-hix5hd2.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static int hix5hd2_ir_probe(struct platform_device *pdev)
return priv->irq;
}

rdev = rc_allocate_device();
rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rdev)
return -ENOMEM;

Expand All @@ -242,7 +242,6 @@ static int hix5hd2_ir_probe(struct platform_device *pdev)
clk_prepare_enable(priv->clock);
priv->rate = clk_get_rate(priv->clock);

rdev->driver_type = RC_DRIVER_IR_RAW;
rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rdev->priv = priv;
rdev->open = hix5hd2_ir_open;
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/rc/ite-cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
return ret;

/* input device for IR remote (and tx) */
rdev = rc_allocate_device();
rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rdev)
goto exit_free_dev_rdev;
itdev->rdev = rdev;
Expand Down Expand Up @@ -1556,7 +1556,6 @@ 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;
rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rdev->open = ite_open;
rdev->close = ite_close;
Expand Down
Loading

0 comments on commit 0f7499f

Please sign in to comment.