[PATCH 1/1] Input: joydev - fix axes values sent in initial js_event

From: Vojtech Bocek
Date: Thu Nov 01 2012 - 12:34:34 EST


Initial input ABS events can't reach joydev because it is not
opened yet.
This patch makes joydev reload ABS values on joydev_open_device.

Signed-off-by: Vojtech Bocek <vbocek@xxxxxxxxx>
---
drivers/input/joydev.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index f362883..f53a7b1 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -156,6 +156,18 @@ static void joydev_event(struct input_handle *handle,
wake_up_interruptible(&joydev->wait);
}

+/* joydev must be locked */
+static void joydev_reload_abs(struct joydev *joydev)
+{
+ int i, abs;
+ struct input_dev *input = joydev->handle.dev;
+
+ for (i = 0; i < joydev->nabs; ++i) {
+ abs = input_abs_get_val(input, joydev->abspam[i]);
+ joydev->abs[i] = joydev_correct(abs, &joydev->corr[i]);
+ }
+}
+
static int joydev_fasync(int fd, struct file *file, int on)
{
struct joydev_client *client = file->private_data;
@@ -200,7 +212,9 @@ static int joydev_open_device(struct joydev *joydev)
retval = -ENODEV;
else if (!joydev->open++) {
retval = input_open_device(&joydev->handle);
- if (retval)
+ if (!retval)
+ joydev_reload_abs(joydev);
+ else
joydev->open--;
}

--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/