All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var
@ 2015-12-18 13:05 Sudip Mukherjee
  2015-12-18 13:05 ` [PATCH 2/5] staging: media: lirc: no space after cast Sudip Mukherjee
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Sudip Mukherjee @ 2015-12-18 13:05 UTC (permalink / raw)
  To: Jarod Wilson, Mauro Carvalho Chehab, Greg Kroah-Hartman
  Cc: linux-kernel, linux-media, devel, Sudip Mukherjee

A NULL comparison can be written as if (var) or if (!var).
Reported by checkpatch.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/staging/media/lirc/lirc_parallel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_parallel.c b/drivers/staging/media/lirc/lirc_parallel.c
index c140834..9df8d14 100644
--- a/drivers/staging/media/lirc/lirc_parallel.c
+++ b/drivers/staging/media/lirc/lirc_parallel.c
@@ -652,7 +652,7 @@ static int __init lirc_parallel_init(void)
 		goto exit_device_put;
 
 	pport = parport_find_base(io);
-	if (pport == NULL) {
+	if (!pport) {
 		pr_notice("no port at %x found\n", io);
 		result = -ENXIO;
 		goto exit_device_put;
@@ -661,7 +661,7 @@ static int __init lirc_parallel_init(void)
 					   pf, kf, lirc_lirc_irq_handler, 0,
 					   NULL);
 	parport_put_port(pport);
-	if (ppdevice == NULL) {
+	if (!ppdevice) {
 		pr_notice("parport_register_device() failed\n");
 		result = -ENXIO;
 		goto exit_device_put;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/5] staging: media: lirc: no space after cast
  2015-12-18 13:05 [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var Sudip Mukherjee
@ 2015-12-18 13:05 ` Sudip Mukherjee
  2015-12-18 13:05 ` [PATCH 3/5] staging: media: lirc: space around operator Sudip Mukherjee
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Sudip Mukherjee @ 2015-12-18 13:05 UTC (permalink / raw)
  To: Jarod Wilson, Mauro Carvalho Chehab, Greg Kroah-Hartman
  Cc: linux-kernel, linux-media, devel, Sudip Mukherjee

checkpatch complains about space after type cast.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/staging/media/lirc/lirc_parallel.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_parallel.c b/drivers/staging/media/lirc/lirc_parallel.c
index 9df8d14..f65ab93 100644
--- a/drivers/staging/media/lirc/lirc_parallel.c
+++ b/drivers/staging/media/lirc/lirc_parallel.c
@@ -251,7 +251,7 @@ static void lirc_lirc_irq_handler(void *blah)
 			/* really long time */
 			data = PULSE_MASK;
 		else
-			data = (int) (signal*1000000 +
+			data = (int)(signal*1000000 +
 					 tv.tv_usec - lasttv.tv_usec +
 					 LIRC_SFH506_DELAY);
 
@@ -291,9 +291,9 @@ static void lirc_lirc_irq_handler(void *blah)
 		/* adjust value to usecs */
 		__u64 helper;
 
-		helper = ((__u64) signal)*1000000;
+		helper = ((__u64)signal)*1000000;
 		do_div(helper, timer);
-		signal = (long) helper;
+		signal = (long)helper;
 
 		if (signal > LIRC_SFH506_DELAY)
 			data = signal - LIRC_SFH506_DELAY;
@@ -398,9 +398,9 @@ static ssize_t lirc_write(struct file *filep, const char __user *buf, size_t n,
 	for (i = 0; i < count; i++) {
 		__u64 helper;
 
-		helper = ((__u64) wbuf[i])*timer;
+		helper = ((__u64)wbuf[i])*timer;
 		do_div(helper, 1000000);
-		wbuf[i] = (int) helper;
+		wbuf[i] = (int)helper;
 	}
 
 	local_irq_save(flags);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/5] staging: media: lirc: space around operator
  2015-12-18 13:05 [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var Sudip Mukherjee
  2015-12-18 13:05 ` [PATCH 2/5] staging: media: lirc: no space after cast Sudip Mukherjee
@ 2015-12-18 13:05 ` Sudip Mukherjee
  2015-12-18 13:05 ` [PATCH 4/5] staging: media: lirc: place operator on previous line Sudip Mukherjee
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Sudip Mukherjee @ 2015-12-18 13:05 UTC (permalink / raw)
  To: Jarod Wilson, Mauro Carvalho Chehab, Greg Kroah-Hartman
  Cc: linux-kernel, linux-media, devel, Sudip Mukherjee

