diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-06-19 12:10:27 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-06-19 14:01:40 +0200 |
| commit | 259b92a30280cdec2b7798df3c14da596c417ef1 (patch) | |
| tree | bb1f7138cb2e2c7be18975cb3cd0cc9a07d8c44f /test | |
| parent | 8087ac3d655c2b2835cf61e7a69611d81d4f303e (diff) | |
Restructure mtdev api
Split the api into plumbing and porcelain layers and move the
plumbing part to its own optional header file.
The main usecase is to fetch events from the device, route them
through the converter and extract the processed events. To simplify
the API, replace the intermediate mtdev_pull() function by the
higher-level mtdev_get(). This function does all the required steps,
and has the same semantics as read().
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'test')
| -rw-r--r-- | test/mtdev.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/test/mtdev.c b/test/mtdev.c index 60fae7b..a4858c5 100644 --- a/test/mtdev.c +++ b/test/mtdev.c | |||
| @@ -26,7 +26,7 @@ | |||
| 26 | * | 26 | * |
| 27 | ****************************************************************************/ | 27 | ****************************************************************************/ |
| 28 | 28 | ||
| 29 | #include <mtdev-mapping.h> | 29 | #include <mtdev.h> |
| 30 | #include <stdio.h> | 30 | #include <stdio.h> |
| 31 | #include <fcntl.h> | 31 | #include <fcntl.h> |
| 32 | 32 | ||
| @@ -64,11 +64,8 @@ static void loop_device(int fd) | |||
| 64 | } | 64 | } |
| 65 | /* while the device has not been inactive for five seconds */ | 65 | /* while the device has not been inactive for five seconds */ |
| 66 | while (!mtdev_idle(&dev, fd, 5000)) { | 66 | while (!mtdev_idle(&dev, fd, 5000)) { |
| 67 | /* fetch all available kernel events */ | 67 | /* extract all available processed events */ |
| 68 | mtdev_pull(&dev, fd, 0); | 68 | while (mtdev_get(&dev, fd, &ev, 1) > 0) { |
| 69 | /* extract all available canonical events */ | ||
| 70 | while (!mtdev_empty(&dev)) { | ||
| 71 | mtdev_get(&dev, &ev); | ||
| 72 | if (use_event(&ev)) | 69 | if (use_event(&ev)) |
| 73 | print_event(&ev); | 70 | print_event(&ev); |
| 74 | } | 71 | } |
