dynamic input_dev allocation for ibmasm driver
This patch updates the ibmasm driver to use the dynamic allocation of input_dev structs to work with the sysfs subsystem. I have tested it on my machine and it seems to work fine.
ibmasm.h | 6 ++--- remote.c | 72 ++++++++++++++++++++++++++++++++++----------------------------- 2 files changed, 42 insertions(+), 36 deletions(-)
drivers/misc/ibmasm/ibmasm.h +3 -3
@@ -141,8 +141,8 @@ struct reverse_heartbeat { };struct ibmasm_remote { -struct input_dev keybd_dev; -struct input_dev mouse_dev; +struct input_dev * keybd_dev; +struct input_dev * mouse_dev; };struct service_processor {
@@ -157,7 +157,7 @@ struct service_processor {char dirname[IBMASM_NAME_SIZE ];char devname[IBMASM_NAME_SIZE ];unsigned int number; -struct ibmasm_remote *remote; +struct ibmasm_remote remote;int serial_line;struct device *dev; };
drivers/misc/ibmasm/remote.c +39 -33
104 lines not on this page · raw message
Quoted 11 lines · Vernon Mauery
This patch updates the ibmasm driver to use the dynamic allocation of
input_devstructs to work with the sysfs subsystem. I have tested it on my machine and it seems to work fine.Signed-off-by Vernon Mauery <[email protected]>ibmasm.h | 6 ++--- remote.c | 72 ++++++++++++++++++++++++++++++++++----------------------------- 2 files changed, 42 insertions(+), 36 deletions(-)
...
Quoted 9 lines
drivers/misc/ibmasm/remote.c +7
-2-input_register_device (&remote->mouse_dev); -input_register_device (&remote->keybd_dev); +if ((ret =input_register_device (mouse_dev))) + goto error_alloc; +if ((ret =input_register_device (keybd_dev))) + goto error_alloc; + + sp->remote.mouse_dev = mouse_dev; + sp->remote.keybd_dev = keybd_dev;
drivers/misc/ibmasm/remote.c void ibmasm_handle_mouse_interrupt(struc · line 269
Quoted 10 lines
drivers/misc/ibmasm/remote.c +5
-0enable_mouse_interrupts (sp);printk (KERN_INFO "ibmasm remote responding to events on RSA card %d\n" , sp->number);return 0 ; + +error_alloc: +input_free_device (mouse_dev); +input_free_device (keybd_dev); +return ret;
Error handling is rotten here. If 2nd input_register_device fails you will whack fully registered remote->mouse_dev. You are missing call to input_unregister_device() there.
Please fix it up and send it my way - I'll add it to the input tree.
Thanks!
Signature · 1 line
Dmitry
Quoted 5 lines · Dmitry Torokhov
Error handling is rotten here. If 2nd
input_register_devicefails you will whack fully registeredremote->mouse_dev. You are missing call toinput_unregister_device()there.Please fix it up and send it my way - I'll add it to the input tree.
Here goes a fixed version:
-------------------------------------------------------------------------------
This patch updates the ibmasm driver to use the dynamic allocation of input_dev structs to work with the sysfs subsystem. I have tested it on my machine and it seems to work fine.
Vojtech: Fixed some problems/bugs in the patch.
ibmasm.h | 6 ++-- remote.c | 76 +++++++++++++++++++++++++++++++++++---------------------------- 2 files changed, 46 insertions(+), 36 deletions(-)
drivers/misc/ibmasm/ibmasm.h +3 -3
@@ -141,8 +141,8 @@ struct reverse_heartbeat { };struct ibmasm_remote { -struct input_dev keybd_dev; -struct input_dev mouse_dev; +struct input_dev *keybd_dev; +struct input_dev *mouse_dev; };struct service_processor {
@@ -157,7 +157,7 @@ struct service_processor {char dirname[IBMASM_NAME_SIZE ];char devname[IBMASM_NAME_SIZE ];unsigned int number; -struct ibmasm_remote *remote; +struct ibmasm_remote remote;int serial_line;struct device *dev; };
drivers/misc/ibmasm/remote.c +43 -33
108 lines not on this page · raw message
Signature · 2 lines
Vojtech Pavlik SuSE Labs, SuSE CR