diff options
Diffstat (limited to 'libusb/os/linux_usbfs.c')
-rw-r--r-- | libusb/os/linux_usbfs.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index ca75779..69a2773 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -220,25 +220,33 @@ static clockid_t find_monotonic_clock(void) static int check_flag_bulk_continuation(void) { struct utsname uts; - int major, minor, sublevel; + int atoms, major, minor, sublevel; if (uname(&uts) < 0) return -1; - if (strlen(uts.release) < 4) + atoms = sscanf(uts.release, "%d.%d.%d", &major, &minor, &sublevel); + if (atoms < 1) + return -1; + + if (major > 2) + return 1; + if (major < 2) return 0; - if (sscanf(uts.release, "%d.%d.%d", &major, &minor, &sublevel) != 3) + + if (atoms < 2) return 0; - if (major < 2) + + /* major == 2 */ + if (minor < 6) return 0; - if (major == 2) { - if (minor < 6) - return 0; - if (minor == 6) { - if (sublevel < 32) - return 0; - } - } - return 1; + if (minor > 6) /* Does not exist, just here for correctness */ + return 1; + + /* 2.6.x */ + if (3 == atoms && sublevel >= 32) + return 1; + + return 0; } /* Return 1 if filename exists inside dirname in sysfs. |