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.
Showing the changes to drivers/media/rc/lirc_dev.c (1 of 1 file). Show all
Unified · Split
| @@ -97,26 +97,25 @@ static void lirc_irctl_cleanup(struct irctl *ir) · 96 unmodified lines | ||
| 97 | 97 | */ |
| 98 | 98 | static int lirc_add_to_buf(struct irctl *ir) |
| 99 | 99 | { |
| 100 | − if (ir->d.add_to_buf) { | |
| 101 | − int res = -ENODATA; | |
| 102 | − int got_data = -1; | |
| 100 | + int res; | |
| 101 | + int got_data = -1; | |
| 103 | 102 | |
| 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; | |
| 112 | 105 | |
| 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); | |
| 115 | 114 | |
| 116 | − return got_data ? 0 : res; | |
| 117 | − } | |
| 115 | + if (res == -ENODEV) | |
| 116 | + kthread_stop(ir->task); | |
| 118 | 117 | |
| 119 | − return 0; | |
| 118 | + return got_data ? 0 : res; | |
| 120 | 119 | } |
| 121 | 120 | |
| 122 | 121 | /* main function of the polling thread |