[PATCH weston 01/20] evdev: rename device_removed() to evdev_input_device_destroy()

Pekka Paalanen ppaalanen at gmail.com
Fri Aug 3 04:38:57 PDT 2012


evdev_input_device_destroy() will completement the API of
evdev_input_device_create(), both being independent from udev.

Since the udev-specific device_removed() would only call
evdev_input_device_destroy() and do nothing else, device_remove() calls
are simply replaced with evdev_input_device_destroy().

Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 src/evdev.c |   42 +++++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 6141bca..9b1a7e6 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -354,7 +354,7 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
 			len = read(fd, &ev, sizeof ev);
 
 		if (len < 0 || len % sizeof ev[0] != 0) {
-			/* FIXME: call device_removed when errno is ENODEV. */
+			/* FIXME: call evdev_input_device_destroy when errno is ENODEV. */
 			return 1;
 		}
 
@@ -529,6 +529,24 @@ err0:
 	return NULL;
 }
 
+static void
+evdev_input_device_destroy(struct evdev_input_device *device)
+{
+	struct evdev_dispatch *dispatch;
+
+	dispatch = device->dispatch;
+	if (dispatch)
+		dispatch->interface->destroy(dispatch);
+
+	wl_event_source_remove(device->source);
+	wl_list_remove(&device->link);
+	if (device->mtdev)
+		mtdev_close_delete(device->mtdev);
+	close(device->fd);
+	free(device->devnode);
+	free(device);
+}
+
 static const char default_seat[] = "seat0";
 
 static void
@@ -551,24 +569,6 @@ device_added(struct udev_device *udev_device, struct evdev_seat *master)
 }
 
 static void
-device_removed(struct evdev_input_device *device)
-{
-	struct evdev_dispatch *dispatch;
-
-	dispatch = device->dispatch;
-	if (dispatch)
-		dispatch->interface->destroy(dispatch);
-
-	wl_event_source_remove(device->source);
-	wl_list_remove(&device->link);
-	if (device->mtdev)
-		mtdev_close_delete(device->mtdev);
-	close(device->fd);
-	free(device->devnode);
-	free(device);
-}
-
-static void
 evdev_notify_keyboard_focus(struct evdev_seat *seat)
 {
 	struct evdev_input_device *device;
@@ -674,7 +674,7 @@ evdev_udev_handler(int fd, uint32_t mask, void *data)
 			wl_list_for_each_safe(device, next,
 					      &master->devices_list, link)
 				if (!strcmp(device->devnode, devnode)) {
-					device_removed(device);
+					evdev_input_device_destroy(device);
 					break;
 				}
 		}
@@ -768,7 +768,7 @@ evdev_remove_devices(struct weston_seat *seat_base)
 	struct evdev_input_device *device, *next;
 
 	wl_list_for_each_safe(device, next, &seat->devices_list, link)
-		device_removed(device);
+		evdev_input_device_destroy(device);
 
 	notify_keyboard_focus_out(&seat->base.seat);
 }
-- 
1.7.8.6



More information about the wayland-devel mailing list