diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-20 11:00:43 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-20 11:00:43 -0800 |
commit | c6699b58f4fe2f968f036a862c09ce44b6968376 (patch) | |
tree | d26743fa88966c2bdfd35ba723e3631f08a1f5fc /drivers/input/joystick | |
parent | 5a1203914a637b642442a861cf462d16401548e1 (diff) | |
parent | 2d9f0d964be94fd51c7303288c6f9c88bf2381fe (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input updates from Dmitry Torokhov:
"Two new touchpad drivers - Cypress APA I2C Trackpad and Cypress PS/2
touchpad and a big update to ALPS driver from Kevin Cernekee that adds
support for "Rushmore" touchpads and paves way for adding support for
"Dolphin" touchpads.
There is also a new input driver for Goldfish emulator and also
Android keyreset driver was folded into SysRq code.
A few more drivers were updated with device tree bindings and others
got some small cleanups and fixes."
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (55 commits)
Input: cyttsp-spi - remove duplicate MODULE_ALIAS()
Input: tsc2005 - add MODULE_ALIAS
Input: tegra-kbc - require CONFIG_OF, remove platform data
Input: synaptics - initialize pointer emulation usage
Input: MT - do not apply filtering on emulated events
Input: bma150 - make some defines public and fix some comments
Input: bma150 - fix checking pm_runtime_get_sync() return value
Input: ALPS - enable trackstick on Rushmore touchpads
Input: ALPS - add support for "Rushmore" touchpads
Input: ALPS - make the V3 packet field decoder "pluggable"
Input: ALPS - move pixel and bitmap info into alps_data struct
Input: ALPS - fix command mode check
Input: ALPS - rework detection of Pinnacle AGx touchpads
Input: ALPS - move {addr,nibble}_command settings into alps_set_defaults()
Input: ALPS - use function pointers for different protocol handlers
Input: ALPS - rework detection sequence
Input: ALPS - introduce helper function for repeated commands
Input: ALPS - move alps_get_model() down below hw_init code
Input: ALPS - copy "model" info into alps_data struct
Input: ALPS - document the alps.h data structures
...
Diffstat (limited to 'drivers/input/joystick')
-rw-r--r-- | drivers/input/joystick/walkera0701.c | 82 |
1 files changed, 46 insertions, 36 deletions
diff --git a/drivers/input/joystick/walkera0701.c b/drivers/input/joystick/walkera0701.c index f8f892b076e8..b76ac580703c 100644 --- a/drivers/input/joystick/walkera0701.c +++ b/drivers/input/joystick/walkera0701.c @@ -12,7 +12,7 @@ * the Free Software Foundation. */ -/* #define WK0701_DEBUG */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define RESERVE 20000 #define SYNC_PULSE 1306000 @@ -67,6 +67,7 @@ static inline void walkera0701_parse_frame(struct walkera_dev *w) { int i; int val1, val2, val3, val4, val5, val6, val7, val8; + int magic, magic_bit; int crc1, crc2; for (crc1 = crc2 = i = 0; i < 10; i++) { @@ -102,17 +103,12 @@ static inline void walkera0701_parse_frame(struct walkera_dev *w) val8 = (w->buf[18] & 1) << 8 | (w->buf[19] << 4) | w->buf[20]; val8 *= (w->buf[18] & 2) - 1; /*sign */ -#ifdef WK0701_DEBUG - { - int magic, magic_bit; - magic = (w->buf[21] << 4) | w->buf[22]; - magic_bit = (w->buf[24] & 8) >> 3; - printk(KERN_DEBUG - "walkera0701: %4d %4d %4d %4d %4d %4d %4d %4d (magic %2x %d)\n", - val1, val2, val3, val4, val5, val6, val7, val8, magic, - magic_bit); - } -#endif + magic = (w->buf[21] << 4) | w->buf[22]; + magic_bit = (w->buf[24] & 8) >> 3; + pr_debug("%4d %4d %4d %4d %4d %4d %4d %4d (magic %2x %d)\n", + val1, val2, val3, val4, val5, val6, val7, val8, + magic, magic_bit); + input_report_abs(w->input_dev, ABS_X, val2); input_report_abs(w->input_dev, ABS_Y, val1); input_report_abs(w->input_dev, ABS_Z, val6); @@ -187,6 +183,9 @@ static int walkera0701_open(struct input_dev *dev) { struct walkera_dev *w = input_get_drvdata(dev); + if (parport_claim(w->pardevice)) + return -EBUSY; + parport_enable_irq(w->parport); return 0; } @@ -197,40 +196,51 @@ static void walkera0701_close(struct input_dev *dev) parport_disable_irq(w->parport); hrtimer_cancel(&w->timer); + + parport_release(w->pardevice); } static int walkera0701_connect(struct walkera_dev *w, int parport) { - int err = -ENODEV; + int error; w->parport = parport_find_number(parport); - if (w->parport == NULL) + if (!w->parport) { + pr_err("parport %d does not exist\n", parport); return -ENODEV; + } if (w->parport->irq == -1) { - printk(KERN_ERR "walkera0701: parport without interrupt\n"); - goto init_err; + pr_err("parport %d does not have interrupt assigned\n", + parport); + error = -EINVAL; + goto err_put_parport; } - err = -EBUSY; w->pardevice = parport_register_device(w->parport, "walkera0701", NULL, NULL, walkera0701_irq_handler, PARPORT_DEV_EXCL, w); - if (!w->pardevice) - goto init_err; - - if (parport_negotiate(w->pardevice->port, IEEE1284_MODE_COMPAT)) - goto init_err1; + if (!w->pardevice) { + pr_err("failed to register parport device\n"); + error = -EIO; + goto err_put_parport; + } - if (parport_claim(w->pardevice)) - goto init_err1; + if (parport_negotiate(w->pardevice->port, IEEE1284_MODE_COMPAT)) { + pr_err("failed to negotiate parport mode\n"); + error = -EIO; + goto err_unregister_device; + } hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); w->timer.function = timer_handler; w->input_dev = input_allocate_device(); - if (!w->input_dev) - goto init_err2; + if (!w->input_dev) { + pr_err("failed to allocate input device\n"); + error = -ENOMEM; + goto err_unregister_device; + } input_set_drvdata(w->input_dev, w); w->input_dev->name = "Walkera WK-0701 TX"; @@ -241,6 +251,7 @@ static int walkera0701_connect(struct walkera_dev *w, int parport) w->input_dev->id.vendor = 0x0001; w->input_dev->id.product = 0x0001; w->input_dev->id.version = 0x0100; + w->input_dev->dev.parent = w->parport->dev; w->input_dev->open = walkera0701_open; w->input_dev->close = walkera0701_close; @@ -254,27 +265,26 @@ static int walkera0701_connect(struct walkera_dev *w, int parport) input_set_abs_params(w->input_dev, ABS_RUDDER, -512, 512, 0, 0); input_set_abs_params(w->input_dev, ABS_MISC, -512, 512, 0, 0); - err = input_register_device(w->input_dev); - if (err) - goto init_err3; + error = input_register_device(w->input_dev); + if (error) { + pr_err("failed to register input device\n"); + goto err_free_input_dev; + } return 0; - init_err3: +err_free_input_dev: input_free_device(w->input_dev); - init_err2: - parport_release(w->pardevice); - init_err1: +err_unregister_device: parport_unregister_device(w->pardevice); - init_err: +err_put_parport: parport_put_port(w->parport); - return err; + return error; } static void walkera0701_disconnect(struct walkera_dev *w) { input_unregister_device(w->input_dev); - parport_release(w->pardevice); parport_unregister_device(w->pardevice); parport_put_port(w->parport); } |