summaryrefslogtreecommitdiff
path: root/libevdev
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2020-02-11 13:23:44 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2020-02-11 21:07:06 +1000
commit0af21e0e74b33d274cf6d26a9a21d453c38c6706 (patch)
treead4123879181e5104169f7f01eb74b9931f5ed45 /libevdev
parent4fc12638d2f154e149413b25979ff0c2207ee83f (diff)
downloadlibevdev-0af21e0e74b33d274cf6d26a9a21d453c38c6706.tar.gz
Simplify some error handling by assuming a >=3.4 kernel
v3.4 was released in 2012, every kernel since has that ioctl. So instead of assuming you're running new libevdev on an 8 year old kernel, let's assume that any error from the ioctl() is an actual error and handle it accordingly. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'libevdev')
-rw-r--r--libevdev/libevdev.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index dbf8ea3..c1375f8 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -708,7 +708,6 @@ sync_mt_state(struct libevdev *dev, int create_events)
struct input_absinfo abs_info;
int rc;
int axis, slot;
- int ioctl_success = 0;
int last_reported_slot = 0;
struct mt_sync_state *mt_state = dev->mt_sync.mt_state;
unsigned long *slot_update = dev->mt_sync.slot_update;
@@ -730,36 +729,26 @@ sync_mt_state(struct libevdev *dev, int create_events)
mt_state->code = axis;
rc = ioctl(dev->fd, EVIOCGMTSLOTS(dev->mt_sync.mt_state_sz), mt_state);
- if (rc < 0) {
- /* if the first ioctl fails with -EINVAL, chances are the kernel
- doesn't support the ioctl. Simply continue */
- if (errno == -EINVAL && !ioctl_success) {
- rc = 0;
- } else /* if the second, ... ioctl fails, really fail */
- goto out;
- } else {
- if (ioctl_success == 0)
- ioctl_success = 1;
-
- for (slot = 0; slot < dev->num_slots; slot++) {
-
- if (*slot_value(dev, slot, axis) == mt_state->val[slot])
- continue;
+ if (rc < 0)
+ goto out;
- if (axis == ABS_MT_TRACKING_ID &&
- *slot_value(dev, slot, axis) != -1 &&
- mt_state->val[slot] != -1) {
- set_bit(tracking_id_changes, slot);
- need_tracking_id_changes = 1;
- }
+ for (slot = 0; slot < dev->num_slots; slot++) {
- *slot_value(dev, slot, axis) = mt_state->val[slot];
+ if (*slot_value(dev, slot, axis) == mt_state->val[slot])
+ continue;
- set_bit(slot_update, AXISBIT(slot, axis));
- /* note that this slot has updates */
- set_bit(slot_update, AXISBIT(slot, ABS_MT_SLOT));
+ if (axis == ABS_MT_TRACKING_ID &&
+ *slot_value(dev, slot, axis) != -1 &&
+ mt_state->val[slot] != -1) {
+ set_bit(tracking_id_changes, slot);
+ need_tracking_id_changes = 1;
}
+ *slot_value(dev, slot, axis) = mt_state->val[slot];
+
+ set_bit(slot_update, AXISBIT(slot, axis));
+ /* note that this slot has updates */
+ set_bit(slot_update, AXISBIT(slot, ABS_MT_SLOT));
}
}