GIT eb5d5829b368c5e32f248a70797bee5a414a2ef0 git+ssh://master.kernel.org/pub/scm/linux/kernel/git/dtor/input.git commit Author: Sergey Vlasov Date: Thu Nov 9 00:34:27 2006 -0500 Input: psmouse - fix attribute access on 64-bit systems psmouse_show_int_attr() and psmouse_set_int_attr() were accessing unsigned int fields as unsigned long, which gave garbage on x86_64. Signed-off-by: Sergey Vlasov Signed-off-by: Dmitry Torokhov commit 721556150e397f606a3f029736d77a27503f94e2 Author: Dmitry Torokhov Date: Sun Nov 5 22:40:19 2006 -0500 Input: mice - handle errors when registering input devices Signed-off-by: Dmitry Torokhov commit 127278ce2254c61f1346500374d61e33f74a8729 Author: Dmitry Torokhov Date: Sun Nov 5 22:40:09 2006 -0500 Input: joysticks - handle errors when registering input devices Signed-off-by: Dmitry Torokhov commit 52c1f5704d7555a16641429b2e7af5d26d7b119a Author: Dmitry Torokhov Date: Sun Nov 5 22:40:03 2006 -0500 Input: touchscreens - handle errors when registering input devices Signed-off-by: Dmitry Torokhov commit 2b03b60e6b8635fffdd15d5d24943950f2bbf96e Author: Dmitry Torokhov Date: Sun Nov 5 22:39:56 2006 -0500 Input: keyboards - handle errors when registering input devices Signed-off-by: Dmitry Torokhov commit 41ad5fbabda0c3930136bb40cfc7a0c23013365f Author: Anssi Hannula Date: Sat Nov 4 22:49:53 2006 -0500 Input: HID - add a quirk for the Logitech USB Receiver Logitech USB Receiver (046d:c101) has two interfaces. The first one contains fields from HID_UP_KEYBOARD and HID_UP_LED, and the other one contains fields from HID_UP_CONSUMER and HID_UP_LOGIVENDOR. This device is used with multiple wireless Logitech products, including UltraX Media Remote. All fields on both interfaces are either keys or leds. All fields in the first interface are marked as Absolute, while the fields in the second interface are marked as Relative. Marking the keys as relative causes hidinput_hid_event() to send release events right after key press events. The device has EV_REP set, so the userspace expects the device to send repeat events if a key is held down. However, as hidinput_hid_event() sends release events immediately, repeat events are not sent at all. In fact, the userspace has no way of knowing if a key is being held down. Fix this by adding a quirk for 046d:c101 which changes relative keys to absolute ones. Signed-off-by: Anssi Hannula Signed-off-by: Dmitry Torokhov commit e52b29c2a637f6854d71a45646d7283d984a6dad Author: Brandon Philips Date: Sat Nov 4 22:09:08 2006 -0500 Input: drivers/char/keyboard.c - small cleanup in k_cur() To save a char pointer in the final assembly change to alternate string form. Signed-off-by: Brandon Philips Signed-off-by: Dmitry Torokhov commit 0fea0e9a9c72dab526447895605fc236c87c2726 Author: Jeff Garzik Date: Thu Nov 2 23:59:40 2006 -0500 Input: logips2pp - handle sysfs errors Signed-off-by: Jeff Garzik Signed-off-by: Dmitry Torokhov commit 8ff22ea7d29d99b3dbec08fd541eb406c6775ec1 Author: Jeff Garzik Date: Thu Nov 2 23:59:30 2006 -0500 Input: trackpoint - handle sysfs errors Also use kzalloc instead of kcalloc since we are allocating single object. Signed-off-by: Jeff Garzik Signed-off-by: Dmitry Torokhov commit 8dd51650baf0861b0a73acb2c08bb944aa45bc61 Author: Dmitry Torokhov Date: Thu Nov 2 23:34:09 2006 -0500 Input: ads7846 - handle errors from sysfs Add sysfs error handling and switch to using attribute groups to simplify it. Signed-off-by: Dmitry Torokhov commit f4e3c711b31cea401b03ce39d4b5f1a30279094c Author: Dmitry Torokhov Date: Thu Nov 2 23:27:49 2006 -0500 Input: i8042 - remove unneeded call to i8042_interrupt() Remove call to i8042_interrupt() from i8042_aux_write(). According to Vojtech it may cause problems with older controllers if it is called right after real interrupt. Also it is not needed anymore since we register IRQs early and not waiting for serio ports to be opened. Signed-off-by: Dmitry Torokhov commit b1b2965057700d6dc9e1f986e8f7743b95ead424 Author: Andrew Morton Date: Thu Nov 2 23:27:44 2006 -0500 Input: lifebook - learn about hard tabs Signed-off-by: Andrew Morton Signed-off-by: Dmitry Torokhov commit 15e9acb83c299963490b1f12d46498ae257d8f4e Author: Greg Chandler Date: Thu Nov 2 23:27:38 2006 -0500 Input: lifebook - add Hitachi Flora-IE 55mi tablet DMI signature This adds another DMI detected touchscreen. It is exactly the same driver as the existing ones, but this allows it to be detected on the Hitachi Flora-IE 55mi tablet. The original Midori drivers are "abeo antiquus". This should allow new life for these machines. Signed-off-by: Dmitry Torokhov commit b187dd7b5231bb359f587bf4d276ffd467ebc884 Author: Dmitry Torokhov Date: Thu Nov 2 23:27:30 2006 -0500 Input: gameport - rearrange gameport_bus initialization Initialize gameport_bus structure at compile time instead of at runtime in gameport_init(). Signed-off-by: Dmitry Torokhov commit 1ea2a69d54f40ecebf594ce5abfa02d53682df8a Author: Marton Nemeth Date: Thu Nov 2 23:27:21 2006 -0500 Input: serio - rearrange serio_bus initialization Initialize serio_bus structure at compile time instead of at runtime in serio_init(). Signed-off-by: Marton Nemeth Signed-off-by: Dmitry Torokhov commit 6a89bc0004c8d9400439db6167c9887456d5d18d Author: Akinobu Mita Date: Thu Nov 2 23:27:11 2006 -0500 Input: lightning - return proper error codes from l4_init() Signed-off-by: Akinobu Mita Signed-off-by: Dmitry Torokhov commit 1447190e39847cc2cc8a826e7061989c83ff4362 Author: Dmitry Torokhov Date: Thu Nov 2 23:26:55 2006 -0500 Input: add comments to input_{allocate|free}_device() Hopefully this will stop people from using input_free_device() incorrectly. Signed-off-by: Dmitry Torokhov drivers/char/keyboard.c | 2 drivers/input/gameport/gameport.c | 19 +-- drivers/input/gameport/lightning.c | 4 - drivers/input/input.c | 25 ++++ drivers/input/joystick/adi.c | 10 +- drivers/input/joystick/amijoy.c | 6 + drivers/input/joystick/analog.c | 10 +- drivers/input/joystick/cobra.c | 7 + drivers/input/joystick/gf2k.c | 4 - drivers/input/joystick/grip_mp.c | 13 ++ drivers/input/joystick/guillemot.c | 4 - drivers/input/joystick/iforce/iforce-main.c | 17 ++- drivers/input/joystick/iforce/iforce-serio.c | 20 +-- drivers/input/joystick/interact.c | 4 - drivers/input/joystick/magellan.c | 14 +- drivers/input/joystick/spaceball.c | 14 +- drivers/input/joystick/spaceorb.c | 14 +- drivers/input/joystick/stinger.c | 14 +- drivers/input/joystick/twidjoy.c | 14 +- drivers/input/joystick/warrior.c | 14 +- drivers/input/keyboard/amikbd.c | 22 +++- drivers/input/keyboard/atkbd.c | 159 +++++++++++++++++++++----- drivers/input/keyboard/corgikbd.c | 17 ++- drivers/input/keyboard/lkkbd.c | 14 +- drivers/input/keyboard/locomokbd.c | 28 +++-- drivers/input/keyboard/maple_keyb.c | 14 ++ drivers/input/keyboard/newtonkbd.c | 14 +- drivers/input/keyboard/spitzkbd.c | 24 ++-- drivers/input/keyboard/sunkbd.c | 20 ++- drivers/input/keyboard/xtkbd.c | 14 +- drivers/input/mouse/amimouse.c | 11 +- drivers/input/mouse/inport.c | 23 +++- drivers/input/mouse/lifebook.c | 82 +++++++------ drivers/input/mouse/logibm.c | 24 +++- drivers/input/mouse/logips2pp.c | 11 +- drivers/input/mouse/pc110pad.c | 26 +++- drivers/input/mouse/psmouse-base.c | 93 +++++++++++---- drivers/input/mouse/rpcmouse.c | 20 +++ drivers/input/mouse/sermouse.c | 13 +- drivers/input/mouse/trackpoint.c | 12 ++ drivers/input/mouse/vsxxxaa.c | 13 +- drivers/input/serio/i8042.c | 21 --- drivers/input/serio/serio.c | 22 ++-- drivers/input/touchscreen/ads7846.c | 95 ++++++++++------ drivers/input/touchscreen/corgi_ts.c | 30 +++-- drivers/input/touchscreen/gunze.c | 14 +- drivers/input/touchscreen/hp680_ts_input.c | 29 +++-- drivers/input/touchscreen/mk712.c | 26 ++-- drivers/input/touchscreen/mtouch.c | 13 +- drivers/usb/input/hid-core.c | 7 + drivers/usb/input/hid-input.c | 4 + drivers/usb/input/hid.h | 1 52 files changed, 766 insertions(+), 379 deletions(-) diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 20b6c8b..7a6c1c0 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c @@ -710,7 +710,7 @@ static void k_fn(struct vc_data *vc, uns static void k_cur(struct vc_data *vc, unsigned char value, char up_flag) { - static const char *cur_chars = "BDCA"; + static const char cur_chars[] = "BDCA"; if (up_flag) return; diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c index a0af97e..bba5894 100644 --- a/drivers/input/gameport/gameport.c +++ b/drivers/input/gameport/gameport.c @@ -730,12 +730,6 @@ static int gameport_driver_remove(struct return 0; } -static struct bus_type gameport_bus = { - .name = "gameport", - .probe = gameport_driver_probe, - .remove = gameport_driver_remove, -}; - static void gameport_add_driver(struct gameport_driver *drv) { int error; @@ -781,6 +775,15 @@ static int gameport_bus_match(struct dev return !gameport_drv->ignore; } +static struct bus_type gameport_bus = { + .name = "gameport", + .dev_attrs = gameport_device_attrs, + .drv_attrs = gameport_driver_attrs, + .match = gameport_bus_match, + .probe = gameport_driver_probe, + .remove = gameport_driver_remove, +}; + static void gameport_set_drv(struct gameport *gameport, struct gameport_driver *drv) { mutex_lock(&gameport->drv_mutex); @@ -790,7 +793,6 @@ static void gameport_set_drv(struct game int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode) { - if (gameport->open) { if (gameport->open(gameport, mode)) { return -1; @@ -818,9 +820,6 @@ static int __init gameport_init(void) { int error; - gameport_bus.dev_attrs = gameport_device_attrs; - gameport_bus.drv_attrs = gameport_driver_attrs; - gameport_bus.match = gameport_bus_match; error = bus_register(&gameport_bus); if (error) { printk(KERN_ERR "gameport: failed to register gameport bus, error: %d\n", error); diff --git a/drivers/input/gameport/lightning.c b/drivers/input/gameport/lightning.c index d65d810..6b4d456 100644 --- a/drivers/input/gameport/lightning.c +++ b/drivers/input/gameport/lightning.c @@ -309,7 +309,7 @@ static int __init l4_init(void) int i, cards = 0; if (!request_region(L4_PORT, 1, "lightning")) - return -1; + return -EBUSY; for (i = 0; i < 2; i++) if (l4_add_card(i) == 0) @@ -319,7 +319,7 @@ static int __init l4_init(void) if (!cards) { release_region(L4_PORT, 1); - return -1; + return -ENODEV; } return 0; diff --git a/drivers/input/input.c b/drivers/input/input.c index 1c8c8a5..7cf2b4f 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -37,7 +37,7 @@ static struct input_handler *input_table /** * input_event() - report new input event - * @handle: device that generated the event + * @dev: device that generated the event * @type: type of the event * @code: event code * @value: value of the event @@ -900,6 +900,15 @@ struct class input_class = { }; EXPORT_SYMBOL_GPL(input_class); +/** + * input_allocate_device - allocate memory for new input device + * + * Returns prepared struct input_dev or NULL. + * + * NOTE: Use input_free_device() to free devices that have not been + * registered; input_unregister_device() should be used for already + * registered devices. + */ struct input_dev *input_allocate_device(void) { struct input_dev *dev; @@ -919,6 +928,20 @@ struct input_dev *input_allocate_device( } EXPORT_SYMBOL(input_allocate_device); +/** + * input_free_device - free memory occupied by input_dev structure + * @dev: input device to free + * + * This function should only be used if input_register_device() + * was not called yet or if it failed. Once device was registered + * use input_unregister_device() and memory will be freed once last + * refrence to the device is dropped. + * + * Device should be allocated by input_allocate_device(). + * + * NOTE: If there are references to the input device then memory + * will not be freed until last reference is dropped. + */ void input_free_device(struct input_dev *dev) { if (dev) { diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c index 704bf70..6279ced 100644 --- a/drivers/input/joystick/adi.c +++ b/drivers/input/joystick/adi.c @@ -521,11 +521,19 @@ static int adi_connect(struct gameport * for (i = 0; i < 2; i++) if (port->adi[i].length > 0) { adi_init_center(port->adi + i); - input_register_device(port->adi[i].dev); + err = input_register_device(port->adi[i].dev); + if (err) + goto fail3; } return 0; + fail3: while (--i >= 0) { + if (port->adi[i].length > 0) { + input_unregister_device(port->adi[i].dev); + port->adi[i].dev = NULL; + } + } fail2: for (i = 0; i < 2; i++) if (port->adi[i].dev) input_free_device(port->adi[i].dev); diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c index 650acf3..e608691 100644 --- a/drivers/input/joystick/amijoy.c +++ b/drivers/input/joystick/amijoy.c @@ -147,7 +147,11 @@ static int __init amijoy_init(void) amijoy_dev[i]->absmax[ABS_X + j] = 1; } - input_register_device(amijoy_dev[i]); + err = input_register_device(amijoy_dev[i]); + if (err) { + input_free_device(amijoy_dev[i]); + goto fail; + } } return 0; diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c index e9a02db..7ef6845 100644 --- a/drivers/input/joystick/analog.c +++ b/drivers/input/joystick/analog.c @@ -434,6 +434,7 @@ static int analog_init_device(struct ana { struct input_dev *input_dev; int i, j, t, v, w, x, y, z; + int error; analog_name(analog); snprintf(analog->phys, sizeof(analog->phys), @@ -505,7 +506,11 @@ static int analog_init_device(struct ana analog_decode(analog, port->axes, port->initial, port->buttons); - input_register_device(analog->dev); + error = input_register_device(analog->dev); + if (error) { + input_free_device(analog->dev); + return error; + } return 0; } @@ -668,7 +673,8 @@ static int analog_connect(struct gamepor return 0; fail3: while (--i >= 0) - input_unregister_device(port->analog[i].dev); + if (port->analog[i].mask) + input_unregister_device(port->analog[i].dev); fail2: gameport_close(gameport); fail1: gameport_set_drvdata(gameport, NULL); kfree(port); diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c index d5e42eb..034ec39 100644 --- a/drivers/input/joystick/cobra.c +++ b/drivers/input/joystick/cobra.c @@ -223,12 +223,15 @@ static int cobra_connect(struct gameport for (j = 0; cobra_btn[j]; j++) set_bit(cobra_btn[j], input_dev->keybit); - input_register_device(cobra->dev[i]); + err = input_register_device(cobra->dev[i]); + if (err) + goto fail4; } return 0; - fail3: for (i = 0; i < 2; i++) + fail4: input_free_device(cobra->dev[i]); + fail3: while (--i >= 0) if (cobra->dev[i]) input_unregister_device(cobra->dev[i]); fail2: gameport_close(gameport); diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c index e4a699f..bacbab5 100644 --- a/drivers/input/joystick/gf2k.c +++ b/drivers/input/joystick/gf2k.c @@ -341,7 +341,9 @@ #endif input_dev->absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0; } - input_register_device(gf2k->dev); + err = input_register_device(gf2k->dev); + if (err) + goto fail2; return 0; diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c index 6243894..8120a9c 100644 --- a/drivers/input/joystick/grip_mp.c +++ b/drivers/input/joystick/grip_mp.c @@ -423,7 +423,10 @@ static int get_and_decode_packet(struct if (!port->registered) { dbg("New Grip pad in multiport slot %d.\n", slot); - register_slot(slot, grip); + if (register_slot(slot, grip)) { + port->mode = GRIP_MODE_RESET; + port->dirty = 0; + } } return flags; } @@ -585,6 +588,7 @@ static int register_slot(int slot, struc struct grip_port *port = grip->port[slot]; struct input_dev *input_dev; int j, t; + int err; port->dev = input_dev = input_allocate_device(); if (!input_dev) @@ -610,7 +614,12 @@ static int register_slot(int slot, struc if (t > 0) set_bit(t, input_dev->keybit); - input_register_device(port->dev); + err = input_register_device(port->dev); + if (err) { + input_free_device(port->dev); + return err; + } + port->registered = 1; if (port->dirty) /* report initial state, if any */ diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c index 840ed9b..dbc5d92 100644 --- a/drivers/input/joystick/guillemot.c +++ b/drivers/input/joystick/guillemot.c @@ -250,7 +250,9 @@ static int guillemot_connect(struct game for (i = 0; (t = guillemot->type->btn[i]) >= 0; i++) set_bit(t, input_dev->keybit); - input_register_device(guillemot->dev); + err = input_register_device(guillemot->dev); + if (err) + goto fail2; return 0; diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c index 24c684b..706e0ae 100644 --- a/drivers/input/joystick/iforce/iforce-main.c +++ b/drivers/input/joystick/iforce/iforce-main.c @@ -325,8 +325,8 @@ #endif if (i == 20) { /* 5 seconds */ printk(KERN_ERR "iforce-main.c: Timeout waiting for response from device.\n"); - input_free_device(input_dev); - return -ENODEV; + error = -ENODEV; + goto fail; } /* @@ -439,10 +439,8 @@ #endif set_bit(iforce->type->ff[i], input_dev->ffbit); error = input_ff_create(input_dev, ff_effects); - if (error) { - input_free_device(input_dev); - return error; - } + if (error) + goto fail; ff = input_dev->ff; ff->upload = iforce_upload_effect; @@ -455,11 +453,16 @@ #endif * Register input device. */ - input_register_device(iforce->dev); + error = input_register_device(iforce->dev); + if (error) + goto fail; printk(KERN_DEBUG "iforce->dev->open = %p\n", iforce->dev->open); return 0; + + fail: input_free_device(input_dev); + return error; } static int __init iforce_init(void) diff --git a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c index ca08f45..ec4be53 100644 --- a/drivers/input/joystick/iforce/iforce-serio.c +++ b/drivers/input/joystick/iforce/iforce-serio.c @@ -141,21 +141,19 @@ static int iforce_serio_connect(struct s serio_set_drvdata(serio, iforce); err = serio_open(serio, drv); - if (err) { - serio_set_drvdata(serio, NULL); - kfree(iforce); - return err; - } + if (err) + goto fail1; err = iforce_init_device(iforce); - if (err) { - serio_close(serio); - serio_set_drvdata(serio, NULL); - kfree(iforce); - return -ENODEV; - } + if (err) + goto fail2; return 0; + + fail2: serio_close(serio); + fail1: serio_set_drvdata(serio, NULL); + kfree(iforce); + return err; } static void iforce_serio_disconnect(struct serio *serio) diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c index bbfeb9c..fec8b3d 100644 --- a/drivers/input/joystick/interact.c +++ b/drivers/input/joystick/interact.c @@ -283,7 +283,9 @@ static int interact_connect(struct gamep for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++) set_bit(t, input_dev->keybit); - input_register_device(interact->dev); + err = input_register_device(interact->dev); + if (err) + goto fail2; return 0; diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c index e3d1944..d512b0a 100644 --- a/drivers/input/joystick/magellan.c +++ b/drivers/input/joystick/magellan.c @@ -157,7 +157,7 @@ static int magellan_connect(struct serio magellan = kzalloc(sizeof(struct magellan), GFP_KERNEL); input_dev = input_allocate_device(); if (!magellan || !input_dev) - goto fail; + goto fail1; magellan->dev = input_dev; snprintf(magellan->phys, sizeof(magellan->phys), "%s/input0", serio->phys); @@ -183,13 +183,17 @@ static int magellan_connect(struct serio err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; + + err = input_register_device(magellan->dev); + if (err) + goto fail3; - input_register_device(magellan->dev); return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(magellan); return err; } diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c index 2a9808c..9b35973 100644 --- a/drivers/input/joystick/spaceball.c +++ b/drivers/input/joystick/spaceball.c @@ -215,7 +215,7 @@ static int spaceball_connect(struct seri spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL); input_dev = input_allocate_device(); if (!spaceball || !input_dev) - goto fail; + goto fail1; spaceball->dev = input_dev; snprintf(spaceball->phys, sizeof(spaceball->phys), "%s/input0", serio->phys); @@ -252,13 +252,17 @@ static int spaceball_connect(struct seri err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; + + err = input_register_device(spaceball->dev); + if (err) + goto fail3; - input_register_device(spaceball->dev); return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(spaceball); return err; } diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c index c4db024..ea9d51e 100644 --- a/drivers/input/joystick/spaceorb.c +++ b/drivers/input/joystick/spaceorb.c @@ -172,7 +172,7 @@ static int spaceorb_connect(struct serio spaceorb = kzalloc(sizeof(struct spaceorb), GFP_KERNEL); input_dev = input_allocate_device(); if (!spaceorb || !input_dev) - goto fail; + goto fail1; spaceorb->dev = input_dev; snprintf(spaceorb->phys, sizeof(spaceorb->phys), "%s/input0", serio->phys); @@ -198,13 +198,17 @@ static int spaceorb_connect(struct serio err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; + + err = input_register_device(spaceorb->dev); + if (err) + goto fail3; - input_register_device(spaceorb->dev); return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(spaceorb); return err; } diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c index 1ffb032..b51a4a4 100644 --- a/drivers/input/joystick/stinger.c +++ b/drivers/input/joystick/stinger.c @@ -143,7 +143,7 @@ static int stinger_connect(struct serio stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL); input_dev = input_allocate_device(); if (!stinger || !input_dev) - goto fail; + goto fail1; stinger->dev = input_dev; snprintf(stinger->phys, sizeof(stinger->phys), "%s/serio0", serio->phys); @@ -168,13 +168,17 @@ static int stinger_connect(struct serio err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; + + err = input_register_device(stinger->dev); + if (err) + goto fail3; - input_register_device(stinger->dev); return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(stinger); return err; } diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c index 49085df..3c1c83e 100644 --- a/drivers/input/joystick/twidjoy.c +++ b/drivers/input/joystick/twidjoy.c @@ -194,7 +194,7 @@ static int twidjoy_connect(struct serio twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL); input_dev = input_allocate_device(); if (!twidjoy || !input_dev) - goto fail; + goto fail1; twidjoy->dev = input_dev; snprintf(twidjoy->phys, sizeof(twidjoy->phys), "%s/input0", serio->phys); @@ -221,13 +221,17 @@ static int twidjoy_connect(struct serio err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; + + err = input_register_device(twidjoy->dev); + if (err) + goto fail3; - input_register_device(twidjoy->dev); return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(twidjoy); return err; } diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c index 35edea1..1e4828b 100644 --- a/drivers/input/joystick/warrior.c +++ b/drivers/input/joystick/warrior.c @@ -149,7 +149,7 @@ static int warrior_connect(struct serio warrior = kzalloc(sizeof(struct warrior), GFP_KERNEL); input_dev = input_allocate_device(); if (!warrior || !input_dev) - goto fail; + goto fail1; warrior->dev = input_dev; snprintf(warrior->phys, sizeof(warrior->phys), "%s/input0", serio->phys); @@ -176,13 +176,17 @@ static int warrior_connect(struct serio err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; + + err = input_register_device(warrior->dev); + if (err) + goto fail3; - input_register_device(warrior->dev); return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(warrior); return err; } diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c index 8abdbd0..16583d7 100644 --- a/drivers/input/keyboard/amikbd.c +++ b/drivers/input/keyboard/amikbd.c @@ -190,7 +190,7 @@ static int __init amikbd_init(void) int i, j; if (!AMIGAHW_PRESENT(AMI_KEYBOARD)) - return -EIO; + return -ENODEV; if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb")) return -EBUSY; @@ -198,8 +198,8 @@ static int __init amikbd_init(void) amikbd_dev = input_allocate_device(); if (!amikbd_dev) { printk(KERN_ERR "amikbd: not enough memory for input device\n"); - release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100); - return -ENOMEM; + err = -ENOMEM; + goto fail1; } amikbd_dev->name = "Amiga Keyboard"; @@ -231,10 +231,22 @@ static int __init amikbd_init(void) memcpy(key_maps[i], temp_map, sizeof(temp_map)); } ciaa.cra &= ~0x41; /* serial data in, turn off TA */ - request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", amikbd_interrupt); + if (request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", + amikbd_interrupt)) { + err = -EBUSY; + goto fail2; + } + + err = input_register_device(amikbd_dev); + if (err) + goto fail3; - input_register_device(amikbd_dev); return 0; + + fail3: free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt); + fail2: input_free_device(amikbd_dev); + fail1: release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100); + return err; } static void __exit amikbd_exit(void) diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index cbb9366..73c6946 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -939,7 +939,7 @@ static int atkbd_connect(struct serio *s atkbd = kzalloc(sizeof(struct atkbd), GFP_KERNEL); dev = input_allocate_device(); if (!atkbd || !dev) - goto fail; + goto fail1; atkbd->dev = dev; ps2_init(&atkbd->ps2dev, serio); @@ -967,14 +967,13 @@ static int atkbd_connect(struct serio *s err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; if (atkbd->write) { if (atkbd_probe(atkbd)) { - serio_close(serio); err = -ENODEV; - goto fail; + goto fail3; } atkbd->set = atkbd_select_set(atkbd, atkbd_set, atkbd_extra); @@ -988,16 +987,22 @@ static int atkbd_connect(struct serio *s atkbd_set_keycode_table(atkbd); atkbd_set_device_attrs(atkbd); - sysfs_create_group(&serio->dev.kobj, &atkbd_attribute_group); + err = sysfs_create_group(&serio->dev.kobj, &atkbd_attribute_group); + if (err) + goto fail3; atkbd_enable(atkbd); - input_register_device(atkbd->dev); + err = input_register_device(atkbd->dev); + if (err) + goto fail4; return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(dev); + fail4: sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(dev); kfree(atkbd); return err; } @@ -1133,9 +1138,11 @@ static ssize_t atkbd_show_extra(struct a static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count) { - struct input_dev *new_dev; + struct input_dev *old_dev, *new_dev; unsigned long value; char *rest; + int err; + unsigned char old_extra, old_set; if (!atkbd->write) return -EIO; @@ -1147,17 +1154,36 @@ static ssize_t atkbd_set_extra(struct at if (atkbd->extra != value) { /* * Since device's properties will change we need to - * unregister old device. But allocate new one first - * to make sure we have it. + * unregister old device. But allocate and register + * new one first to make sure we have it. */ - if (!(new_dev = input_allocate_device())) + old_dev = atkbd->dev; + old_extra = atkbd->extra; + old_set = atkbd->set; + + new_dev = input_allocate_device(); + if (!new_dev) return -ENOMEM; - input_unregister_device(atkbd->dev); + atkbd->dev = new_dev; atkbd->set = atkbd_select_set(atkbd, atkbd->set, value); atkbd_activate(atkbd); + atkbd_set_keycode_table(atkbd); atkbd_set_device_attrs(atkbd); - input_register_device(atkbd->dev); + + err = input_register_device(atkbd->dev); + if (err) { + input_free_device(new_dev); + + atkbd->dev = old_dev; + atkbd->set = atkbd_select_set(atkbd, old_set, old_extra); + atkbd_set_keycode_table(atkbd); + atkbd_set_device_attrs(atkbd); + + return err; + } + input_unregister_device(old_dev); + } return count; } @@ -1169,23 +1195,41 @@ static ssize_t atkbd_show_scroll(struct static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count) { - struct input_dev *new_dev; + struct input_dev *old_dev, *new_dev; unsigned long value; char *rest; + int err; + unsigned char old_scroll; value = simple_strtoul(buf, &rest, 10); if (*rest || value > 1) return -EINVAL; if (atkbd->scroll != value) { - if (!(new_dev = input_allocate_device())) + old_dev = atkbd->dev; + old_scroll = atkbd->scroll; + + new_dev = input_allocate_device(); + if (!new_dev) return -ENOMEM; - input_unregister_device(atkbd->dev); + atkbd->dev = new_dev; atkbd->scroll = value; atkbd_set_keycode_table(atkbd); atkbd_set_device_attrs(atkbd); - input_register_device(atkbd->dev); + + err = input_register_device(atkbd->dev); + if (err) { + input_free_device(new_dev); + + atkbd->scroll = old_scroll; + atkbd->dev = old_dev; + atkbd_set_keycode_table(atkbd); + atkbd_set_device_attrs(atkbd); + + return err; + } + input_unregister_device(old_dev); } return count; } @@ -1197,9 +1241,11 @@ static ssize_t atkbd_show_set(struct atk static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) { - struct input_dev *new_dev; + struct input_dev *old_dev, *new_dev; unsigned long value; char *rest; + int err; + unsigned char old_set, old_extra; if (!atkbd->write) return -EIO; @@ -1209,15 +1255,32 @@ static ssize_t atkbd_set_set(struct atkb return -EINVAL; if (atkbd->set != value) { - if (!(new_dev = input_allocate_device())) + old_dev = atkbd->dev; + old_extra = atkbd->extra; + old_set = atkbd->set; + + new_dev = input_allocate_device(); + if (!new_dev) return -ENOMEM; - input_unregister_device(atkbd->dev); + atkbd->dev = new_dev; atkbd->set = atkbd_select_set(atkbd, value, atkbd->extra); atkbd_activate(atkbd); atkbd_set_keycode_table(atkbd); atkbd_set_device_attrs(atkbd); - input_register_device(atkbd->dev); + + err = input_register_device(atkbd->dev); + if (err) { + input_free_device(new_dev); + + atkbd->dev = old_dev; + atkbd->set = atkbd_select_set(atkbd, old_set, old_extra); + atkbd_set_keycode_table(atkbd); + atkbd_set_device_attrs(atkbd); + + return err; + } + input_unregister_device(old_dev); } return count; } @@ -1229,9 +1292,11 @@ static ssize_t atkbd_show_softrepeat(str static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count) { - struct input_dev *new_dev; + struct input_dev *old_dev, *new_dev; unsigned long value; char *rest; + int err; + unsigned char old_softrepeat, old_softraw; if (!atkbd->write) return -EIO; @@ -1241,15 +1306,32 @@ static ssize_t atkbd_set_softrepeat(stru return -EINVAL; if (atkbd->softrepeat != value) { - if (!(new_dev = input_allocate_device())) + old_dev = atkbd->dev; + old_softrepeat = atkbd->softrepeat; + old_softraw = atkbd->softraw; + + new_dev = input_allocate_device(); + if (!new_dev) return -ENOMEM; - input_unregister_device(atkbd->dev); + atkbd->dev = new_dev; atkbd->softrepeat = value; if (atkbd->softrepeat) atkbd->softraw = 1; atkbd_set_device_attrs(atkbd); - input_register_device(atkbd->dev); + + err = input_register_device(atkbd->dev); + if (err) { + input_free_device(new_dev); + + atkbd->dev = old_dev; + atkbd->softrepeat = old_softrepeat; + atkbd->softraw = old_softraw; + atkbd_set_device_attrs(atkbd); + + return err; + } + input_unregister_device(old_dev); } return count; } @@ -1262,22 +1344,39 @@ static ssize_t atkbd_show_softraw(struct static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count) { - struct input_dev *new_dev; + struct input_dev *old_dev, *new_dev; unsigned long value; char *rest; + int err; + unsigned char old_softraw; value = simple_strtoul(buf, &rest, 10); if (*rest || value > 1) return -EINVAL; if (atkbd->softraw != value) { - if (!(new_dev = input_allocate_device())) + old_dev = atkbd->dev; + old_softraw = atkbd->softraw; + + new_dev = input_allocate_device(); + if (!new_dev) return -ENOMEM; - input_unregister_device(atkbd->dev); + atkbd->dev = new_dev; atkbd->softraw = value; atkbd_set_device_attrs(atkbd); - input_register_device(atkbd->dev); + + err = input_register_device(atkbd->dev); + if (err) { + input_free_device(new_dev); + + atkbd->dev = old_dev; + atkbd->softraw = old_softraw; + atkbd_set_device_attrs(atkbd); + + return err; + } + input_unregister_device(old_dev); } return count; } diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index befdd60..1016c94 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c @@ -291,15 +291,12 @@ static int __init corgikbd_probe(struct { struct corgikbd *corgikbd; struct input_dev *input_dev; - int i; + int i, err = -ENOMEM; corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL); input_dev = input_allocate_device(); - if (!corgikbd || !input_dev) { - kfree(corgikbd); - input_free_device(input_dev); - return -ENOMEM; - } + if (!corgikbd || !input_dev) + goto fail; platform_set_drvdata(pdev, corgikbd); @@ -341,7 +338,9 @@ static int __init corgikbd_probe(struct set_bit(SW_TABLET_MODE, input_dev->swbit); set_bit(SW_HEADPHONE_INSERT, input_dev->swbit); - input_register_device(corgikbd->input); + err = input_register_device(corgikbd->input); + if (err) + goto fail; mod_timer(&corgikbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); @@ -362,6 +361,10 @@ static int __init corgikbd_probe(struct pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN); return 0; + + fail: input_free_device(input_dev); + kfree(corgikbd); + return err; } static int corgikbd_remove(struct platform_device *pdev) diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c index 708d5a1..0067c1f 100644 --- a/drivers/input/keyboard/lkkbd.c +++ b/drivers/input/keyboard/lkkbd.c @@ -651,7 +651,7 @@ lkkbd_connect (struct serio *serio, stru input_dev = input_allocate_device (); if (!lk || !input_dev) { err = -ENOMEM; - goto fail; + goto fail1; } lk->serio = serio; @@ -696,15 +696,19 @@ lkkbd_connect (struct serio *serio, stru err = serio_open (serio, drv); if (err) - goto fail; + goto fail2; + + err = input_register_device (lk->dev); + if (err) + goto fail3; - input_register_device (lk->dev); lk->serio->write (lk->serio, LK_CMD_POWERCYCLE_RESET); return 0; - fail: serio_set_drvdata (serio, NULL); - input_free_device (input_dev); + fail3: serio_close (serio); + fail2: serio_set_drvdata (serio, NULL); + fail1: input_free_device (input_dev); kfree (lk); return err; } diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c index 5788dbc..2ade518 100644 --- a/drivers/input/keyboard/locomokbd.c +++ b/drivers/input/keyboard/locomokbd.c @@ -193,22 +193,22 @@ static int locomokbd_probe(struct locomo { struct locomokbd *locomokbd; struct input_dev *input_dev; - int i, ret; + int i, err; locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL); input_dev = input_allocate_device(); if (!locomokbd || !input_dev) { - ret = -ENOMEM; - goto free; + err = -ENOMEM; + goto err_free_mem; } /* try and claim memory region */ if (!request_mem_region((unsigned long) dev->mapbase, dev->length, LOCOMO_DRIVER_NAME(dev))) { - ret = -EBUSY; + err = -EBUSY; printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n"); - goto free; + goto err_free_mem; } locomokbd->ldev = dev; @@ -244,24 +244,28 @@ static int locomokbd_probe(struct locomo clear_bit(0, input_dev->keybit); /* attempt to get the interrupt */ - ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); - if (ret) { + err = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); + if (err) { printk(KERN_ERR "locomokbd: Can't get irq for keyboard\n"); - goto out; + goto err_release_region; } - input_register_device(locomokbd->input); + err = input_register_device(locomokbd->input); + if (err) + goto err_free_irq; return 0; -out: + err_free_irq: + free_irq(dev->irq[0], locomokbd); + err_release_region: release_mem_region((unsigned long) dev->mapbase, dev->length); locomo_set_drvdata(dev, NULL); -free: + err_free_mem: input_free_device(input_dev); kfree(locomokbd); - return ret; + return err; } static int locomokbd_remove(struct locomo_dev *dev) diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c index cc6aaf9..99836b3 100644 --- a/drivers/input/keyboard/maple_keyb.c +++ b/drivers/input/keyboard/maple_keyb.c @@ -94,13 +94,13 @@ static int dc_kbd_connect(struct maple_d struct input_dev *input_dev; unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); int i; + int err; dev->private_data = kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL); input_dev = input_allocate_device(); if (!kbd || !input_dev) { - kfree(kbd); - input_free_device(input_dev); - return -ENOMEM; + err = -ENOMEM; + goto fail; } kbd->dev = input_dev; @@ -113,10 +113,16 @@ static int dc_kbd_connect(struct maple_d set_bit(dc_kbd_keycode[i], input_dev->keybit); clear_bit(0, input_dev->keybit); - input_register_device(kbd->dev); + err = input_register_device(kbd->dev); + if (err) + goto fail; maple_getcond_callback(dev, dc_kbd_callback, 1, MAPLE_FUNC_KEYBOARD); return 0; + + fail: input_free_device(input_dev); + kfree(kbd); + return err; } diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c index 9282e4e..33e8139 100644 --- a/drivers/input/keyboard/newtonkbd.c +++ b/drivers/input/keyboard/newtonkbd.c @@ -91,7 +91,7 @@ static int nkbd_connect(struct serio *se nkbd = kzalloc(sizeof(struct nkbd), GFP_KERNEL); input_dev = input_allocate_device(); if (!nkbd || !input_dev) - goto fail; + goto fail1; nkbd->serio = serio; nkbd->dev = input_dev; @@ -119,13 +119,17 @@ static int nkbd_connect(struct serio *se err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; + + err = input_register_device(nkbd->dev); + if (err) + goto fail3; - input_register_device(nkbd->dev); return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(nkbd); return err; } diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c index 28b2748..8a2166c 100644 --- a/drivers/input/keyboard/spitzkbd.c +++ b/drivers/input/keyboard/spitzkbd.c @@ -346,17 +346,12 @@ static int __init spitzkbd_probe(struct { struct spitzkbd *spitzkbd; struct input_dev *input_dev; - int i; + int i, err = -ENOMEM; spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL); - if (!spitzkbd) - return -ENOMEM; - input_dev = input_allocate_device(); - if (!input_dev) { - kfree(spitzkbd); - return -ENOMEM; - } + if (!spitzkbd || !input_dev) + goto fail; platform_set_drvdata(dev, spitzkbd); strcpy(spitzkbd->phys, "spitzkbd/input0"); @@ -400,7 +395,9 @@ static int __init spitzkbd_probe(struct set_bit(SW_TABLET_MODE, input_dev->swbit); set_bit(SW_HEADPHONE_INSERT, input_dev->swbit); - input_register_device(input_dev); + err = input_register_device(input_dev); + if (err) + goto fail; mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); @@ -434,13 +431,15 @@ static int __init spitzkbd_probe(struct request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr, IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "Spitzkbd SWB", spitzkbd); - request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr, + request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr, IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "Spitzkbd HP", spitzkbd); - printk(KERN_INFO "input: Spitz Keyboard Registered\n"); - return 0; + + fail: input_free_device(input_dev); + kfree(spitzkbd); + return err; } static int spitzkbd_remove(struct platform_device *dev) @@ -474,6 +473,7 @@ static struct platform_driver spitzkbd_d .resume = spitzkbd_resume, .driver = { .name = "spitz-keyboard", + .owner = THIS_MODULE, }, }; diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index cac4781..d1b62f7 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c @@ -243,7 +243,7 @@ static int sunkbd_connect(struct serio * sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL); input_dev = input_allocate_device(); if (!sunkbd || !input_dev) - goto fail; + goto fail1; sunkbd->serio = serio; sunkbd->dev = input_dev; @@ -255,11 +255,11 @@ static int sunkbd_connect(struct serio * err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; if (sunkbd_initialize(sunkbd) < 0) { - serio_close(serio); - goto fail; + err = -ENODEV; + goto fail3; } snprintf(sunkbd->name, sizeof(sunkbd->name), "Sun Type %d keyboard", sunkbd->type); @@ -287,11 +287,17 @@ static int sunkbd_connect(struct serio * clear_bit(0, input_dev->keybit); sunkbd_enable(sunkbd, 1); - input_register_device(sunkbd->dev); + + err = input_register_device(sunkbd->dev); + if (err) + goto fail4; + return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail4: sunkbd_enable(sunkbd, 0); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(sunkbd); return err; } diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c index 8c11dc9..b53f716 100644 --- a/drivers/input/keyboard/xtkbd.c +++ b/drivers/input/keyboard/xtkbd.c @@ -95,7 +95,7 @@ static int xtkbd_connect(struct serio *s xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL); input_dev = input_allocate_device(); if (!xtkbd || !input_dev) - goto fail; + goto fail1; xtkbd->serio = serio; xtkbd->dev = input_dev; @@ -124,13 +124,17 @@ static int xtkbd_connect(struct serio *s err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; + + err = input_register_device(xtkbd->dev); + if (err) + goto fail3; - input_register_device(xtkbd->dev); return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(xtkbd); return err; } diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c index 599a7b2..239a0e1 100644 --- a/drivers/input/mouse/amimouse.c +++ b/drivers/input/mouse/amimouse.c @@ -95,10 +95,13 @@ static void amimouse_close(struct input_ static int __init amimouse_init(void) { + int err; + if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_MOUSE)) return -ENODEV; - if (!(amimouse_dev = input_allocate_device())) + amimouse_dev = input_allocate_device(); + if (!amimouse_dev) return -ENOMEM; amimouse_dev->name = "Amiga mouse"; @@ -114,7 +117,11 @@ static int __init amimouse_init(void) amimouse_dev->open = amimouse_open; amimouse_dev->close = amimouse_close; - input_register_device(amimouse_dev); + err = input_register_device(amimouse_dev); + if (err) { + input_free_device(amimouse_dev); + return err; + } return 0; } diff --git a/drivers/input/mouse/inport.c b/drivers/input/mouse/inport.c index e1252fa..13dd967 100644 --- a/drivers/input/mouse/inport.c +++ b/drivers/input/mouse/inport.c @@ -135,6 +135,7 @@ static void inport_close(struct input_de static int __init inport_init(void) { unsigned char a, b, c; + int err; if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) { printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE); @@ -145,15 +146,16 @@ static int __init inport_init(void) b = inb(INPORT_SIGNATURE_PORT); c = inb(INPORT_SIGNATURE_PORT); if (a == b || a != c) { - release_region(INPORT_BASE, INPORT_EXTENT); printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE); - return -ENODEV; + err = -ENODEV; + goto err_release_region; } - if (!(inport_dev = input_allocate_device())) { + inport_dev = input_allocate_device(); + if (!inport_dev) { printk(KERN_ERR "inport.c: Not enough memory for input device\n"); - release_region(INPORT_BASE, INPORT_EXTENT); - return -ENOMEM; + err = -ENOMEM; + goto err_release_region; } inport_dev->name = INPORT_NAME; @@ -174,9 +176,18 @@ static int __init inport_init(void) outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); outb(INPORT_MODE_BASE, INPORT_DATA_PORT); - input_register_device(inport_dev); + err = input_register_device(inport_dev); + if (err) + goto err_free_dev; return 0; + + err_free_dev: + input_free_device(inport_dev); + err_release_region: + release_region(INPORT_BASE, INPORT_EXTENT); + + return err; } static void __exit inport_exit(void) diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c index c57e885..29542f0 100644 --- a/drivers/input/mouse/lifebook.c +++ b/drivers/input/mouse/lifebook.c @@ -21,47 +21,51 @@ #include "psmouse.h" #include "lifebook.h" static struct dmi_system_id lifebook_dmi_table[] = { - { - .ident = "LifeBook B", - .matches = { - DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B Series"), - }, - }, - { - .ident = "Lifebook B", - .matches = { - DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK B Series"), - }, - }, - { - .ident = "Lifebook B213x/B2150", - .matches = { - DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B2131/B2133/B2150"), - }, - }, - { - .ident = "Zephyr", - .matches = { - DMI_MATCH(DMI_PRODUCT_NAME, "ZEPHYR"), - }, - }, - { - .ident = "CF-18", - .matches = { - DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"), - }, - }, - { - .ident = "Lifebook B142", - .matches = { - DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B142"), - }, - - }, - { } + { + .ident = "FLORA-ie 55mi", + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "FLORA-ie 55mi"), + }, + }, + { + .ident = "LifeBook B", + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B Series"), + }, + }, + { + .ident = "Lifebook B", + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK B Series"), + }, + }, + { + .ident = "Lifebook B213x/B2150", + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B2131/B2133/B2150"), + }, + }, + { + .ident = "Zephyr", + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "ZEPHYR"), + }, + }, + { + .ident = "CF-18", + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"), + }, + }, + { + .ident = "Lifebook B142", + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B142"), + }, + }, + { } }; - static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse) { unsigned char *packet = psmouse->packet; diff --git a/drivers/input/mouse/logibm.c b/drivers/input/mouse/logibm.c index 8e9c2f3..db20599 100644 --- a/drivers/input/mouse/logibm.c +++ b/drivers/input/mouse/logibm.c @@ -124,6 +124,8 @@ static void logibm_close(struct input_de static int __init logibm_init(void) { + int err; + if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) { printk(KERN_ERR "logibm.c: Can't allocate ports at %#x\n", LOGIBM_BASE); return -EBUSY; @@ -134,18 +136,19 @@ static int __init logibm_init(void) udelay(100); if (inb(LOGIBM_SIGNATURE_PORT) != LOGIBM_SIGNATURE_BYTE) { - release_region(LOGIBM_BASE, LOGIBM_EXTENT); printk(KERN_ERR "logibm.c: Didn't find Logitech busmouse at %#x\n", LOGIBM_BASE); - return -ENODEV; + err = -ENODEV; + goto err_release_region; } outb(LOGIBM_DEFAULT_MODE, LOGIBM_CONFIG_PORT); outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); - if (!(logibm_dev = input_allocate_device())) { + logibm_dev = input_allocate_device(); + if (!logibm_dev) { printk(KERN_ERR "logibm.c: Not enough memory for input device\n"); - release_region(LOGIBM_BASE, LOGIBM_EXTENT); - return -ENOMEM; + err = -ENOMEM; + goto err_release_region; } logibm_dev->name = "Logitech bus mouse"; @@ -162,9 +165,18 @@ static int __init logibm_init(void) logibm_dev->open = logibm_open; logibm_dev->close = logibm_close; - input_register_device(logibm_dev); + err = input_register_device(logibm_dev); + if (err) + goto err_free_dev; return 0; + + err_free_dev: + input_free_device(logibm_dev); + err_release_region: + release_region(LOGIBM_BASE, LOGIBM_EXTENT); + + return err; } static void __exit logibm_exit(void) diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index 8a4f862..d3ddea2 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c @@ -328,6 +328,7 @@ int ps2pp_init(struct psmouse *psmouse, unsigned char model, buttons; const struct ps2pp_info *model_info; int use_ps2pp = 0; + int error; param[0] = 0; ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); @@ -393,8 +394,14 @@ int ps2pp_init(struct psmouse *psmouse, psmouse->set_resolution = ps2pp_set_resolution; psmouse->disconnect = ps2pp_disconnect; - device_create_file(&psmouse->ps2dev.serio->dev, - &psmouse_attr_smartscroll.dattr); + error = device_create_file(&psmouse->ps2dev.serio->dev, + &psmouse_attr_smartscroll.dattr); + if (error) { + printk(KERN_ERR + "logips2pp.c: failed to create smartscroll " + "sysfs attribute, error: %d\n", error); + return -1; + } } } diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c index 8c075aa..f155c1f 100644 --- a/drivers/input/mouse/pc110pad.c +++ b/drivers/input/mouse/pc110pad.c @@ -108,6 +108,7 @@ static int pc110pad_open(struct input_de static int __init pc110pad_init(void) { struct pci_dev *dev; + int err; dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); if (dev) { @@ -124,16 +125,16 @@ static int __init pc110pad_init(void) outb(PC110PAD_OFF, pc110pad_io + 2); if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) { - release_region(pc110pad_io, 4); printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq); - return -EBUSY; + err = -EBUSY; + goto err_release_region; } - if (!(pc110pad_dev = input_allocate_device())) { - free_irq(pc110pad_irq, NULL); - release_region(pc110pad_io, 4); + pc110pad_dev = input_allocate_device(); + if (!pc110pad_dev) { printk(KERN_ERR "pc110pad: Not enough memory.\n"); - return -ENOMEM; + err = -ENOMEM; + goto err_free_irq; } pc110pad_dev->name = "IBM PC110 TouchPad"; @@ -153,9 +154,20 @@ static int __init pc110pad_init(void) pc110pad_dev->open = pc110pad_open; pc110pad_dev->close = pc110pad_close; - input_register_device(pc110pad_dev); + err = input_register_device(pc110pad_dev); + if (err) + goto err_free_dev; return 0; + + err_free_dev: + input_free_device(pc110pad_dev); + err_free_irq: + free_irq(pc110pad_irq, NULL); + err_release_region: + release_region(pc110pad_io, 4); + + return err; } static void __exit pc110pad_exit(void) diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 6f9b2c7..58beca9 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -1102,7 +1102,7 @@ static int psmouse_connect(struct serio { struct psmouse *psmouse, *parent = NULL; struct input_dev *input_dev; - int retval = -ENOMEM; + int retval = 0, error = -ENOMEM; mutex_lock(&psmouse_mutex); @@ -1118,7 +1118,7 @@ static int psmouse_connect(struct serio psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL); input_dev = input_allocate_device(); if (!psmouse || !input_dev) - goto out; + goto err_free; ps2_init(&psmouse->ps2dev, serio); INIT_WORK(&psmouse->resync_work, psmouse_resync, psmouse); @@ -1129,14 +1129,13 @@ static int psmouse_connect(struct serio serio_set_drvdata(serio, psmouse); - retval = serio_open(serio, drv); - if (retval) - goto out; + error = serio_open(serio, drv); + if (error) + goto err_clear_drvdata; if (psmouse_probe(psmouse) < 0) { - serio_close(serio); - retval = -ENODEV; - goto out; + error = -ENODEV; + goto err_close_serio; } psmouse->rate = psmouse_rate; @@ -1150,30 +1149,44 @@ static int psmouse_connect(struct serio psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); psmouse_initialize(psmouse); - input_register_device(psmouse->dev); + error = input_register_device(psmouse->dev); + if (error) + goto err_protocol_disconnect; if (parent && parent->pt_activate) parent->pt_activate(parent); - sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group); + error = sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group); + if (error) + goto err_pt_deactivate; psmouse_activate(psmouse); - retval = 0; - -out: - if (retval) { - serio_set_drvdata(serio, NULL); - input_free_device(input_dev); - kfree(psmouse); - } - + out: /* If this is a pass-through port the parent needs to be re-activated */ if (parent) psmouse_activate(parent); mutex_unlock(&psmouse_mutex); return retval; + + err_pt_deactivate: + if (parent && parent->pt_deactivate) + parent->pt_deactivate(parent); + err_protocol_disconnect: + if (psmouse->disconnect) + psmouse->disconnect(psmouse); + psmouse_set_state(psmouse, PSMOUSE_IGNORE); + err_close_serio: + serio_close(serio); + err_clear_drvdata: + serio_set_drvdata(serio, NULL); + err_free: + input_free_device(input_dev); + kfree(psmouse); + + retval = error; + goto out; } @@ -1336,14 +1349,14 @@ ssize_t psmouse_attr_set_helper(struct d static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char *buf) { - unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset); + unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); - return sprintf(buf, "%lu\n", *field); + return sprintf(buf, "%u\n", *field); } static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count) { - unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset); + unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); unsigned long value; char *rest; @@ -1351,6 +1364,9 @@ static ssize_t psmouse_set_int_attr(stru if (*rest) return -EINVAL; + if ((unsigned int)value != value) + return -EINVAL; + *field = value; return count; @@ -1365,17 +1381,20 @@ static ssize_t psmouse_attr_set_protocol { struct serio *serio = psmouse->ps2dev.serio; struct psmouse *parent = NULL; - struct input_dev *new_dev; - const struct psmouse_protocol *proto; + struct input_dev *old_dev, *new_dev; + const struct psmouse_protocol *proto, *old_proto; + int error; int retry = 0; - if (!(proto = psmouse_protocol_by_name(buf, count))) + proto = psmouse_protocol_by_name(buf, count); + if (!proto) return -EINVAL; if (psmouse->type == proto->type) return count; - if (!(new_dev = input_allocate_device())) + new_dev = input_allocate_device(); + if (!new_dev) return -ENOMEM; while (serio->child) { @@ -1408,11 +1427,13 @@ static ssize_t psmouse_attr_set_protocol parent->pt_deactivate(parent); } + old_dev = psmouse->dev; + old_proto = psmouse_protocol_by_type(psmouse->type); + if (psmouse->disconnect) psmouse->disconnect(psmouse); psmouse_set_state(psmouse, PSMOUSE_IGNORE); - input_unregister_device(psmouse->dev); psmouse->dev = new_dev; psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); @@ -1426,7 +1447,23 @@ static ssize_t psmouse_attr_set_protocol psmouse_initialize(psmouse); psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); - input_register_device(psmouse->dev); + error = input_register_device(psmouse->dev); + if (error) { + if (psmouse->disconnect) + psmouse->disconnect(psmouse); + + psmouse_set_state(psmouse, PSMOUSE_IGNORE); + input_free_device(new_dev); + psmouse->dev = old_dev; + psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); + psmouse_switch_protocol(psmouse, old_proto); + psmouse_initialize(psmouse); + psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); + + return error; + } + + input_unregister_device(old_dev); if (parent && parent->pt_activate) parent->pt_activate(parent); diff --git a/drivers/input/mouse/rpcmouse.c b/drivers/input/mouse/rpcmouse.c index ea04685..fbdcfd8 100644 --- a/drivers/input/mouse/rpcmouse.c +++ b/drivers/input/mouse/rpcmouse.c @@ -66,7 +66,10 @@ static irqreturn_t rpcmouse_irq(int irq, static int __init rpcmouse_init(void) { - if (!(rpcmouse_dev = input_allocate_device())) + int err; + + rpcmouse_dev = input_allocate_device(); + if (!rpcmouse_dev) return -ENOMEM; rpcmouse_dev->name = "Acorn RiscPC Mouse"; @@ -85,13 +88,22 @@ static int __init rpcmouse_init(void) if (request_irq(IRQ_VSYNCPULSE, rpcmouse_irq, IRQF_SHARED, "rpcmouse", rpcmouse_dev)) { printk(KERN_ERR "rpcmouse: unable to allocate VSYNC interrupt\n"); - input_free_device(rpcmouse_dev); - return -EBUSY; + err = -EBUSY; + goto err_free_dev; } - input_register_device(rpcmouse_dev); + err = input_register_device(rpcmouse_dev); + if (err) + goto err_free_irq; return 0; + + err_free_irq: + free_irq(IRQ_VSYNCPULSE, rpcmouse_dev); + err_free_dev: + input_free_device(rpcmouse_dev); + + return err; } static void __exit rpcmouse_exit(void) diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c index 2a272c5..10b51e7 100644 --- a/drivers/input/mouse/sermouse.c +++ b/drivers/input/mouse/sermouse.c @@ -246,7 +246,7 @@ static int sermouse_connect(struct serio sermouse = kzalloc(sizeof(struct sermouse), GFP_KERNEL); input_dev = input_allocate_device(); if (!sermouse || !input_dev) - goto fail; + goto fail1; sermouse->dev = input_dev; snprintf(sermouse->phys, sizeof(sermouse->phys), "%s/input0", serio->phys); @@ -275,14 +275,17 @@ static int sermouse_connect(struct serio err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; - input_register_device(sermouse->dev); + err = input_register_device(sermouse->dev); + if (err) + goto fail3; return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(sermouse); return err; } diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index ae5871a..9ab5b5e 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c @@ -293,6 +293,7 @@ int trackpoint_detect(struct psmouse *ps struct ps2dev *ps2dev = &psmouse->ps2dev; unsigned char firmware_id; unsigned char button_info; + int error; if (trackpoint_start_protocol(psmouse, &firmware_id)) return -1; @@ -305,7 +306,7 @@ int trackpoint_detect(struct psmouse *ps button_info = 0; } - psmouse->private = priv = kcalloc(1, sizeof(struct trackpoint_data), GFP_KERNEL); + psmouse->private = priv = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL); if (!priv) return -1; @@ -318,7 +319,14 @@ int trackpoint_detect(struct psmouse *ps trackpoint_defaults(priv); trackpoint_sync(psmouse); - sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group); + error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group); + if (error) { + printk(KERN_ERR + "trackpoint.c: failed to create sysfs attributes, error: %d\n", + error); + kfree(priv); + return -1; + } printk(KERN_INFO "IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n", firmware_id, (button_info & 0xf0) >> 4, button_info & 0x0f); diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c index ffdb50e..ffd0d66 100644 --- a/drivers/input/mouse/vsxxxaa.c +++ b/drivers/input/mouse/vsxxxaa.c @@ -497,7 +497,7 @@ vsxxxaa_connect (struct serio *serio, st mouse = kzalloc (sizeof (struct vsxxxaa), GFP_KERNEL); input_dev = input_allocate_device (); if (!mouse || !input_dev) - goto fail; + goto fail1; mouse->dev = input_dev; mouse->serio = serio; @@ -527,7 +527,7 @@ vsxxxaa_connect (struct serio *serio, st err = serio_open (serio, drv); if (err) - goto fail; + goto fail2; /* * Request selftest. Standard packet format and differential @@ -535,12 +535,15 @@ vsxxxaa_connect (struct serio *serio, st */ serio->write (serio, 'T'); /* Test */ - input_register_device (input_dev); + err = input_register_device (input_dev); + if (err) + goto fail3; return 0; - fail: serio_set_drvdata (serio, NULL); - input_free_device (input_dev); + fail3: serio_close (serio); + fail2: serio_set_drvdata (serio, NULL); + fail1: input_free_device (input_dev); kfree (mouse); return err; } diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 7e3141f..d365f22 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -255,25 +255,10 @@ static int i8042_kbd_write(struct serio static int i8042_aux_write(struct serio *serio, unsigned char c) { struct i8042_port *port = serio->port_data; - int retval; - -/* - * Send the byte out. - */ - - if (port->mux == -1) - retval = i8042_command(&c, I8042_CMD_AUX_SEND); - else - retval = i8042_command(&c, I8042_CMD_MUX_SEND + port->mux); -/* - * Make sure the interrupt happens and the character is received even - * in the case the IRQ isn't wired, so that we can receive further - * characters later. - */ - - i8042_interrupt(0, NULL); - return retval; + return i8042_command(&c, port->mux == -1 ? + I8042_CMD_AUX_SEND : + I8042_CMD_MUX_SEND + port->mux); } /* diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 211943f..3cb99d4 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c @@ -784,12 +784,6 @@ static int serio_driver_remove(struct de return 0; } -static struct bus_type serio_bus = { - .name = "serio", - .probe = serio_driver_probe, - .remove = serio_driver_remove, -}; - static void serio_add_driver(struct serio_driver *drv) { int error; @@ -946,15 +940,21 @@ irqreturn_t serio_interrupt(struct serio return ret; } +static struct bus_type serio_bus = { + .name = "serio", + .dev_attrs = serio_device_attrs, + .drv_attrs = serio_driver_attrs, + .match = serio_bus_match, + .uevent = serio_uevent, + .probe = serio_driver_probe, + .remove = serio_driver_remove, + .resume = serio_resume, +}; + static int __init serio_init(void) { int error; - serio_bus.dev_attrs = serio_device_attrs; - serio_bus.drv_attrs = serio_driver_attrs; - serio_bus.match = serio_bus_match; - serio_bus.uevent = serio_uevent; - serio_bus.resume = serio_resume; error = bus_register(&serio_bus); if (error) { printk(KERN_ERR "serio: failed to register serio bus, error: %d\n", error); diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index f56d6a0..8f56af8 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -76,6 +76,7 @@ struct ads7846 { char phys[32]; struct spi_device *spi; + struct attribute_group *attr_group; u16 model; u16 vref_delay_usecs; u16 x_plate_ohms; @@ -317,6 +318,48 @@ static ssize_t ads7846_disable_store(str static DEVICE_ATTR(disable, 0664, ads7846_disable_show, ads7846_disable_store); +static struct attribute *ads7846_attributes[] = { + &dev_attr_temp0.attr, + &dev_attr_temp1.attr, + &dev_attr_vbatt.attr, + &dev_attr_vaux.attr, + &dev_attr_pen_down.attr, + &dev_attr_disable.attr, + NULL, +}; + +static struct attribute_group ads7846_attr_group = { + .attrs = ads7846_attributes, +}; + +/* + * ads7843/7845 don't have temperature sensors, and + * use the other sensors a bit differently too + */ + +static struct attribute *ads7843_attributes[] = { + &dev_attr_vbatt.attr, + &dev_attr_vaux.attr, + &dev_attr_pen_down.attr, + &dev_attr_disable.attr, + NULL, +}; + +static struct attribute_group ads7843_attr_group = { + .attrs = ads7843_attributes, +}; + +static struct attribute *ads7845_attributes[] = { + &dev_attr_vaux.attr, + &dev_attr_pen_down.attr, + &dev_attr_disable.attr, + NULL, +}; + +static struct attribute_group ads7845_attr_group = { + .attrs = ads7845_attributes, +}; + /*--------------------------------------------------------------------------*/ /* @@ -788,38 +831,30 @@ static int __devinit ads7846_probe(struc (void) ads7846_read12_ser(&spi->dev, READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON); - /* ads7843/7845 don't have temperature sensors, and - * use the other sensors a bit differently too - */ - if (ts->model == 7846) { - device_create_file(&spi->dev, &dev_attr_temp0); - device_create_file(&spi->dev, &dev_attr_temp1); + switch (ts->model) { + case 7846: + ts->attr_group = &ads7846_attr_group; + break; + case 7845: + ts->attr_group = &ads7845_attr_group; + break; + default: + ts->attr_group = &ads7843_attr_group; + break; } - if (ts->model != 7845) - device_create_file(&spi->dev, &dev_attr_vbatt); - device_create_file(&spi->dev, &dev_attr_vaux); - - device_create_file(&spi->dev, &dev_attr_pen_down); - - device_create_file(&spi->dev, &dev_attr_disable); + err = sysfs_create_group(&spi->dev.kobj, ts->attr_group); + if (err) + goto err_free_irq; err = input_register_device(input_dev); if (err) - goto err_remove_attr; + goto err_remove_attr_group; return 0; - err_remove_attr: - device_remove_file(&spi->dev, &dev_attr_disable); - device_remove_file(&spi->dev, &dev_attr_pen_down); - if (ts->model == 7846) { - device_remove_file(&spi->dev, &dev_attr_temp1); - device_remove_file(&spi->dev, &dev_attr_temp0); - } - if (ts->model != 7845) - device_remove_file(&spi->dev, &dev_attr_vbatt); - device_remove_file(&spi->dev, &dev_attr_vaux); - + err_remove_attr_group: + sysfs_remove_group(&spi->dev.kobj, ts->attr_group); + err_free_irq: free_irq(spi->irq, ts); err_free_mem: input_free_device(input_dev); @@ -835,15 +870,7 @@ static int __devexit ads7846_remove(stru ads7846_suspend(spi, PMSG_SUSPEND); - device_remove_file(&spi->dev, &dev_attr_disable); - device_remove_file(&spi->dev, &dev_attr_pen_down); - if (ts->model == 7846) { - device_remove_file(&spi->dev, &dev_attr_temp1); - device_remove_file(&spi->dev, &dev_attr_temp0); - } - if (ts->model != 7845) - device_remove_file(&spi->dev, &dev_attr_vbatt); - device_remove_file(&spi->dev, &dev_attr_vaux); + sysfs_remove_group(&spi->dev.kobj, ts->attr_group); free_irq(ts->spi->irq, ts); /* suspend left the IRQ disabled */ diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c index 66121f6..e294558 100644 --- a/drivers/input/touchscreen/corgi_ts.c +++ b/drivers/input/touchscreen/corgi_ts.c @@ -175,17 +175,19 @@ static int read_xydata(struct corgi_ts * static void new_data(struct corgi_ts *corgi_ts) { + struct input_dev *dev = corgi_ts->input; + if (corgi_ts->power_mode != PWR_MODE_ACTIVE) return; if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0) return; - input_report_abs(corgi_ts->input, ABS_X, corgi_ts->tc.x); - input_report_abs(corgi_ts->input, ABS_Y, corgi_ts->tc.y); - input_report_abs(corgi_ts->input, ABS_PRESSURE, corgi_ts->tc.pressure); - input_report_key(corgi_ts->input, BTN_TOUCH, (corgi_ts->pendown != 0)); - input_sync(corgi_ts->input); + input_report_abs(dev, ABS_X, corgi_ts->tc.x); + input_report_abs(dev, ABS_Y, corgi_ts->tc.y); + input_report_abs(dev, ABS_PRESSURE, corgi_ts->tc.pressure); + input_report_key(dev, BTN_TOUCH, corgi_ts->pendown); + input_sync(dev); } static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer) @@ -219,12 +221,14 @@ static void ts_interrupt_main(struct cor static void corgi_ts_timer(unsigned long data) { struct corgi_ts *corgits_data = (struct corgi_ts *) data; + ts_interrupt_main(corgits_data, 1); } static irqreturn_t ts_interrupt(int irq, void *dev_id) { struct corgi_ts *corgits_data = dev_id; + ts_interrupt_main(corgits_data, 0); return IRQ_HANDLED; } @@ -272,7 +276,7 @@ static int __init corgits_probe(struct p corgi_ts = kzalloc(sizeof(struct corgi_ts), GFP_KERNEL); input_dev = input_allocate_device(); if (!corgi_ts || !input_dev) - goto fail; + goto fail1; platform_set_drvdata(pdev, corgi_ts); @@ -281,7 +285,7 @@ static int __init corgits_probe(struct p if (corgi_ts->irq_gpio < 0) { err = -ENODEV; - goto fail; + goto fail1; } corgi_ts->input = input_dev; @@ -319,10 +323,12 @@ static int __init corgits_probe(struct p if (request_irq(corgi_ts->irq_gpio, ts_interrupt, IRQF_DISABLED, "ts", corgi_ts)) { err = -EBUSY; - goto fail; + goto fail1; } - input_register_device(corgi_ts->input); + err = input_register_device(corgi_ts->input); + if (err) + goto fail2; corgi_ts->power_mode = PWR_MODE_ACTIVE; @@ -331,17 +337,17 @@ static int __init corgits_probe(struct p return 0; - fail: input_free_device(input_dev); + fail2: free_irq(corgi_ts->irq_gpio, corgi_ts); + fail1: input_free_device(input_dev); kfree(corgi_ts); return err; - } static int corgits_remove(struct platform_device *pdev) { struct corgi_ts *corgi_ts = platform_get_drvdata(pdev); - free_irq(corgi_ts->irq_gpio, NULL); + free_irq(corgi_ts->irq_gpio, corgi_ts); del_timer_sync(&corgi_ts->timer); corgi_ts->machinfo->put_hsync(); input_unregister_device(corgi_ts->input); diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c index 817c219..44f397f 100644 --- a/drivers/input/touchscreen/gunze.c +++ b/drivers/input/touchscreen/gunze.c @@ -123,7 +123,7 @@ static int gunze_connect(struct serio *s input_dev = input_allocate_device(); if (!gunze || !input_dev) { err = -ENOMEM; - goto fail; + goto fail1; } gunze->serio = serio; @@ -146,13 +146,17 @@ static int gunze_connect(struct serio *s err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; + + err = input_register_device(gunze->dev); + if (err) + goto fail3; - input_register_device(gunze->dev); return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(gunze); return err; } diff --git a/drivers/input/touchscreen/hp680_ts_input.c b/drivers/input/touchscreen/hp680_ts_input.c index 58fca31..2490874 100644 --- a/drivers/input/touchscreen/hp680_ts_input.c +++ b/drivers/input/touchscreen/hp680_ts_input.c @@ -76,38 +76,47 @@ static irqreturn_t hp680_ts_interrupt(in static int __init hp680_ts_init(void) { + int err; + hp680_ts_dev = input_allocate_device(); if (!hp680_ts_dev) return -ENOMEM; hp680_ts_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); - hp680_ts_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y); hp680_ts_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); - hp680_ts_dev->absmin[ABS_X] = HP680_TS_ABS_X_MIN; - hp680_ts_dev->absmin[ABS_Y] = HP680_TS_ABS_Y_MIN; - hp680_ts_dev->absmax[ABS_X] = HP680_TS_ABS_X_MAX; - hp680_ts_dev->absmax[ABS_Y] = HP680_TS_ABS_Y_MAX; + input_set_abs_params(hp680_ts_dev, ABS_X, + HP680_TS_ABS_X_MIN, HP680_TS_ABS_X_MAX, 0, 0); + input_set_abs_params(hp680_ts_dev, ABS_Y, + HP680_TS_ABS_Y_MIN, HP680_TS_ABS_Y_MAX, 0, 0); hp680_ts_dev->name = "HP Jornada touchscreen"; hp680_ts_dev->phys = "hp680_ts/input0"; - input_register_device(hp680_ts_dev); - if (request_irq(HP680_TS_IRQ, hp680_ts_interrupt, IRQF_DISABLED, MODNAME, 0) < 0) { printk(KERN_ERR "hp680_touchscreen.c: Can't allocate irq %d\n", HP680_TS_IRQ); - input_unregister_device(hp680_ts_dev); - return -EBUSY; + err = -EBUSY; + goto fail1; } + err = input_register_device(hp680_ts_dev); + if (err) + goto fail2; + return 0; + + fail2: free_irq(HP680_TS_IRQ, NULL); + cancel_delayed_work(&work); + flush_scheduled_work(); + fail1: input_free_device(hp680_ts_dev); + return err; } static void __exit hp680_ts_exit(void) { - free_irq(HP680_TS_IRQ, 0); + free_irq(HP680_TS_IRQ, NULL); cancel_delayed_work(&work); flush_scheduled_work(); input_unregister_device(hp680_ts_dev); diff --git a/drivers/input/touchscreen/mk712.c b/drivers/input/touchscreen/mk712.c index 4cbcaa6..44140fe 100644 --- a/drivers/input/touchscreen/mk712.c +++ b/drivers/input/touchscreen/mk712.c @@ -96,15 +96,13 @@ static irqreturn_t mk712_interrupt(int i goto end; } - if (~status & MK712_STATUS_TOUCH) - { + if (~status & MK712_STATUS_TOUCH) { debounce = 1; input_report_key(mk712_dev, BTN_TOUCH, 0); goto end; } - if (debounce) - { + if (debounce) { debounce = 0; goto end; } @@ -113,8 +111,7 @@ static irqreturn_t mk712_interrupt(int i input_report_abs(mk712_dev, ABS_X, last_x); input_report_abs(mk712_dev, ABS_Y, last_y); -end: - + end: last_x = inw(mk712_io + MK712_X) & 0x0fff; last_y = inw(mk712_io + MK712_Y) & 0x0fff; input_sync(mk712_dev); @@ -169,13 +166,14 @@ static int __init mk712_init(void) (inw(mk712_io + MK712_STATUS) & 0xf333)) { printk(KERN_WARNING "mk712: device not present\n"); err = -ENODEV; - goto fail; + goto fail1; } - if (!(mk712_dev = input_allocate_device())) { + mk712_dev = input_allocate_device(); + if (!mk712_dev) { printk(KERN_ERR "mk712: not enough memory\n"); err = -ENOMEM; - goto fail; + goto fail1; } mk712_dev->name = "ICS MicroClock MK712 TouchScreen"; @@ -196,13 +194,17 @@ static int __init mk712_init(void) if (request_irq(mk712_irq, mk712_interrupt, 0, "mk712", mk712_dev)) { printk(KERN_WARNING "mk712: unable to get IRQ\n"); err = -EBUSY; - goto fail; + goto fail1; } - input_register_device(mk712_dev); + err = input_register_device(mk712_dev); + if (err) + goto fail2; + return 0; - fail: input_free_device(mk712_dev); + fail2: free_irq(mk712_irq, mk712_dev); + fail1: input_free_device(mk712_dev); release_region(mk712_io, 8); return err; } diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c index 3b4c616..c66b399 100644 --- a/drivers/input/touchscreen/mtouch.c +++ b/drivers/input/touchscreen/mtouch.c @@ -137,7 +137,7 @@ static int mtouch_connect(struct serio * input_dev = input_allocate_device(); if (!mtouch || !input_dev) { err = -ENOMEM; - goto fail; + goto fail1; } mtouch->serio = serio; @@ -160,14 +160,17 @@ static int mtouch_connect(struct serio * err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; - input_register_device(mtouch->dev); + err = input_register_device(mtouch->dev); + if (err) + goto fail3; return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(mtouch); return err; } diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 6daf85c..6095d9c 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1643,6 +1643,9 @@ #define USB_DEVICE_ID_RARITAN_KVM_DONGLE #define USB_VENDOR_ID_AIRCABLE 0x16CA #define USB_DEVICE_ID_AIRCABLE1 0x1502 +#define USB_VENDOR_ID_LOGITECH 0x046d +#define USB_DEVICE_ID_LOGITECH_USB_RECEIVER 0xc101 + /* * Alphabetically sorted blacklist by quirk type. */ @@ -1811,7 +1814,9 @@ static const struct hid_blacklist { { USB_VENDOR_ID_PANJIT, 0x0004, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, - + + { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_USB_RECEIVER, HID_QUIRK_BAD_RELATIVE_KEYS }, + { 0, 0 } }; diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 9a808a3..c8ce65c 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -564,6 +564,10 @@ #endif || ((device->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007))) goto ignore; + if ((device->quirks & HID_QUIRK_BAD_RELATIVE_KEYS) && + usage->type == EV_KEY && (field->flags & HID_MAIN_ITEM_RELATIVE)) + field->flags &= ~HID_MAIN_ITEM_RELATIVE; + set_bit(usage->type, input->evbit); while (usage->code <= max && test_and_set_bit(usage->code, bit)) diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index 9b50eff..8aa9ec0 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -260,6 +260,7 @@ #define HID_QUIRK_CYMOTION 0x00000800 #define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000 #define HID_QUIRK_POWERBOOK_FN_ON 0x00002000 #define HID_QUIRK_INVERT_HWHEEL 0x00004000 +#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00008000 /* * This is the global environment of the parser. This information is