evdev: Do not open the already opened device
authorJengHyun Kang <jhyuni.kang@samsung.com>
Mon, 22 Aug 2016 07:54:29 +0000 (16:54 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 4 Dec 2023 10:24:41 +0000 (19:24 +0900)
Change-Id: I96ba5287f28dfa301628232a5a6a02f1baf1c7a2

src/evdev.c

index 5a43dee831edba0c0e84946d622741dc55c37756..641a23c0413d8e6b233a4e6333b4dfa92b650d36 100644 (file)
@@ -2441,6 +2441,7 @@ evdev_device_create(struct libinput_seat *seat,
        const char *devnode;
        char *sysname = str_sanitize(udev_device_get_sysname(udev_device));
        char buf[STRERR_BUFSIZE] = {0, };
+       struct libinput_device *dev;
 
 #ifdef HAVE_INPUT_SET_DEFAULT_PROPERTY
        if (input_set_default_property(udev_device) < 0)
@@ -2458,6 +2459,15 @@ evdev_device_create(struct libinput_seat *seat,
                goto err;
        }
 
+       list_for_each(dev, &seat->devices_list, link) {
+               struct evdev_device *d = (struct evdev_device*)dev;
+               if (strcmp(devnode, udev_device_get_devnode(d->udev_device))== 0) {
+                       log_info(libinput,
+                               "%s device is already opened\n", d->devname);
+                       return NULL;
+               }
+       }
+
        /* Use non-blocking mode so that we can loop on read on
         * evdev_device_data() until all events on the fd are
         * read.  mtdev_get() also expects this. */