diff options
author | Henrik Rydberg <rydberg@euromail.se> | 2010-06-18 01:47:41 +0200 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2010-10-12 15:39:31 +0200 |
commit | ffb67f4795ace2d6d9f5890faae60b97e18f84fb (patch) | |
tree | b2f35b34769b3a756aed47ddd623a77e2b4aaf2e /src | |
parent | d62cfe70ee85872c36aaa182d110793ce8f14d57 (diff) | |
download | xorg-input-kobomultitouch-ffb67f4795ace2d6d9f5890faae60b97e18f84fb.tar.gz xorg-input-kobomultitouch-ffb67f4795ace2d6d9f5890faae60b97e18f84fb.tar.bz2 xorg-input-kobomultitouch-ffb67f4795ace2d6d9f5890faae60b97e18f84fb.zip |
Improve error handling in mtouch open and close
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src')
-rw-r--r-- | src/mtouch.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/mtouch.c b/src/mtouch.c index 8a83d64..ec5eac9 100644 --- a/src/mtouch.c +++ b/src/mtouch.c @@ -32,26 +32,37 @@ int configure_mtouch(struct MTouch *mt, int fd) return 0; } + int open_mtouch(struct MTouch *mt, int fd) { - mtdev_open(&mt->dev, fd); + int ret; + ret = mtdev_open(&mt->dev, fd); + if (ret) + goto error; init_hwstate(&mt->hs, &mt->caps); init_mtstate(&mt->prev_state); init_mtstate(&mt->state); init_memory(&mt->mem); if (use_grab) { - int rc; - SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)1)); - return rc; + SYSCALL(ret = ioctl(fd, EVIOCGRAB, 1)); + if (ret) + goto close; } return 0; + close: + mtdev_close(&mt->dev); + error: + return ret; } + int close_mtouch(struct MTouch *mt, int fd) { + int ret; if (use_grab) { - int rc; - SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)0)); + SYSCALL(ret = ioctl(fd, EVIOCGRAB, 0)); + if (ret) + xf86Msg(X_WARNING, "mtouch: ungrab failed\n"); } mtdev_close(&mt->dev); return 0; |