Re: [PATCH v2 1/7] [media] rc-main: assign driver type during allocation
Hi Sean, > > 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; > > > > If ir->sampling = 0 then it should be RC_DRIVER_SCANCODE. > > > > @@ -481,7 +481,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; > > That assignment shouldn't really be there any more. I think this doesn't change the driver's behavior, because I either do like: - dev = rc_allocate_device(); + dev = rc_allocate_device(RC_DRIVER_SCANCODE); [ ... ] if (ir->sampling) { dev->driver_type = RC_DRIVER_IR_RAW; dev->timeout = 10 * 1000 * 1000; /* 10 ms */ } else { - dev->driver_type = RC_DRIVER_SCANCODE; Or I would need to do aftr the long switch...case statement + if (ir->sampling) { + dev = rc_allocate_device(RC_DRIVER_IR_RAW); + ... + } else { + dev = rc_allocate_device(RC_DRIVER_SCANCODE); + ... I prefered the first way because it doesn't alter much the driver. > > 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; > > This is not correct, I'm afraid. If you look at the code you can see that > if raw_decode is true, then it should be RC_DRIVER_IR_RAW. Same here, the driver doesn't change the behavior. raw_decode can be both 'true' or 'false' it's set as default RC_DRIVER_SCANCODE and depending on value of raw_decode it's chaged to RC_DRIVER_IR_RAW. also in this case I can do + if (raw_decode) { + rc = rc_allocate_device(RC_DRIVER_IR_RAW); + ... + } else { + rc = rc_allocate_device(RC_DRIVER_SCANCODE); + ... but also in this case my original approach doesn't add much changes. Thanks, Andi -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/7] [media] rc-main: assign driver type during allocation
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 YoungSigned-off-by: Andi Shyti --- drivers/hid/hid-picolcd_cir.c | 3 +-- drivers/media/common/siano/smsir.c | 3 +-- drivers/media/i2c/ir-kbd-i2c.c | 2 +- drivers/media/pci/bt8xx/bttv-input.c| 2 +- drivers/media/pci/cx23885/cx23885-input.c | 11 +-- drivers/media/pci/cx88/cx88-input.c | 3 +-- drivers/media/pci/dm1105/dm1105.c | 3 +-- drivers/media/pci/mantis/mantis_input.c | 2 +- drivers/media/pci/saa7134/saa7134-input.c | 2 +- drivers/media/pci/smipcie/smipcie-ir.c | 3 +-- drivers/media/pci/ttpci/budget-ci.c | 2 +- drivers/media/rc/ati_remote.c | 3 +-- drivers/media/rc/ene_ir.c | 3 +-- drivers/media/rc/fintek-cir.c | 3 +-- drivers/media/rc/gpio-ir-recv.c | 3 +-- drivers/media/rc/igorplugusb.c | 3 +-- drivers/media/rc/iguanair.c | 3 +-- drivers/media/rc/img-ir/img-ir-hw.c | 2 +- drivers/media/rc/img-ir/img-ir-raw.c| 3 +-- drivers/media/rc/imon.c | 3 +-- drivers/media/rc/ir-hix5hd2.c | 3 +-- drivers/media/rc/ite-cir.c | 3 +-- drivers/media/rc/mceusb.c | 3 +-- drivers/media/rc/meson-ir.c | 3 +-- drivers/media/rc/nuvoton-cir.c | 3 +-- drivers/media/rc/rc-loopback.c | 3 +-- drivers/media/rc/rc-main.c | 4 +++- drivers/media/rc/redrat3.c | 3 +-- drivers/media/rc/st_rc.c| 3 +-- drivers/media/rc/streamzap.c| 3 +-- drivers/media/rc/sunxi-cir.c| 3 +-- drivers/media/rc/ttusbir.c | 3 +-- drivers/media/rc/winbond-cir.c | 3 +-- drivers/media/usb/au0828/au0828-input.c | 3 +-- drivers/media/usb/cx231xx/cx231xx-input.c | 2 +- drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 3 +-- drivers/media/usb/dvb-usb/dvb-usb-remote.c | 3 +-- drivers/media/usb/em28xx/em28xx-input.c | 2 +- drivers/media/usb/tm6000/tm6000-input.c | 3 +-- drivers/staging/media/cec/cec-core.c| 3 +-- include/media/rc-core.h | 4 +++- 41 files changed, 45 insertions(+), 80 deletions(-) diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c index 9628651..38b0ea8 100644 --- a/drivers/hid/hid-picolcd_cir.c +++ b/drivers/hid/hid-picolcd_cir.c @@ -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; rdev->open = picolcd_cir_open; rdev->close= picolcd_cir_close; diff --git a/drivers/media/common/siano/smsir.c b/drivers/media/common/siano/smsir.c index 41f2a39..ee30c7b 100644 --- a/drivers/media/common/siano/smsir.c +++ b/drivers/media/common/siano/smsir.c @@ -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; @@ -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; dev->map_name = sms_get_board(board_id)->rc_codes; dev->driver_name = MODULE_NAME; diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index bf82726..918fd7d 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c @@ -398,7 +398,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; } diff --git
Re: [PATCH v2 1/7] [media] rc-main: assign driver type during allocation
On Fri, Sep 02, 2016 at 02:16:23AM +0900, Andi Shyti wrote: > 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> Signed-off-by: Andi Shyti > --- ... > diff --git a/drivers/media/pci/cx88/cx88-input.c > b/drivers/media/pci/cx88/cx88-input.c > index 3f1342c..e52bf69 100644 > --- a/drivers/media/pci/cx88/cx88-input.c > +++ b/drivers/media/pci/cx88/cx88-input.c > @@ -271,7 +271,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; > If ir->sampling = 0 then it should be RC_DRIVER_SCANCODE. > @@ -481,7 +481,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; That assignment shouldn't really be there any more. > diff --git a/drivers/media/pci/saa7134/saa7134-input.c > b/drivers/media/pci/saa7134/saa7134-input.c > index c8042c3..e9d4a47 100644 > --- a/drivers/media/pci/saa7134/saa7134-input.c > +++ b/drivers/media/pci/saa7134/saa7134-input.c > @@ -849,7 +849,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; This is not correct, I'm afraid. If you look at the code you can see that if raw_decode is true, then it should be RC_DRIVER_IR_RAW. Sean -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html