char name[128];
int version;
- if ((fd = open(path, O_RDONLY)) != -1) {
- if (ioctl(fd, HIDIOCGDEVINFO, &devinfo) == -1) {
- perror("ioctl HIDIOCGDEVINFO");
- close(fd);
- return -1;
- }
- if (ioctl(fd, HIDIOCGNAME(sizeof(name)), name) == -1) {
- perror("ioctl HIDIOCGNAME");
- close(fd);
- return -1;
- }
- if (ioctl(fd, HIDIOCGVERSION, &version) == -1) {
- perror("ioctl HIDIOCGVERSION");
- close(fd);
- return -1;
- }
- if (devinfo.vendor != JABRA_VID &&
- devinfo.vendor != PLANTRONICS_VID) {
- close(fd);
- return -1;
- }
+ fd = open(path, O_RDONLY);
+ if (fd == -1)
return fd;
- }
- if (errno == ENOENT) {
- return 0;
+ if (ioctl(fd, HIDIOCGDEVINFO, &devinfo) == -1) {
+ perror("ioctl HIDIOCGDEVINFO");
+ close(fd);
+ return -1;
+ }
+ if (ioctl(fd, HIDIOCGNAME(sizeof(name)), name) == -1) {
+ perror("ioctl HIDIOCGNAME");
+ close(fd);
+ return -1;
+ }
+ if (ioctl(fd, HIDIOCGVERSION, &version) == -1) {
+ perror("ioctl HIDIOCGVERSION");
+ close(fd);
+ return -1;
+ }
+ if (devinfo.vendor != JABRA_VID &&
+ devinfo.vendor != PLANTRONICS_VID) {
+ close(fd);
+ return -1;
}
- perror("ioctl HIDIOCGVERSION");
- return -1;
+ return fd;
}
static void writeUsage(int fd, unsigned report_type, unsigned page, unsigned code, __s32 value) {