checkpatch complains about missing space around operators.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/staging/media/lirc/lirc_parallel.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_parallel.c b/drivers/staging/media/lirc/lirc_parallel.c
index f65ab93..e09894d 100644
--- a/drivers/staging/media/lirc/lirc_parallel.c
+++ b/drivers/staging/media/lirc/lirc_parallel.c
@@ -161,17 +161,17 @@ static unsigned int init_lirc_timer(void)
 			     || (now.tv_sec == tv.tv_sec
 				 && now.tv_usec < tv.tv_usec)));
 
-	timeelapsed = (now.tv_sec + 1 - tv.tv_sec)*1000000
+	timeelapsed = (now.tv_sec + 1 - tv.tv_sec) * 1000000
 		     + (now.tv_usec - tv.tv_usec);
 	if (count >= 1000 && timeelapsed > 0) {
 		if (default_timer == 0) {
 			/* autodetect timer */
-			newtimer = (1000000*count)/timeelapsed;
+			newtimer = (1000000 * count) / timeelapsed;
 			pr_info("%u Hz timer detected\n", newtimer);
 			return newtimer;
 		}
-		newtimer = (1000000*count)/timeelapsed;
-		if (abs(newtimer - default_timer) > default_timer/10) {
+		newtimer = (1000000 * count) / timeelapsed;
+		if (abs(newtimer - default_timer) > default_timer / 10) {
 			/* bad timer */
 			pr_notice("bad timer: %u Hz\n", newtimer);
 			pr_notice("using default timer: %u Hz\n",
@@ -196,7 +196,7 @@ static int lirc_claim(void)
 			return 0;
 		}
 	}
-	out(LIRC_LP_CONTROL, LP_PSELECP|LP_PINITP);
+	out(LIRC_LP_CONTROL, LP_PSELECP | LP_PINITP);
 	is_claimed = 1;
 	return 1;
 }
@@ -251,7 +251,7 @@ static void lirc_lirc_irq_handler(void *blah)
 			/* really long time */
 			data = PULSE_MASK;
 		else
-			data = (int)(signal*1000000 +
+			data = (int)(signal * 1000000 +
 					 tv.tv_usec - lasttv.tv_usec +
 					 LIRC_SFH506_DELAY);
 
@@ -269,7 +269,7 @@ static void lirc_lirc_irq_handler(void *blah)
 		init = 1;
 	}
 
-	timeout = timer/10;	/* timeout after 1/10 sec. */
+	timeout = timer / 10;	/* timeout after 1/10 sec. */
 	signal = 1;
 	level = lirc_get_timer();
 	do {
@@ -291,7 +291,7 @@ static void lirc_lirc_irq_handler(void *blah)
 		/* adjust value to usecs */
 		__u64 helper;
 
-		helper = ((__u64)signal)*1000000;
+		helper = ((__u64)signal) * 1000000;
 		do_div(helper, timer);
 		signal = (long)helper;
 
@@ -299,7 +299,7 @@ static void lirc_lirc_irq_handler(void *blah)
 			data = signal - LIRC_SFH506_DELAY;
 		else
 			data = 1;
-		rbuf_write(PULSE_BIT|data); /* pulse */
+		rbuf_write(PULSE_BIT | data); /* pulse */
 	}
 	do_gettimeofday(&lasttv);
 #else
@@ -336,7 +336,7 @@ static ssize_t lirc_read(struct file *filep, char __user *buf, size_t n,
 	set_current_state(TASK_INTERRUPTIBLE);
 	while (count < n) {
 		if (rptr != wptr) {
-			if (copy_to_user(buf+count, &rbuf[rptr],
+			if (copy_to_user(buf + count, &rbuf[rptr],
 					 sizeof(int))) {
 				result = -EFAULT;
 				break;
@@ -398,7 +398,7 @@ static ssize_t lirc_write(struct file *filep, const char __user *buf, size_t n,
 	for (i = 0; i < count; i++) {
 		__u64 helper;
 
-		helper = ((__u64)wbuf[i])*timer;
+		helper = ((__u64)wbuf[i]) * timer;
 		do_div(helper, 1000000);
 		wbuf[i] = (int)helper;
 	}
@@ -669,7 +669,7 @@ static int __init lirc_parallel_init(void)
 	if (parport_claim(ppdevice) != 0)
 		goto skip_init;
 	is_claimed = 1;
-	out(LIRC_LP_CONTROL, LP_PSELECP|LP_PINITP);
+	out(LIRC_LP_CONTROL, LP_PSELECP | LP_PINITP);
 
 #ifdef LIRC_TIMER
 	if (debug)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/5] staging: media: lirc: place operator on previous line
  2015-12-18 13:05 [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var Sudip Mukherjee
  2015-12-18 13:05 ` [PATCH 2/5] staging: media: lirc: no space after cast Sudip Mukherjee
  2015-12-18 13:05 ` [PATCH 3/5] staging: media: lirc: space around operator Sudip Mukherjee
@ 2015-12-18 13:05 ` Sudip Mukherjee
  2016-01-25 16:26   ` Mauro Carvalho Chehab
  2015-12-18 13:05 ` [PATCH 5/5] staging: media: lirc: use new parport device model Sudip Mukherjee
  2015-12-30  4:28 ` [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var Sudip Mukherjee
  4 siblings, 1 reply; 14+ messages in thread
From: Sudip Mukherjee @ 2015-12-18 13:05 UTC (permalink / raw)
  To: Jarod Wilson, Mauro Carvalho Chehab, Greg Kroah-Hartman
  Cc: linux-kernel, linux-media, devel, Sudip Mukherjee

checkpatch complains about the logical operator, which should be on the
previous line.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/staging/media/lirc/lirc_parallel.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_parallel.c b/drivers/staging/media/lirc/lirc_parallel.c
index e09894d..0156114 100644
--- a/drivers/staging/media/lirc/lirc_parallel.c
+++ b/drivers/staging/media/lirc/lirc_parallel.c
@@ -157,9 +157,9 @@ static unsigned int init_lirc_timer(void)
 			count++;
 		level = newlevel;
 		do_gettimeofday(&now);
-	} while (count < 1000 && (now.tv_sec < tv.tv_sec
-			     || (now.tv_sec == tv.tv_sec
-				 && now.tv_usec < tv.tv_usec)));
+	} while (count < 1000 && (now.tv_sec < tv.tv_sec ||
+				  (now.tv_sec == tv.tv_sec &&
+				   now.tv_usec < tv.tv_usec)));
 
 	timeelapsed = (now.tv_sec + 1 - tv.tv_sec) * 1000000
 		     + (now.tv_usec - tv.tv_usec);
@@ -279,8 +279,8 @@ static void lirc_lirc_irq_handler(void *blah)
 		level = newlevel;
 
 		/* giving up */
-		if (signal > timeout
-		    || (check_pselecd && (in(1) & LP_PSELECD))) {
+		if (signal > timeout ||
+		    (check_pselecd && (in(1) & LP_PSELECD))) {
 			signal = 0;
 			pr_notice("timeout\n");
 			break;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/5] staging: media: lirc: use new parport device model
  2015-12-18 13:05 [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var Sudip Mukherjee
                   ` (2 preceding siblings ...)
  2015-12-18 13:05 ` [PATCH 4/5] staging: media: lirc: place operator on previous line Sudip Mukherjee
@ 2015-12-18 13:05 ` Sudip Mukherjee
  2016-01-25 16:29   ` Mauro Carvalho Chehab
  2015-12-30  4:28 ` [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var Sudip Mukherjee
  4 siblings, 1 reply; 14+ messages in thread
From: Sudip Mukherjee @ 2015-12-18 13:05 UTC (permalink / raw)
  To: Jarod Wilson, Mauro Carvalho Chehab, Greg Kroah-Hartman
  Cc: linux-kernel, linux-media, devel, Sudip Mukherjee

Modify lirc_parallel driver to use the new parallel port device model.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var
  2015-12-18 13:05 [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var Sudip Mukherjee
                   ` (3 preceding siblings ...)
  2015-12-18 13:05 ` [PATCH 5/5] staging: media: lirc: use new parport device model Sudip Mukherjee
@ 2015-12-30  4:28 ` Sudip Mukherjee
  4 siblings, 0 replies; 14+ messages in thread
From: Sudip Mukherjee @ 2015-12-30  4:28 UTC (permalink / raw)
  To: Jarod Wilson, Mauro Carvalho Chehab, Greg Kroah-Hartman
  Cc: linux-kernel, linux-media, devel

On Fri, Dec 18, 2015 at 06:35:25PM +0530, Sudip Mukherjee wrote:
> A NULL comparison can be written as if (var) or if (!var).
> Reported by checkpatch.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---

Hi Mauro,

A gentle ping.   
Can this series be considered for 4.5?

regards
sudip

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/5] staging: media: lirc: place operator on previous line
  2015-12-18 13:05 ` [PATCH 4/5] staging: media: lirc: place operator on previous line Sudip Mukherjee
@ 2016-01-25 16:26   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 14+ messages in thread
From: Mauro Carvalho Chehab @ 2016-01-25 16:26 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: Jarod Wilson, Greg Kroah-Hartman, linux-kernel, linux-media, devel

Em Fri, 18 Dec 2015 18:35:28 +0530
Sudip Mukherjee <sudipm.mukherjee@gmail.com> escreveu:

> checkpatch complains about the logical operator, which should be on the
> previous line.

IMHO, this is a matter of personal taste. I prefer to keep the operator
on the next line, as it makes clearer to see why the logic was broken.

Anyway, this patch doesn't apply.

> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>  drivers/staging/media/lirc/lirc_parallel.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/media/lirc/lirc_parallel.c b/drivers/staging/media/lirc/lirc_parallel.c
> index e09894d..0156114 100644
> --- a/drivers/staging/media/lirc/lirc_parallel.c
> +++ b/drivers/staging/media/lirc/lirc_parallel.c
> @@ -157,9 +157,9 @@ static unsigned int init_lirc_timer(void)
>  			count++;
>  		level = newlevel;
>  		do_gettimeofday(&now);
> -	} while (count < 1000 && (now.tv_sec < tv.tv_sec
> -			     || (now.tv_sec == tv.tv_sec
> -				 && now.tv_usec < tv.tv_usec)));
> +	} while (count < 1000 && (now.tv_sec < tv.tv_sec ||
> +				  (now.tv_sec == tv.tv_sec &&
> +				   now.tv_usec < tv.tv_usec)));
>  
>  	timeelapsed = (now.tv_sec + 1 - tv.tv_sec) * 1000000
>  		     + (now.tv_usec - tv.tv_usec);
> @@ -279,8 +279,8 @@ static void lirc_lirc_irq_handler(void *blah)
>  		level = newlevel;
>  
>  		/* giving up */
> -		if (signal > timeout
> -		    || (check_pselecd && (in(1) & LP_PSELECD))) {
> +		if (signal > timeout ||
> +		    (check_pselecd && (in(1) & LP_PSELECD))) {
>  			signal = 0;
>  			pr_notice("timeout\n");
>  			break;

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] staging: media: lirc: use new parport device model
  2015-12-18 13:05 ` [PATCH 5/5] staging: media: lirc: use new parport device model Sudip Mukherjee
@ 2016-01-25 16:29   ` Mauro Carvalho Chehab
  2016-01-25 17:02     ` Sudip Mukherjee
  0 siblings, 1 reply; 14+ messages in thread
From: Mauro Carvalho Chehab @ 2016-01-25 16:29 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: Jarod Wilson, Greg Kroah-Hartman, linux-kernel, linux-media, devel

Em Fri, 18 Dec 2015 18:35:29 +0530
Sudip Mukherjee <sudipm.mukherjee@gmail.com> 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 <sudip@vectorindia.org>
> ---
>  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);
>  }

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] staging: media: lirc: use new parport device model
  2016-01-25 16:29   ` Mauro Carvalho Chehab
@ 2016-01-25 17:02     ` Sudip Mukherjee
  2016-01-25 17:12       ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 14+ messages in thread
From: Sudip Mukherjee @ 2016-01-25 17:02 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Jarod Wilson, Greg Kroah-Hartman, linux-kernel, linux-media, devel

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 <sudipm.mukherjee@gmail.com> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] staging: media: lirc: use new parport device model
  2016-01-25 17:02     ` Sudip Mukherjee
@ 2016-01-25 17:12       ` Mauro Carvalho Chehab
  2016-01-25 17:33         ` Sudip Mukherjee
                           ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Mauro Carvalho Chehab @ 2016-01-25 17:12 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: Jarod Wilson, Greg Kroah-Hartman, linux-kernel, linux-media, devel

Em Mon, 25 Jan 2016 22:32:31 +0530
Sudip Mukherjee <sudipm.mukherjee@gmail.com> 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 <sudipm.mukherjee@gmail.com> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] staging: media: lirc: use new parport device model
  2016-01-25 17:12       ` Mauro Carvalho Chehab
@ 2016-01-25 17:33         ` Sudip Mukherjee
  2016-01-25 17:40           ` Mauro Carvalho Chehab
  2016-03-03 11:49         ` Sudip Mukherjee
  2016-05-25 11:54         ` Sudip Mukherjee
  2 siblings, 1 reply; 14+ messages in thread
From: Sudip Mukherjee @ 2016-01-25 17:33 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Jarod Wilson, Greg Kroah-Hartman, linux-kernel, linux-media, devel

On Monday 25 January 2016 10:42 PM, Mauro Carvalho Chehab wrote:
> Em Mon, 25 Jan 2016 22:32:31 +0530
> Sudip Mukherjee <sudipm.mukherjee@gmail.com> 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 <sudipm.mukherjee@gmail.com> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] staging: media: lirc: use new parport device model
  2016-01-25 17:33         ` Sudip Mukherjee
@ 2016-01-25 17:40           ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 14+ messages in thread
From: Mauro Carvalho Chehab @ 2016-01-25 17:40 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: Jarod Wilson, Greg Kroah-Hartman, linux-kernel, linux-media, devel

Em Mon, 25 Jan 2016 23:03:43 +0530
Sudip Mukherjee <sudipm.mukherjee@gmail.com> escreveu:

> On Monday 25 January 2016 10:42 PM, Mauro Carvalho Chehab wrote:
> > Em Mon, 25 Jan 2016 22:32:31 +0530
> > Sudip Mukherjee <sudipm.mukherjee@gmail.com> 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 <sudipm.mukherjee@gmail.com> 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
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] staging: media: lirc: use new parport device model
  2016-01-25 17:12       ` Mauro Carvalho Chehab
  2016-01-25 17:33         ` Sudip Mukherjee
@ 2016-03-03 11:49         ` Sudip Mukherjee
  2016-05-25 11:54         ` Sudip Mukherjee
  2 siblings, 0 replies; 14+ messages in thread
From: Sudip Mukherjee @ 2016-03-03 11:49 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Jarod Wilson, Greg Kroah-Hartman, linux-kernel, linux-media, devel

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 <sudipm.mukherjee@gmail.com> 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 <sudipm.mukherjee@gmail.com> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] staging: media: lirc: use new parport device model
  2016-01-25 17:12       ` Mauro Carvalho Chehab
  2016-01-25 17:33         ` Sudip Mukherjee
  2016-03-03 11:49         ` Sudip Mukherjee
@ 2016-05-25 11:54         ` Sudip Mukherjee
  2 siblings, 0 replies; 14+ messages in thread
From: Sudip Mukherjee @ 2016-05-25 11:54 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Jarod Wilson, Greg Kroah-Hartman, linux-kernel, linux-media, devel

On Monday 25 January 2016 10:42 PM, Mauro Carvalho Chehab wrote:
> Em Mon, 25 Jan 2016 22:32:31 +0530
> Sudip Mukherjee <sudipm.mukherjee@gmail.com> 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 <sudipm.mukherjee@gmail.com> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-05-25 16:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-18 13:05 [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var Sudip Mukherjee
2015-12-18 13:05 ` [PATCH 2/5] staging: media: lirc: no space after cast Sudip Mukherjee
2015-12-18 13:05 ` [PATCH 3/5] staging: media: lirc: space around operator Sudip Mukherjee
2015-12-18 13:05 ` [PATCH 4/5] staging: media: lirc: place operator on previous line Sudip Mukherjee
2016-01-25 16:26   ` Mauro Carvalho Chehab
2015-12-18 13:05 ` [PATCH 5/5] staging: media: lirc: use new parport device model Sudip Mukherjee
2016-01-25 16:29   ` Mauro Carvalho Chehab
2016-01-25 17:02     ` Sudip Mukherjee
2016-01-25 17:12       ` Mauro Carvalho Chehab
2016-01-25 17:33         ` Sudip Mukherjee
2016-01-25 17:40           ` Mauro Carvalho Chehab
2016-03-03 11:49         ` Sudip Mukherjee
2016-05-25 11:54         ` Sudip Mukherjee
2015-12-30  4:28 ` [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var Sudip Mukherjee

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.