Public paste
libevdev patch
By: Guest | Date: May 19 2021 17:46 | Format: None | Expires: never | Size: 4.98 KB | Hits: 99

  1.  libevdev/libevdev.c | 24 ++++++++++++++++++++++++
  2.  1 file changed, 24 insertions(+)
  3.  
  4. diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
  5. index b941cfb..7e8d935 100644
  6. --- a/libevdev/libevdev.c
  7. +++ b/libevdev/libevdev.c
  8. @@ -236,10 +236,12 @@ libevdev_new_from_fd(int fd, struct libevdev **dev)
  9.         int rc;
  10.  
  11.         d = libevdev_new();
  12. +       log_error(NULL, "[libevdev] libevdev_new\n");
  13.         if (!d)
  14.                 return -ENOMEM;
  15.  
  16.         rc = libevdev_set_fd(d, fd);
  17. +       log_error(NULL, "[libevdev] libevdev_set_fd returned %d\n", rc);
  18.         if (rc < 0)
  19.                 libevdev_free(d);
  20.         else
  21. @@ -389,11 +391,13 @@ libevdev_set_fd(struct libevdev* dev, int fd)
  22.         libevdev_reset(dev);
  23.  
  24.         rc = ioctl(fd, EVIOCGBIT(0, sizeof(dev->bits)), dev->bits);
  25. +       log_error(NULL, "[libevdev] ioctl1 returned %d, errno=%d (%s)\n", rc, errno, strerror(errno));
  26.         if (rc < 0)
  27.                 goto out;
  28.  
  29.         memset(buf, 0, sizeof(buf));
  30.         rc = ioctl(fd, EVIOCGNAME(sizeof(buf) - 1), buf);
  31. +       log_error(NULL, "[libevdev] ioctl2 returned %d\n", rc);
  32.         if (rc < 0)
  33.                 goto out;
  34.  
  35. @@ -408,6 +412,7 @@ libevdev_set_fd(struct libevdev* dev, int fd)
  36.         dev->phys = NULL;
  37.         memset(buf, 0, sizeof(buf));
  38.         rc = ioctl(fd, EVIOCGPHYS(sizeof(buf) - 1), buf);
  39. +       log_error(NULL, "[libevdev] ioctl3 returned %d\n", rc);
  40.         if (rc < 0) {
  41.                 /* uinput has no phys */
  42.                 if (errno != ENOENT)
  43. @@ -424,6 +429,7 @@ libevdev_set_fd(struct libevdev* dev, int fd)
  44.         dev->uniq = NULL;
  45.         memset(buf, 0, sizeof(buf));
  46.         rc = ioctl(fd, EVIOCGUNIQ(sizeof(buf) - 1), buf);
  47. +       log_error(NULL, "[libevdev] ioctl4 returned %d\n", rc);
  48.         if (rc < 0) {
  49.                 if (errno != ENOENT)
  50.                         goto out;
  51. @@ -436,10 +442,12 @@ libevdev_set_fd(struct libevdev* dev, int fd)
  52.         }
  53.  
  54.         rc = ioctl(fd, EVIOCGID, &dev->ids);
  55. +       log_error(NULL, "[libevdev] ioctl5 returned %d\n", rc);
  56.         if (rc < 0)
  57.                 goto out;
  58.  
  59.         rc = ioctl(fd, EVIOCGVERSION, &dev->driver_version);
  60. +       log_error(NULL, "[libevdev] ioctl6 returned %d\n", rc);
  61.         if (rc < 0)
  62.                 goto out;
  63.  
  64. @@ -448,50 +456,62 @@ libevdev_set_fd(struct libevdev* dev, int fd)
  65.            than that everything is as expected.
  66.          */
  67.         rc = ioctl(fd, EVIOCGPROP(sizeof(dev->props)), dev->props);
  68. +       log_error(NULL, "[libevdev] ioctl7 returned %d\n", rc);
  69.         if (rc < 0 && errno != EINVAL)
  70.                 goto out;
  71.  
  72.         rc = ioctl(fd, EVIOCGBIT(EV_REL, sizeof(dev->rel_bits)), dev->rel_bits);
  73. +       log_error(NULL, "[libevdev] ioctl8 returned %d\n", rc);
  74.         if (rc < 0)
  75.                 goto out;
  76.  
  77.         rc = ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(dev->abs_bits)), dev->abs_bits);
  78. +       log_error(NULL, "[libevdev] ioctl9 returned %d\n", rc);
  79.         if (rc < 0)
  80.                 goto out;
  81.  
  82.         rc = ioctl(fd, EVIOCGBIT(EV_LED, sizeof(dev->led_bits)), dev->led_bits);
  83. +       log_error(NULL, "[libevdev] ioctl10 returned %d\n", rc);
  84.         if (rc < 0)
  85.                 goto out;
  86.  
  87.         rc = ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(dev->key_bits)), dev->key_bits);
  88. +       log_error(NULL, "[libevdev] ioctl11 returned %d\n", rc);
  89.         if (rc < 0)
  90.                 goto out;
  91.  
  92.         rc = ioctl(fd, EVIOCGBIT(EV_SW, sizeof(dev->sw_bits)), dev->sw_bits);
  93. +       log_error(NULL, "[libevdev] ioctl12 returned %d\n", rc);
  94.         if (rc < 0)
  95.                 goto out;
  96.  
  97.         rc = ioctl(fd, EVIOCGBIT(EV_MSC, sizeof(dev->msc_bits)), dev->msc_bits);
  98. +       log_error(NULL, "[libevdev] ioctl13 returned %d\n", rc);
  99.         if (rc < 0)
  100.                 goto out;
  101.  
  102.         rc = ioctl(fd, EVIOCGBIT(EV_FF, sizeof(dev->ff_bits)), dev->ff_bits);
  103. +       log_error(NULL, "[libevdev] ioctl14 returned %d\n", rc);
  104.         if (rc < 0)
  105.                 goto out;
  106.  
  107.         rc = ioctl(fd, EVIOCGBIT(EV_SND, sizeof(dev->snd_bits)), dev->snd_bits);
  108. +       log_error(NULL, "[libevdev] ioctl15 returned %d\n", rc);
  109.         if (rc < 0)
  110.                 goto out;
  111.  
  112.         rc = ioctl(fd, EVIOCGKEY(sizeof(dev->key_values)), dev->key_values);
  113. +       log_error(NULL, "[libevdev] ioctl16 returned %d\n", rc);
  114.         if (rc < 0)
  115.                 goto out;
  116.  
  117.         rc = ioctl(fd, EVIOCGLED(sizeof(dev->led_values)), dev->led_values);
  118. +       log_error(NULL, "[libevdev] ioctl17 returned %d\n", rc);
  119.         if (rc < 0)
  120.                 goto out;
  121.  
  122.         rc = ioctl(fd, EVIOCGSW(sizeof(dev->sw_values)), dev->sw_values);
  123. +       log_error(NULL, "[libevdev] ioctl18 returned %d\n", rc);
  124.         if (rc < 0)
  125.                 goto out;
  126.  
  127. @@ -500,6 +520,7 @@ libevdev_set_fd(struct libevdev* dev, int fd)
  128.                 for (i = 0; i < REP_CNT; i++)
  129.                         set_bit(dev->rep_bits, i);
  130.                 rc = ioctl(fd, EVIOCGREP, dev->rep_values);
  131. +               log_error(NULL, "[libevdev] ioctl18b returned %d\n", rc);
  132.                 if (rc < 0)
  133.                         goto out;
  134.         }
  135. @@ -508,6 +529,7 @@ libevdev_set_fd(struct libevdev* dev, int fd)
  136.                 if (bit_is_set(dev->abs_bits, i)) {
  137.                         struct input_absinfo abs_info;
  138.                         rc = ioctl(fd, EVIOCGABS(i), &abs_info);
  139. +                       log_error(NULL, "[libevdev] ioctl18c returned %d\n", rc);
  140.                         if (rc < 0)
  141.                                 goto out;
  142.  
  143. @@ -520,6 +542,7 @@ libevdev_set_fd(struct libevdev* dev, int fd)
  144.         dev->fd = fd;
  145.  
  146.         rc = init_slots(dev);
  147. +       log_error(NULL, "[libevdev] init_slots returned %d\n", rc);
  148.         if (rc != 0)
  149.                 goto out;
  150.  
  151. @@ -529,6 +552,7 @@ libevdev_set_fd(struct libevdev* dev, int fd)
  152.         }
  153.  
  154.         rc = init_event_queue(dev);
  155. +       log_error(NULL, "[libevdev] init_event_queue returned %d\n", rc);
  156.         if (rc < 0) {
  157.                 dev->fd = -1;
  158.                 return -rc;
  159.