History

[media] lirc_dev: simplify if statement in lirc_add_to_buf

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.

Andi Shyti committed 10 years ago

Commit 19e56531 parent 7fe579d1 file · +15 −16Browse files

Showing the changes to drivers/media/rc/lirc_dev.c (1 of 1 file). Show all

Unified · Split

drivers/media/rc/lirc_dev.c+15−16
@@ -97,26 +97,25 @@ static void lirc_irctl_cleanup(struct irctl *ir) · 96 unmodified lines
97 */97 */
98static int lirc_add_to_buf(struct irctl *ir)98static int lirc_add_to_buf(struct irctl *ir)
99{99{
100 if (ir->d.add_to_buf) {100 int res;
101 int res = -ENODATA;101 int got_data = -1;
102 int got_data = -1;
103 102
104 /*103 if (!ir->d.add_to_buf)
105 * service the device as long as it is returning104 return 0;
106 * data and we have space
107 */
108 do {
109 got_data++;
110 res = ir->d.add_to_buf(ir->d.data, ir->buf);
111 } while (!res);
112 105
113 if (res == -ENODEV)106 /*
114 kthread_stop(ir->task);107 * service the device as long as it is returning
108 * data and we have space
109 */
110 do {
111 got_data++;
112 res = ir->d.add_to_buf(ir->d.data, ir->buf);
113 } while (!res);
115 114
116 return got_data ? 0 : res;115 if (res == -ENODEV)
117 }116 kthread_stop(ir->task);
118 117
119 return 0;118 return got_data ? 0 : res;
120}119}
121 120
122/* main function of the polling thread121/* main function of the polling thread