[PATCH weston 06/10] evdev: only use mtdev for Protocol A devices

Peter Hutterer peter.hutterer at who-t.net
Tue Aug 6 18:04:45 PDT 2013


For Protocol B devices, mtdev merely routes the events and is not needed.
For Protocol A devices, mtdev is needed, so fail for those devices now if we
mtdev fails.
---
 src/evdev.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 7a379c5..319c9c1 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -468,6 +468,15 @@ evdev_handle_device(struct evdev_device *device)
 			device->is_mt = 1;
 			device->mt.slot = 0;
 			device->caps |= EVDEV_TOUCH;
+
+			if (!TEST_BIT(abs_bits, ABS_MT_SLOT)) {
+				device->mtdev = mtdev_new_open(device->fd);
+				if (!device->mtdev) {
+					weston_log("mtdev required but failed to open for %s\n",
+						   device->devnode);
+					return 0;
+				}
+			}
 		}
 	}
 	if (TEST_BIT(ev_bits, EV_REL)) {
@@ -577,6 +586,8 @@ evdev_device_create(struct weston_seat *seat, const char *path, int device_fd)
 	device->devname = strdup(devname);
 
 	if (!evdev_handle_device(device)) {
+		if (device->mtdev)
+			mtdev_close_delete(device->mtdev);
 		free(device->devnode);
 		free(device->devname);
 		free(device);
@@ -592,13 +603,6 @@ evdev_device_create(struct weston_seat *seat, const char *path, int device_fd)
 	if (device->dispatch == NULL)
 		goto err1;
 
-
-	if (device->is_mt) {
-		device->mtdev = mtdev_new_open(device->fd);
-		if (!device->mtdev)
-			weston_log("mtdev failed to open for %s\n", path);
-	}
-
 	device->source = wl_event_loop_add_fd(ec->input_loop, device->fd,
 					      WL_EVENT_READABLE,
 					      evdev_device_data, device);
@@ -610,6 +614,8 @@ evdev_device_create(struct weston_seat *seat, const char *path, int device_fd)
 err2:
 	device->dispatch->interface->destroy(device->dispatch);
 err1:
+	if (device->mtdev)
+		mtdev_close_delete(device->mtdev);
 	free(device->devname);
 	free(device->devnode);
 	free(device);
-- 
1.8.2.1



More information about the wayland-devel mailing list