mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch 0/7] Another input update
@ 2005-11-03  4:21 Dmitry Torokhov
  2005-11-03  4:21 ` [patch 1/7] dmasound_awacs: convert to dynamic input allocation Dmitry Torokhov
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2005-11-03  4:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: LKML, Andrew Morton, Vojtech Pavlik

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




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [patch 1/7] dmasound_awacs: convert to dynamic input allocation
  2005-11-03  4:21 [patch 0/7] Another input update Dmitry Torokhov
@ 2005-11-03  4:21 ` Dmitry Torokhov
  2005-11-03  4:21 ` [patch 2/7] locomokbd: " Dmitry Torokhov
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2005-11-03  4:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: LKML, Andrew Morton, Vojtech Pavlik

[-- Attachment #1: input-dynalloc-dmasound.patch --]
[-- Type: text/plain, Size: 2200 bytes --]

From: Ian Wienand <ianw@gelato.unsw.edu.au>

Input: convert dmasound_awacs (OSS) to dynamic input allocation

Signed-off-by: Ian Wienand <ianw@gelato.unsw.edu.au>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 sound/oss/dmasound/dmasound_awacs.c |   31 +++++++++++++++++++------------
 1 files changed, 19 insertions(+), 12 deletions(-)

Index: work/sound/oss/dmasound/dmasound_awacs.c
===================================================================
--- work.orig/sound/oss/dmasound/dmasound_awacs.c
+++ work/sound/oss/dmasound/dmasound_awacs.c
@@ -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 C
 		return -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:


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [patch 2/7] locomokbd: convert to dynamic input allocation
  2005-11-03  4:21 [patch 0/7] Another input update Dmitry Torokhov
  2005-11-03  4:21 ` [patch 1/7] dmasound_awacs: convert to dynamic input allocation Dmitry Torokhov
@ 2005-11-03  4:21 ` Dmitry Torokhov
  2005-11-03  4:21 ` [patch 3/7] Do not register statically allocated input devices Dmitry Torokhov
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2005-11-03  4:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: LKML, Andrew Morton, Vojtech Pavlik

