Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1294798 > unrolled thread

[PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var

Started bySudip Mukherjee <sudipm.mukherjee@gmail.com>
First post2015-12-18 14:10 +0100
Last post2015-12-30 05:30 +0100
Articles 5 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-12-18 14:10 +0100
    [PATCH 3/5] staging: media: lirc: space around operator Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-12-18 14:10 +0100
    [PATCH 2/5] staging: media: lirc: no space after cast Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-12-18 14:10 +0100
    [PATCH 5/5] staging: media: lirc: use new parport device model Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-12-18 14:10 +0100
    Re: [PATCH 1/5] staging: media: lirc: replace NULL comparisons with  !var Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-12-30 05:30 +0100

#1294798 — [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2015-12-18 14:10 +0100
Subject[PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var
Message-ID<qH2Xf-64F-3@gated-at.bofh.it>
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1294800 — [PATCH 3/5] staging: media: lirc: space around operator

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2015-12-18 14:10 +0100
Subject[PATCH 3/5] staging: media: lirc: space around operator
Message-ID<qH2Xg-64F-15@gated-at.bofh.it>
In reply to#1294798
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1294801 — [PATCH 2/5] staging: media: lirc: no space after cast

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2015-12-18 14:10 +0100
Subject[PATCH 2/5] staging: media: lirc: no space after cast
Message-ID<qH2Xg-64F-17@gated-at.bofh.it>
In reply to#1294798
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1294803 — [PATCH 5/5] staging: media: lirc: use new parport device model

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2015-12-18 14:10 +0100
Subject[PATCH 5/5] staging: media: lirc: use new parport device model
Message-ID<qH2Xg-64F-21@gated-at.bofh.it>
In reply to#1294798
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299230 — Re: [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2015-12-30 05:30 +0100
SubjectRe: [PATCH 1/5] staging: media: lirc: replace NULL comparisons with !var
Message-ID<qLgyC-1C8-5@gated-at.bofh.it>
In reply to#1294798
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web