[PATCH 5/5] staging: media: lirc: use new parport device model
Modify lirc_parallel driver to use the new parallel port device model. Signed-off-by: Sudip Mukherjee --- drivers/staging/media/lirc/lirc_parallel.c | 100 +++-- 1 file changed, 65 insertions(+), 35 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_parallel.c b/drivers/staging/media/lirc/lirc_parallel.c index 0156114..20ec9b6 100644 --- a/drivers/staging/media/lirc/lirc_parallel.c +++ b/drivers/staging/media/lirc/lirc_parallel.c @@ -629,43 +629,26 @@ static void kf(void *handle) */ } -/*** module initialization and cleanup ***/ - -static int __init lirc_parallel_init(void) +static void lirc_parallel_attach(struct parport *port) { - int result; + struct pardev_cb lirc_parallel_cb; - result = platform_driver_register(&lirc_parallel_driver); - if (result) { - pr_notice("platform_driver_register returned %d\n", result); - return result; - } + if (port->base != io) + return; - lirc_parallel_dev = platform_device_alloc(LIRC_DRIVER_NAME, 0); - if (!lirc_parallel_dev) { - result = -ENOMEM; - goto exit_driver_unregister; - } + pport = port; + memset(&lirc_parallel_cb, 0, sizeof(lirc_parallel_cb)); + lirc_parallel_cb.preempt = pf; + lirc_parallel_cb.wakeup = kf; + lirc_parallel_cb.irq_func = lirc_lirc_irq_handler; - result = platform_device_add(lirc_parallel_dev); - if (result) - goto exit_device_put; - - pport = parport_find_base(io); - if (!pport) { - pr_notice("no port at %x found\n", io); - result = -ENXIO; - goto exit_device_put; - } - ppdevice = parport_register_device(pport, LIRC_DRIVER_NAME, - pf, kf, lirc_lirc_irq_handler, 0, - NULL); - parport_put_port(pport); + ppdevice = parport_register_dev_model(port, LIRC_DRIVER_NAME, + &lirc_parallel_cb, 0); if (!ppdevice) { pr_notice("parport_register_device() failed\n"); - result = -ENXIO; - goto exit_device_put; + return; } + if (parport_claim(ppdevice) != 0) goto skip_init; is_claimed = 1; @@ -693,18 +676,66 @@ static int __init lirc_parallel_init(void) is_claimed = 0; parport_release(ppdevice); - skip_init: + +skip_init: + return; +} + +static void lirc_parallel_detach(struct parport *port) +{ + if (port->base != io) + return; + + parport_unregister_device(ppdevice); +} + +static struct parport_driver lirc_parport_driver = { + .name = LIRC_DRIVER_NAME, + .match_port = lirc_parallel_attach, + .detach = lirc_parallel_detach, + .devmodel = true, +}; + +/*** module initialization and cleanup ***/ + +static int __init lirc_parallel_init(void) +{ + int result; + + result = platform_driver_register(&lirc_parallel_driver); + if (result) { + pr_notice("platform_driver_register returned %d\n", result); + return result; + } + + lirc_parallel_dev = platform_device_alloc(LIRC_DRIVER_NAME, 0); + if (!lirc_parallel_dev) { + result = -ENOMEM; + goto exit_driver_unregister; + } + + result = platform_device_add(lirc_parallel_dev); + if (result) + goto exit_device_put; + + result = parport_register_driver(&lirc_parport_driver); + if (result) { + pr_notice("parport_register_driver returned %d\n", result); + goto exit_device_put; + } + driver.dev = &lirc_parallel_dev->dev; driver.minor = lirc_register_driver(&driver); if (driver.minor < 0) { pr_notice("register_chrdev() failed\n"); - parport_unregister_device(ppdevice); result = -EIO; - goto exit_device_put; + goto exit_unregister; } pr_info("installed using port 0x%04x irq %d\n", io, irq); return 0; +exit_unregister: + parport_unregister_driver(&lirc_parport_driver); exit_device_put: platform_device_put(lirc_parallel_dev); exit_driver_unregister: @@ -714,9 +745,8 @@ exit_driver_unregister: static void __exit lirc_parallel_exit(void) { - parport_unregister_device(ppdevice); lirc_unregister_driver(driver.minor); - + parport_unregister_driver(&lirc_parport_driver); platform_device_unregister(lirc_parallel_dev); platform_driver_unregister(&lirc_parallel_driver); } -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 5/5] staging: media: lirc: use new parport device model
On Monday 25 January 2016 10:42 PM, Mauro Carvalho Chehab wrote: Em Mon, 25 Jan 2016 22:32:31 +0530 Sudip Mukherjee escreveu: On Mon, Jan 25, 2016 at 02:29:06PM -0200, Mauro Carvalho Chehab wrote: Em Fri, 18 Dec 2015 18:35:29 +0530 Sudip Mukherjee escreveu: Modify lirc_parallel driver to use the new parallel port device model. Did you or someone else tested this patch? Only build tested and tested by inserting and removing the module. But since the only change is in the way it registers and nothing else so it should not break. It would be worth to wait for a while in the hope that someone could test with a real hardware. Hi Mauro, Since no one has commented on the patch till now, maybe you can merge now, or do i need to resend? Regards Sudip ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 5/5] staging: media: lirc: use new parport device model
On Mon, Jan 25, 2016 at 03:12:57PM -0200, Mauro Carvalho Chehab wrote: > Em Mon, 25 Jan 2016 22:32:31 +0530 > Sudip Mukherjee escreveu: > > > On Mon, Jan 25, 2016 at 02:29:06PM -0200, Mauro Carvalho Chehab wrote: > > > Em Fri, 18 Dec 2015 18:35:29 +0530 > > > Sudip Mukherjee escreveu: > > > > > > > Modify lirc_parallel driver to use the new parallel port device model. > > > > > > Did you or someone else tested this patch? > > > > Only build tested and tested by inserting and removing the module. > > But since the only change is in the way it registers and nothing else > > so it should not break. > > It would be worth to wait for a while in the hope that someone could > test with a real hardware. Hi Mauro, Merge window is almost going to open. Maybe now you can consider applying it. regards sudip ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 5/5] staging: media: lirc: use new parport device model
Em Fri, 18 Dec 2015 18:35:29 +0530 Sudip Mukherjee escreveu: > Modify lirc_parallel driver to use the new parallel port device model. Did you or someone else tested this patch? Regards, Mauro > > Signed-off-by: Sudip Mukherjee > --- > drivers/staging/media/lirc/lirc_parallel.c | 100 > +++-- > 1 file changed, 65 insertions(+), 35 deletions(-) > > diff --git a/drivers/staging/media/lirc/lirc_parallel.c > b/drivers/staging/media/lirc/lirc_parallel.c > index 0156114..20ec9b6 100644 > --- a/drivers/staging/media/lirc/lirc_parallel.c > +++ b/drivers/staging/media/lirc/lirc_parallel.c > @@ -629,43 +629,26 @@ static void kf(void *handle) > */ > } > > -/*** module initialization and cleanup ***/ > - > -static int __init lirc_parallel_init(void) > +static void lirc_parallel_attach(struct parport *port) > { > - int result; > + struct pardev_cb lirc_parallel_cb; > > - result = platform_driver_register(&lirc_parallel_driver); > - if (result) { > - pr_notice("platform_driver_register returned %d\n", result); > - return result; > - } > + if (port->base != io) > + return; > > - lirc_parallel_dev = platform_device_alloc(LIRC_DRIVER_NAME, 0); > - if (!lirc_parallel_dev) { > - result = -ENOMEM; > - goto exit_driver_unregister; > - } > + pport = port; > + memset(&lirc_parallel_cb, 0, sizeof(lirc_parallel_cb)); > + lirc_parallel_cb.preempt = pf; > + lirc_parallel_cb.wakeup = kf; > + lirc_parallel_cb.irq_func = lirc_lirc_irq_handler; > > - result = platform_device_add(lirc_parallel_dev); > - if (result) > - goto exit_device_put; > - > - pport = parport_find_base(io); > - if (!pport) { > - pr_notice("no port at %x found\n", io); > - result = -ENXIO; > - goto exit_device_put; > - } > - ppdevice = parport_register_device(pport, LIRC_DRIVER_NAME, > -pf, kf, lirc_lirc_irq_handler, 0, > -NULL); > - parport_put_port(pport); > + ppdevice = parport_register_dev_model(port, LIRC_DRIVER_NAME, > + &lirc_parallel_cb, 0); > if (!ppdevice) { > pr_notice("parport_register_device() failed\n"); > - result = -ENXIO; > - goto exit_device_put; > + return; > } > + > if (parport_claim(ppdevice) != 0) > goto skip_init; > is_claimed = 1; > @@ -693,18 +676,66 @@ static int __init lirc_parallel_init(void) > > is_claimed = 0; > parport_release(ppdevice); > - skip_init: > + > +skip_init: > + return; > +} > + > +static void lirc_parallel_detach(struct parport *port) > +{ > + if (port->base != io) > + return; > + > + parport_unregister_device(ppdevice); > +} > + > +static struct parport_driver lirc_parport_driver = { > + .name = LIRC_DRIVER_NAME, > + .match_port = lirc_parallel_attach, > + .detach = lirc_parallel_detach, > + .devmodel = true, > +}; > + > +/*** module initialization and cleanup ***/ > + > +static int __init lirc_parallel_init(void) > +{ > + int result; > + > + result = platform_driver_register(&lirc_parallel_driver); > + if (result) { > + pr_notice("platform_driver_register returned %d\n", result); > + return result; > + } > + > + lirc_parallel_dev = platform_device_alloc(LIRC_DRIVER_NAME, 0); > + if (!lirc_parallel_dev) { > + result = -ENOMEM; > + goto exit_driver_unregister; > + } > + > + result = platform_device_add(lirc_parallel_dev); > + if (result) > + goto exit_device_put; > + > + result = parport_register_driver(&lirc_parport_driver); > + if (result) { > + pr_notice("parport_register_driver returned %d\n", result); > + goto exit_device_put; > + } > + > driver.dev = &lirc_parallel_dev->dev; > driver.minor = lirc_register_driver(&driver); > if (driver.minor < 0) { > pr_notice("register_chrdev() failed\n"); > - parport_unregister_device(ppdevice); > result = -EIO; > - goto exit_device_put; > + goto exit_unregister; > } > pr_info("installed using port 0x%04x irq %d\n", io, irq); > return 0; > > +exit_unregister: > + parport_unregister_driver(&lirc_parport_driver); > exit_device_put: > platform_device_put(lirc_parallel_dev); > exit_driver_unregister: > @@ -714,9 +745,8 @@ exit_driver_unregister: > > static void __exit lirc_parallel_exit(void) > { > - parport_unregister_device(ppdevice); > lirc_unregister_driver(driver.minor); > - > + parport_unregister_driver(&lirc_parport_driver); > platform_device_unregister(lirc_parallel_dev); > platform_driver_unregister(&lirc_pa
Re: [PATCH 5/5] staging: media: lirc: use new parport device model
On Mon, Jan 25, 2016 at 02:29:06PM -0200, Mauro Carvalho Chehab wrote: > Em Fri, 18 Dec 2015 18:35:29 +0530 > Sudip Mukherjee escreveu: > > > Modify lirc_parallel driver to use the new parallel port device model. > > Did you or someone else tested this patch? Only build tested and tested by inserting and removing the module. But since the only change is in the way it registers and nothing else so it should not break. Only patch 1/5 is applying now. I will send v2 after removing patch 4/5. regards sudip ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 5/5] staging: media: lirc: use new parport device model
Em Mon, 25 Jan 2016 22:32:31 +0530 Sudip Mukherjee escreveu: > On Mon, Jan 25, 2016 at 02:29:06PM -0200, Mauro Carvalho Chehab wrote: > > Em Fri, 18 Dec 2015 18:35:29 +0530 > > Sudip Mukherjee escreveu: > > > > > Modify lirc_parallel driver to use the new parallel port device model. > > > > Did you or someone else tested this patch? > > Only build tested and tested by inserting and removing the module. > But since the only change is in the way it registers and nothing else > so it should not break. It would be worth to wait for a while in the hope that someone could test with a real hardware. > > Only patch 1/5 is applying now. I will send v2 after removing patch 4/5. I applied the other patches, with some fixes from my side. > > regards > sudip ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 5/5] staging: media: lirc: use new parport device model
On Monday 25 January 2016 10:42 PM, Mauro Carvalho Chehab wrote: Em Mon, 25 Jan 2016 22:32:31 +0530 Sudip Mukherjee escreveu: On Mon, Jan 25, 2016 at 02:29:06PM -0200, Mauro Carvalho Chehab wrote: Em Fri, 18 Dec 2015 18:35:29 +0530 Sudip Mukherjee escreveu: Modify lirc_parallel driver to use the new parallel port device model. Did you or someone else tested this patch? Only build tested and tested by inserting and removing the module. But since the only change is in the way it registers and nothing else so it should not break. It would be worth to wait for a while in the hope that someone could test with a real hardware. Sure, we have lots of time for 4.6 merge window. May be if you have the schematic somewhere then I can try to build one. Its a Homebrew one, so maybe I can try. regards sudip ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 5/5] staging: media: lirc: use new parport device model
Em Mon, 25 Jan 2016 23:03:43 +0530 Sudip Mukherjee escreveu: > On Monday 25 January 2016 10:42 PM, Mauro Carvalho Chehab wrote: > > Em Mon, 25 Jan 2016 22:32:31 +0530 > > Sudip Mukherjee escreveu: > > > >> On Mon, Jan 25, 2016 at 02:29:06PM -0200, Mauro Carvalho Chehab wrote: > >>> Em Fri, 18 Dec 2015 18:35:29 +0530 > >>> Sudip Mukherjee escreveu: > >>> > Modify lirc_parallel driver to use the new parallel port device model. > >>> > >>> Did you or someone else tested this patch? > >> > >> Only build tested and tested by inserting and removing the module. > >> But since the only change is in the way it registers and nothing else > >> so it should not break. > > > > It would be worth to wait for a while in the hope that someone could > > test with a real hardware. > > Sure, we have lots of time for 4.6 merge window. May be if you have the > schematic somewhere then I can try to build one. Its a Homebrew one, so > maybe I can try. Take a look at: http://www.lirc.org/parallel.html Regards, Mauro > > regards > sudip > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel