signal11/hidapi — pull request #122 by kdienes (2013-05-19 03:32:26+00:00)
Title: Better kernel version detection.

This originally turned up on Debian unstable, using the linux-image-3.8-trunk-amd64 package.

$ uname -a
Linux pavillion 3.8-trunk-amd64 #1 SMP Debian 3.8.5-1~experimental.1 x86_64 GNU/Linux

When run with this kernel, hidapi prints "Couldn't sscanf() version string", which is somewhat reasonable. But then in hid_read_timeout(), kernel_version is 0, which triggers the workaround for Linux 2.6.34, and leads to corrupt packets.

This patch does three things:

1) Successfully parses version numbers with only %d.%d and not %.d.%d.%d.
2) Tracks unrecognized kernel versions as a distinct value (KERNEL_VERSION_UNKNOWN).
3) Uses the workaround for 2.6.34 only if the kernel was positively identified.