Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1437598
| From | Andi Shyti <andi.shyti@samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v3 07/15] [media] lirc_dev: simplify if statement in lirc_add_to_buf |
| Date | 2016-07-06 11:50 +0200 |
| Message-ID | <rRRCW-7w1-21@gated-at.bofh.it> (permalink) |
| References | <rRRCW-7w1-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
The whole function is inside an 'if' statement
("if (ir->d.add_to_buf)").
Check the opposite of that statement at the beginning and exit,
this way we can have one level less of indentation.
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
drivers/media/rc/lirc_dev.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index cfa6031..c2826a7 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -97,26 +97,25 @@ static void lirc_irctl_cleanup(struct irctl *ir)
*/
static int lirc_add_to_buf(struct irctl *ir)
{
- if (ir->d.add_to_buf) {
- int res = -ENODATA;
- int got_data = -1;
+ int res;
+ int got_data = -1;
- /*
- * service the device as long as it is returning
- * data and we have space
- */
- do {
- got_data++;
- res = ir->d.add_to_buf(ir->d.data, ir->buf);
- } while (!res);
+ if (!ir->d.add_to_buf)
+ return 0;
- if (res == -ENODEV)
- kthread_stop(ir->task);
+ /*
+ * service the device as long as it is returning
+ * data and we have space
+ */
+ do {
+ got_data++;
+ res = ir->d.add_to_buf(ir->d.data, ir->buf);
+ } while (!res);
- return got_data ? 0 : res;
- }
+ if (res == -ENODEV)
+ kthread_stop(ir->task);
- return 0;
+ return got_data ? 0 : res;
}
/* main function of the polling thread
--
2.8.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v3 00/15] lirc_dev fixes and beautification Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 10/15] [media] lirc_dev: remove compat_ioctl assignment Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 11/15] [media] lirc_dev: fix variable constant comparisons Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 07/15] [media] lirc_dev: simplify if statement in lirc_add_to_buf Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 03/15] [media] lirc_dev: remove unnecessary debug prints Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 02/15] [media] lirc_dev: allow bufferless driver registration Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 15/15] [media] lirc_dev: use LIRC_CAN_REC() define to check if the device can receive Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 06/15] [media] lirc_dev: do not use goto to create loops Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 12/15] [media] lirc_dev: fix error return value Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 04/15] [media] lirc_dev: replace printk with pr_* or dev_* Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 01/15] [media] lirc_dev: place buffer allocation on separate function Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 05/15] [media] lirc_dev: simplify goto paths Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 08/15] [media] lirc_dev: remove double if ... else statement Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 09/15] [media] lirc_dev: merge three if statements in only one Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200
csiph-web