[PATCH libinput 2/4] Move closing the device fd into evdev.c

Jonas Ådahl jadahl at gmail.com
Wed Feb 5 13:29:55 PST 2014


On Tue, Feb 04, 2014 at 07:22:33AM +1000, Peter Hutterer wrote:
> evdev_device_remove() already calls close(device->fd). Move the
> close_restricted call there to avoid one privileged call in the backend and
> one in the device.

Now we have open_restricted in path.c, udev-seat.c, and close_restricted
in path.c, udev-seat.c and evdev.c, all opening and closing evdev
devices. Maybe we could just put it all in evdev.c instead?

It would simplify the error path in the next patch as well.

The other two looks good to me.

Jonas

> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  src/evdev.c     | 2 +-
>  src/path.c      | 1 -
>  src/udev-seat.c | 3 ---
>  3 files changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/src/evdev.c b/src/evdev.c
> index 46bd35a..c1d33a9 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -720,7 +720,7 @@ evdev_device_remove(struct evdev_device *device)
>  
>  	if (device->mtdev)
>  		mtdev_close_delete(device->mtdev);
> -	close(device->fd);
> +	close_restricted(device->base.seat->libinput, device->fd);
>  	list_remove(&device->base.link);
>  
>  	notify_removed_device(&device->base);
> diff --git a/src/path.c b/src/path.c
> index 2893ad4..29d722b 100644
> --- a/src/path.c
> +++ b/src/path.c
> @@ -42,7 +42,6 @@ path_input_disable(struct libinput *libinput)
>  	struct evdev_device *device = input->device;
>  
>  	if (device) {
> -		close_restricted(libinput, device->fd);
>  		evdev_device_remove(device);
>  		input->device = NULL;
>  	}
> diff --git a/src/udev-seat.c b/src/udev-seat.c
> index 5936511..86b17d7 100644
> --- a/src/udev-seat.c
> +++ b/src/udev-seat.c
> @@ -169,7 +169,6 @@ static void
>  evdev_udev_handler(void *data)
>  {
>  	struct udev_input *input = data;
> -	struct libinput *libinput = &input->base;
>  	struct udev_device *udev_device;
>  	struct evdev_device *device, *next;
>  	const char *action;
> @@ -198,7 +197,6 @@ evdev_udev_handler(void *data)
>  				if (!strcmp(device->devnode, devnode)) {
>  					log_info("input device %s, %s removed\n",
>  						 device->devname, device->devnode);
> -					close_restricted(libinput, device->fd);
>  					evdev_device_remove(device);
>  					break;
>  				}
> @@ -219,7 +217,6 @@ udev_input_remove_devices(struct udev_input *input)
>  		libinput_seat_ref(&seat->base);
>  		list_for_each_safe(device, next,
>  				   &seat->base.devices_list, base.link) {
> -			close_restricted(&input->base, device->fd);
>  			evdev_device_remove(device);
>  			if (list_empty(&seat->base.devices_list)) {
>  				/* if the seat may be referenced by the
> -- 
> 1.8.4.2
> 
> _______________________________________________
> 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