diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-06-18 01:39:40 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-06-18 01:39:40 +0200 |
| commit | 309df849b8ad3772b912d498eacda9f38a6e4f1e (patch) | |
| tree | 03c47e2a3399672d4528397c1ef980601f0488b9 | |
| parent | d62c625535494361b8ba0a004a1d24ce485f0b59 (diff) | |
Correct semantic error in mtdev_idle
The current semantics, that a non-empty conversion pipe means
the device is not idle, is not very useful. This patch changes
the semantics to simply checking if the fetch buffer is empty,
and if there are no events to fetch from the device.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
| -rw-r--r-- | include/mtdev.h | 4 | ||||
| -rw-r--r-- | src/iobuf.c | 8 |
2 files changed, 4 insertions, 8 deletions
diff --git a/include/mtdev.h b/include/mtdev.h index 7d442f1..4170512 100644 --- a/include/mtdev.h +++ b/include/mtdev.h | |||
| @@ -151,8 +151,8 @@ int mtdev_open(struct mtdev *dev, int fd); | |||
| 151 | * @fd: file descriptor of the kernel device | 151 | * @fd: file descriptor of the kernel device |
| 152 | * @ms: number of milliseconds to wait for activity | 152 | * @ms: number of milliseconds to wait for activity |
| 153 | * | 153 | * |
| 154 | * Returns true if the device is idle, i.e., there are no buffered | 154 | * Returns true if the device is idle, i.e., there are no fetched |
| 155 | * events and there is nothing to fetch from the kernel device. | 155 | * events in the pipe and there is nothing to fetch from the device. |
| 156 | */ | 156 | */ |
| 157 | int mtdev_idle(struct mtdev *dev, int fd, int ms); | 157 | int mtdev_idle(struct mtdev *dev, int fd, int ms); |
| 158 | 158 | ||
diff --git a/src/iobuf.c b/src/iobuf.c index 6516a2c..050f2ed 100644 --- a/src/iobuf.c +++ b/src/iobuf.c | |||
| @@ -32,13 +32,9 @@ | |||
| 32 | 32 | ||
| 33 | int mtdev_idle(struct mtdev *dev, int fd, int ms) | 33 | int mtdev_idle(struct mtdev *dev, int fd, int ms) |
| 34 | { | 34 | { |
| 35 | struct mtdev_state *state = dev->state; | 35 | struct mtdev_iobuf *buf = &dev->state->iobuf; |
| 36 | struct mtdev_iobuf *buf = &state->iobuf; | ||
| 37 | struct pollfd fds = { fd, POLLIN, 0 }; | 36 | struct pollfd fds = { fd, POLLIN, 0 }; |
| 38 | return evbuf_empty(&state->outbuf) && | 37 | return buf->head == buf->tail && poll(&fds, 1, ms) <= 0; |
| 39 | evbuf_empty(&state->inbuf) && | ||
| 40 | buf->head == buf->tail && | ||
| 41 | poll(&fds, 1, ms) <= 0; | ||
| 42 | } | 38 | } |
| 43 | 39 | ||
| 44 | int mtdev_fetch(struct mtdev *dev, int fd, struct input_event *ev) | 40 | int mtdev_fetch(struct mtdev *dev, int fd, struct input_event *ev) |
