[PATCH libinput 2/3] udev: factor out device_removed handling
Jonas Ådahl
jadahl at gmail.com
Fri Mar 21 13:19:59 PDT 2014
On Fri, Mar 21, 2014 at 02:13:21PM +1000, Peter Hutterer wrote:
> No functional changes
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> I needed this for the rescan patch but it makes the calls more symmetrical,
> so we might as well push it independently.
Reviewed-by: Jonas Ådahl <jadahl at gmail.com> on all 3 patches, with some
comments inline in this one and the documentation patch.
Jonas
>
> src/udev-seat.c | 41 +++++++++++++++++++++++------------------
> 1 file changed, 23 insertions(+), 18 deletions(-)
>
> diff --git a/src/udev-seat.c b/src/udev-seat.c
> index e622de2..366c92b 100644
> --- a/src/udev-seat.c
> +++ b/src/udev-seat.c
> @@ -116,6 +116,26 @@ device_added(struct udev_device *udev_device, struct udev_input *input)
> return 0;
> }
>
> +static void
> +device_removed(struct udev_device *udev_device, struct udev_input *input)
> +{
> + const char *devnode;
> + struct evdev_device *device, *next;
> + struct udev_seat *seat;
> +
> + devnode = udev_device_get_devnode(udev_device);
> + list_for_each(seat, &input->base.seat_list, base.link) {
> + list_for_each_safe(device, next,
> + &seat->base.devices_list, base.link)
Indentation is off here now. While it was not like that to begin with,
here should actually be braces as well.
> + if (!strcmp(device->devnode, devnode)) {
> + log_info("input device %s, %s removed\n",
> + device->devname, device->devnode);
And here as well.
> + evdev_device_remove(device);
> + break;
> + }
> + }
> +}
> +
> static int
> udev_input_add_devices(struct udev_input *input, struct udev *udev)
> {
> @@ -155,10 +175,7 @@ evdev_udev_handler(void *data)
> {
> struct udev_input *input = data;
> struct udev_device *udev_device;
> - struct evdev_device *device, *next;
> const char *action;
> - const char *devnode;
> - struct udev_seat *seat;
>
> udev_device = udev_monitor_receive_device(input->udev_monitor);
> if (!udev_device)
> @@ -171,22 +188,10 @@ evdev_udev_handler(void *data)
> if (strncmp("event", udev_device_get_sysname(udev_device), 5) != 0)
> goto out;
>
> - if (!strcmp(action, "add")) {
> + if (!strcmp(action, "add"))
> device_added(udev_device, input);
> - }
> - else if (!strcmp(action, "remove")) {
> - devnode = udev_device_get_devnode(udev_device);
> - list_for_each(seat, &input->base.seat_list, base.link) {
> - list_for_each_safe(device, next,
> - &seat->base.devices_list, base.link)
> - if (!strcmp(device->devnode, devnode)) {
> - log_info("input device %s, %s removed\n",
> - device->devname, device->devnode);
> - evdev_device_remove(device);
> - break;
> - }
> - }
> - }
> + else if (!strcmp(action, "remove"))
> + device_removed(udev_device, input);
>
> out:
> udev_device_unref(udev_device);
> --
> 1.8.5.3
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list