Another input update
Subsystems (2)
cover Another input update
Linus,
Please consider pulling from:
www.kernel.org/pub/scm/linux/kernel/git/dtor/input.git
The main change is that now input core refuses to register input devices that were not dynamically allocated to prevent an OOPS when attaching input interfaces to such devices.
Changelog:
Input: convert dmasound_awacs (OSS) to dynamic input allocation
(Ian Wienand)
Input: locomokbd - convert to dynamic input allocation
Input: do not register statically allocated devices
Input: fix input device deregistration
Input: locomokbd - fix wrong bustype
Input: logips2pp - add support for MX3100
Input: lkkbd - miscellaneous fixes
Vojtech, please bless the pull.
Thanks!
--
Dmitry
PATCH 1/7 dmasound_awacs: convert to dynamic input allocation
From: Ian Wienand <[email protected]>
Input: convert dmasound_awacs (OSS) to dynamic input allocation
---
sound/oss/dmasound/dmasound_awacs.c | 31 +++++++++++++++++++------------ 1 files changed, 19 insertions(+), 12 deletions(-)
sound/oss/dmasound/dmasound_awacs.c +19 -12
@@ -2805,16 +2805,7 @@ __init setup_beep(void)return 0 ; } -static struct input_dev awacs_beep_dev = { - .evbit = {BIT (EV_SND ) }, - .sndbit = {BIT (SND_BELL ) |BIT (SND_TONE ) }, - .event = awacs_beep_event, - .name ="dmasound beeper" , - .phys ="macio/input0" ,/* what the heck is this?? */ - .id = { - .bustype =BUS_HOST , - }, -}; +static struct input_dev *awacs_beep_dev;int __init dmasound_awacs_init (void ) {
@@ -2907,6 +2898,22 @@ printk("dmasound_pmac: couldn't find a Creturn -ENODEV ; } + awacs_beep_dev =input_allocate_device (); +if (!awacs_beep_dev) { +release_OF_resource (io,0 ); +release_OF_resource (io,1 ); +release_OF_resource (io,2 ); +printk (KERN_ERR "dmasound: can't allocate input device !\n" ); +return -ENOMEM ; + } + + awacs_beep_dev->name ="dmasound beeper" ; + awacs_beep_dev->phys ="macio/input0" ; + awacs_beep_dev->id.bustype =BUS_HOST ; + awacs_beep_dev->event = awacs_beep_event; + awacs_beep_dev->sndbit[0 ] =BIT (SND_BELL ) |BIT (SND_TONE ); + awacs_beep_dev->evbit[0 ] =BIT (EV_SND ); +/* all OF versions I've seen use this value */ if (i2s_node) i2s =ioremap (io->addrs[0 ].address,0x1000 );
@@ -3140,14 +3147,14 @@ printk("dmasound_pmac: Awacs/Screamer Co* XXX: we should handle errors here, but that would mean * rewriting the whole init code. later.. */ -input_register_device (&awacs_beep_dev); +input_register_device (awacs_beep_dev);return dmasound_init (); } static void __exit dmasound_awacs_cleanup(void) { -input_unregister_device (&awacs_beep_dev); +input_unregister_device (awacs_beep_dev);switch (awacs_revision) {case AWACS_TUMBLER :
PATCH 2/7 locomokbd: convert to dynamic input allocation
In reply to Dmitry TorokhovInput: locomokbd - convert to dynamic input allocation
---
drivers/input/keyboard/locomokbd.c | 63 ++++++++++++++++++------------------- 1 files changed, 31 insertions(+), 32 deletions(-)
drivers/input/keyboard/locomokbd.c +31 -32
@@ -76,7 +76,7 @@ static unsigned char locomokbd_keycode[Lstruct locomokbd {unsigned char keycode[LOCOMOKBD_NUMKEYS ]; -struct input_dev input; +struct input_dev *input;char phys[32 ];struct locomo_dev *ldev;
@@ -136,8 +136,7 @@ static void locomokbd_scankeyboard(strucspin_lock_irqsave (&locomokbd->lock, flags); -if (regs) -input_regs (&locomokbd->input, regs); +input_regs (locomokbd->input, regs);locomokbd_charge_all (membase);
@@ -152,16 +151,16 @@ static void locomokbd_scankeyboard(struc scancode =SCANCODE (col, row);if (rowd &KB_ROWMASK (row)) { num_pressed +=1 ; -input_report_key (&locomokbd->input, locomokbd->keycode[scancode],1 ); +input_report_key (locomokbd->input, locomokbd->keycode[scancode],1 ); }else { -input_report_key (&locomokbd->input, locomokbd->keycode[scancode],0 ); +input_report_key (locomokbd->input, locomokbd->keycode[scancode],0 ); } }locomokbd_reset_col (membase, col); }locomokbd_activate_all (membase); -input_sync (&locomokbd->input); +input_sync (locomokbd->input);/* if any keys are pressed, enable the timer */ if (num_pressed)
@@ -196,13 +195,15 @@ static void locomokbd_timer_callback(uns static int locomokbd_probe(struct locomo_dev *dev) { struct locomokbd *locomokbd; + struct input_dev *input_dev; int i, ret; - locomokbd = kmalloc(sizeof(struct locomokbd), GFP_KERNEL); - if (!locomokbd) - return -ENOMEM; - - memset(locomokbd, 0, sizeof(struct locomokbd)); + locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL); + input_dev = input_allocate_device(); + if (!locomokbd || !input_dev) { + ret = -ENOMEM; + goto free; + } /* try and claim memory region */ if (!request_mem_region((unsigned long) dev->mapbase,
@@ -224,27 +225,26 @@ static int locomokbd_probe(struct locomo locomokbd->timer.function = locomokbd_timer_callback; locomokbd->timer.data = (unsigned long ) locomokbd; - locomokbd->input.evbit[0 ] =BIT (EV_KEY ) |BIT (EV_REP ); + locomokbd->input = input_dev; +strcpy (locomokbd->phys,"locomokbd/input0" ); -init_input_dev (&locomokbd->input); - locomokbd->input.keycode = locomokbd->keycode; - locomokbd->input.keycodesize =sizeof (unsigned char ); - locomokbd->input.keycodemax =ARRAY_SIZE (locomokbd_keycode); - locomokbd->input.private = locomokbd; + input_dev->name ="LoCoMo keyboard" ; + input_dev->phys = locomokbd->phys; + input_dev->id.bustype =BUS_XTKBD ; + input_dev->id.vendor =0x0001 ; + input_dev->id.product =0x0001 ; + input_dev->id.version =0x0100 ; + input_dev->private = locomokbd; + + input_dev->evbit[0 ] =BIT (EV_KEY ) |BIT (EV_REP ); + input_dev->keycode = locomokbd->keycode; + input_dev->keycodesize =sizeof (unsigned char ); + input_dev->keycodemax =ARRAY_SIZE (locomokbd_keycode);memcpy (locomokbd->keycode, locomokbd_keycode,sizeof (locomokbd->keycode));for (i =0 ; i <LOCOMOKBD_NUMKEYS ; i++) -set_bit (locomokbd->keycode[i], locomokbd->input.keybit); -clear_bit (0 , locomokbd->input.keybit); - -strcpy (locomokbd->phys,"locomokbd/input0" ); - - locomokbd->input.name ="LoCoMo keyboard" ; - locomokbd->input.phys = locomokbd->phys; - locomokbd->input.id.bustype =BUS_XTKBD ; - locomokbd->input.id.vendor =0x0001 ; - locomokbd->input.id.product =0x0001 ; - locomokbd->input.id.version =0x0100 ; +set_bit (locomokbd->keycode[i], input_dev->keybit); +clear_bit (0 , input_dev->keybit);/* attempt to get the interrupt */ ret =request_irq (dev->irq[0 ], locomokbd_interrupt,0 ,"locomokbd" , locomokbd);
@@ -253,9 +253,7 @@ static int locomokbd_probe(struct locomo goto out; } -input_register_device (&locomokbd->input); - -printk (KERN_INFO "input: LoCoMo keyboard on locomokbd\n" ); +input_register_device (locomokbd->input);return 0 ;
@@ -263,6 +261,7 @@ out:release_mem_region ((unsigned long ) dev->mapbase, dev->length);locomo_set_drvdata (dev,NULL ); free: +input_free_device (input_dev);kfree (locomokbd);return ret;
@@ -276,7 +275,7 @@ static int locomokbd_remove(struct locomdel_timer_sync (&locomokbd->timer); -input_unregister_device (&locomokbd->input); +input_unregister_device (locomokbd->input);locomo_set_drvdata (dev,NULL );release_mem_region ((unsigned long ) dev->mapbase, dev->length);
PATCH 3/7 Do not register statically allocated input devices
In reply to Dmitry TorokhovInput: do not register statically allocated devices
Do not register statically allocated input devices to prevent OOPS when attaching input interfaces since it requires class device to be properly initialized.
---
drivers/input/input.c | 26 +++++++++++++++----------- include/linux/input.h | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-)
drivers/input/input.c +15 -11
@@ -377,7 +377,7 @@ static int input_devices_read(char *buf,list_for_each_entry (dev, &input_dev_list, node) { - path = dev->dynalloc ?kobject_get_path (&dev->cdev.kobj,GFP_KERNEL ) :NULL ; + path =kobject_get_path (&dev->cdev.kobj,GFP_KERNEL ); len =sprintf (buf,"I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n" , dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version);
@@ -741,15 +741,21 @@ static void input_register_classdevice(ssysfs_create_group (&dev->cdev.kobj, &input_dev_caps_attr_group); } -void input_register_device (struct input_dev *dev) +int input_register_device (struct input_dev *dev) {struct input_handle *handle;struct input_handler *handler;struct input_device_id *id; -set_bit (EV_SYN , dev->evbit); +if (!dev->dynalloc) { +printk (KERN_WARNING "input: device %s is statically allocated, will not register\n" +"Please convert to input_allocate_device() or contact [email protected]\n" , + dev->name ? dev->name :"<Unknown>" ); +return -EINVAL ; + }init_MUTEX (&dev->sem); +set_bit (EV_SYN , dev->evbit);/* * If delay and period are pre-set by the driver, then autorepeating
@@ -767,8 +773,7 @@ void input_register_device(struct input_INIT_LIST_HEAD (&dev->h_list);list_add_tail (&dev->node, &input_dev_list); -if (dev->dynalloc) -input_register_classdevice (dev); +input_register_classdevice (dev);list_for_each_entry (handler, &input_handler_list, node)if (!handler->blacklist || !input_match_device (handler->blacklist, dev))
@@ -776,8 +781,9 @@ void input_register_device(struct input_if ((handle = handler->connect (handler, dev, id)))input_link_handle (handle); -input_wakeup_procfs_readers (); + +return 0 ; }void input_unregister_device (struct input_dev *dev)
@@ -797,11 +803,9 @@ void input_unregister_device(struct inpulist_del_init (&dev->node); -if (dev->dynalloc) { -sysfs_remove_group (&dev->cdev.kobj, &input_dev_caps_attr_group); -sysfs_remove_group (&dev->cdev.kobj, &input_dev_id_attr_group); -class_device_unregister (&dev->cdev); - } +sysfs_remove_group (&dev->cdev.kobj, &input_dev_caps_attr_group); +sysfs_remove_group (&dev->cdev.kobj, &input_dev_id_attr_group); +class_device_unregister (&dev->cdev);input_wakeup_procfs_readers (); }
include/linux/input.h +1 -1
@@ -1007,7 +1007,7 @@ static inline void input_put_device(struclass_device_put (&dev->cdev); } -void input_register_device (struct input_dev *); +int input_register_device (struct input_dev *);void input_unregister_device (struct input_dev *);void input_register_handler (struct input_handler *);
PATCH 4/7 Fix input device deregistration
In reply to Dmitry TorokhovInput: fix input device deregistration
Remove main attribute group (name, phys, uniq) when unregistering input devices.
---
drivers/input/input.c | 1 + 1 files changed, 1 insertion(+)
drivers/input/input.c +1 -0
@@ -805,6 +805,7 @@ void input_unregister_device(struct inpusysfs_remove_group (&dev->cdev.kobj, &input_dev_caps_attr_group);sysfs_remove_group (&dev->cdev.kobj, &input_dev_id_attr_group); +sysfs_remove_group (&dev->cdev.kobj, &input_dev_group);class_device_unregister (&dev->cdev);input_wakeup_procfs_readers ();
PATCH 5/7 locomokbd: fix wrong bustype
In reply to Dmitry TorokhovFrom: Pavel Machek <[email protected]>
Input: locomokbd - fix wrong bustype
---
drivers/input/keyboard/locomokbd.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/input/keyboard/locomokbd.c +1 -1
@@ -230,7 +230,7 @@ static int locomokbd_probe(struct locomo input_dev->name ="LoCoMo keyboard" ; input_dev->phys = locomokbd->phys; - input_dev->id.bustype =BUS_XTKBD ; + input_dev->id.bustype =BUS_HOST ; input_dev->id.vendor =0x0001 ; input_dev->id.product =0x0001 ; input_dev->id.version =0x0100 ;
PATCH 6/7 logips2pp: add MX3100 signature
In reply to Dmitry TorokhovFrom: Mirco Macrelli <[email protected]>
Input: logips2pp - add support for MX3100
---
drivers/input/mouse/logips2pp.c | 3 +++ 1 files changed, 3 insertions(+)
drivers/input/mouse/logips2pp.c +3 -0
@@ -217,6 +217,9 @@ static struct ps2pp_info *get_model_info {61 ,PS2PP_KIND_MX ,/* MX700 */ PS2PP_WHEEL |PS2PP_SIDE_BTN |PS2PP_TASK_BTN | PS2PP_EXTRA_BTN | PS2PP_NAV_BTN }, + { 66, PS2PP_KIND_MX, /* MX3100 reciver */ +PS2PP_WHEEL |PS2PP_SIDE_BTN |PS2PP_TASK_BTN | + PS2PP_EXTRA_BTN | PS2PP_NAV_BTN | PS2PP_HWHEEL }, { 73, 0, PS2PP_SIDE_BTN }, { 75, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 76, PS2PP_KIND_WHEEL, PS2PP_WHEEL },
PATCH 7/7 lkkbd: misc fixes
In reply to Dmitry TorokhovFrom: Jan-Benedict Glaw <[email protected]>
Input: lkkbd - miscellaneous fixes
* Hide debugging code into #ifdef, which allows to simplify the large switch statement
* Update macros to not reference variables not given as arguments
---
drivers/input/keyboard/lkkbd.c | 101 +++++++++++++++++++++++------------------ 1 files changed, 59 insertions(+), 42 deletions(-)
drivers/input/keyboard/lkkbd.c +59 -42
@@ -273,11 +273,11 @@ static lk_keycode_t lkkbd_keycode[LK_NUM [0xfb] = KEY_APOSTROPHE, }; -#define CHECK_LED (LED ,BITS ) do { \ - if (test_bit (LED, lk->dev->led)) \ - leds_on |= BITS; \ - else \ - leds_off |= BITS; \ +#define CHECK_LED (LK ,VAR_ON ,VAR_OFF ,LED ,BITS ) do { \ + if (test_bit (LED, (LK)->dev->led)) \ + VAR_ON |= BITS; \ + else \ + VAR_OFF |= BITS; \ } while (0)/*
@@ -298,6 +298,42 @@ struct lkkbd {int ctrlclick_volume; }; +#ifdef LKKBD_DEBUG +/* +* Responses from the keyboard and mapping back to their names. +*/ +static struct { +unsigned char value; +unsigned char *name; +} lk_response[] = { +#define RESPONSE(x) { .value = (x), .name = #x, } +RESPONSE (LK_STUCK_KEY ), +RESPONSE (LK_SELFTEST_FAILED ), +RESPONSE (LK_ALL_KEYS_UP ), +RESPONSE (LK_METRONOME ), +RESPONSE (LK_OUTPUT_ERROR ), +RESPONSE (LK_INPUT_ERROR ), +RESPONSE (LK_KBD_LOCKED ), +RESPONSE (LK_KBD_TEST_MODE_ACK ), +RESPONSE (LK_PREFIX_KEY_DOWN ), +RESPONSE (LK_MODE_CHANGE_ACK ), +RESPONSE (LK_RESPONSE_RESERVED ), +#undef RESPONSE +}; + +static unsigned char * +response_name (unsigned char value) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (lk_response); i++) +if (lk_response[i].value == value) +return lk_response[i].name; + +return "<unknown>" ; +} +#endif /* LKKBD_DEBUG */ +/* * Calculate volume parameter byte for a given volume. */
@@ -440,43 +476,24 @@ lkkbd_interrupt (struct serio *serio, uninput_report_key (lk->dev, lk->keycode[i],0 );input_sync (lk->dev);break ; -case LK_METRONOME : -DBG (KERN_INFO "Got LK_METRONOME and don't " -"know how to handle...\n" ); + +case 0x01 : +DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n" ); + lk->ignore_bytes =LK_NUM_IGNORE_BYTES ; + lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data; +schedule_work (&lk->tq);break ; + +case LK_METRONOME :case LK_OUTPUT_ERROR : -DBG (KERN_INFO "Got LK_OUTPUT_ERROR and don't " -"know how to handle...\n" ); -break ;case LK_INPUT_ERROR : -DBG (KERN_INFO "Got LK_INPUT_ERROR and don't " -"know how to handle...\n" ); -break ;case LK_KBD_LOCKED : -DBG (KERN_INFO "Got LK_KBD_LOCKED and don't " -"know how to handle...\n" ); -break ;case LK_KBD_TEST_MODE_ACK : -DBG (KERN_INFO "Got LK_KBD_TEST_MODE_ACK and don't " -"know how to handle...\n" ); -break ;case LK_PREFIX_KEY_DOWN : -DBG (KERN_INFO "Got LK_PREFIX_KEY_DOWN and don't " -"know how to handle...\n" ); -break ;case LK_MODE_CHANGE_ACK : -DBG (KERN_INFO "Got LK_MODE_CHANGE_ACK and ignored " -"it properly...\n" ); -break ;case LK_RESPONSE_RESERVED : -DBG (KERN_INFO "Got LK_RESPONSE_RESERVED and don't " -"know how to handle...\n" ); -break ; -case 0x01 : -DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n" ); - lk->ignore_bytes =LK_NUM_IGNORE_BYTES ; - lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data; -schedule_work (&lk->tq); +DBG (KERN_INFO "Got %s and don't know how to handle...\n" , +response_name (data));break ;default :
@@ -509,10 +526,10 @@ lkkbd_event (struct input_dev *dev, unsiswitch (type) {case EV_LED : -CHECK_LED (LED_CAPSL ,LK_LED_SHIFTLOCK ); -CHECK_LED (LED_COMPOSE ,LK_LED_COMPOSE ); -CHECK_LED (LED_SCROLLL ,LK_LED_SCROLLLOCK ); -CHECK_LED (LED_SLEEP ,LK_LED_WAIT ); +CHECK_LED (lk, leds_on, leds_off,LED_CAPSL ,LK_LED_SHIFTLOCK ); +CHECK_LED (lk, leds_on, leds_off,LED_COMPOSE ,LK_LED_COMPOSE ); +CHECK_LED (lk, leds_on, leds_off,LED_SCROLLL ,LK_LED_SCROLLLOCK ); +CHECK_LED (lk, leds_on, leds_off,LED_SLEEP ,LK_LED_WAIT );if (leds_on !=0 ) { lk->serio->write (lk->serio,LK_CMD_LED_ON ); lk->serio->write (lk->serio, leds_on);
@@ -574,10 +591,10 @@ lkkbd_reinit (void *data) lk->serio->write (lk->serio,LK_CMD_SET_DEFAULTS );/* Set LEDs */ -CHECK_LED (LED_CAPSL ,LK_LED_SHIFTLOCK ); -CHECK_LED (LED_COMPOSE ,LK_LED_COMPOSE ); -CHECK_LED (LED_SCROLLL ,LK_LED_SCROLLLOCK ); -CHECK_LED (LED_SLEEP ,LK_LED_WAIT ); +CHECK_LED (lk, leds_on, leds_off,LED_CAPSL ,LK_LED_SHIFTLOCK ); +CHECK_LED (lk, leds_on, leds_off,LED_COMPOSE ,LK_LED_COMPOSE ); +CHECK_LED (lk, leds_on, leds_off,LED_SCROLLL ,LK_LED_SCROLLLOCK ); +CHECK_LED (lk, leds_on, leds_off,LED_SLEEP ,LK_LED_WAIT );if (leds_on !=0 ) { lk->serio->write (lk->serio,LK_CMD_LED_ON ); lk->serio->write (lk->serio, leds_on);
Dmitry Torokhov
maintainerQuoted 20 lines · Dmitry Torokhov
Linus,
Please consider pulling from:
www.kernel.org/pub/scm/linux/kernel/git/dtor/input.git
The main change is that now input core refuses to register input devices that were not dynamically allocated to prevent an OOPS when attaching input interfaces to such devices.
Changelog:
Input: convertdmasound_awacs(OSS) to dynamic input allocation
(Ian Wienand)
Input: locomokbd - convert to dynamic input allocation
Input: do not register statically allocated devices
Input: fix input device deregistration
Input: locomokbd - fix wrong bustype
Input: logips2pp - add support for MX3100
Input: lkkbd - miscellaneous fixes
Quoted 2 lines
Vojtech, please bless the pull.
*ping*
--
Dmitry
Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Dmitry Torokhov
www.kernel.org/pub/scm/linux/kernel/git/dtor/input.git
That's not a valid git url, and please in the future do include a diffstat too so that I know what files are supposed to change..
Quoted 1 line
*ping*
Pulled.
Linus