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
9797 */
9898 static int lirc_add_to_buf(struct irctl *ir)
9999 {
100− if (ir->d.add_to_buf) {
101− int res = -ENODATA;
102− int got_data = -1;
100+ int res;
101+ int got_data = -1;
103102
104− /*
105− * service the device as long as it is returning
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);
103+ if (!ir->d.add_to_buf)
104+ return 0;
112105
113− if (res == -ENODEV)
114− kthread_stop(ir->task);
106+ /*
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);
115114
116− return got_data ? 0 : res;
117− }
115+ if (res == -ENODEV)
116+ kthread_stop(ir->task);
118117
119− return 0;
118+ return got_data ? 0 : res;
120119 }
121120
122121 /* main function of the polling thread