[-- Attachment #1: input-dynalloc-locomo.patch --]
[-- Type: text/plain, Size: 4692 bytes --]

Input: locomokbd - convert to dynamic input allocation

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/keyboard/locomokbd.c |   63 ++++++++++++++++++-------------------
 1 files changed, 31 insertions(+), 32 deletions(-)

Index: work/drivers/input/keyboard/locomokbd.c
===================================================================
--- work.orig/drivers/input/keyboard/locomokbd.c
+++ work/drivers/input/keyboard/locomokbd.c
@@ -76,7 +76,7 @@ static unsigned char locomokbd_keycode[L
 
 struct 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(struc
 
 	spin_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 locom
 
 	del_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);


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [patch 3/7] Do not register statically allocated input devices
  2005-11-03  4:21 [patch 0/7] Another input update Dmitry Torokhov
  2005-11-03  4:21 ` [patch 1/7] dmasound_awacs: convert to dynamic input allocation Dmitry Torokhov
  2005-11-03  4:21 ` [patch 2/7] locomokbd: " Dmitry Torokhov
@ 2005-11-03  4:21 ` Dmitry Torokhov
  2005-11-03  4:21 ` [patch 4/7] Fix input device deregistration Dmitry Torokhov
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2005-11-03  4:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: LKML, Andrew Morton, Vojtech Pavlik

[-- Attachment #1: input-dont-register-statically-allocated.patch --]
[-- Type: text/plain, Size: 3351 bytes --]

Input: 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.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/input.c |   26 +++++++++++++++-----------
 include/linux/input.h |    2 +-
 2 files changed, 16 insertions(+), 12 deletions(-)

Index: work/drivers/input/input.c
===================================================================
--- work.orig/drivers/input/input.c
+++ work/drivers/input/input.c
@@ -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(s
 	sysfs_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 dtor_core@ameritech.net\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 inpu
 
 	list_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();
 }
Index: work/include/linux/input.h
===================================================================
--- work.orig/include/linux/input.h
+++ work/include/linux/input.h
@@ -1007,7 +1007,7 @@ static inline void input_put_device(stru
 	class_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 *);


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [patch 4/7] Fix input device deregistration
  2005-11-03  4:21 [patch 0/7] Another input update Dmitry Torokhov
                   ` (2 preceding siblings ...)
  2005-11-03  4:21 ` [patch 3/7] Do not register statically allocated input devices Dmitry Torokhov
@ 2005-11-03  4:21 ` Dmitry Torokhov
  2005-11-03  4:21 ` [patch 5/7] locomokbd: fix wrong bustype Dmitry Torokhov
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2005-11-03  4:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: LKML, Andrew Morton, Vojtech Pavlik

[-- Attachment #1: input-remove-dev-attr-group.patch --]
[-- Type: text/plain, Size: 735 bytes --]

Input: fix input device deregistration

Remove main attribute group (name, phys, uniq) when unregistering
input devices.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/input.c |    1 +
 1 files changed, 1 insertion(+)

Index: work/drivers/input/input.c
===================================================================
--- work.orig/drivers/input/input.c
+++ work/drivers/input/input.c
@@ -805,6 +805,7 @@ void input_unregister_device(struct inpu
 
 	sysfs_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();


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [patch 5/7] locomokbd: fix wrong bustype
  2005-11-03  4:21 [patch 0/7] Another input update Dmitry Torokhov
                   ` (3 preceding siblings ...)
  2005-11-03  4:21 ` [patch 4/7] Fix input device deregistration Dmitry Torokhov
@ 2005-11-03  4:21 ` Dmitry Torokhov
  2005-11-03  4:21 ` [patch 6/7] logips2pp: add MX3100 signature Dmitry Torokhov
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2005-11-03  4:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: LKML, Andrew Morton, Vojtech Pavlik

[-- Attachment #1: locomo-fix-bustype.patch --]
[-- Type: text/plain, Size: 786 bytes --]

From: Pavel Machek <pavel@suse.cz>

Input: locomokbd - fix wrong bustype

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/keyboard/locomokbd.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

Index: work/drivers/input/keyboard/locomokbd.c
===================================================================
--- work.orig/drivers/input/keyboard/locomokbd.c
+++ work/drivers/input/keyboard/locomokbd.c
@@ -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;


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [patch 6/7] logips2pp: add MX3100 signature
  2005-11-03  4:21 [patch 0/7] Another input update Dmitry Torokhov
                   ` (4 preceding siblings ...)
  2005-11-03  4:21 ` [patch 5/7] locomokbd: fix wrong bustype Dmitry Torokhov
@ 2005-11-03  4:21 ` Dmitry Torokhov
  2005-11-03  4:21 ` [patch 7/7] lkkbd: misc fixes Dmitry Torokhov
  2005-11-07 17:28 ` [patch 0/7] Another input update Dmitry Torokhov
  7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2005-11-03  4:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: LKML, Andrew Morton, Vojtech Pavlik

[-- Attachment #1: logips2pp-add-mx3100.patch --]
[-- Type: text/plain, Size: 925 bytes --]

From: Mirco Macrelli <pigaz@pigaz.org>

Input: logips2pp - add support for MX3100

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/mouse/logips2pp.c |    3 +++
 1 files changed, 3 insertions(+)

Index: work/drivers/input/mouse/logips2pp.c
===================================================================
--- work.orig/drivers/input/mouse/logips2pp.c
+++ work/drivers/input/mouse/logips2pp.c
@@ -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 },


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [patch 7/7] lkkbd: misc fixes
  2005-11-03  4:21 [patch 0/7] Another input update Dmitry Torokhov
                   ` (5 preceding siblings ...)
  2005-11-03  4:21 ` [patch 6/7] logips2pp: add MX3100 signature Dmitry Torokhov
@ 2005-11-03  4:21 ` Dmitry Torokhov
  2005-11-07 17:28 ` [patch 0/7] Another input update Dmitry Torokhov
  7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2005-11-03  4:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: LKML, Andrew Morton, Vojtech Pavlik

[-- Attachment #1: lkkbd-misc-fixes.patch --]
[-- Type: text/plain, Size: 5104 bytes --]

From: Jan-Benedict Glaw <jbglaw@lug-owl.de>

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

Signed-off-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/keyboard/lkkbd.c |  101 +++++++++++++++++++++++------------------
 1 files changed, 59 insertions(+), 42 deletions(-)

Index: work/drivers/input/keyboard/lkkbd.c
===================================================================
--- work.orig/drivers/input/keyboard/lkkbd.c
+++ work/drivers/input/keyboard/lkkbd.c
@@ -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, un
 					input_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, unsi
 
 	switch (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);


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch 0/7] Another input update
  2005-11-03  4:21 [patch 0/7] Another input update Dmitry Torokhov
                   ` (6 preceding siblings ...)
  2005-11-03  4:21 ` [patch 7/7] lkkbd: misc fixes Dmitry Torokhov
@ 2005-11-07 17:28 ` Dmitry Torokhov
  2005-11-07 18:31   ` Linus Torvalds
  7 siblings, 1 reply; 10+ messages in thread
From: Dmitry Torokhov @ 2005-11-07 17:28 UTC (permalink / raw)
  To: Vojtech Pavlik; +Cc: Linus Torvalds, LKML, Andrew Morton

On 11/2/05, Dmitry Torokhov <dtor_core@ameritech.net> wrote:
> 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.
>

*ping*

--
Dmitry

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch 0/7] Another input update
  2005-11-07 17:28 ` [patch 0/7] Another input update Dmitry Torokhov
@ 2005-11-07 18:31   ` Linus Torvalds
  0 siblings, 0 replies; 10+ messages in thread
From: Linus Torvalds @ 2005-11-07 18:31 UTC (permalink / raw)
  To: dtor_core; +Cc: Vojtech Pavlik, LKML, Andrew Morton



On Mon, 7 Nov 2005, Dmitry Torokhov wrote:

> On 11/2/05, Dmitry Torokhov <dtor_core@ameritech.net> wrote:
> >
> >        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..

> *ping*

Pulled.

		Linus

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-11-07 18:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-03  4:21 [patch 0/7] Another input update Dmitry Torokhov
2005-11-03  4:21 ` [patch 1/7] dmasound_awacs: convert to dynamic input allocation Dmitry Torokhov
2005-11-03  4:21 ` [patch 2/7] locomokbd: " Dmitry Torokhov
2005-11-03  4:21 ` [patch 3/7] Do not register statically allocated input devices Dmitry Torokhov
2005-11-03  4:21 ` [patch 4/7] Fix input device deregistration Dmitry Torokhov
2005-11-03  4:21 ` [patch 5/7] locomokbd: fix wrong bustype Dmitry Torokhov
2005-11-03  4:21 ` [patch 6/7] logips2pp: add MX3100 signature Dmitry Torokhov
2005-11-03  4:21 ` [patch 7/7] lkkbd: misc fixes Dmitry Torokhov
2005-11-07 17:28 ` [patch 0/7] Another input update Dmitry Torokhov
2005-11-07 18:31   ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®