From f43aaba191bfbe20a1f55ec05f43813ce381cd53 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 19 Jan 2006 12:26:57 +0000 Subject: [ARM] Convert request_irq+set_irq_type to request_irq with SA_TRIGGER There's no need to have request_irq followed by set_irq_type. Just use request_irq with the appropriate SA_TRIGGER flags. Signed-off-by: Russell King --- drivers/input/touchscreen/ads7846.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index dd8c6a9ffc7..b45a45ca7cc 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -29,9 +29,6 @@ #ifdef CONFIG_ARCH_OMAP #include #endif - -#else -#define set_irq_type(irq,type) do{}while(0) #endif @@ -509,14 +506,14 @@ static int __devinit ads7846_probe(struct spi_device *spi) ts->msg.complete = ads7846_rx; ts->msg.context = ts; - if (request_irq(spi->irq, ads7846_irq, SA_SAMPLE_RANDOM, - spi->dev.bus_id, ts)) { + if (request_irq(spi->irq, ads7846_irq, + SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING, + spi->dev.bus_id, ts)) { dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); input_unregister_device(&ts->input); kfree(ts); return -EBUSY; } - set_irq_type(spi->irq, IRQT_FALLING); dev_info(&spi->dev, "touchscreen, irq %d\n", spi->irq); -- cgit v1.2.3 From 01387959022def72f95f4bc1341aa69e32a06b30 Mon Sep 17 00:00:00 2001 From: Alessandro Zummo Date: Sun, 29 Jan 2006 21:50:40 -0500 Subject: Input: add ixp4xx beeper driver This is a driver for beeper found in LinkSys NSLU2 boxes. It should work on any ixp4xx based platform. Signed-off-by: Alessandro Zummo Signed-off-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 12 +++ drivers/input/misc/Makefile | 1 + drivers/input/misc/ixp4xx-beeper.c | 183 +++++++++++++++++++++++++++++++++++++ 3 files changed, 196 insertions(+) create mode 100644 drivers/input/misc/ixp4xx-beeper.c (limited to 'drivers/input') diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index e08dbe08f46..4bad588d0e5 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -50,6 +50,18 @@ config INPUT_WISTRON_BTNS To compile this driver as a module, choose M here: the module will be called wistron_btns. +config INPUT_IXP4XX_BEEPER + tristate "IXP4XX Beeper support" + depends on ARCH_IXP4XX + help + If you say yes here, you can connect a beeper to the + ixp4xx gpio pins. This is used by the LinkSys NSLU2. + + If unsure, say Y. + + To compile this driver as a module, choose M here: the + module will be called ixp4xx-beeper. + config INPUT_UINPUT tristate "User level driver support" help diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index ce44cce0128..184c4129470 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -11,3 +11,4 @@ obj-$(CONFIG_INPUT_98SPKR) += 98spkr.o obj-$(CONFIG_INPUT_UINPUT) += uinput.o obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o +obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c new file mode 100644 index 00000000000..d448bb5e486 --- /dev/null +++ b/drivers/input/misc/ixp4xx-beeper.c @@ -0,0 +1,183 @@ +/* + * Generic IXP4xx beeper driver + * + * Copyright (C) 2005 Tower Technologies + * + * based on nslu2-io.c + * Copyright (C) 2004 Karen Spearel + * + * Author: Alessandro Zummo + * Maintainers: http://www.nslu2-linux.org/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include +#include +#include +#include + +MODULE_AUTHOR("Alessandro Zummo "); +MODULE_DESCRIPTION("ixp4xx beeper driver"); +MODULE_LICENSE("GPL"); + +static DEFINE_SPINLOCK(beep_lock); + +static void ixp4xx_spkr_control(unsigned int pin, unsigned int count) +{ + unsigned long flags; + + spin_lock_irqsave(&beep_lock, flags); + + if (count) { + gpio_line_config(pin, IXP4XX_GPIO_OUT); + gpio_line_set(pin, IXP4XX_GPIO_LOW); + + *IXP4XX_OSRT2 = (count & ~IXP4XX_OST_RELOAD_MASK) | IXP4XX_OST_ENABLE; + } else { + gpio_line_config(pin, IXP4XX_GPIO_IN); + gpio_line_set(pin, IXP4XX_GPIO_HIGH); + + *IXP4XX_OSRT2 = 0; + } + + spin_unlock_irqrestore(&beep_lock, flags); +} + +static int ixp4xx_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) +{ + unsigned int pin = (unsigned int) dev->private; + unsigned int count = 0; + + if (type != EV_SND) + return -1; + + switch (code) { + case SND_BELL: + if (value) + value = 1000; + case SND_TONE: + break; + default: + return -1; + } + + if (value > 20 && value < 32767) +#ifndef FREQ + count = (ixp4xx_get_board_tick_rate() / (value * 4)) - 1; +#else + count = (FREQ / (value * 4)) - 1; +#endif + + ixp4xx_spkr_control(pin, count); + + return 0; +} + +static irqreturn_t ixp4xx_spkr_interrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + /* clear interrupt */ + *IXP4XX_OSST = IXP4XX_OSST_TIMER_2_PEND; + + /* flip the beeper output */ + *IXP4XX_GPIO_GPOUTR ^= (1 << (unsigned int) dev_id); + + return IRQ_HANDLED; +} + +static int __devinit ixp4xx_spkr_probe(struct platform_device *dev) +{ + struct input_dev *input_dev; + int err; + + input_dev = input_allocate_device(); + if (!input_dev) + return -ENOMEM; + + input_dev->private = (void *) dev->id; + input_dev->name = "ixp4xx beeper", + input_dev->phys = "ixp4xx/gpio"; + input_dev->id.bustype = BUS_HOST; + input_dev->id.vendor = 0x001f; + input_dev->id.product = 0x0001; + input_dev->id.version = 0x0100; + input_dev->cdev.dev = &dev->dev; + + input_dev->evbit[0] = BIT(EV_SND); + input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); + input_dev->event = ixp4xx_spkr_event; + + err = request_irq(IRQ_IXP4XX_TIMER2, &ixp4xx_spkr_interrupt, + SA_INTERRUPT | SA_TIMER, "ixp4xx-beeper", (void *) dev->id); + if (err) + goto err_free_device; + + err = input_register_device(input_dev); + if (err) + goto err_free_irq; + + platform_set_drvdata(dev, input_dev); + + return 0; + + err_free_irq: + free_irq(IRQ_IXP4XX_TIMER2, dev); + err_free_device: + input_free_device(input_dev); + + return err; +} + +static int __devexit ixp4xx_spkr_remove(struct platform_device *dev) +{ + struct input_dev *input_dev = platform_get_drvdata(dev); + unsigned int pin = (unsigned int) input_dev->private; + + input_unregister_device(input_dev); + platform_set_drvdata(dev, NULL); + + /* turn the speaker off */ + disable_irq(IRQ_IXP4XX_TIMER2); + ixp4xx_spkr_control(pin, 0); + + free_irq(IRQ_IXP4XX_TIMER2, dev); + + return 0; +} + +static void ixp4xx_spkr_shutdown(struct platform_device *dev) +{ + struct input_dev *input_dev = platform_get_drvdata(dev); + unsigned int pin = (unsigned int) input_dev->private; + + /* turn off the speaker */ + disable_irq(IRQ_IXP4XX_TIMER2); + ixp4xx_spkr_control(pin, 0); +} + +static struct platform_driver ixp4xx_spkr_platform_driver = { + .driver = { + .name = "ixp4xx-beeper", + .owner = THIS_MODULE, + }, + .probe = ixp4xx_spkr_probe, + .remove = __devexit_p(ixp4xx_spkr_remove), + .shutdown = ixp4xx_spkr_shutdown, +}; + +static int __init ixp4xx_spkr_init(void) +{ + return platform_driver_register(&ixp4xx_spkr_platform_driver); +} + +static void __exit ixp4xx_spkr_exit(void) +{ + platform_driver_unregister(&ixp4xx_spkr_platform_driver); +} + +module_init(ixp4xx_spkr_init); +module_exit(ixp4xx_spkr_exit); -- cgit v1.2.3 From a3f3f3176686ada02d9eb5e4a6d7dff1ee13396c Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 29 Jan 2006 21:50:46 -0500 Subject: Input: psmouse - set name for Genius mice Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/psmouse-base.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/input') diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 7665fd9ce55..19b1b012172 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -403,6 +403,7 @@ static int genius_detect(struct psmouse *psmouse, int set_properties) set_bit(REL_WHEEL, psmouse->dev->relbit); psmouse->vendor = "Genius"; + psmouse->name = "Mouse"; psmouse->pktsize = 4; } -- cgit v1.2.3 From 5ae08f80ec5b2b08dd2f76a166140dd156fb31a1 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Sun, 29 Jan 2006 21:50:52 -0500 Subject: Input: iforce - do not return ENOMEM upon successful allocation Signed-off-by: Alexey Dobriyan Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/iforce/iforce-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c index 64b9c31c47f..b6bc0499804 100644 --- a/drivers/input/joystick/iforce/iforce-main.c +++ b/drivers/input/joystick/iforce/iforce-main.c @@ -345,7 +345,7 @@ int iforce_init_device(struct iforce *iforce) int i; input_dev = input_allocate_device(); - if (input_dev) + if (!input_dev) return -ENOMEM; init_waitqueue_head(&iforce->wait); -- cgit v1.2.3 From 74570d413cbb5cede06a0183a91d3006f134bf6b Mon Sep 17 00:00:00 2001 From: Kimball Murray Date: Sun, 29 Jan 2006 21:50:59 -0500 Subject: Input: mousedev - fix memory leak Apparently, "while true; do cat /dev/input/mice; done" causes an OOM in a short amount of time. Funny that nobody noticed, it actually is very easy to trigger just by switching between VT1 and VT7... Signed-off-by: Pete Zaitcev Signed-off-by: Dmitry Torokhov --- drivers/input/mousedev.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index 81fd7a97a93..9abed18d2ec 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c @@ -356,7 +356,7 @@ static void mousedev_free(struct mousedev *mousedev) kfree(mousedev); } -static int mixdev_release(void) +static void mixdev_release(void) { struct input_handle *handle; @@ -370,8 +370,6 @@ static int mixdev_release(void) mousedev_free(mousedev); } } - - return 0; } static int mousedev_release(struct inode * inode, struct file * file) @@ -384,9 +382,8 @@ static int mousedev_release(struct inode * inode, struct file * file) if (!--list->mousedev->open) { if (list->mousedev->minor == MOUSEDEV_MIX) - return mixdev_release(); - - if (!mousedev_mix.open) { + mixdev_release(); + else if (!mousedev_mix.open) { if (list->mousedev->exist) input_close_device(&list->mousedev->handle); else -- cgit v1.2.3 From ffc6b529e8c46c73827008c7406f43482d71beed Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sun, 29 Jan 2006 21:51:07 -0500 Subject: Input: make needlessly global code static Signed-off-by: Adrian Bunk Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/twidjoy.c | 4 ++-- drivers/input/touchscreen/mk712.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c index cd3a1e742a3..7f8b0093c5b 100644 --- a/drivers/input/joystick/twidjoy.c +++ b/drivers/input/joystick/twidjoy.c @@ -265,13 +265,13 @@ static struct serio_driver twidjoy_drv = { * The functions for inserting/removing us as a module. */ -int __init twidjoy_init(void) +static int __init twidjoy_init(void) { serio_register_driver(&twidjoy_drv); return 0; } -void __exit twidjoy_exit(void) +static void __exit twidjoy_exit(void) { serio_unregister_driver(&twidjoy_drv); } diff --git a/drivers/input/touchscreen/mk712.c b/drivers/input/touchscreen/mk712.c index 4844d250a5e..3226830eea0 100644 --- a/drivers/input/touchscreen/mk712.c +++ b/drivers/input/touchscreen/mk712.c @@ -154,7 +154,7 @@ static void mk712_close(struct input_dev *dev) spin_unlock_irqrestore(&mk712_lock, flags); } -int __init mk712_init(void) +static int __init mk712_init(void) { int err; -- cgit v1.2.3 From 3575c3410071dc778d2d9c6002493a5dce73ec0b Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 29 Jan 2006 21:51:16 -0500 Subject: Input: grip - fix crash when accessing device Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/grip.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/input') diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c index a936e7aedb1..330c6717c14 100644 --- a/drivers/input/joystick/grip.c +++ b/drivers/input/joystick/grip.c @@ -192,6 +192,9 @@ static void grip_poll(struct gameport *gameport) for (i = 0; i < 2; i++) { dev = grip->dev[i]; + if (!dev) + continue; + grip->reads++; switch (grip->mode[i]) { -- cgit v1.2.3 From 0399addd71565b27eae27821fa04dad44f8644fe Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 29 Jan 2006 21:51:21 -0500 Subject: Input: grip - handle errors from input_register_device() Also set .owner in driver structure so we'll have a link between module and driver in sysfs. Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/grip.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c index 330c6717c14..20cb98ac2d7 100644 --- a/drivers/input/joystick/grip.c +++ b/drivers/input/joystick/grip.c @@ -384,12 +384,15 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) if (t > 0) set_bit(t, input_dev->keybit); - input_register_device(grip->dev[i]); + err = input_register_device(grip->dev[i]); + if (err) + goto fail4; } return 0; - fail3: for (i = 0; i < 2; i++) + fail4: input_free_device(grip->dev[i]); + fail3: while (--i >= 0) if (grip->dev[i]) input_unregister_device(grip->dev[i]); fail2: gameport_close(gameport); @@ -414,6 +417,7 @@ static void grip_disconnect(struct gameport *gameport) static struct gameport_driver grip_drv = { .driver = { .name = "grip", + .owner = THIS_MODULE, }, .description = DRIVER_DESC, .connect = grip_connect, -- cgit v1.2.3 From 84c61896bd756a440c54be07b6e97ad230f31a16 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 29 Jan 2006 21:51:31 -0500 Subject: Input: db9 - fix possible crash with Saturn gamepads Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/db9.c | 70 +++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 34 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c index 499344c7275..98479b82842 100644 --- a/drivers/input/joystick/db9.c +++ b/drivers/input/joystick/db9.c @@ -275,68 +275,70 @@ static unsigned char db9_saturn_read_packet(struct parport *port, unsigned char /* * db9_saturn_report() analyzes packet and reports. */ -static int db9_saturn_report(unsigned char id, unsigned char data[60], struct input_dev *dev, int n, int max_pads) +static int db9_saturn_report(unsigned char id, unsigned char data[60], struct input_dev *devs[], int n, int max_pads) { + struct input_dev *dev; int tmp, i, j; tmp = (id == 0x41) ? 60 : 10; - for (j = 0; (j < tmp) && (n < max_pads); j += 10, n++) { + for (j = 0; j < tmp && n < max_pads; j += 10, n++) { + dev = devs[n]; switch (data[j]) { case 0x16: /* multi controller (analog 4 axis) */ - input_report_abs(dev + n, db9_abs[5], data[j + 6]); + input_report_abs(dev, db9_abs[5], data[j + 6]); case 0x15: /* mission stick (analog 3 axis) */ - input_report_abs(dev + n, db9_abs[3], data[j + 4]); - input_report_abs(dev + n, db9_abs[4], data[j + 5]); + input_report_abs(dev, db9_abs[3], data[j + 4]); + input_report_abs(dev, db9_abs[4], data[j + 5]); case 0x13: /* racing controller (analog 1 axis) */ - input_report_abs(dev + n, db9_abs[2], data[j + 3]); + input_report_abs(dev, db9_abs[2], data[j + 3]); case 0x34: /* saturn keyboard (udlr ZXC ASD QE Esc) */ case 0x02: /* digital pad (digital 2 axis + buttons) */ - input_report_abs(dev + n, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64)); - input_report_abs(dev + n, db9_abs[1], !(data[j + 1] & 32) - !(data[j + 1] & 16)); + input_report_abs(dev, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64)); + input_report_abs(dev, db9_abs[1], !(data[j + 1] & 32) - !(data[j + 1] & 16)); for (i = 0; i < 9; i++) - input_report_key(dev + n, db9_cd32_btn[i], ~data[j + db9_saturn_byte[i]] & db9_saturn_mask[i]); + input_report_key(dev, db9_cd32_btn[i], ~data[j + db9_saturn_byte[i]] & db9_saturn_mask[i]); break; case 0x19: /* mission stick x2 (analog 6 axis + buttons) */ - input_report_abs(dev + n, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64)); - input_report_abs(dev + n, db9_abs[1], !(data[j + 1] & 32) - !(data[j + 1] & 16)); + input_report_abs(dev, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64)); + input_report_abs(dev, db9_abs[1], !(data[j + 1] & 32) - !(data[j + 1] & 16)); for (i = 0; i < 9; i++) - input_report_key(dev + n, db9_cd32_btn[i], ~data[j + db9_saturn_byte[i]] & db9_saturn_mask[i]); - input_report_abs(dev + n, db9_abs[2], data[j + 3]); - input_report_abs(dev + n, db9_abs[3], data[j + 4]); - input_report_abs(dev + n, db9_abs[4], data[j + 5]); + input_report_key(dev, db9_cd32_btn[i], ~data[j + db9_saturn_byte[i]] & db9_saturn_mask[i]); + input_report_abs(dev, db9_abs[2], data[j + 3]); + input_report_abs(dev, db9_abs[3], data[j + 4]); + input_report_abs(dev, db9_abs[4], data[j + 5]); /* - input_report_abs(dev + n, db9_abs[8], (data[j + 6] & 128 ? 0 : 1) - (data[j + 6] & 64 ? 0 : 1)); - input_report_abs(dev + n, db9_abs[9], (data[j + 6] & 32 ? 0 : 1) - (data[j + 6] & 16 ? 0 : 1)); + input_report_abs(dev, db9_abs[8], (data[j + 6] & 128 ? 0 : 1) - (data[j + 6] & 64 ? 0 : 1)); + input_report_abs(dev, db9_abs[9], (data[j + 6] & 32 ? 0 : 1) - (data[j + 6] & 16 ? 0 : 1)); */ - input_report_abs(dev + n, db9_abs[6], data[j + 7]); - input_report_abs(dev + n, db9_abs[7], data[j + 8]); - input_report_abs(dev + n, db9_abs[5], data[j + 9]); + input_report_abs(dev, db9_abs[6], data[j + 7]); + input_report_abs(dev, db9_abs[7], data[j + 8]); + input_report_abs(dev, db9_abs[5], data[j + 9]); break; case 0xd3: /* sankyo ff (analog 1 axis + stop btn) */ - input_report_key(dev + n, BTN_A, data[j + 3] & 0x80); - input_report_abs(dev + n, db9_abs[2], data[j + 3] & 0x7f); + input_report_key(dev, BTN_A, data[j + 3] & 0x80); + input_report_abs(dev, db9_abs[2], data[j + 3] & 0x7f); break; case 0xe3: /* shuttle mouse (analog 2 axis + buttons. signed value) */ - input_report_key(dev + n, BTN_START, data[j + 1] & 0x08); - input_report_key(dev + n, BTN_A, data[j + 1] & 0x04); - input_report_key(dev + n, BTN_C, data[j + 1] & 0x02); - input_report_key(dev + n, BTN_B, data[j + 1] & 0x01); - input_report_abs(dev + n, db9_abs[2], data[j + 2] ^ 0x80); - input_report_abs(dev + n, db9_abs[3], (0xff-(data[j + 3] ^ 0x80))+1); /* */ + input_report_key(dev, BTN_START, data[j + 1] & 0x08); + input_report_key(dev, BTN_A, data[j + 1] & 0x04); + input_report_key(dev, BTN_C, data[j + 1] & 0x02); + input_report_key(dev, BTN_B, data[j + 1] & 0x01); + input_report_abs(dev, db9_abs[2], data[j + 2] ^ 0x80); + input_report_abs(dev, db9_abs[3], (0xff-(data[j + 3] ^ 0x80))+1); /* */ break; case 0xff: default: /* no pad */ - input_report_abs(dev + n, db9_abs[0], 0); - input_report_abs(dev + n, db9_abs[1], 0); + input_report_abs(dev, db9_abs[0], 0); + input_report_abs(dev, db9_abs[1], 0); for (i = 0; i < 9; i++) - input_report_key(dev + n, db9_cd32_btn[i], 0); + input_report_key(dev, db9_cd32_btn[i], 0); break; } } return n; } -static int db9_saturn(int mode, struct parport *port, struct input_dev *dev) +static int db9_saturn(int mode, struct parport *port, struct input_dev *devs[]) { unsigned char id, data[60]; int type, n, max_pads; @@ -361,7 +363,7 @@ static int db9_saturn(int mode, struct parport *port, struct input_dev *dev) max_pads = min(db9_modes[mode].n_pads, DB9_MAX_DEVICES); for (tmp = 0, i = 0; i < n; i++) { id = db9_saturn_read_packet(port, data, type + i, 1); - tmp = db9_saturn_report(id, data, dev, tmp, max_pads); + tmp = db9_saturn_report(id, data, devs, tmp, max_pads); } return 0; } @@ -489,7 +491,7 @@ static void db9_timer(unsigned long private) case DB9_SATURN_DPP: case DB9_SATURN_DPP_2: - db9_saturn(db9->mode, port, dev); + db9_saturn(db9->mode, port, db9->dev); break; case DB9_CD32_PAD: -- cgit v1.2.3 From 2e9d675ed24bcefd0d99b531a9d7faf794b762c8 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 29 Jan 2006 21:51:36 -0500 Subject: Input: db9 - handle errors from input_register_device() Also db9_remove shouldn't be marked __exit as it is also called from __init code. Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/db9.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c index 98479b82842..dcffc34f30c 100644 --- a/drivers/input/joystick/db9.c +++ b/drivers/input/joystick/db9.c @@ -616,7 +616,7 @@ static struct db9 __init *db9_probe(int parport, int mode) if (!input_dev) { printk(KERN_ERR "db9.c: Not enough memory for input device\n"); err = -ENOMEM; - goto err_free_devs; + goto err_unreg_devs; } sprintf(db9->phys[i], "%s/input%d", db9->pd->port->name, i); @@ -642,13 +642,17 @@ static struct db9 __init *db9_probe(int parport, int mode) input_set_abs_params(input_dev, db9_abs[j], 1, 255, 0, 0); } - input_register_device(input_dev); + err = input_register_device(input_dev); + if (err) + goto err_free_dev; } parport_put_port(pp); return db9; - err_free_devs: + err_free_dev: + input_free_device(db9->dev[i]); + err_unreg_devs: while (--i >= 0) input_unregister_device(db9->dev[i]); kfree(db9); @@ -660,7 +664,7 @@ static struct db9 __init *db9_probe(int parport, int mode) return ERR_PTR(err); } -static void __exit db9_remove(struct db9 *db9) +static void db9_remove(struct db9 *db9) { int i; @@ -698,7 +702,8 @@ static int __init db9_init(void) if (err) { while (--i >= 0) - db9_remove(db9_base[i]); + if (db9_base[i]) + db9_remove(db9_base[i]); return err; } -- cgit v1.2.3 From 847fd5fbf70e82baf042556968f885066489b164 Mon Sep 17 00:00:00 2001 From: Zinx Verituse Date: Sun, 29 Jan 2006 21:51:51 -0500 Subject: Input: sidewinder - fix an oops Dynalloc conversion strikes again... Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/sidewinder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c index 78dd163cd70..03f9e7ed030 100644 --- a/drivers/input/joystick/sidewinder.c +++ b/drivers/input/joystick/sidewinder.c @@ -736,7 +736,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) sprintf(sw->name, "Microsoft SideWinder %s", sw_name[sw->type]); sprintf(sw->phys[i], "%s/input%d", gameport->phys, i); - input_dev = input_allocate_device(); + sw->dev[i] = input_dev = input_allocate_device(); if (!input_dev) { err = -ENOMEM; goto fail3; -- cgit v1.2.3 From 07cf779c0098fd0007d2348e1cf948cc07bfe096 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 29 Jan 2006 21:51:56 -0500 Subject: Input: sidewinder - handle errors from input_register_device() Also set .owner in driver structure so we'll have a link between module and driver in sysfs. Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/sidewinder.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c index 03f9e7ed030..2b2ec1057de 100644 --- a/drivers/input/joystick/sidewinder.c +++ b/drivers/input/joystick/sidewinder.c @@ -771,12 +771,15 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k); - input_register_device(sw->dev[i]); + err = input_register_device(sw->dev[i]); + if (err) + goto fail4; } return 0; - fail3: while (--i >= 0) + fail4: input_free_device(sw->dev[i]); + fail3: while (--i >= 0) input_unregister_device(sw->dev[i]); fail2: gameport_close(gameport); fail1: gameport_set_drvdata(gameport, NULL); @@ -801,6 +804,7 @@ static void sw_disconnect(struct gameport *gameport) static struct gameport_driver sw_drv = { .driver = { .name = "sidewinder", + .owner = THIS_MODULE, }, .description = DRIVER_DESC, .connect = sw_connect, -- cgit v1.2.3 From c7fd018d75cae2b0c1cf03003b38f4c76e3df826 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 29 Jan 2006 21:52:04 -0500 Subject: Input: gamecon - fix crash when accessing device Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/gamecon.c | 343 ++++++++++++++++++++++----------------- 1 file changed, 194 insertions(+), 149 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c index 7df2d82f2c8..d9757452c93 100644 --- a/drivers/input/joystick/gamecon.c +++ b/drivers/input/joystick/gamecon.c @@ -159,6 +159,48 @@ static void gc_n64_read_packet(struct gc *gc, unsigned char *data) } +static void gc_n64_process_packet(struct gc *gc) +{ + unsigned char data[GC_N64_LENGTH]; + signed char axes[2]; + struct input_dev *dev; + int i, j, s; + + gc_n64_read_packet(gc, data); + + for (i = 0; i < GC_MAX_DEVICES; i++) { + + dev = gc->dev[i]; + if (!dev) + continue; + + s = gc_status_bit[i]; + + if (s & gc->pads[GC_N64] & ~(data[8] | data[9])) { + + axes[0] = axes[1] = 0; + + for (j = 0; j < 8; j++) { + if (data[23 - j] & s) + axes[0] |= 1 << j; + if (data[31 - j] & s) + axes[1] |= 1 << j; + } + + input_report_abs(dev, ABS_X, axes[0]); + input_report_abs(dev, ABS_Y, -axes[1]); + + input_report_abs(dev, ABS_HAT0X, !(s & data[6]) - !(s & data[7])); + input_report_abs(dev, ABS_HAT0Y, !(s & data[4]) - !(s & data[5])); + + for (j = 0; j < 10; j++) + input_report_key(dev, gc_n64_btn[j], s & data[gc_n64_bytes[j]]); + + input_sync(dev); + } + } +} + /* * NES/SNES support. */ @@ -198,6 +240,39 @@ static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data) } } +static void gc_nes_process_packet(struct gc *gc) +{ + unsigned char data[GC_SNES_LENGTH]; + struct input_dev *dev; + int i, j, s; + + gc_nes_read_packet(gc, gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH, data); + + for (i = 0; i < GC_MAX_DEVICES; i++) { + + dev = gc->dev[i]; + if (!dev) + continue; + + s = gc_status_bit[i]; + + if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) { + input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7])); + input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5])); + } + + if (s & gc->pads[GC_NES]) + for (j = 0; j < 4; j++) + input_report_key(dev, gc_snes_btn[j], s & data[gc_nes_bytes[j]]); + + if (s & gc->pads[GC_SNES]) + for (j = 0; j < 8; j++) + input_report_key(dev, gc_snes_btn[j], s & data[gc_snes_bytes[j]]); + + input_sync(dev); + } +} + /* * Multisystem joystick support */ @@ -219,6 +294,35 @@ static void gc_multi_read_packet(struct gc *gc, int length, unsigned char *data) } } +static void gc_multi_process_packet(struct gc *gc) +{ + unsigned char data[GC_MULTI2_LENGTH]; + struct input_dev *dev; + int i, s; + + gc_multi_read_packet(gc, gc->pads[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH, data); + + for (i = 0; i < GC_MAX_DEVICES; i++) { + + dev = gc->dev[i]; + if (!dev) + continue; + + s = gc_status_bit[i]; + + if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) { + input_report_abs(dev, ABS_X, !(s & data[2]) - !(s & data[3])); + input_report_abs(dev, ABS_Y, !(s & data[0]) - !(s & data[1])); + input_report_key(dev, BTN_TRIGGER, s & data[4]); + } + + if (s & gc->pads[GC_MULTI2]) + input_report_key(dev, BTN_THUMB, s & data[5]); + + input_sync(dev); + } +} + /* * PSX support * @@ -263,10 +367,11 @@ static short gc_psx_ddr_btn[] = { BTN_0, BTN_1, BTN_2, BTN_3 }; * the psx pad. */ -static void gc_psx_command(struct gc *gc, int b, unsigned char data[5]) +static void gc_psx_command(struct gc *gc, int b, unsigned char data[GC_MAX_DEVICES]) { int i, j, cmd, read; - for (i = 0; i < 5; i++) + + for (i = 0; i < GC_MAX_DEVICES; i++) data[i] = 0; for (i = 0; i < GC_PSX_LENGTH; i++, b >>= 1) { @@ -274,7 +379,7 @@ static void gc_psx_command(struct gc *gc, int b, unsigned char data[5]) parport_write_data(gc->pd->port, cmd | GC_PSX_POWER); udelay(gc_psx_delay); read = parport_read_status(gc->pd->port) ^ 0x80; - for (j = 0; j < 5; j++) + for (j = 0; j < GC_MAX_DEVICES; j++) data[j] |= (read & gc_status_bit[j] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) ? (1 << i) : 0; parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); udelay(gc_psx_delay); @@ -286,11 +391,12 @@ static void gc_psx_command(struct gc *gc, int b, unsigned char data[5]) * device identifier code. */ -static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES], unsigned char id[5]) +static void gc_psx_read_packet(struct gc *gc, unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES], + unsigned char id[GC_MAX_DEVICES]) { int i, j, max_len = 0; unsigned long flags; - unsigned char data2[5]; + unsigned char data2[GC_MAX_DEVICES]; parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); /* Select pad */ udelay(gc_psx_delay); @@ -303,7 +409,7 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES gc_psx_command(gc, 0x42, id); /* Get device ids */ gc_psx_command(gc, 0, data2); /* Dump status */ - for (i =0; i < 5; i++) /* Find the longest pad */ + for (i =0; i < GC_MAX_DEVICES; i++) /* Find the longest pad */ if((gc_status_bit[i] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) && (GC_PSX_LEN(id[i]) > max_len) && (GC_PSX_LEN(id[i]) <= GC_PSX_BYTES)) @@ -311,7 +417,7 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES for (i = 0; i < max_len; i++) { /* Read in all the data */ gc_psx_command(gc, 0, data2); - for (j = 0; j < 5; j++) + for (j = 0; j < GC_MAX_DEVICES; j++) data[j][i] = data2[j]; } @@ -319,185 +425,124 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); - for(i = 0; i < 5; i++) /* Set id's to the real value */ + for(i = 0; i < GC_MAX_DEVICES; i++) /* Set id's to the real value */ id[i] = GC_PSX_ID(id[i]); } -/* - * gc_timer() reads and analyzes console pads data. - */ +static void gc_psx_process_packet(struct gc *gc) +{ + unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES]; + unsigned char id[GC_MAX_DEVICES]; + struct input_dev *dev; + int i, j; -#define GC_MAX_LENGTH GC_N64_LENGTH + gc_psx_read_packet(gc, data, id); -static void gc_timer(unsigned long private) -{ - struct gc *gc = (void *) private; - unsigned char data[GC_MAX_LENGTH]; - unsigned char data_psx[5][GC_PSX_BYTES]; - int i, j, s; + for (i = 0; i < GC_MAX_DEVICES; i++) { -/* - * N64 pads - must be read first, any read confuses them for 200 us - */ + dev = gc->dev[i]; + if (!dev) + continue; - if (gc->pads[GC_N64]) { + switch (id[i]) { - gc_n64_read_packet(gc, data); + case GC_PSX_RUMBLE: - for (i = 0; i < 5; i++) { + input_report_key(dev, BTN_THUMBL, ~data[i][0] & 0x04); + input_report_key(dev, BTN_THUMBR, ~data[i][0] & 0x02); - s = gc_status_bit[i]; + case GC_PSX_NEGCON: + case GC_PSX_ANALOG: - if (s & gc->pads[GC_N64] & ~(data[8] | data[9])) { + if (gc->pads[GC_DDR] & gc_status_bit[i]) { + for(j = 0; j < 4; j++) + input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j)); + } else { + for (j = 0; j < 4; j++) + input_report_abs(dev, gc_psx_abs[j + 2], data[i][j + 2]); - signed char axes[2]; - axes[0] = axes[1] = 0; + input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128); + input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128); + } - for (j = 0; j < 8; j++) { - if (data[23 - j] & s) axes[0] |= 1 << j; - if (data[31 - j] & s) axes[1] |= 1 << j; + for (j = 0; j < 8; j++) + input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j)); + + input_report_key(dev, BTN_START, ~data[i][0] & 0x08); + input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01); + + input_sync(dev); + + break; + + case GC_PSX_NORMAL: + if (gc->pads[GC_DDR] & gc_status_bit[i]) { + for(j = 0; j < 4; j++) + input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j)); + } else { + input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128); + input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128); + + /* for some reason if the extra axes are left unset they drift */ + /* for (j = 0; j < 4; j++) + input_report_abs(dev, gc_psx_abs[j + 2], 128); + * This needs to be debugged properly, + * maybe fuzz processing needs to be done in input_sync() + * --vojtech + */ } - input_report_abs(gc->dev[i], ABS_X, axes[0]); - input_report_abs(gc->dev[i], ABS_Y, -axes[1]); + for (j = 0; j < 8; j++) + input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j)); - input_report_abs(gc->dev[i], ABS_HAT0X, !(s & data[6]) - !(s & data[7])); - input_report_abs(gc->dev[i], ABS_HAT0Y, !(s & data[4]) - !(s & data[5])); + input_report_key(dev, BTN_START, ~data[i][0] & 0x08); + input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01); - for (j = 0; j < 10; j++) - input_report_key(gc->dev[i], gc_n64_btn[j], s & data[gc_n64_bytes[j]]); + input_sync(dev); - input_sync(gc->dev[i]); - } + break; + + case 0: /* not a pad, ignore */ + break; } } +} /* - * NES and SNES pads + * gc_timer() initiates reads of console pads data. */ - if (gc->pads[GC_NES] || gc->pads[GC_SNES]) { - - gc_nes_read_packet(gc, gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH, data); - - for (i = 0; i < 5; i++) { - - s = gc_status_bit[i]; +static void gc_timer(unsigned long private) +{ + struct gc *gc = (void *) private; - if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) { - input_report_abs(gc->dev[i], ABS_X, !(s & data[6]) - !(s & data[7])); - input_report_abs(gc->dev[i], ABS_Y, !(s & data[4]) - !(s & data[5])); - } +/* + * N64 pads - must be read first, any read confuses them for 200 us + */ - if (s & gc->pads[GC_NES]) - for (j = 0; j < 4; j++) - input_report_key(gc->dev[i], gc_snes_btn[j], s & data[gc_nes_bytes[j]]); + if (gc->pads[GC_N64]) + gc_n64_process_packet(gc); - if (s & gc->pads[GC_SNES]) - for (j = 0; j < 8; j++) - input_report_key(gc->dev[i], gc_snes_btn[j], s & data[gc_snes_bytes[j]]); +/* + * NES and SNES pads + */ - input_sync(gc->dev[i]); - } - } + if (gc->pads[GC_NES] || gc->pads[GC_SNES]) + gc_nes_process_packet(gc); /* * Multi and Multi2 joysticks */ - if (gc->pads[GC_MULTI] || gc->pads[GC_MULTI2]) { - - gc_multi_read_packet(gc, gc->pads[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH, data); - - for (i = 0; i < 5; i++) { - - s = gc_status_bit[i]; - - if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) { - input_report_abs(gc->dev[i], ABS_X, !(s & data[2]) - !(s & data[3])); - input_report_abs(gc->dev[i], ABS_Y, !(s & data[0]) - !(s & data[1])); - input_report_key(gc->dev[i], BTN_TRIGGER, s & data[4]); - } - - if (s & gc->pads[GC_MULTI2]) - input_report_key(gc->dev[i], BTN_THUMB, s & data[5]); - - input_sync(gc->dev[i]); - } - } + if (gc->pads[GC_MULTI] || gc->pads[GC_MULTI2]) + gc_multi_process_packet(gc); /* * PSX controllers */ - if (gc->pads[GC_PSX] || gc->pads[GC_DDR]) { - - gc_psx_read_packet(gc, data_psx, data); - - for (i = 0; i < 5; i++) { - switch (data[i]) { - - case GC_PSX_RUMBLE: - - input_report_key(gc->dev[i], BTN_THUMBL, ~data_psx[i][0] & 0x04); - input_report_key(gc->dev[i], BTN_THUMBR, ~data_psx[i][0] & 0x02); - - case GC_PSX_NEGCON: - case GC_PSX_ANALOG: - - if (gc->pads[GC_DDR] & gc_status_bit[i]) { - for(j = 0; j < 4; j++) - input_report_key(gc->dev[i], gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j)); - } else { - for (j = 0; j < 4; j++) - input_report_abs(gc->dev[i], gc_psx_abs[j+2], data_psx[i][j + 2]); - - input_report_abs(gc->dev[i], ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128); - input_report_abs(gc->dev[i], ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128); - } - - for (j = 0; j < 8; j++) - input_report_key(gc->dev[i], gc_psx_btn[j], ~data_psx[i][1] & (1 << j)); - - input_report_key(gc->dev[i], BTN_START, ~data_psx[i][0] & 0x08); - input_report_key(gc->dev[i], BTN_SELECT, ~data_psx[i][0] & 0x01); - - input_sync(gc->dev[i]); - - break; - - case GC_PSX_NORMAL: - if (gc->pads[GC_DDR] & gc_status_bit[i]) { - for(j = 0; j < 4; j++) - input_report_key(gc->dev[i], gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j)); - } else { - input_report_abs(gc->dev[i], ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128); - input_report_abs(gc->dev[i], ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128); - - /* for some reason if the extra axes are left unset they drift */ - /* for (j = 0; j < 4; j++) - input_report_abs(gc->dev[i], gc_psx_abs[j+2], 128); - * This needs to be debugged properly, - * maybe fuzz processing needs to be done in input_sync() - * --vojtech - */ - } - - for (j = 0; j < 8; j++) - input_report_key(gc->dev[i], gc_psx_btn[j], ~data_psx[i][1] & (1 << j)); - - input_report_key(gc->dev[i], BTN_START, ~data_psx[i][0] & 0x08); - input_report_key(gc->dev[i], BTN_SELECT, ~data_psx[i][0] & 0x01); - - input_sync(gc->dev[i]); - - break; - - case 0: /* not a pad, ignore */ - break; - } - } - } + if (gc->pads[GC_PSX] || gc->pads[GC_DDR]) + gc_psx_process_packet(gc); mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); } @@ -654,7 +699,7 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads) gc->timer.data = (long) gc; gc->timer.function = gc_timer; - for (i = 0; i < n_pads; i++) { + for (i = 0; i < n_pads && i < GC_MAX_DEVICES; i++) { if (!pads[i]) continue; -- cgit v1.2.3 From 77fc46ca5b331df3fc0ffef24012ba0d51d601b3 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 29 Jan 2006 21:52:11 -0500 Subject: Input: gamecon - handle errors from input_register_device() Also gc_remove shouldn't be marked __exit as it is also called from __init code. Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/gamecon.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c index d9757452c93..900587acdb4 100644 --- a/drivers/input/joystick/gamecon.c +++ b/drivers/input/joystick/gamecon.c @@ -706,9 +706,11 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads) sprintf(gc->phys[i], "%s/input%d", gc->pd->port->name, i); err = gc_setup_pad(gc, i, pads[i]); if (err) - goto err_free_devs; + goto err_unreg_devs; - input_register_device(gc->dev[i]); + err = input_register_device(gc->dev[i]); + if (err) + goto err_free_dev; } if (!gc->pads[0]) { @@ -720,9 +722,12 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads) parport_put_port(pp); return gc; - err_free_devs: + err_free_dev: + input_free_device(gc->dev[i]); + err_unreg_devs: while (--i >= 0) - input_unregister_device(gc->dev[i]); + if (gc->dev[i]) + input_unregister_device(gc->dev[i]); err_free_gc: kfree(gc); err_unreg_pardev: @@ -733,7 +738,7 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads) return ERR_PTR(err); } -static void __exit gc_remove(struct gc *gc) +static void gc_remove(struct gc *gc) { int i; @@ -771,7 +776,8 @@ static int __init gc_init(void) if (err) { while (--i >= 0) - gc_remove(gc_base[i]); + if (gc_base[i]) + gc_remove(gc_base[i]); return err; } -- cgit v1.2.3 From ab52cd66ae4c3e097811b6c370de7fc057959419 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 29 Jan 2006 21:52:18 -0500 Subject: Input: turbografx - handle errors from input_register_device() Also tgfx_remove shouldn't be marked __exit as it is also called from __init code. Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/turbografx.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c index 7e9764937d0..b154938e88a 100644 --- a/drivers/input/joystick/turbografx.c +++ b/drivers/input/joystick/turbografx.c @@ -204,14 +204,14 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) if (n_buttons[i] > 6) { printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]); err = -EINVAL; - goto err_free_devs; + goto err_unreg_devs; } tgfx->dev[i] = input_dev = input_allocate_device(); if (!input_dev) { printk(KERN_ERR "turbografx.c: Not enough memory for input device\n"); err = -ENOMEM; - goto err_free_devs; + goto err_unreg_devs; } tgfx->sticks |= (1 << i); @@ -238,7 +238,9 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) for (j = 0; j < n_buttons[i]; j++) set_bit(tgfx_buttons[j], input_dev->keybit); - input_register_device(tgfx->dev[i]); + err = input_register_device(tgfx->dev[i]); + if (err) + goto err_free_dev; } if (!tgfx->sticks) { @@ -249,9 +251,12 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) return tgfx; - err_free_devs: + err_free_dev: + input_free_device(tgfx->dev[i]); + err_unreg_devs: while (--i >= 0) - input_unregister_device(tgfx->dev[i]); + if (tgfx->dev[i]) + input_unregister_device(tgfx->dev[i]); err_free_tgfx: kfree(tgfx); err_unreg_pardev: @@ -262,7 +267,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) return ERR_PTR(err); } -static void __exit tgfx_remove(struct tgfx *tgfx) +static void tgfx_remove(struct tgfx *tgfx) { int i; @@ -300,7 +305,8 @@ static int __init tgfx_init(void) if (err) { while (--i >= 0) - tgfx_remove(tgfx_base[i]); + if (tgfx_base[i]) + tgfx_remove(tgfx_base[i]); return err; } -- cgit v1.2.3 From 4d462b9e2372f9f5a885f8b7e1597fe7412347fd Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 29 Jan 2006 21:52:26 -0500 Subject: Input: tmdc - handle errors from input_register_device() Also set .owner in driver structure so we'll have a link between module and driver in sysfs. Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/tmdc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c index 60e2aac7d06..bb23ed2a04a 100644 --- a/drivers/input/joystick/tmdc.c +++ b/drivers/input/joystick/tmdc.c @@ -284,13 +284,13 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data) struct tmdc_port *port; struct input_dev *input_dev; int i, j, b = 0; + int err; tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL); input_dev = input_allocate_device(); if (!port || !input_dev) { - kfree(port); - input_free_device(input_dev); - return -ENOMEM; + err = -ENOMEM; + goto fail; } port->mode = data[TMDC_BYTE_ID]; @@ -347,9 +347,15 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data) b += port->btnc[i]; } - input_register_device(port->dev); + err = input_register_device(port->dev); + if (err) + goto fail; return 0; + + fail: input_free_device(input_dev); + kfree(port); + return err; } /* @@ -424,6 +430,7 @@ static void tmdc_disconnect(struct gameport *gameport) static struct gameport_driver tmdc_drv = { .driver = { .name = "tmdc", + .owner = THIS_MODULE, }, .description = DRIVER_DESC, .connect = tmdc_connect, -- cgit v1.2.3 From 275c6ce25d679a4c0981a9a259e60e732a123cc6 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 29 Jan 2006 21:52:39 -0500 Subject: Input: a3d - convert to dynamic input_dev allocation Also set .owner in driver structure so we'll have a link between module and driver in sysfs. Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/a3d.c | 88 +++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 42 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c index 4571ea3a4b9..4612d13ea75 100644 --- a/drivers/input/joystick/a3d.c +++ b/drivers/input/joystick/a3d.c @@ -57,7 +57,7 @@ static char *a3d_names[] = { NULL, "FP-Gaming Assassin 3D", "MadCatz Panther", " struct a3d { struct gameport *gameport; struct gameport *adc; - struct input_dev dev; + struct input_dev *dev; int axes[4]; int buttons; int mode; @@ -115,7 +115,7 @@ static int a3d_csum(char *data, int count) static void a3d_read(struct a3d *a3d, unsigned char *data) { - struct input_dev *dev = &a3d->dev; + struct input_dev *dev = a3d->dev; switch (a3d->mode) { @@ -265,14 +265,20 @@ static void a3d_close(struct input_dev *dev) static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) { struct a3d *a3d; + struct input_dev *input_dev; struct gameport *adc; unsigned char data[A3D_MAX_LENGTH]; int i; int err; - if (!(a3d = kzalloc(sizeof(struct a3d), GFP_KERNEL))) - return -ENOMEM; + a3d = kzalloc(sizeof(struct a3d), GFP_KERNEL); + input_dev = input_allocate_device(); + if (!a3d || !input_dev) { + err = -ENOMEM; + goto fail1; + } + a3d->dev = input_dev; a3d->gameport = gameport; gameport_set_drvdata(gameport, a3d); @@ -302,42 +308,48 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) sprintf(a3d->phys, "%s/input0", gameport->phys); + input_dev->name = a3d_names[a3d->mode]; + input_dev->phys = a3d->phys; + input_dev->id.bustype = BUS_GAMEPORT; + input_dev->id.vendor = GAMEPORT_ID_VENDOR_MADCATZ; + input_dev->id.product = a3d->mode; + input_dev->id.version = 0x0100; + input_dev->cdev.dev = &gameport->dev; + input_dev->private = a3d; + input_dev->open = a3d_open; + input_dev->close = a3d_close; + if (a3d->mode == A3D_MODE_PXL) { int axes[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RUDDER }; a3d->length = 33; - init_input_dev(&a3d->dev); - - a3d->dev.evbit[0] |= BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); - a3d->dev.relbit[0] |= BIT(REL_X) | BIT(REL_Y); - a3d->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_THROTTLE) | BIT(ABS_RUDDER) - | BIT(ABS_HAT0X) | BIT(ABS_HAT0Y) | BIT(ABS_HAT1X) | BIT(ABS_HAT1Y); - - a3d->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE) - | BIT(BTN_SIDE) | BIT(BTN_EXTRA); - - a3d->dev.keybit[LONG(BTN_JOYSTICK)] |= BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | BIT(BTN_PINKIE); + input_dev->evbit[0] |= BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); + input_dev->relbit[0] |= BIT(REL_X) | BIT(REL_Y); + input_dev->absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_THROTTLE) | BIT(ABS_RUDDER) + | BIT(ABS_HAT0X) | BIT(ABS_HAT0Y) | BIT(ABS_HAT1X) | BIT(ABS_HAT1Y); + input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE) + | BIT(BTN_SIDE) | BIT(BTN_EXTRA); + input_dev->keybit[LONG(BTN_JOYSTICK)] |= BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) + | BIT(BTN_PINKIE); a3d_read(a3d, data); for (i = 0; i < 4; i++) { if (i < 2) - input_set_abs_params(&a3d->dev, axes[i], 48, a3d->dev.abs[axes[i]] * 2 - 48, 0, 8); + input_set_abs_params(input_dev, axes[i], 48, input_dev->abs[axes[i]] * 2 - 48, 0, 8); else - input_set_abs_params(&a3d->dev, axes[i], 2, 253, 0, 0); - input_set_abs_params(&a3d->dev, ABS_HAT0X + i, -1, 1, 0, 0); + input_set_abs_params(input_dev, axes[i], 2, 253, 0, 0); + input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0); } } else { a3d->length = 29; - init_input_dev(&a3d->dev); - - a3d->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_REL); - a3d->dev.relbit[0] |= BIT(REL_X) | BIT(REL_Y); - a3d->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE); + input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_REL); + input_dev->relbit[0] |= BIT(REL_X) | BIT(REL_Y); + input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE); a3d_read(a3d, data); @@ -358,24 +370,17 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) } } - a3d->dev.private = a3d; - a3d->dev.open = a3d_open; - a3d->dev.close = a3d_close; - - a3d->dev.name = a3d_names[a3d->mode]; - a3d->dev.phys = a3d->phys; - a3d->dev.id.bustype = BUS_GAMEPORT; - a3d->dev.id.vendor = GAMEPORT_ID_VENDOR_MADCATZ; - a3d->dev.id.product = a3d->mode; - a3d->dev.id.version = 0x0100; - - input_register_device(&a3d->dev); - printk(KERN_INFO "input: %s on %s\n", a3d_names[a3d->mode], a3d->phys); + err = input_register_device(a3d->dev); + if (err) + goto fail3; return 0; -fail2: gameport_close(gameport); -fail1: gameport_set_drvdata(gameport, NULL); + fail3: if (a3d->adc) + gameport_unregister_port(a3d->adc); + fail2: gameport_close(gameport); + fail1: gameport_set_drvdata(gameport, NULL); + input_free_device(input_dev); kfree(a3d); return err; } @@ -384,11 +389,9 @@ static void a3d_disconnect(struct gameport *gameport) { struct a3d *a3d = gameport_get_drvdata(gameport); - input_unregister_device(&a3d->dev); - if (a3d->adc) { + input_unregister_device(a3d->dev); + if (a3d->adc) gameport_unregister_port(a3d->adc); - a3d->adc = NULL; - } gameport_close(gameport); gameport_set_drvdata(gameport, NULL); kfree(a3d); @@ -397,6 +400,7 @@ static void a3d_disconnect(struct gameport *gameport) static struct gameport_driver a3d_drv = { .driver = { .name = "adc", + .owner = THIS_MODULE, }, .description = DRIVER_DESC, .connect = a3d_connect, -- cgit v1.2.3 From 97d4ebfe7946bc9b89791c932a15c990a24aa94d Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Tue, 31 Jan 2006 01:31:07 -0500 Subject: Input: iforce - fix detection of USB devices Recent conversion to wait_event_interruptible_timeout() caused USB detection routine erroneously report timeouts for perfectly working devices. Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/iforce/iforce-packets.c | 4 ++-- drivers/input/joystick/iforce/iforce-usb.c | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c index 4a2629243e1..76cb1f88f4e 100644 --- a/drivers/input/joystick/iforce/iforce-packets.c +++ b/drivers/input/joystick/iforce/iforce-packets.c @@ -167,9 +167,9 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data, iforce->expect_packet = 0; iforce->ecmd = cmd; memcpy(iforce->edata, data, IFORCE_MAX_LENGTH); - wake_up(&iforce->wait); } #endif + wake_up(&iforce->wait); if (!iforce->type) { being_used--; @@ -264,7 +264,7 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet) wait_event_interruptible_timeout(iforce->wait, iforce->ctrl->status != -EINPROGRESS, HZ); - if (iforce->ctrl->status != -EINPROGRESS) { + if (iforce->ctrl->status) { usb_unlink_urb(iforce->ctrl); return -1; } diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c index bc2fce60f9f..fe79d158456 100644 --- a/drivers/input/joystick/iforce/iforce-usb.c +++ b/drivers/input/joystick/iforce/iforce-usb.c @@ -95,7 +95,6 @@ static void iforce_usb_irq(struct urb *urb, struct pt_regs *regs) goto exit; } - wake_up(&iforce->wait); iforce_process_packet(iforce, (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs); -- cgit v1.2.3 From a09d31ff762a3671f2ae41b3bca50a100c5e4da6 Mon Sep 17 00:00:00 2001 From: Alessandro Zummo Date: Wed, 15 Feb 2006 00:48:40 -0500 Subject: Input: ixp4xx-beeper - fix compile error Signed-off-by: Alessandro Zummo Signed-off-by: Dmitry Torokhov --- drivers/input/misc/ixp4xx-beeper.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/input') diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c index d448bb5e486..3a6ae85cd69 100644 --- a/drivers/input/misc/ixp4xx-beeper.c +++ b/drivers/input/misc/ixp4xx-beeper.c @@ -19,6 +19,7 @@ #include #include #include +#include #include MODULE_AUTHOR("Alessandro Zummo "); -- cgit v1.2.3 From 50f6dde0ad05ee4ee8450feb731b15b716115c4d Mon Sep 17 00:00:00 2001 From: Meelis Roos Date: Wed, 15 Feb 2006 00:48:58 -0500 Subject: Input: logips2pp - add new signature (99) Add Logitech mouse type 99 (Premium Optical Wheel Mouse, model M-BT58, plain 3 buttons + wheel) to cure the following message: logips2pp: Detected unknown logitech mouse model 99 Signed-off-by: Meelis Roos Signed-off-by: Andrew Morton Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/logips2pp.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/input') diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index c88520d3d13..40333d61093 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c @@ -232,6 +232,7 @@ static struct ps2pp_info *get_model_info(unsigned char model) { 88, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 96, 0, 0 }, { 97, PS2PP_KIND_TP3, PS2PP_WHEEL | PS2PP_HWHEEL }, + { 99, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 100, PS2PP_KIND_MX, /* MX510 */ PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN | PS2PP_EXTRA_BTN | PS2PP_NAV_BTN }, -- cgit v1.2.3 From b8044c74bcd64bd1a9d2e8cec58fdcd40f16f5a4 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 15 Feb 2006 00:49:09 -0500 Subject: Input: trackpoint - enable devices connected to external port Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/trackpoint.c | 20 ++++++++++++++------ drivers/input/mouse/trackpoint.h | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index b4898d8a68e..6d9ec9ab1b9 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c @@ -68,15 +68,19 @@ struct trackpoint_attr_data { size_t field_offset; unsigned char command; unsigned char mask; + unsigned char inverted; }; static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse, void *data, char *buf) { struct trackpoint_data *tp = psmouse->private; struct trackpoint_attr_data *attr = data; - unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); + unsigned char value = *(unsigned char *)((char *)tp + attr->field_offset); + + if (attr->inverted) + value = !value; - return sprintf(buf, "%u\n", *field); + return sprintf(buf, "%u\n", value); } static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data, @@ -120,6 +124,9 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data, if (*rest || value > 1) return -EINVAL; + if (attr->inverted) + value = !value; + if (*field != value) { *field = value; trackpoint_toggle_bit(&psmouse->ps2dev, attr->command, attr->mask); @@ -129,11 +136,12 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data, } -#define TRACKPOINT_BIT_ATTR(_name, _command, _mask) \ +#define TRACKPOINT_BIT_ATTR(_name, _command, _mask, _inv) \ static struct trackpoint_attr_data trackpoint_attr_##_name = { \ .field_offset = offsetof(struct trackpoint_data, _name), \ .command = _command, \ .mask = _mask, \ + .inverted = _inv, \ }; \ PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ &trackpoint_attr_##_name, \ @@ -150,9 +158,9 @@ TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH); TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME); TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV); -TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON); -TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); -TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); +TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, 0); +TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK, 0); +TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV, 1); static struct attribute *trackpoint_attrs[] = { &psmouse_attr_sensitivity.dattr.attr, diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h index 9857d8b6ad6..050298b1a09 100644 --- a/drivers/input/mouse/trackpoint.h +++ b/drivers/input/mouse/trackpoint.h @@ -78,7 +78,7 @@ #define TP_TOGGLE_MB 0x23 /* Disable/Enable Middle Button */ #define TP_MASK_MB 0x01 -#define TP_TOGGLE_EXT_DEV 0x23 /* Toggle external device */ +#define TP_TOGGLE_EXT_DEV 0x23 /* Disable external device */ #define TP_MASK_EXT_DEV 0x02 #define TP_TOGGLE_DRIFT 0x23 /* Drift Correction */ #define TP_MASK_DRIFT 0x80 @@ -125,7 +125,7 @@ #define TP_DEF_MB 0x00 #define TP_DEF_PTSON 0x00 #define TP_DEF_SKIPBACK 0x00 -#define TP_DEF_EXT_DEV 0x01 +#define TP_DEF_EXT_DEV 0x00 /* 0 means enabled */ #define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd)) -- cgit v1.2.3 From a90f7e98b7df3309ebc0e389076990456db20989 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 15 Feb 2006 00:49:22 -0500 Subject: Input: ads7846 - convert to to dynamic input_dev allocation Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/ads7846.c | 79 ++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 32 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index b45a45ca7cc..72cf0a26d67 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -60,7 +60,7 @@ struct ts_event { }; struct ads7846 { - struct input_dev input; + struct input_dev *input; char phys[32]; struct spi_device *spi; @@ -152,7 +152,7 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) struct ser_req *req = kzalloc(sizeof *req, SLAB_KERNEL); int status; int sample; - int i; + int i; if (!req) return -ENOMEM; @@ -236,11 +236,12 @@ SHOW(vbatt) static void ads7846_rx(void *ads) { - struct ads7846 *ts = ads; - unsigned Rt; - unsigned sync = 0; - u16 x, y, z1, z2; - unsigned long flags; + struct ads7846 *ts = ads; + struct input_dev *input_dev = ts->input; + unsigned Rt; + unsigned sync = 0; + u16 x, y, z1, z2; + unsigned long flags; /* adjust: 12 bit samples (left aligned), built from * two 8 bit values writen msb-first. @@ -276,21 +277,21 @@ static void ads7846_rx(void *ads) * won't notice that, even if nPENIRQ never fires ... */ if (!ts->pendown && Rt != 0) { - input_report_key(&ts->input, BTN_TOUCH, 1); + input_report_key(input_dev, BTN_TOUCH, 1); sync = 1; } else if (ts->pendown && Rt == 0) { - input_report_key(&ts->input, BTN_TOUCH, 0); + input_report_key(input_dev, BTN_TOUCH, 0); sync = 1; } if (Rt) { - input_report_abs(&ts->input, ABS_X, x); - input_report_abs(&ts->input, ABS_Y, y); - input_report_abs(&ts->input, ABS_PRESSURE, Rt); + input_report_abs(input_dev, ABS_X, x); + input_report_abs(input_dev, ABS_Y, y); + input_report_abs(input_dev, ABS_PRESSURE, Rt); sync = 1; } if (sync) - input_sync(&ts->input); + input_sync(input_dev); #ifdef VERBOSE if (Rt || ts->pendown) @@ -396,9 +397,11 @@ static int ads7846_resume(struct spi_device *spi) static int __devinit ads7846_probe(struct spi_device *spi) { struct ads7846 *ts; + struct input_dev *input_dev; struct ads7846_platform_data *pdata = spi->dev.platform_data; struct spi_transfer *x; int i; + int err; if (!spi->irq) { dev_dbg(&spi->dev, "no IRQ?\n"); @@ -423,13 +426,18 @@ static int __devinit ads7846_probe(struct spi_device *spi) * to discard the four garbage LSBs. */ - if (!(ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL))) - return -ENOMEM; + ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL); + input_dev = input_allocate_device(); + if (!ts || !input_dev) { + err = -ENOMEM; + goto err_free_mem; + } dev_set_drvdata(&spi->dev, ts); + spi->dev.power.power_state = PMSG_ON; ts->spi = spi; - spi->dev.power.power_state = PMSG_ON; + ts->input = input_dev; init_timer(&ts->timer); ts->timer.data = (unsigned long) ts; @@ -439,28 +447,25 @@ static int __devinit ads7846_probe(struct spi_device *spi) ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100; ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; - init_input_dev(&ts->input); + snprintf(ts->phys, sizeof(ts->phys), "%s/input0", spi->dev.bus_id); - ts->input.dev = &spi->dev; - ts->input.name = "ADS784x Touchscreen"; - snprintf(ts->phys, sizeof ts->phys, "%s/input0", spi->dev.bus_id); - ts->input.phys = ts->phys; + input_dev->name = "ADS784x Touchscreen"; + input_dev->phys = ts->phys; + input_dev->cdev.dev = &spi->dev; - ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); - ts->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); - input_set_abs_params(&ts->input, ABS_X, + input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); + input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); + input_set_abs_params(input_dev, ABS_X, pdata->x_min ? : 0, pdata->x_max ? : MAX_12BIT, 0, 0); - input_set_abs_params(&ts->input, ABS_Y, + input_set_abs_params(input_dev, ABS_Y, pdata->y_min ? : 0, pdata->y_max ? : MAX_12BIT, 0, 0); - input_set_abs_params(&ts->input, ABS_PRESSURE, + input_set_abs_params(input_dev, ABS_PRESSURE, pdata->pressure_min, pdata->pressure_max, 0, 0); - input_register_device(&ts->input); - /* set up the transfers to read touchscreen state; this assumes we * use formula #2 for pressure, not #3. */ @@ -510,9 +515,8 @@ static int __devinit ads7846_probe(struct spi_device *spi) SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING, spi->dev.bus_id, ts)) { dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); - input_unregister_device(&ts->input); - kfree(ts); - return -EBUSY; + err = -EBUSY; + goto err_free_mem; } dev_info(&spi->dev, "touchscreen, irq %d\n", spi->irq); @@ -534,7 +538,18 @@ static int __devinit ads7846_probe(struct spi_device *spi) device_create_file(&spi->dev, &dev_attr_vbatt); device_create_file(&spi->dev, &dev_attr_vaux); + err = input_register_device(input_dev); + if (err) + goto err_free_irq; + return 0; + + err_free_irq: + free_irq(spi->irq, ts); + err_free_mem: + input_free_device(input_dev); + kfree(ts); + return err; } static int __devexit ads7846_remove(struct spi_device *spi) @@ -554,7 +569,7 @@ static int __devexit ads7846_remove(struct spi_device *spi) device_remove_file(&spi->dev, &dev_attr_vbatt); device_remove_file(&spi->dev, &dev_attr_vaux); - input_unregister_device(&ts->input); + input_unregister_device(ts->input); kfree(ts); dev_dbg(&spi->dev, "unregistered touchscreen\n"); -- cgit v1.2.3 From d93f70b2d758e79ee4ac9d6d982e3f532453911f Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 15 Feb 2006 00:49:35 -0500 Subject: Input: ads7846 - assorted updates This updates the ads7846 touchscreen driver: - to allow faster clocking (this driver doesn't push sample rates); - bugfixes the conversion of spi_transfer to lists; - some dma-unsafe command buffers are fixed. Signed-off-by: David Brownell Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/ads7846.c | 68 ++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 24 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 72cf0a26d67..8c12a974b41 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -48,10 +48,13 @@ #define TS_POLL_PERIOD msecs_to_jiffies(10) +/* this driver doesn't aim at the peak continuous sample rate */ +#define SAMPLE_BITS (8 /*cmd*/ + 16 /*sample*/ + 2 /* before, after */) + struct ts_event { /* For portability, we can't read 12 bit values using SPI (which * would make the controller deliver them as native byteorder u16 - * with msbs zeroed). Instead, we read them as two 8-byte values, + * with msbs zeroed). Instead, we read them as two 8-bit values, * which need byteswapping then range adjustment. */ __be16 x; @@ -68,6 +71,7 @@ struct ads7846 { u16 vref_delay_usecs; u16 x_plate_ohms; + u8 read_x, read_y, read_z1, read_z2; struct ts_event tc; struct spi_transfer xfer[8]; @@ -117,10 +121,10 @@ struct ads7846 { #define READ_12BIT_DFR(x) (ADS_START | ADS_A2A1A0_d_ ## x \ | ADS_12_BIT | ADS_DFR) -static const u8 read_y = READ_12BIT_DFR(y) | ADS_PD10_ADC_ON; -static const u8 read_z1 = READ_12BIT_DFR(z1) | ADS_PD10_ADC_ON; -static const u8 read_z2 = READ_12BIT_DFR(z2) | ADS_PD10_ADC_ON; -static const u8 read_x = READ_12BIT_DFR(x) | ADS_PD10_PDOWN; /* LAST */ +#define READ_Y (READ_12BIT_DFR(y) | ADS_PD10_ADC_ON) +#define READ_Z1 (READ_12BIT_DFR(z1) | ADS_PD10_ADC_ON) +#define READ_Z2 (READ_12BIT_DFR(z2) | ADS_PD10_ADC_ON) +#define READ_X (READ_12BIT_DFR(x) | ADS_PD10_PDOWN) /* LAST */ /* single-ended samples need to first power up reference voltage; * we leave both ADC and VREF powered @@ -128,8 +132,8 @@ static const u8 read_x = READ_12BIT_DFR(x) | ADS_PD10_PDOWN; /* LAST */ #define READ_12BIT_SER(x) (ADS_START | ADS_A2A1A0_ ## x \ | ADS_12_BIT | ADS_SER) -static const u8 ref_on = READ_12BIT_DFR(x) | ADS_PD10_ALL_ON; -static const u8 ref_off = READ_12BIT_DFR(y) | ADS_PD10_PDOWN; +#define REF_ON (READ_12BIT_DFR(x) | ADS_PD10_ALL_ON) +#define REF_OFF (READ_12BIT_DFR(y) | ADS_PD10_PDOWN) /*--------------------------------------------------------------------------*/ @@ -138,7 +142,9 @@ static const u8 ref_off = READ_12BIT_DFR(y) | ADS_PD10_PDOWN; */ struct ser_req { + u8 ref_on; u8 command; + u8 ref_off; u16 scratch; __be16 sample; struct spi_message msg; @@ -160,7 +166,8 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) INIT_LIST_HEAD(&req->msg.transfers); /* activate reference, so it has time to settle; */ - req->xfer[0].tx_buf = &ref_on; + req->ref_on = REF_ON; + req->xfer[0].tx_buf = &req->ref_on; req->xfer[0].len = 1; req->xfer[1].rx_buf = &req->scratch; req->xfer[1].len = 2; @@ -182,7 +189,8 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) /* REVISIT: take a few more samples, and compare ... */ /* turn off reference */ - req->xfer[4].tx_buf = &ref_off; + req->ref_off = REF_OFF; + req->xfer[4].tx_buf = &req->ref_off; req->xfer[4].len = 1; req->xfer[5].rx_buf = &req->scratch; req->xfer[5].len = 2; @@ -400,7 +408,6 @@ static int __devinit ads7846_probe(struct spi_device *spi) struct input_dev *input_dev; struct ads7846_platform_data *pdata = spi->dev.platform_data; struct spi_transfer *x; - int i; int err; if (!spi->irq) { @@ -414,9 +421,9 @@ static int __devinit ads7846_probe(struct spi_device *spi) } /* don't exceed max specified sample rate */ - if (spi->max_speed_hz > (125000 * 16)) { + if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) { dev_dbg(&spi->dev, "f(sample) %d KHz?\n", - (spi->max_speed_hz/16)/1000); + (spi->max_speed_hz/SAMPLE_BITS)/1000); return -EINVAL; } @@ -469,45 +476,58 @@ static int __devinit ads7846_probe(struct spi_device *spi) /* set up the transfers to read touchscreen state; this assumes we * use formula #2 for pressure, not #3. */ + INIT_LIST_HEAD(&ts->msg.transfers); x = ts->xfer; /* y- still on; turn on only y+ (and ADC) */ - x->tx_buf = &read_y; + ts->read_y = READ_Y; + x->tx_buf = &ts->read_y; x->len = 1; + spi_message_add_tail(x, &ts->msg); + x++; x->rx_buf = &ts->tc.y; x->len = 2; - x++; + spi_message_add_tail(x, &ts->msg); /* turn y+ off, x- on; we'll use formula #2 */ if (ts->model == 7846) { - x->tx_buf = &read_z1; + x++; + ts->read_z1 = READ_Z1; + x->tx_buf = &ts->read_z1; x->len = 1; + spi_message_add_tail(x, &ts->msg); + x++; x->rx_buf = &ts->tc.z1; x->len = 2; - x++; + spi_message_add_tail(x, &ts->msg); - x->tx_buf = &read_z2; + x++; + ts->read_z2 = READ_Z2; + x->tx_buf = &ts->read_z2; x->len = 1; + spi_message_add_tail(x, &ts->msg); + x++; x->rx_buf = &ts->tc.z2; x->len = 2; - x++; + spi_message_add_tail(x, &ts->msg); } /* turn y- off, x+ on, then leave in lowpower */ - x->tx_buf = &read_x; + x++; + ts->read_x = READ_X; + x->tx_buf = &ts->read_x; x->len = 1; + spi_message_add_tail(x, &ts->msg); + x++; x->rx_buf = &ts->tc.x; x->len = 2; - x++; - - CS_CHANGE(x[-1]); + CS_CHANGE(*x); + spi_message_add_tail(x, &ts->msg); - for (i = 0; i < x - ts->xfer; i++) - spi_message_add_tail(&ts->xfer[i], &ts->msg); ts->msg.complete = ads7846_rx; ts->msg.context = ts; -- cgit v1.2.3 From 02860ab6cd2c71dbe42fa70a65a97823c213635b Mon Sep 17 00:00:00 2001 From: Arthur Othieno Date: Wed, 15 Feb 2006 00:49:48 -0500 Subject: Input: kill remnants of 98kbd{,-io} and 98spkr 98kbd{,-io} and 98spkr all went out with PC98 subarch. Remove stale Makefile entries that remained. Signed-off-by: Arthur Othieno Signed-off-by: Andrew Morton Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/Makefile | 1 - drivers/input/misc/Makefile | 1 - drivers/input/serio/Makefile | 1 - 3 files changed, 3 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 6e0afbb2238..2708167ba17 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile @@ -11,7 +11,6 @@ obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o -obj-$(CONFIG_KEYBOARD_98KBD) += 98kbd.o obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 184c4129470..415c4917898 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -7,7 +7,6 @@ obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o -obj-$(CONFIG_INPUT_98SPKR) += 98spkr.o obj-$(CONFIG_INPUT_UINPUT) += uinput.o obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile index 678a8599f9f..4155197867a 100644 --- a/drivers/input/serio/Makefile +++ b/drivers/input/serio/Makefile @@ -13,7 +13,6 @@ obj-$(CONFIG_SERIO_RPCKBD) += rpckbd.o obj-$(CONFIG_SERIO_SA1111) += sa1111ps2.o obj-$(CONFIG_SERIO_AMBAKMI) += ambakmi.o obj-$(CONFIG_SERIO_Q40KBD) += q40kbd.o -obj-$(CONFIG_SERIO_98KBD) += 98kbd-io.o obj-$(CONFIG_SERIO_GSCPS2) += gscps2.o obj-$(CONFIG_HP_SDC) += hp_sdc.o obj-$(CONFIG_HIL_MLC) += hp_sdc_mlc.o hil_mlc.o -- cgit v1.2.3 From 8bd0ee93fef9733c72fef1817330b3ee2b71cf9d Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sat, 11 Mar 2006 00:23:38 -0500 Subject: [PATCH] Input: psmouse - disable autoresync Automatic resynchronization in psmouse driver causes problems on some hardware so disable it by default for now. People with KVM switches that require resync can still enable it via module parameter or sysfs attribute. Signed-off-by: Dmitry Torokhov Signed-off-by: Linus Torvalds --- drivers/input/mouse/psmouse-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/input') diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 19b1b012172..ad621746767 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -58,7 +58,7 @@ static unsigned int psmouse_resetafter = 5; module_param_named(resetafter, psmouse_resetafter, uint, 0644); MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never)."); -static unsigned int psmouse_resync_time = 5; +static unsigned int psmouse_resync_time; module_param_named(resync_time, psmouse_resync_time, uint, 0644); MODULE_PARM_DESC(resync_time, "How long can mouse stay idle before forcing resync (in seconds, 0 = never)."); -- cgit v1.2.3