[PATCH libevdev 5/8] Make uinput-code backwards-compatible to missing UI_SET_PROPBIT ioctl

David Herrmann dh.herrmann at gmail.com
Mon Oct 21 01:59:48 PDT 2013


Hi Peter

On Mon, Oct 14, 2013 at 8:14 AM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  libevdev/libevdev-uinput.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/libevdev/libevdev-uinput.c b/libevdev/libevdev-uinput.c
> index dc62159..ea9cf78 100644
> --- a/libevdev/libevdev-uinput.c
> +++ b/libevdev/libevdev-uinput.c
> @@ -40,6 +40,14 @@
>
>  #define SYS_INPUT_DIR "/sys/devices/virtual/input/"
>
> +#ifndef UINPUT_IOCTL_BASE
> +#define UINPUT_IOCTL_BASE       'U'
> +#endif
> +
> +#ifndef UI_SET_PROPBIT
> +#define UI_SET_PROPBIT _IOW(UINPUT_IOCTL_BASE, 110, int)
> +#endif
> +
>  static struct libevdev_uinput *
>  alloc_uinput_device(const char *name)
>  {
> @@ -132,8 +140,17 @@ set_props(const struct libevdev *dev, int fd, struct uinput_user_dev *uidev)
>                         continue;
>
>                 rc = ioctl(fd, UI_SET_PROPBIT, prop);
> -               if (rc == -1)
> +               if (rc == -1) {
> +                       /* If UI_SET_PROPBIT is not supported, treat -EINVAL
> +                        * as success. The kernel only sends -EINVAL for an
> +                        * invalid ioctl, invalid INPUT_PROP_MAX or if the
> +                        * ioctl is called on an already created device. The
> +                        * last two can't happen here.
> +                        */
> +                       if (errno == -EINVAL)
> +                               rc = 0;

We could be more strict by testing whether it's the first ioctl that
fails. But being pedantic is something for hardware developers. So
this looks fine.

Reviewed-by: David Herrmann <dh.herrmann at gmail.com>

Thanks
David

>                         break;
> +               }
>         }
>         return rc;
>  }
> --
> 1.8.3.1
>
> _______________________________________________
> Input-tools mailing list
> Input-tools at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/input-tools


More information about the Input-tools mailing list