From a123e5c46a3bac616cdee8e3aeebeadc7d015cc4 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 3 Aug 2012 14:38:57 +0300 Subject: [PATCH] evdev: rename device_removed() to evdev_input_device_destroy() 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 --- src/evdev.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 6141bca3..9b1a7e69 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 @@ -550,24 +568,6 @@ device_added(struct udev_device *udev_device, struct evdev_seat *master) evdev_input_device_create(master, c->wl_display, devnode); } -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) { @@ -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); }