Skip to contentSkip to conversation

Input: add MAX7359 key switch controller driver, v2

PATCH In review Kim Kyuwon 7 participants 23 messages May 9, 2009 – Sep 19, 2009

Subsystems (2)
lore
Share & tools
lore

Kim Kyuwon

author
#0 lore raw

PATCH 1/1 Input: add MAX7359 key switch controller driver, v2

The Maxim MAX7359 is a I2C interfaced key switch controller which provides microprocessors with management of up to 64 key switches.
This patch adds support for the MAX7359 key switch controller.

---
 drivers/input/keyboard/Kconfig          |   11 +
 drivers/input/keyboard/Makefile         |    1 +
 drivers/input/keyboard/max7359_keypad.c |  369 +++++++++++++++++++++++++++++++
 include/linux/max7359_keypad.h          |   27 +++
 4 files changed, 408 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/keyboard/max7359_keypad.c
 create mode 100644 include/linux/max7359_keypad.h
drivers/input/keyboard/Kconfig +11 -0
index ea2638b..56193e6 100644
@@ -332,4 +332,15 @@ config KEYBOARD_SH_KEYSC
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called sh_keysc.
+
+config KEYBOARD_MAX7359
+	tristate "Maxim MAX7359 Key Switch Controller"
+	depends on I2C
+	help
+	  If you say yes here you get support for the Maxim MAX7359 Key
+	  Switch Controller chip. This providers microprocessors with
+	  management of up to 64 key switches
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called max7359_keypad.
 endif
drivers/input/keyboard/Makefile +1 -0
index 36351e1..a9e7502 100644
@@ -28,3 +28,4 @@ obj-$(CONFIG_KEYBOARD_HP7XX)		+= jornada720_kbd.o
 obj-$(CONFIG_KEYBOARD_MAPLE)		+= maple_keyb.o
 obj-$(CONFIG_KEYBOARD_BFIN)		+= bf54x-keys.o
 obj-$(CONFIG_KEYBOARD_SH_KEYSC)		+= sh_keysc.o
+obj-$(CONFIG_KEYBOARD_MAX7359)		+= max7359_keypad.o
drivers/input/keyboard/max7359_keypad.c new file +369 -0

369 lines not on this page · raw message

include/linux/max7359_keypad.h new file +27 -0
new file mode 100644
index 0000000..0541598
@@ -0,0 +1,27 @@
+/*
+ * max7359_keypad.h - MAX7359 Keypad Controller Driver
+ *
+ * Copyright (C) 2009 Samsung Electronics
+ * Kim Kyuwon <[email protected]>
+ *
+ * Based on pxa27x_keypad.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Datasheet: http://www.maxim-ic.com/quick_view2.cfm/qv_pk/5456
+ */
+
+#ifndef _MAX7359_KEYPAD_H_
+#define _MAX7359_KEYPAD_H_
+
+struct max7359_keypad_platform_data {
+	/* code map for the keys */
+	unsigned int	*key_map;
+	unsigned int	key_map_size;
+};
+
+#define KEY(row, col, val)	(((row) << 28) | ((col) << 24) | (val))
+
+#endif /* _MAX7359_KEYPAD_H_ */
Signature · 1 line
1.5.2.5
Reviewed-by on v1 1/1
#1 lore raw

Hi Kim,

Quoted 5 lines · Kim Kyuwon

The Maxim MAX7359 is a I2C interfaced key switch controller which provides microprocessors with management of up to 64 key switches.
This patch adds support for the MAX7359 key switch controller.

Thanks for implementing review comments. Please add

Signature · 3 lines
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni
maintainer
#2 lore raw
Quoted 7 lines · Trilok Soni

Hi Kim,

Quoted 4 lines · Kim Kyuwon

The Maxim MAX7359 is a I2C interfaced key switch controller which provides microprocessors with management of up to 64 key switches.
This patch adds support for the MAX7359 key switch controller.

Quoted 7 lines
Quoted 1 line

Thanks for implementing review comments. Please add

Looks good, thank you Kim. I will keep it in my tree for now until I figure out what to do with KEY() macro for matrix keyboards (should not be long though).

Trilok, I also wanted to thank you for doing reviews of the drivers posted on the linux-input, it is much appreciated.

Signature · 4 lines
Dmitry

P.S. I made a bunch of random changes, mostly to streamline the probe
code (below), hopfully I did not break anything.
drivers/input/keyboard/max7359_keypad.c +40 -56
index 918386c..280edc3 100644
@@ -70,12 +70,9 @@ static int max7359_write_reg(struct i2c_client *client, u8 reg, u8 val)
 {
 	int ret = i2c_smbus_write_byte_data(client, reg, val);
 
-	if (ret >= 0)
-		return 0;
-
-	dev_err(&client->dev, "%s: reg 0x%x, val 0x%x, err %d\n",
-						__func__, reg, val, ret);
-
+	if (ret < 0)
+		dev_err(&client->dev, "%s: reg 0x%x, val 0x%x, err %d\n",
+			__func__, reg, val, ret);
 	return ret;
 }
 
@@ -85,7 +82,7 @@ static int max7359_read_reg(struct i2c_client *client, int reg)
 
 	if (ret < 0)
 		dev_err(&client->dev, "%s: reg 0x%x, err %d\n",
-						__func__, reg, ret);
+			__func__, reg, ret);
 	return ret;
 }
 
@@ -93,17 +90,16 @@ static void max7359_build_keycode(struct max7359_keypad *keypad)
 {
 	struct max7359_keypad_platform_data *pdata = keypad->pdata;
 	struct input_dev *input_dev = keypad->input_dev;
-	unsigned int *key;
 	int i;
 
-	key = pdata->key_map;
-	for (i = 0; i < pdata->key_map_size; i++, key++) {
-		int row = ((*key) >> 28) & 0xf;
-		int col = ((*key) >> 24) & 0xf;
-		short code = (*key) & 0xffff;
+	for (i = 0; i < pdata->key_map_size; i++) {
+		unsigned int key = pdata->key_map[i];
+		int row = (key >> 28) & 0xf;
+		int col = (key >> 24) & 0xf;
+		unsigned short code = key & 0xffff;
 
 		keypad->keycodes[(row << 3) + col] = code;
-		set_bit(code, input_dev->keybit);
+		__set_bit(code, input_dev->keybit);
 	}
 }
 
@@ -125,7 +121,8 @@ static void max7359_worker(struct work_struct *work)
 	release = val & 0x40;
 
 	input_report_key(keypad->input_dev,
-		max7359_lookup_matrix_keycode(keypad, row, col), !release);
+			 max7359_lookup_matrix_keycode(keypad, row, col),
+			 !release);
 	input_sync(keypad->input_dev);
 
 	enable_irq(keypad->irq);
@@ -141,9 +138,6 @@ static irqreturn_t max7359_interrupt(int irq, void *dev_id)
 	if (!work_pending(&keypad->work)) {
 		disable_irq_nosync(keypad->irq);
 		schedule_work(&keypad->work);
-	} else {
-		dev_warn(&keypad->client->dev,
-				"Another job is currently pending \n");
 	}
 
 	return IRQ_HANDLED;
@@ -204,71 +198,59 @@ static int __devinit max7359_probe(struct i2c_client *client,
 					const struct i2c_device_id *id)
 {
 	struct max7359_keypad *keypad;
-	struct max7359_keypad_platform_data *pdata;
+	struct max7359_keypad_platform_data *pdata = client->dev.platform_data;
 	struct input_dev *input_dev;
 	int ret;
+	int error;
 
-	keypad = kzalloc(sizeof(struct max7359_keypad), GFP_KERNEL);
-	if (keypad == NULL) {
-		dev_err(&client->dev, "failed to allocate driver data\n");
-		return -ENOMEM;
+	if (!client->irq) {
+		dev_err(&client->dev, "The irq number should not be zero\n");
+		return -EINVAL;
 	}
 
-	keypad->client = client;
-	pdata = keypad->pdata = client->dev.platform_data;
-	i2c_set_clientdata(client, keypad);
-
 	/* Detect MAX7359: The initial Keys FIFO value is '0x3F' */
 	ret = max7359_read_reg(client, MAX7359_REG_KEYFIFO);
 	if (ret < 0) {
 		dev_err(&client->dev, "failed to detect device\n");
-		goto failed_free;
-	} else {
-		dev_info(&client->dev, "keys FIFO is 0x%02x"
-				", succeeded in detecting device\n", ret);
+		return -ENODEV;
 	}
 
-	/* Initialize MAX7359 */
-	max7359_initialize(client);
+	dev_dbg(&client->dev, "keys FIFO is 0x%02x\n", ret);
 
-	/* Create and register the input driver. */
+	keypad = kzalloc(sizeof(struct max7359_keypad), GFP_KERNEL);
 	input_dev = input_allocate_device();
-	if (!input_dev) {
-		dev_err(&client->dev, "failed to allocate input device\n");
-		ret = -ENOMEM;
-		goto failed_free;
+	if (!keypad || !input_dev) {
+		dev_err(&client->dev, "failed to allocate memory\n");
+		error = -ENOMEM;
+		goto failed_free_mem;
 	}
 
+	keypad->client = client;
+	keypad->pdata = pdata;
+	keypad->input_dev = input_dev;
+	keypad->irq = client->irq;
+	INIT_WORK(&keypad->work, max7359_worker);
+
 	input_dev->name = client->name;
 	input_dev->id.bustype = BUS_I2C;
 	input_dev->open = max7359_open;
 	input_dev->close = max7359_close;
 	input_dev->dev.parent = &client->dev;
 
-	input_set_drvdata(input_dev, keypad);
-
 	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
 	input_dev->keycodesize = sizeof(keypad->keycodes[0]);
 	input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
 	input_dev->keycode = keypad->keycodes;
 
-	keypad->input_dev = input_dev;
+	input_set_drvdata(input_dev, keypad);
 
 	max7359_build_keycode(keypad);
 
-	INIT_WORK(&keypad->work, max7359_worker);
-
-	keypad->irq = client->irq;
-	if (!keypad->irq) {
-		dev_err(&client->dev, "The irq number should not be zero\n");
-		goto failed_free_dev;
-	}
-
-	ret = request_irq(keypad->irq, max7359_interrupt,
-				IRQF_TRIGGER_LOW, client->name, keypad);
-	if (ret) {
+	error = request_irq(keypad->irq, max7359_interrupt,
+			    IRQF_TRIGGER_LOW, client->name, keypad);
+	if (error) {
 		dev_err(&client->dev, "failed to register interrupt\n");
-		goto failed_free_dev;
+		goto failed_free_mem;
 	}
 
 	/* Register the input device */
@@ -278,16 +260,18 @@ static int __devinit max7359_probe(struct i2c_client *client,
 		goto failed_free_irq;
 	}
 
+	/* Initialize MAX7359 */
+	max7359_initialize(client);
+
+	i2c_set_clientdata(client, keypad);
 	device_init_wakeup(&client->dev, 1);
 
 	return 0;
 
 failed_free_irq:
 	free_irq(keypad->irq, keypad);
-failed_free_dev:
+failed_free_mem:
 	input_free_device(input_dev);
-failed_free:
-	i2c_set_clientdata(client, NULL);
 	kfree(keypad);
 	return ret;
 }
author
#3 lore raw
Quoted 47 lines · Dmitry Torokhov

P.S. I made a bunch of random changes, mostly to streamline the probe code (below), hopfully I did not break anything.

drivers/input/keyboard/max7359_keypad.c +8 -16
index 918386c..280edc3 100644
@@ -204,71 +198,59 @@ static int __devinit max7359_probe(struct i2c_client *client,
                                       const struct i2c_device_id *id)
 {
       struct max7359_keypad *keypad;
-       struct max7359_keypad_platform_data *pdata;
+       struct max7359_keypad_platform_data *pdata = client->dev.platform_data;
       struct input_dev *input_dev;
       int ret;
+       int error;
 
-       keypad = kzalloc(sizeof(struct max7359_keypad), GFP_KERNEL);
-       if (keypad == NULL) {
-               dev_err(&client->dev, "failed to allocate driver data\n");
-               return -ENOMEM;
+       if (!client->irq) {
+               dev_err(&client->dev, "The irq number should not be zero\n");
+               return -EINVAL;
       }
 
-       keypad->client = client;
-       pdata = keypad->pdata = client->dev.platform_data;
-       i2c_set_clientdata(client, keypad);
-
       /* Detect MAX7359: The initial Keys FIFO value is '0x3F' */
       ret = max7359_read_reg(client, MAX7359_REG_KEYFIFO);
       if (ret < 0) {
               dev_err(&client->dev, "failed to detect device\n");
-               goto failed_free;
-       } else {
-               dev_info(&client->dev, "keys FIFO is 0x%02x"
-                               ", succeeded in detecting device\n", ret);
+               return -ENODEV;
       }
 
-       /* Initialize MAX7359 */
-       max7359_initialize(client);
+       dev_dbg(&client->dev, "keys FIFO is 0x%02x\n", ret);
 
-       /* Create and register the input driver. */
+       keypad = kzalloc(sizeof(struct max7359_keypad), GFP_KERNEL);

drivers/input/keyboard/max7359_keypad.c static int __devinit max7359_probe(struct i2c_client *client, · line 226

Quoted 10 lines
drivers/input/keyboard/max7359_keypad.c +4 -4
       input_dev = input_allocate_device();
-       if (!input_dev) {
-               dev_err(&client->dev, "failed to allocate input device\n");
-               ret = -ENOMEM;
-               goto failed_free;
+       if (!keypad || !input_dev) {
+               dev_err(&client->dev, "failed to allocate memory\n");
+               error = -ENOMEM;
+               goto failed_free_mem;
       }

Hi Dmitry,

Thank you for streamlining this driver. I confirmed this streamlined driver is nicely working on my S3C6410 board and of course I mostly like your changes. But I'm afraid this 'error' variable is not used at the final return statement in the probe function.

Thanks & Regards,
Kyuwon

P.S. You may need this kind of patch.
--

drivers/input/keyboard/max7359_keypad.c +6 -7
index 280edc3..6e09e0d 100644
@@ -200,7 +200,6 @@ static int __devinit max7359_probe(struct i2c_client *client,
 	struct max7359_keypad *keypad;
 	struct max7359_keypad_platform_data *pdata = client->dev.platform_data;
 	struct input_dev *input_dev;
-	int ret;
 	int error;
 
 	if (!client->irq) {
@@ -209,13 +208,13 @@ static int __devinit max7359_probe(struct i2c_client *client,
 	}
 
 	/* Detect MAX7359: The initial Keys FIFO value is '0x3F' */
-	ret = max7359_read_reg(client, MAX7359_REG_KEYFIFO);
-	if (ret < 0) {
+	error = max7359_read_reg(client, MAX7359_REG_KEYFIFO);
+	if (error < 0) {
 		dev_err(&client->dev, "failed to detect device\n");
 		return -ENODEV;
 	}
 
-	dev_dbg(&client->dev, "keys FIFO is 0x%02x\n", ret);
+	dev_dbg(&client->dev, "keys FIFO is 0x%02x\n", error);
 
 	keypad = kzalloc(sizeof(struct max7359_keypad), GFP_KERNEL);
 	input_dev = input_allocate_device();
@@ -254,8 +253,8 @@ static int __devinit max7359_probe(struct i2c_client *client,
 	}
 
 	/* Register the input device */
-	ret = input_register_device(input_dev);
-	if (ret) {
+	error = input_register_device(input_dev);
+	if (error) {
 		dev_err(&client->dev, "failed to register input device\n");
 		goto failed_free_irq;
 	}
@@ -273,7 +272,7 @@ failed_free_irq:
 failed_free_mem:
 	input_free_device(input_dev);
 	kfree(keypad);
-	return ret;
+	return error;
 }
 
 static int __devexit max7359_remove(struct i2c_client *client)
maintainer
#4 lore raw

Hi KIm,

Quoted 5 lines · On Sunday 10 May 2009 18:51:32 Kim Kyuwon wrote:

Hi Dmitry,

Thank you for streamlining this driver. I confirmed this streamlined driver is nicely working on my S3C6410 board and of course I mostly like your changes.

Great, thanks for testing.

Quoted 2 lines

But I'm afraid this 'error' variable is not used at the final return statement in the probe function.

*blush* Hm, apparently I did not quite finish converting it all to use "error" ;) I personally like calling such variables "error" if they are "returned" only in error path and "ret" or "retval" when they are returned upon both error and successful completion of a function. I will fold your patch into the original version, thanks a lot.

Signature · 1 line
Dmitry
#5 lore raw
In reply to Trilok Soni

Hi Trilok,

Quoted 7 lines · Trilok Soni

Hi Kim,

Quoted 4 lines · Kim Kyuwon

The Maxim MAX7359 is a I2C interfaced key switch controller which provides microprocessors with management of up to 64 key switches.
This patch adds support for the MAX7359 key switch controller.

Quoted 6 lines
Quoted 1 line

Thanks for implementing review comments. Please add

Sorry, I didn't know I should put the "Reviewed-by" in the reviewed patch.(I'm still kernelnewbie :) ) If possible, I want Dmitry to add "Reviewed-by" when he sends this driver to mainline, or I will send new patch again.

Thanks again for you reviewing.

Kyuwon (규원)
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#6 lore raw
Quoted 13 lines · Kim Kyuwon

Hi Trilok,

Quoted 10 lines · Trilok Soni

Hi Kim,

Quoted 5 lines · Kim Kyuwon

The Maxim MAX7359 is a I2C interfaced key switch controller which provides microprocessors with management of up to 64 key switches.
This patch adds support for the MAX7359 key switch controller.

Quoted 6 lines
Quoted 3 lines

Thanks for implementing review comments. Please add

Sorry, I didn't know I should put the "Reviewed-by" in the reviewed patch.(I'm still kernelnewbie :) )

You are not supposed to add it until somebody explicitely asks you to do that, same with Acked-by... The reason is that these tags constitute certain endorsement of the patch and while one person may review the patch he/she may not yet feel that review process is complete. Hope this makes some sense...

Quoted 4 lines

If possible, I want Dmitry to add
"Reviewed-by" when he sends this driver to mainline, or I will send new patch again.

I have it added to my copy.

Signature · 1 line
Dmitry
#7 lore raw

Hi,

Quoted 27 lines · Dmitry Torokhov
Quoted 13 lines · Kim Kyuwon

Hi Trilok,

Quoted 10 lines · Trilok Soni

Hi Kim,

Quoted 5 lines · Kim Kyuwon

The Maxim MAX7359 is a I2C interfaced key switch controller which provides microprocessors with management of up to 64 key switches.
This patch adds support for the MAX7359 key switch controller.

Quoted 6 lines
Quoted 3 lines

Thanks for implementing review comments. Please add

Sorry, I didn't know I should put the "Reviewed-by" in the reviewed patch.(I'm still kernelnewbie :) )

You are not supposed to add it until somebody explicitely asks you to do that, same with Acked-by... The reason is that these tags constitute certain endorsement of the patch and while one person may review the patch he/she may not yet feel that review process is complete. Hope this makes some sense...

Quoted 6 lines
Quoted 4 lines

If possible, I want Dmitry to add
"Reviewed-by" when he sends this driver to mainline, or I will send new patch again.

I have it added to my copy.

I was looking at Palm Pre released linux-2.6.24 patch today at their site http://palm.cdnetworks.net/opensource/1.0.1/linux-2.6.24-patch.gz
and I found that Palm Pre also uses the same switch controller but they seems to have written another version of this driver.

---Trilok Soni

#8 lore raw

Hi Dmitry,

Quoted 37 lines · Trilok Soni

Hi,

Quoted 33 lines · Dmitry Torokhov
Quoted 13 lines · Kim Kyuwon

Hi Trilok,

Quoted 10 lines · Trilok Soni

Hi Kim,

Quoted 5 lines · Kim Kyuwon

The Maxim MAX7359 is a I2C interfaced key switch controller which provides microprocessors with management of up to 64 key switches.
This patch adds support for the MAX7359 key switch controller.

Quoted 6 lines
Quoted 3 lines

Thanks for implementing review comments. Please add

Sorry, I didn't know I should put the "Reviewed-by" in the reviewed patch.(I'm still kernelnewbie :) )

You are not supposed to add it until somebody explicitely asks you to do that, same with Acked-by... The reason is that these tags constitute certain endorsement of the patch and while one person may review the patch he/she may not yet feel that review process is complete. Hope this makes some sense...

Quoted 4 lines

If possible, I want Dmitry to add
"Reviewed-by" when he sends this driver to mainline, or I will send new patch again.

I have it added to my copy.

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni

maintainer
#9 lore raw
Quoted 8 lines · Trilok Soni

Hi Dmitry,

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

I was wondering if somebody could test the patch below and if it still works then I will apply to the next branch. Thanks!

Signature · 15 lines
Dmitry


Input: max7359 - use threaded IRQs

From: Dmitry Torokhov <[email protected]>

Convert max7359 driver to use IRQ threading instead of using
workqueue.

Signed-off-by: Dmitry Torokhov <[email protected]>
---

 drivers/input/keyboard/max7359_keypad.c |   34 +++++++++++++------------------
 1 files changed, 14 insertions(+), 20 deletions(-)
drivers/input/keyboard/max7359_keypad.c +14 -20
index e359db3..c823c0b 100644
@@ -57,8 +57,6 @@ struct max7359_keypad {
 	/* matrix key code map */
 	unsigned short keycodes[MAX7359_MAX_KEY_NUM];
 
-	struct work_struct work;
-
 	struct input_dev *input_dev;
 	struct i2c_client *client;
 
@@ -103,10 +101,10 @@ static void max7359_build_keycode(struct max7359_keypad *keypad,
 	__clear_bit(KEY_RESERVED, input_dev->keybit);
 }
 
-static void max7359_worker(struct work_struct *work)
+/* runs in an IRQ thread -- can (and will!) sleep */
+static irqreturn_t max7359_interrupt(int irq, void *dev_id)
 {
-	struct max7359_keypad *keypad =
-			container_of(work, struct max7359_keypad, work);
+	struct max7359_keypad *keypad = dev_id;
 	struct input_dev *input_dev = keypad->input_dev;
 	int val, row, col, release, code;
 
@@ -116,26 +114,23 @@ static void max7359_worker(struct work_struct *work)
 	release = val & 0x40;
 	code = (row << 3) + col;
 
+	dev_dbg(&keypad->client->dev,
+		"key[%d:%d] %s\n", row, col, release ? "release" : "press");
+
 	input_event(input_dev, EV_MSC, MSC_SCAN, code);
 	input_report_key(input_dev, keypad->keycodes[code], !release);
 	input_sync(input_dev);
 
 	enable_irq(keypad->irq);
-
-	dev_dbg(&keypad->client->dev, "key[%d:%d] %s\n", row, col,
-					(release ? "release" : "press"));
+	return IRQ_HANDLED;
 }
 
-static irqreturn_t max7359_interrupt(int irq, void *dev_id)
+static irqreturn_t max7359_hardirq(int irq, void *dev_id)
 {
 	struct max7359_keypad *keypad = dev_id;
 
-	if (!work_pending(&keypad->work)) {
-		disable_irq_nosync(keypad->irq);
-		schedule_work(&keypad->work);
-	}
-
-	return IRQ_HANDLED;
+	disable_irq_nosync(keypad->irq);
+	return IRQ_WAKE_THREAD;
 }
 
 /*
@@ -223,7 +218,6 @@ static int __devinit max7359_probe(struct i2c_client *client,
 	keypad->client = client;
 	keypad->input_dev = input_dev;
 	keypad->irq = client->irq;
-	INIT_WORK(&keypad->work, max7359_worker);
 
 	input_dev->name = client->name;
 	input_dev->id.bustype = BUS_I2C;
@@ -241,8 +235,9 @@ static int __devinit max7359_probe(struct i2c_client *client,
 
 	max7359_build_keycode(keypad, keymap_data);
 
-	error = request_irq(keypad->irq, max7359_interrupt,
-			    IRQF_TRIGGER_LOW, client->name, keypad);
+	error = request_threaded_irq(keypad->irq,
+				     max7359_hardirq, max7359_interrupt,
+				     IRQF_TRIGGER_LOW, client->name, keypad);
 	if (error) {
 		dev_err(&client->dev, "failed to register interrupt\n");
 		goto failed_free_mem;
@@ -275,9 +270,8 @@ static int __devexit max7359_remove(struct i2c_client *client)
 {
 	struct max7359_keypad *keypad = i2c_get_clientdata(client);
 
-	cancel_work_sync(&keypad->work);
-	input_unregister_device(keypad->input_dev);
 	free_irq(keypad->irq, keypad);
+	input_unregister_device(keypad->input_dev);
 	i2c_set_clientdata(client, NULL);
 	kfree(keypad);
 
author
#10 lore raw
Quoted 4 lines · Dmitry Torokhov
Quoted 3 lines · Trilok Soni

Hi Dmitry,

Quoted 9 lines
Quoted 5 lines

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

I was wondering if somebody could test the patch below and if it still works then I will apply to the next branch. Thanks!

Dear Marek,

Because I don't have the NCP board(which includes the max7359 keypad) now, I can't test this patch. Marek, could you please test this patch?

Sincerely,
Kyuwon

#11 lore raw

Hello,

Quoted 6 lines · Kim Kyuwon
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Trilok Soni

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

Quoted 8 lines
Quoted 3 lines

I was wondering if somebody could test the patch below and if it still works then I will apply to the next branch. Thanks!

Dear Marek,

Because I don't have the NCP board(which includes the max7359 keypad) now, I can't test this patch. Marek, could you please test this patch?

I would like to, but I could not find the base version to which I can apply that patch. I've tried v2 version posted in '[PATCH] Input: add MAX7359 key switch controller driver, v2' mail from Sat 2009-05-09 04:10 with 2 patches posted in replies to that main, but the latest patch still fails to apply.

Could someone send me a complete patch, so I can do a test?

Best regards
--
Marek Szyprowski
Samsung Poland R&D Center

maintainer Reviewed-by Trilok Soni
#12 lore raw
Quoted 18 lines · Marek Szyprowski

Hello,

Quoted 6 lines · Kim Kyuwon
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Trilok Soni

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

Quoted 8 lines
Quoted 3 lines

I was wondering if somebody could test the patch below and if it still works then I will apply to the next branch. Thanks!

Dear Marek,

Because I don't have the NCP board(which includes the max7359 keypad) now, I can't test this patch. Marek, could you please test this patch?

Quoted 7 lines

I would like to, but I could not find the base version to which I can apply that patch. I've tried v2 version posted in '[PATCH] Input: add MAX7359 key switch controller driver, v2' mail from Sat 2009-05-09 04:10 with 2 patches posted in replies to that main, but the latest patch still fails to apply.

Could someone send me a complete patch, so I can do a test?

Sending everything as attachments, maybe that will help...

Signature · 1 line
Dmitry

Input: mcs5000_ts - use threaded IRQs

From: Dmitry Torokhov <[email protected]>

Threaded IRQs are exactly what this driver needs since it communicates with the device over I2C bus, which requires sleeping.

---

 drivers/input/touchscreen/mcs5000_ts.c |  162 +++++++++++---------------------
 1 files changed, 57 insertions(+), 105 deletions(-)
drivers/input/touchscreen/mcs5000_ts.c +57 -105
index d6c1a94..ff54ea9 100644
@@ -20,7 +20,6 @@
 #include <linux/interrupt.h>
 #include <linux/input.h>
 #include <linux/irq.h>
-#include <linux/workqueue.h>
 
 /* Registers */
 #define MCS5000_TS_STATUS		0x00
@@ -105,17 +104,12 @@ enum mcs5000_ts_read_offset {
 struct mcs5000_ts_data {
 	struct i2c_client *client;
 	struct input_dev *input_dev;
-	struct work_struct ts_event_work;
-	struct mcs5000_ts_platform_data *platform_data;
-
-	unsigned int irq;
-	atomic_t irq_disable;
+	const struct mcs5000_ts_platform_data *platform_data;
 };
 
-static struct i2c_driver mcs5000_ts_driver;
-
-static void mcs5000_ts_input_read(struct mcs5000_ts_data *data)
+static irqreturn_t mcs5000_ts_interrupt(int irq, void *dev_id)
 {
+	struct mcs5000_ts_data *data = dev_id;
 	struct i2c_client *client = data->client;
 	u8 buffer[READ_BLOCK_SIZE];
 	int err;
@@ -126,7 +120,7 @@ static void mcs5000_ts_input_read(struct mcs5000_ts_data *data)
 			READ_BLOCK_SIZE, buffer);
 	if (err < 0) {
 		dev_err(&client->dev, "%s, err[%d]\n", __func__, err);
-		return;
+		goto out;
 	}
 
 	switch (buffer[READ_INPUT_INFO]) {
@@ -134,6 +128,7 @@ static void mcs5000_ts_input_read(struct mcs5000_ts_data *data)
 		input_report_key(data->input_dev, BTN_TOUCH, 0);
 		input_sync(data->input_dev);
 		break;
+
 	case INPUT_TYPE_SINGLE:
 		x = (buffer[READ_X_POS_UPPER] << 8) | buffer[READ_X_POS_LOWER];
 		y = (buffer[READ_Y_POS_UPPER] << 8) | buffer[READ_Y_POS_LOWER];
@@ -143,98 +138,40 @@ static void mcs5000_ts_input_read(struct mcs5000_ts_data *data)
 		input_report_abs(data->input_dev, ABS_Y, y);
 		input_sync(data->input_dev);
 		break;
+
 	case INPUT_TYPE_DUAL:
 		/* TODO */
 		break;
+
 	case INPUT_TYPE_PALM:
 		/* TODO */
 		break;
+
 	case INPUT_TYPE_PROXIMITY:
 		/* TODO */
 		break;
+
 	default:
 		dev_err(&client->dev, "Unknown ts input type %d\n",
 				buffer[READ_INPUT_INFO]);
 		break;
 	}
-}
-
-static void mcs5000_ts_irq_worker(struct work_struct *work)
-{
-	struct mcs5000_ts_data *data = container_of(work,
-			struct mcs5000_ts_data, ts_event_work);
-
-	mcs5000_ts_input_read(data);
-
-	atomic_dec(&data->irq_disable);
-	enable_irq(data->irq);
-}
-
-static irqreturn_t mcs5000_ts_interrupt(int irq, void *dev_id)
-{
-	struct mcs5000_ts_data *data = dev_id;
-
-	if (!work_pending(&data->ts_event_work)) {
-		disable_irq_nosync(data->irq);
-		atomic_inc(&data->irq_disable);
-		schedule_work(&data->ts_event_work);
-	}
 
+ out:
+	enable_irq(irq);
 	return IRQ_HANDLED;
 }
 
-static int mcs5000_ts_input_init(struct mcs5000_ts_data *data)
+static irqreturn_t mcs5000_ts_hardirq(int irq, void *dev_id)
 {
-	struct input_dev *input_dev;
-	int ret = 0;
-
-	INIT_WORK(&data->ts_event_work, mcs5000_ts_irq_worker);
-
-	data->input_dev = input_allocate_device();
-	if (data->input_dev == NULL) {
-		ret = -ENOMEM;
-		goto err_input;
-	}
-
-	input_dev = data->input_dev;
-	input_dev->name = "MELPAS MCS-5000 Touchscreen";
-	input_dev->id.bustype = BUS_I2C;
-	input_dev->dev.parent = &data->client->dev;
-	set_bit(EV_ABS, input_dev->evbit);
-	set_bit(ABS_X, input_dev->absbit);
-	set_bit(ABS_Y, input_dev->absbit);
-	set_bit(EV_KEY, input_dev->evbit);
-	set_bit(BTN_TOUCH, input_dev->keybit);
-	input_set_abs_params(input_dev, ABS_X, 0, MCS5000_MAX_XC, 0, 0);
-	input_set_abs_params(input_dev, ABS_Y, 0, MCS5000_MAX_YC, 0, 0);
-
-	ret = input_register_device(data->input_dev);
-	if (ret < 0)
-		goto err_register;
-
-	ret = request_irq(data->irq, mcs5000_ts_interrupt, IRQF_TRIGGER_LOW,
-			"mcs5000_ts_input", data);
-	if (ret < 0) {
-		dev_err(&data->client->dev, "Failed to register interrupt\n");
-		goto err_irq;
-	}
-
-	input_set_drvdata(input_dev, data);
-
-	return 0;
-err_irq:
-	input_unregister_device(data->input_dev);
-	data->input_dev = NULL;
-err_register:
-	input_free_device(data->input_dev);
-err_input:
-	return ret;
+	disable_irq_nosync(irq);
+	return IRQ_WAKE_THREAD;
 }
 
 static void mcs5000_ts_phys_init(struct mcs5000_ts_data *data)
 {
+	const struct mcs5000_ts_platform_data *platform_data = data->platform_data;
 	struct i2c_client *client = data->client;
-	struct mcs5000_ts_platform_data *platform_data = data->platform_data;
 
 	/* Touch reset & sleep mode */
 	i2c_smbus_write_byte_data(client, MCS5000_TS_OP_MODE,
@@ -259,53 +196,69 @@ static int __devinit mcs5000_ts_probe(struct i2c_client *client,
 		const struct i2c_device_id *idp)
 {
 	struct mcs5000_ts_data *data;
-	int ret;
+	struct input_dev *input_dev;
+	int error;
+
+	if (!client->dev.platform_data)
+		return -EINVAL;
 
 	data = kzalloc(sizeof(struct mcs5000_ts_data), GFP_KERNEL);
-	if (!data) {
-		dev_err(&client->dev, "Failed to allocate driver data\n");
-		ret = -ENOMEM;
-		goto exit;
+	input_dev = input_allocate_device();
+	if (!data || !input_dev) {
+		dev_err(&client->dev, "Failed to allocate memory\n");
+		error = -ENOMEM;
+		goto err_free_mem;
 	}
 
 	data->client = client;
+	data->input_dev = input_dev;
 	data->platform_data = client->dev.platform_data;
-	data->irq = client->irq;
-	atomic_set(&data->irq_disable, 0);
 
-	i2c_set_clientdata(client, data);
+	input_dev->name = "MELPAS MCS-5000 Touchscreen";
+	input_dev->id.bustype = BUS_I2C;
+	input_dev->dev.parent = &data->client->dev;
+
+	__set_bit(EV_ABS, input_dev->evbit);
+	__set_bit(EV_KEY, input_dev->evbit);
+	__set_bit(BTN_TOUCH, input_dev->keybit);
+	input_set_abs_params(input_dev, ABS_X, 0, MCS5000_MAX_XC, 0, 0);
+	input_set_abs_params(input_dev, ABS_Y, 0, MCS5000_MAX_YC, 0, 0);
 
-	if (data->platform_data && data->platform_data->set_pin)
+	input_set_drvdata(input_dev, data);
+
+	if (data->platform_data->set_pin)
 		data->platform_data->set_pin();
 
-	ret = mcs5000_ts_input_init(data);
-	if (ret)
-		goto exit_free;
+	error = request_threaded_irq(client->irq,
+				mcs5000_ts_hardirq, mcs5000_ts_interrupt,
+				IRQF_TRIGGER_LOW, "mcs5000_ts_input", data);
+	if (error < 0) {
+		dev_err(&data->client->dev, "Failed to register interrupt\n");
+		goto err_free_mem;
+	}
+
+	error = input_register_device(data->input_dev);
+	if (error < 0)
+		goto err_free_irq;
 
 	mcs5000_ts_phys_init(data);
+	i2c_set_clientdata(client, data);
 
 	return 0;
 
-exit_free:
+err_free_irq:
+	free_irq(client->irq, data);
+err_free_mem:
+	input_free_device(input_dev);
 	kfree(data);
-	i2c_set_clientdata(client, NULL);
-exit:
-	return ret;
+	return error;
 }
 
 static int __devexit mcs5000_ts_remove(struct i2c_client *client)
 {
 	struct mcs5000_ts_data *data = i2c_get_clientdata(client);
 
-	free_irq(data->irq, data);
-	cancel_work_sync(&data->ts_event_work);
-
-	/*
-	 * If work indeed has been cancelled, disable_irq() will have been left
-	 * unbalanced from mcs5000_ts_interrupt().
-	 */
-	while (atomic_dec_return(&data->irq_disable) >= 0)
-		enable_irq(data->irq);
+	free_irq(client->irq, data);
 
 	input_unregister_device(data->input_dev);
 	kfree(data);
@@ -326,9 +279,8 @@ static int mcs5000_ts_suspend(struct i2c_client *client, pm_message_t mesg)
 
 static int mcs5000_ts_resume(struct i2c_client *client)
 {
-	struct mcs5000_ts_data *data;
+	struct mcs5000_ts_data *data = i2c_get_clientdata(client);
 
-	data = i2c_get_clientdata(client);
 	mcs5000_ts_phys_init(data);
 
 	return 0;

Input: add touchscreen driver for MELFAS MCS-5000 controller

From: Joonyoung Shim <[email protected]>

The MELPAS MCS-5000 is the touchscreen controller. The overview of this controller can see at the following website:

http://www.melfas.com/product/product01.asp?k_r=eng_

This driver is tested on s3c6410 NCP board and supports only the i2c interface.

---

 drivers/input/touchscreen/Kconfig      |   12 +
 drivers/input/touchscreen/Makefile     |    1 
 drivers/input/touchscreen/mcs5000_ts.c |  374 ++++++++++++++++++++++++++++++++
 include/linux/i2c/mcs5000_ts.h         |   11 +
 4 files changed, 398 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/touchscreen/mcs5000_ts.c
 create mode 100644 include/linux/i2c/mcs5000_ts.h
drivers/input/touchscreen/Kconfig +12 -0
index 1c05b32..350e2cc 100644
@@ -505,4 +505,16 @@ config TOUCHSCREEN_W90X900
 	  To compile this driver as a module, choose M here: the
 	  module will be called w90p910_ts.
 
+config TOUCHSCREEN_MCS5000
+	tristate "MELFAS MCS-5000 touchscreen"
+	depends on I2C
+	help
+	  Say Y here if you have the MELFAS MCS-5000 touchscreen controller
+	  chip in your system.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called mcs5000_ts.
+
 endif
drivers/input/touchscreen/Makefile +1 -0
index 3e1c5e0..91e820f 100644
@@ -40,3 +40,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ATMEL)	+= atmel-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE)	+= mainstone-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)	+= zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)	+= w90p910_ts.o
+obj-$(CONFIG_TOUCHSCREEN_MCS5000)	+= mcs5000_ts.o
drivers/input/touchscreen/mcs5000_ts.c new file +374 -0

374 lines not on this page · raw message

include/linux/i2c/mcs5000_ts.h new file +11 -0
new file mode 100644
index 0000000..69d92b6
@@ -0,0 +1,11 @@
+#ifndef __LINUX_MCS5000_TS_H
+#define __LINUX_MCS5000_TS_H
+
+/* platform data for the MELFAS MCS5000 touchscreen driver */
+struct mcs5000_ts_platform_data {
+	void (*set_pin)(void);
+	int x_size;
+	int y_size;
+};
+
+#endif	/* __LINUX_MCS5000_TS_H */

Input: add MAX7359 key switch controller driver, v2

From: Kim Kyuwon <[email protected]>

The Maxim MAX7359 is a I2C interfaced key switch controller which provides microprocessors with management of up to 64 key switches.
This patch adds support for the MAX7359 key switch controller.

---

 drivers/input/keyboard/Kconfig          |   11 +
 drivers/input/keyboard/Makefile         |    1 
 drivers/input/keyboard/max7359_keypad.c |  348 +++++++++++++++++++++++++++++++
 3 files changed, 360 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/keyboard/max7359_keypad.c
drivers/input/keyboard/Kconfig +11 -0
index a6b989a..667dfd4 100644
@@ -250,6 +250,17 @@ config KEYBOARD_MAPLE
 	  To compile this driver as a module, choose M here: the
 	  module will be called maple_keyb.
 
+config KEYBOARD_MAX7359
+	tristate "Maxim MAX7359 Key Switch Controller"
+	depends on I2C
+	help
+	  If you say yes here you get support for the Maxim MAX7359 Key
+	  Switch Controller chip. This providers microprocessors with
+	  management of up to 64 key switches
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called max7359_keypad.
+
 config KEYBOARD_NEWTON
 	tristate "Newton keyboard"
 	select SERIO
drivers/input/keyboard/Makefile +1 -0
index b5b5eae..1ace21a 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_KEYBOARD_LM8323)		+= lm8323.o
 obj-$(CONFIG_KEYBOARD_LOCOMO)		+= locomokbd.o
 obj-$(CONFIG_KEYBOARD_MAPLE)		+= maple_keyb.o
 obj-$(CONFIG_KEYBOARD_MATRIX)		+= matrix_keypad.o
+obj-$(CONFIG_KEYBOARD_MAX7359)		+= max7359_keypad.o
 obj-$(CONFIG_KEYBOARD_NEWTON)		+= newtonkbd.o
 obj-$(CONFIG_KEYBOARD_OMAP)		+= omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)		+= pxa27x_keypad.o
drivers/input/keyboard/max7359_keypad.c new file +348 -0

348 lines not on this page · raw message

Input: max7359 - use threaded IRQs

From: Dmitry Torokhov <[email protected]>

Convert max7359 driver to use IRQ threading instead of using workqueue.

---

 drivers/input/keyboard/max7359_keypad.c |   51 +++++++++++--------------------
 1 files changed, 18 insertions(+), 33 deletions(-)
drivers/input/keyboard/max7359_keypad.c +18 -33

120 lines not on this page · raw message

#13 lore raw

Hi Dmitry,

Quoted 24 lines · Dmitry Torokhov
Quoted 23 lines · Marek Szyprowski

Hello,

Quoted 6 lines · Kim Kyuwon
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Trilok Soni

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

Quoted 8 lines
Quoted 3 lines

I was wondering if somebody could test the patch below and if it still works then I will apply to the next branch. Thanks!

Dear Marek,

Because I don't have the NCP board(which includes the max7359 keypad) now, I can't test this patch. Marek, could you please test this patch?

I would like to, but I could not find the base version to which I can apply that patch. I've tried v2 version posted in '[PATCH] Input: add MAX7359 key switch controller driver, v2' mail from Sat 2009-05-09 04:10 with 2 patches posted in replies to that main, but the latest patch still fails to apply.

Quoted 4 lines
Quoted 2 lines

Could someone send me a complete patch, so I can do a test?

Sending everything as attachments, maybe that will help...

I never saw/reviewed melfas touchscreen driver on linux-input ML, did I missed something?

Signature · 3 lines
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni
#14 lore raw
In reply to Dmitry Torokhov

Hello,

Quoted 23 lines · Dmitry Torokhov
Quoted 22 lines · Marek Szyprowski

Hello,

Quoted 6 lines · Kim Kyuwon
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Trilok Soni

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

Quoted 8 lines
Quoted 3 lines

I was wondering if somebody could test the patch below and if it still works then I will apply to the next branch. Thanks!

Dear Marek,

Because I don't have the NCP board(which includes the max7359 keypad) now, I can't test this patch. Marek, could you please test this patch?

I would like to, but I could not find the base version to which I can apply that patch. I've tried v2 version posted in '[PATCH] Input: add MAX7359 key switch controller driver, v2' mail from Sat 2009-05-09 04:10 with 2 patches posted in replies to that main, but the latest patch still fails to apply.

Quoted 4 lines
Quoted 2 lines

Could someone send me a complete patch, so I can do a test?

Sending everything as attachments, maybe that will help...

Ok. I've did the tests.

MAX7359 keypad driver works after your patch, but reports much more events than the previous version. In this test I pressed quickly the first button on the keypad.

Old version:

NCP:~# hexdump /dev/input/event0
0000000 0037 0000 e733 000b 0001 00e7 0001 0000
0000010 0037 0000 e748 000b 0000 0000 0000 0000
0000020 0037 0000 94e2 000d 0001 00e7 0000 0000
0000030 0037 0000 94f3 000d 0000 0000 0000 0000

New version:

NCP:~# hexdump /dev/input/event0
0000000 0110 0000 4f07 0009 0004 0004 0000 0000
0000010 0110 0000 4f30 0009 0001 00e7 0001 0000
0000020 0110 0000 4f3b 0009 0000 0000 0000 0000
0000030 0110 0000 9d43 0009 0004 0004 003f 0000
0000040 0110 0000 9d5d 0009 0000 0000 0000 0000
0000050 0110 0000 fcb6 000a 0004 0004 0000 0000
0000060 0110 0000 fcd2 000a 0001 00e7 0000 0000
0000070 0110 0000 fcd9 000a 0000 0000 0000 0000
0000080 0110 0000 4ae9 000b 0004 0004 003f 0000
0000090 0110 0000 4b02 000b 0000 0000 0000 0000

Melfas-MCS-5000 touch screen driver stopped working after your patch. The 'v3' version worked fine here. Tests has been done on 2.6.30 kernel on NCP board (I had to cherrypick a gpio-matrix keypad driver to compile the updated MAX7359 driver, but this shouldn't matter at all).

Best regards
--
Marek Szyprowski
Samsung Poland R&D Center

#15 lore raw

Hi Marek,

Quoted 38 lines · Marek Szyprowski

Hello,

Quoted 23 lines · Dmitry Torokhov
Quoted 22 lines · Marek Szyprowski

Hello,

Quoted 6 lines · Kim Kyuwon
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Trilok Soni

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

Quoted 8 lines
Quoted 3 lines

I was wondering if somebody could test the patch below and if it still works then I will apply to the next branch. Thanks!

Dear Marek,

Because I don't have the NCP board(which includes the max7359 keypad) now, I can't test this patch. Marek, could you please test this patch?

I would like to, but I could not find the base version to which I can apply that patch. I've tried v2 version posted in '[PATCH] Input: add MAX7359 key switch controller driver, v2' mail from Sat 2009-05-09 04:10 with 2 patches posted in replies to that main, but the latest patch still fails to apply.

Quoted 4 lines
Quoted 2 lines

Could someone send me a complete patch, so I can do a test?

Sending everything as attachments, maybe that will help...

Ok. I've did the tests.

MAX7359 keypad driver works after your patch, but reports much more events than the previous version. In this test I pressed quickly the first button on the keypad.

Quoted 7 lines

Old version:

NCP:~# hexdump /dev/input/event0
0000000 0037 0000 e733 000b 0001 00e7 0001 0000
0000010 0037 0000 e748 000b 0000 0000 0000 0000
0000020 0037 0000 94e2 000d 0001 00e7 0000 0000
0000030 0037 0000 94f3 000d 0000 0000 0000 0000

Please use evtest instead. It will give better output atleast.

Signature · 3 lines
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni
#16 lore raw

Hello,

Quoted 48 lines · Trilok Soni
Quoted 38 lines · Marek Szyprowski

Hello,

Quoted 23 lines · Dmitry Torokhov
Quoted 22 lines · Marek Szyprowski

Hello,

Quoted 6 lines · Kim Kyuwon
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Trilok Soni

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

Quoted 8 lines
Quoted 3 lines

I was wondering if somebody could test the patch below and if it still works then I will apply to the next branch. Thanks!

Dear Marek,

Because I don't have the NCP board(which includes the max7359 keypad) now, I can't test this patch. Marek, could you please test this patch?

I would like to, but I could not find the base version to which I can apply that patch. I've tried v2 version posted in '[PATCH] Input: add MAX7359 key switch controller driver, v2' mail from Sat 2009-05-09 04:10 with 2 patches posted in replies to that main, but the latest patch still fails to apply.

Quoted 4 lines
Quoted 2 lines

Could someone send me a complete patch, so I can do a test?

Sending everything as attachments, maybe that will help...

Ok. I've did the tests.

MAX7359 keypad driver works after your patch, but reports much more events than the previous version. In this test I pressed quickly the first button on the keypad.

Quoted 7 lines

Old version:

NCP:~# hexdump /dev/input/event0
0000000 0037 0000 e733 000b 0001 00e7 0001 0000
0000010 0037 0000 e748 000b 0000 0000 0000 0000
0000020 0037 0000 94e2 000d 0001 00e7 0000 0000
0000030 0037 0000 94f3 000d 0000 0000 0000 0000
Quoted 1 line

Please use evtest instead. It will give better output atleast.

Ok.

Old version (clean v2 patch):

NCP:~# evtest /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "max7359"
Supported events:
  Event type 0 (Sync)
  Event type 1 (Key)
    Event code 107 (End)
    Event code 139 (Menu)
    Event code 148 (Prog1)
    Event code 149 (Prog2)
    Event code 177 (ScrollUp)
    Event code 178 (ScrollDown)
    Event code 212 (Camera)
    Event code 231 (?)
    Event code 474 (?)
  Event type 20 (Repeat)
Testing ... (interrupt to exit)
Event: time 38.740081, type 1 (Key), code 139 (Menu), value 1
Event: time 38.740101, -------------- Report Sync ------------
Event: time 38.850061, type 1 (Key), code 139 (Menu), value 0
Event: time 38.850077, -------------- Report Sync ------------

New version (updated platform definition to use struct matrix_keymap_data instead of max7359_keypad_platform_data):

NCP:~# evtest /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "max7359"
Supported events:
  Event type 0 (Sync)
  Event type 1 (Key)
    Event code 107 (End)
    Event code 139 (Menu)
    Event code 148 (Prog1)
    Event code 149 (Prog2)
    Event code 177 (ScrollUp)
    Event code 178 (ScrollDown)
    Event code 212 (Camera)
    Event code 231 (?)
    Event code 474 (?)
  Event type 4 (Misc)
    Event code 4 (ScanCode)
  Event type 20 (Repeat)
Testing ... (interrupt to exit)
Event: time 75.680066, type 4 (Misc), code 4 (ScanCode), value 01
Event: time 75.680095, type 1 (Key), code 139 (Menu), value 1
Event: time 75.680107, -------------- Report Sync ------------
Event: time 75.700072, type 4 (Misc), code 4 (ScanCode), value 3f
Event: time 75.700095, -------------- Report Sync ------------
Event: time 75.830064, type 4 (Misc), code 4 (ScanCode), value 01
Event: time 75.830093, type 1 (Key), code 139 (Menu), value 0
Event: time 75.830100, -------------- Report Sync ------------
Event: time 75.850073, type 4 (Misc), code 4 (ScanCode), value 3f
Event: time 75.850097, -------------- Report Sync ------------

Something is definitely different. It looks that I missed a patch that added some additional events, because I don't think that the threaded irq patch would cause this.

Best regards
--
Marek Szyprowski
Samsung Poland R&D Center

#17 lore raw

Hi Market,

Quoted 114 lines · Marek Szyprowski

Hello,

Quoted 48 lines · Trilok Soni
Quoted 38 lines · Marek Szyprowski

Hello,

Quoted 23 lines · Dmitry Torokhov
Quoted 22 lines · Marek Szyprowski

Hello,

Quoted 6 lines · Kim Kyuwon
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Trilok Soni

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

Quoted 8 lines
Quoted 3 lines

I was wondering if somebody could test the patch below and if it still works then I will apply to the next branch. Thanks!

Dear Marek,

Because I don't have the NCP board(which includes the max7359 keypad) now, I can't test this patch. Marek, could you please test this patch?

I would like to, but I could not find the base version to which I can apply that patch. I've tried v2 version posted in '[PATCH] Input: add MAX7359 key switch controller driver, v2' mail from Sat 2009-05-09 04:10 with 2 patches posted in replies to that main, but the latest patch still fails to apply.

Quoted 4 lines
Quoted 2 lines

Could someone send me a complete patch, so I can do a test?

Sending everything as attachments, maybe that will help...

Ok. I've did the tests.

MAX7359 keypad driver works after your patch, but reports much more events than the previous version. In this test I pressed quickly the first button on the keypad.

Quoted 7 lines

Old version:

NCP:~# hexdump /dev/input/event0
0000000 0037 0000 e733 000b 0001 00e7 0001 0000
0000010 0037 0000 e748 000b 0000 0000 0000 0000
0000020 0037 0000 94e2 000d 0001 00e7 0000 0000
0000030 0037 0000 94f3 000d 0000 0000 0000 0000
Quoted 1 line

Please use evtest instead. It will give better output atleast.

Ok.

Old version (clean v2 patch):

NCP:~# evtest /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "max7359"
Supported events:
 Event type 0 (Sync)
 Event type 1 (Key)
   Event code 107 (End)
   Event code 139 (Menu)
   Event code 148 (Prog1)
   Event code 149 (Prog2)
   Event code 177 (ScrollUp)
   Event code 178 (ScrollDown)
   Event code 212 (Camera)
   Event code 231 (?)
   Event code 474 (?)
 Event type 20 (Repeat)
Testing ... (interrupt to exit)
Event: time 38.740081, type 1 (Key), code 139 (Menu), value 1
Event: time 38.740101, -------------- Report Sync ------------
Event: time 38.850061, type 1 (Key), code 139 (Menu), value 0
Event: time 38.850077, -------------- Report Sync ------------

New version (updated platform definition to use struct matrix_keymap_data instead of max7359_keypad_platform_data):

NCP:~# evtest /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "max7359"
Supported events:
 Event type 0 (Sync)
 Event type 1 (Key)
   Event code 107 (End)
   Event code 139 (Menu)
   Event code 148 (Prog1)
   Event code 149 (Prog2)
   Event code 177 (ScrollUp)
   Event code 178 (ScrollDown)
   Event code 212 (Camera)
   Event code 231 (?)
   Event code 474 (?)
 Event type 4 (Misc)
   Event code 4 (ScanCode)
 Event type 20 (Repeat)
Testing ... (interrupt to exit)
Event: time 75.680066, type 4 (Misc), code 4 (ScanCode), value 01
Event: time 75.680095, type 1 (Key), code 139 (Menu), value 1
Event: time 75.680107, -------------- Report Sync ------------
Event: time 75.700072, type 4 (Misc), code 4 (ScanCode), value 3f
Event: time 75.700095, -------------- Report Sync ------------
Event: time 75.830064, type 4 (Misc), code 4 (ScanCode), value 01
Event: time 75.830093, type 1 (Key), code 139 (Menu), value 0
Event: time 75.830100, -------------- Report Sync ------------
Event: time 75.850073, type 4 (Misc), code 4 (ScanCode), value 3f
Event: time 75.850097, -------------- Report Sync ------------
Quoted 3 lines

Something is definitely different. It looks that I missed a patch that added some additional events, because I don't think that the threaded irq patch would cause this.

Nope, it is not because of threaded irq patch but MSC_SCAN event generation. Not to worry.

Signature · 7 lines
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#18 lore raw

Hello,

Quoted 117 lines · Trilok Soni
Quoted 81 lines · Marek Szyprowski

Hello,

Quoted 48 lines · Trilok Soni
Quoted 38 lines · Marek Szyprowski

Hello,

Quoted 23 lines · Dmitry Torokhov
Quoted 22 lines · Marek Szyprowski

Hello,

Quoted 6 lines · Kim Kyuwon
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Trilok Soni

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

Quoted 8 lines
Quoted 3 lines

I was wondering if somebody could test the patch below and if it still works then I will apply to the next branch. Thanks!

Dear Marek,

Because I don't have the NCP board(which includes the max7359 keypad) now, I can't test this patch. Marek, could you please test this patch?

I would like to, but I could not find the base version to which I can apply that patch. I've tried v2 version posted in '[PATCH] Input: add MAX7359 key switch controller driver, v2' mail from Sat 2009-05-09 04:10 with 2 patches posted in replies to that main, but the latest patch still fails to apply.

Quoted 4 lines
Quoted 2 lines

Could someone send me a complete patch, so I can do a test?

Sending everything as attachments, maybe that will help...

Ok. I've did the tests.

MAX7359 keypad driver works after your patch, but reports much more events than the previous version. In this test I pressed quickly the first button on the keypad.

Quoted 7 lines

Old version:

NCP:~# hexdump /dev/input/event0
0000000 0037 0000 e733 000b 0001 00e7 0001 0000
0000010 0037 0000 e748 000b 0000 0000 0000 0000
0000020 0037 0000 94e2 000d 0001 00e7 0000 0000
0000030 0037 0000 94f3 000d 0000 0000 0000 0000
Quoted 1 line

Please use evtest instead. It will give better output atleast.

Ok.

Old version (clean v2 patch):

NCP:~# evtest /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "max7359"
Supported events:
 Event type 0 (Sync)
 Event type 1 (Key)
   Event code 107 (End)
   Event code 139 (Menu)
   Event code 148 (Prog1)
   Event code 149 (Prog2)
   Event code 177 (ScrollUp)
   Event code 178 (ScrollDown)
   Event code 212 (Camera)
   Event code 231 (?)
   Event code 474 (?)
 Event type 20 (Repeat)
Testing ... (interrupt to exit)
Event: time 38.740081, type 1 (Key), code 139 (Menu), value 1
Event: time 38.740101, -------------- Report Sync ------------
Event: time 38.850061, type 1 (Key), code 139 (Menu), value 0
Event: time 38.850077, -------------- Report Sync ------------
Quoted 1 line

New version (updated platform definition to use struct matrix_keymap_data instead of

max7359_keypad_platform_data):

Quoted 32 lines
NCP:~# evtest /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "max7359"
Supported events:
 Event type 0 (Sync)
 Event type 1 (Key)
   Event code 107 (End)
   Event code 139 (Menu)
   Event code 148 (Prog1)
   Event code 149 (Prog2)
   Event code 177 (ScrollUp)
   Event code 178 (ScrollDown)
   Event code 212 (Camera)
   Event code 231 (?)
   Event code 474 (?)
 Event type 4 (Misc)
   Event code 4 (ScanCode)
 Event type 20 (Repeat)
Testing ... (interrupt to exit)
Event: time 75.680066, type 4 (Misc), code 4 (ScanCode), value 01
Event: time 75.680095, type 1 (Key), code 139 (Menu), value 1
Event: time 75.680107, -------------- Report Sync ------------
Event: time 75.700072, type 4 (Misc), code 4 (ScanCode), value 3f
Event: time 75.700095, -------------- Report Sync ------------
Event: time 75.830064, type 4 (Misc), code 4 (ScanCode), value 01
Event: time 75.830093, type 1 (Key), code 139 (Menu), value 0
Event: time 75.830100, -------------- Report Sync ------------
Event: time 75.850073, type 4 (Misc), code 4 (ScanCode), value 3f
Event: time 75.850097, -------------- Report Sync ------------
Quoted 7 lines
Quoted 1 line

Something is definitely different. It looks that I missed a patch that added some additional events,

because I don't think that the

Quoted 2 lines

threaded irq patch would cause this.

Nope, it is not because of threaded irq patch but MSC_SCAN event generation. Not to worry.

I'm sorry for the commotion, but I did the test in a wrong way. I thought Dmitry has sent me a patch with the threaded irq already integrated. Joonyoung Shim has pointed me that I was wrong. I had to apply the threaded irq patch on top of the patch Dmitry has sent me.

To sum up - the threaded irq version does not work here on ARM S3C6410 NCP board. In /proc/interrupts I only noticed that only 1 interrupt has been triggered. No events are reported. Same was with Melfas Touchscreen driver (also only 1 interrupt triggered).

Best regards
--
Marek Szyprowski
Samsung Poland R&D Center

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#19 lore raw
Quoted 135 lines · Marek Szyprowski

Hello,

Quoted 117 lines · Trilok Soni
Quoted 81 lines · Marek Szyprowski

Hello,

Quoted 48 lines · Trilok Soni
Quoted 38 lines · Marek Szyprowski

Hello,

Quoted 23 lines · Dmitry Torokhov
Quoted 22 lines · Marek Szyprowski

Hello,

Quoted 6 lines · Kim Kyuwon
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Trilok Soni

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

Quoted 8 lines
Quoted 3 lines

I was wondering if somebody could test the patch below and if it still works then I will apply to the next branch. Thanks!

Dear Marek,

Because I don't have the NCP board(which includes the max7359 keypad) now, I can't test this patch. Marek, could you please test this patch?

I would like to, but I could not find the base version to which I can apply that patch. I've tried v2 version posted in '[PATCH] Input: add MAX7359 key switch controller driver, v2' mail from Sat 2009-05-09 04:10 with 2 patches posted in replies to that main, but the latest patch still fails to apply.

Quoted 4 lines
Quoted 2 lines

Could someone send me a complete patch, so I can do a test?

Sending everything as attachments, maybe that will help...

Ok. I've did the tests.

MAX7359 keypad driver works after your patch, but reports much more events than the previous version. In this test I pressed quickly the first button on the keypad.

Quoted 7 lines

Old version:

NCP:~# hexdump /dev/input/event0
0000000 0037 0000 e733 000b 0001 00e7 0001 0000
0000010 0037 0000 e748 000b 0000 0000 0000 0000
0000020 0037 0000 94e2 000d 0001 00e7 0000 0000
0000030 0037 0000 94f3 000d 0000 0000 0000 0000
Quoted 1 line

Please use evtest instead. It will give better output atleast.

Ok.

Old version (clean v2 patch):

NCP:~# evtest /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "max7359"
Supported events:
 Event type 0 (Sync)
 Event type 1 (Key)
   Event code 107 (End)
   Event code 139 (Menu)
   Event code 148 (Prog1)
   Event code 149 (Prog2)
   Event code 177 (ScrollUp)
   Event code 178 (ScrollDown)
   Event code 212 (Camera)
   Event code 231 (?)
   Event code 474 (?)
 Event type 20 (Repeat)
Testing ... (interrupt to exit)
Event: time 38.740081, type 1 (Key), code 139 (Menu), value 1
Event: time 38.740101, -------------- Report Sync ------------
Event: time 38.850061, type 1 (Key), code 139 (Menu), value 0
Event: time 38.850077, -------------- Report Sync ------------
Quoted 1 line

New version (updated platform definition to use struct matrix_keymap_data instead of

max7359_keypad_platform_data):

Quoted 32 lines
NCP:~# evtest /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "max7359"
Supported events:
 Event type 0 (Sync)
 Event type 1 (Key)
   Event code 107 (End)
   Event code 139 (Menu)
   Event code 148 (Prog1)
   Event code 149 (Prog2)
   Event code 177 (ScrollUp)
   Event code 178 (ScrollDown)
   Event code 212 (Camera)
   Event code 231 (?)
   Event code 474 (?)
 Event type 4 (Misc)
   Event code 4 (ScanCode)
 Event type 20 (Repeat)
Testing ... (interrupt to exit)
Event: time 75.680066, type 4 (Misc), code 4 (ScanCode), value 01
Event: time 75.680095, type 1 (Key), code 139 (Menu), value 1
Event: time 75.680107, -------------- Report Sync ------------
Event: time 75.700072, type 4 (Misc), code 4 (ScanCode), value 3f
Event: time 75.700095, -------------- Report Sync ------------
Event: time 75.830064, type 4 (Misc), code 4 (ScanCode), value 01
Event: time 75.830093, type 1 (Key), code 139 (Menu), value 0
Event: time 75.830100, -------------- Report Sync ------------
Event: time 75.850073, type 4 (Misc), code 4 (ScanCode), value 3f
Event: time 75.850097, -------------- Report Sync ------------
Quoted 7 lines
Quoted 1 line

Something is definitely different. It looks that I missed a patch that added some additional events,

because I don't think that the

Quoted 2 lines

threaded irq patch would cause this.

Nope, it is not because of threaded irq patch but MSC_SCAN event generation. Not to worry.

I'm sorry for the commotion, but I did the test in a wrong way. I thought Dmitry has sent me a patch with the threaded irq already integrated. Joonyoung Shim has pointed me that I was wrong. I had to apply the threaded irq patch on top of the patch Dmitry has sent me.

Quoted 5 lines

To sum up - the threaded irq version does not work here on ARM S3C6410 NCP board. In /proc/interrupts I only noticed that only 1 interrupt has been triggered. No events are reported. Same was with Melfas Touchscreen driver (also only 1 interrupt triggered).

Now that most issues have with threaded IRQs have been fixed in mainline would you mind retesting the threaded IRQ patch? Below is the latest version of it.

Thanks!

Signature · 14 lines
Dmitry

Input: max7359 - use threaded IRQs

From: Dmitry Torokhov <[email protected]>

Convert max7359 driver to use IRQ threading instead of using
workqueue.

Signed-off-by: Dmitry Torokhov <[email protected]>
---

 drivers/input/keyboard/max7359_keypad.c |   47 ++++++++-----------------------
 1 files changed, 12 insertions(+), 35 deletions(-)
drivers/input/keyboard/max7359_keypad.c +12 -35
index 8b3ee14..768c204 100644
@@ -58,12 +58,8 @@ struct max7359_keypad {
 	/* matrix key code map */
 	unsigned short keycodes[MAX7359_MAX_KEY_NUM];
 
-	struct work_struct work;
-
 	struct input_dev *input_dev;
 	struct i2c_client *client;
-
-	u32 irq;
 };
 
 static int max7359_write_reg(struct i2c_client *client, u8 reg, u8 val)
@@ -106,10 +102,10 @@ static void max7359_build_keycode(struct max7359_keypad *keypad,
 	__clear_bit(KEY_RESERVED, input_dev->keybit);
 }
 
-static void max7359_worker(struct work_struct *work)
+/* runs in an IRQ thread -- can (and will!) sleep */
+static irqreturn_t max7359_interrupt(int irq, void *dev_id)
 {
-	struct max7359_keypad *keypad =
-			container_of(work, struct max7359_keypad, work);
+	struct max7359_keypad *keypad = dev_id;
 	struct input_dev *input_dev = keypad->input_dev;
 	int val, row, col, release, code;
 
@@ -120,25 +116,13 @@ static void max7359_worker(struct work_struct *work)
 
 	code = MATRIX_SCAN_CODE(row, col, MAX7359_ROW_SHIFT);
 
+	dev_dbg(&keypad->client->dev,
+		"key[%d:%d] %s\n", row, col, release ? "release" : "press");
+
 	input_event(input_dev, EV_MSC, MSC_SCAN, code);
 	input_report_key(input_dev, keypad->keycodes[code], !release);
 	input_sync(input_dev);
 
-	enable_irq(keypad->irq);
-
-	dev_dbg(&keypad->client->dev, "key[%d:%d] %s\n", row, col,
-					(release ? "release" : "press"));
-}
-
-static irqreturn_t max7359_interrupt(int irq, void *dev_id)
-{
-	struct max7359_keypad *keypad = dev_id;
-
-	if (!work_pending(&keypad->work)) {
-		disable_irq_nosync(keypad->irq);
-		schedule_work(&keypad->work);
-	}
-
 	return IRQ_HANDLED;
 }
 
@@ -226,8 +210,6 @@ static int __devinit max7359_probe(struct i2c_client *client,
 
 	keypad->client = client;
 	keypad->input_dev = input_dev;
-	keypad->irq = client->irq;
-	INIT_WORK(&keypad->work, max7359_worker);
 
 	input_dev->name = client->name;
 	input_dev->id.bustype = BUS_I2C;
@@ -245,8 +227,8 @@ static int __devinit max7359_probe(struct i2c_client *client,
 
 	max7359_build_keycode(keypad, keymap_data);
 
-	error = request_irq(keypad->irq, max7359_interrupt,
-			    IRQF_TRIGGER_LOW, client->name, keypad);
+	error = request_threaded_irq(client->irq, NULL, max7359_interrupt,
+				     IRQF_TRIGGER_LOW, client->name, keypad);
 	if (error) {
 		dev_err(&client->dev, "failed to register interrupt\n");
 		goto failed_free_mem;
@@ -268,7 +250,7 @@ static int __devinit max7359_probe(struct i2c_client *client,
 	return 0;
 
 failed_free_irq:
-	free_irq(keypad->irq, keypad);
+	free_irq(client->irq, keypad);
 failed_free_mem:
 	input_free_device(input_dev);
 	kfree(keypad);
@@ -279,9 +261,8 @@ static int __devexit max7359_remove(struct i2c_client *client)
 {
 	struct max7359_keypad *keypad = i2c_get_clientdata(client);
 
-	cancel_work_sync(&keypad->work);
+	free_irq(client->irq, keypad);
 	input_unregister_device(keypad->input_dev);
-	free_irq(keypad->irq, keypad);
 	i2c_set_clientdata(client, NULL);
 	kfree(keypad);
 
@@ -291,22 +272,18 @@ static int __devexit max7359_remove(struct i2c_client *client)
 #ifdef CONFIG_PM
 static int max7359_suspend(struct i2c_client *client, pm_message_t mesg)
 {
-	struct max7359_keypad *keypad = i2c_get_clientdata(client);
-
 	max7359_fall_deepsleep(client);
 
 	if (device_may_wakeup(&client->dev))
-		enable_irq_wake(keypad->irq);
+		enable_irq_wake(client->irq);
 
 	return 0;
 }
 
 static int max7359_resume(struct i2c_client *client)
 {
-	struct max7359_keypad *keypad = i2c_get_clientdata(client);
-
 	if (device_may_wakeup(&client->dev))
-		disable_irq_wake(keypad->irq);
+		disable_irq_wake(client->irq);
 
 	/* Restore the default setting */
 	max7359_take_catnap(client);

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#20 lore raw
Quoted 133 lines · Dmitry Torokhov
Quoted 126 lines · Marek Szyprowski

Hello,

Quoted 110 lines · Trilok Soni
Quoted 75 lines · Marek Szyprowski

Hello,

Quoted 36 lines · Trilok Soni
Quoted 34 lines · Marek Szyprowski

Hello,

Quoted 16 lines · Dmitry Torokhov
Quoted 15 lines · Marek Szyprowski

Hello,

Quoted 13 lines · Kim Kyuwon
Quoted 8 lines · Dmitry Torokhov
Quoted 4 lines · Trilok Soni

I don't see this driver picked up yet in your -next branch. We should target this driver to be mainlined in next merge window. This is very important driver for some of the embedded systems, including palm pre :)

I was wondering if somebody could test the patch below and if it still works then I will apply to the next branch. Thanks!

Dear Marek,

Because I don't have the NCP board(which includes the max7359 keypad) now, I can't test this patch. Marek, could you please test this patch?

Quoted 8 lines
Quoted 7 lines

I would like to, but I could not find the base version to which I can apply that patch. I've tried v2 version posted in '[PATCH] Input: add MAX7359 key switch controller driver, v2' mail from Sat 2009-05-09 04:10 with 2 patches posted in replies to that main, but the latest patch still fails to apply.

Could someone send me a complete patch, so I can do a test?

Sending everything as attachments, maybe that will help...

Ok. I've did the tests.

MAX7359 keypad driver works after your patch, but reports much more events than the previous version. In this test I pressed quickly the first button on the keypad.

Quoted 8 lines
Quoted 7 lines

Old version:

NCP:~# hexdump /dev/input/event0
0000000 0037 0000 e733 000b 0001 00e7 0001 0000
0000010 0037 0000 e748 000b 0000 0000 0000 0000
0000020 0037 0000 94e2 000d 0001 00e7 0000 0000
0000030 0037 0000 94f3 000d 0000 0000 0000 0000

Please use evtest instead. It will give better output atleast.

Ok.

Old version (clean v2 patch):

NCP:~# evtest /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "max7359"
Supported events:
잾vent type 0 (Sync)
잾vent type 1 (Key)
  잾vent code 107 (End)
  잾vent code 139 (Menu)
  잾vent code 148 (Prog1)
  잾vent code 149 (Prog2)
  잾vent code 177 (ScrollUp)
  잾vent code 178 (ScrollDown)
  잾vent code 212 (Camera)
  잾vent code 231 (?)
  잾vent code 474 (?)
잾vent type 20 (Repeat)
Testing ... (interrupt to exit)
Event: time 38.740081, type 1 (Key), code 139 (Menu), value 1
Event: time 38.740101, -------------- Report Sync ------------
Event: time 38.850061, type 1 (Key), code 139 (Menu), value 0
Event: time 38.850077, -------------- Report Sync ------------
Quoted 1 line

New version (updated platform definition to use struct matrix_keymap_data instead of

max7359_keypad_platform_data):

Quoted 31 lines
NCP:~# evtest /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "max7359"
Supported events:
잾vent type 0 (Sync)
잾vent type 1 (Key)
  잾vent code 107 (End)
  잾vent code 139 (Menu)
  잾vent code 148 (Prog1)
  잾vent code 149 (Prog2)
  잾vent code 177 (ScrollUp)
  잾vent code 178 (ScrollDown)
  잾vent code 212 (Camera)
  잾vent code 231 (?)
  잾vent code 474 (?)
잾vent type 4 (Misc)
  잾vent code 4 (ScanCode)
잾vent type 20 (Repeat)
Testing ... (interrupt to exit)
Event: time 75.680066, type 4 (Misc), code 4 (ScanCode), value 01
Event: time 75.680095, type 1 (Key), code 139 (Menu), value 1
Event: time 75.680107, -------------- Report Sync ------------
Event: time 75.700072, type 4 (Misc), code 4 (ScanCode), value 3f
Event: time 75.700095, -------------- Report Sync ------------
Event: time 75.830064, type 4 (Misc), code 4 (ScanCode), value 01
Event: time 75.830093, type 1 (Key), code 139 (Menu), value 0
Event: time 75.830100, -------------- Report Sync ------------
Event: time 75.850073, type 4 (Misc), code 4 (ScanCode), value 3f
Event: time 75.850097, -------------- Report Sync ------------
Quoted 6 lines
Quoted 1 line

Something is definitely different. It looks that I missed a patch that added some additional events,

because I don't think that the

Quoted 2 lines

threaded irq patch would cause this.

Nope, it is not because of threaded irq patch but MSC_SCAN event generation. Not to worry.

I'm sorry for the commotion, but I did the test in a wrong way. I thought Dmitry has sent me a patch with the threaded irq already integrated. Joonyoung Shim has pointed me that I was wrong. I had to apply the threaded irq patch on top of the patch Dmitry has sent me.

Quoted 5 lines

To sum up - the threaded irq version does not work here on ARM S3C6410 NCP board. In /proc/interrupts I only noticed that only 1 interrupt has been triggered. No events are reported. Same was with Melfas Touchscreen driver (also only 1 interrupt triggered).

Quoted 6 lines

Now that most issues have with threaded IRQs have been fixed in mainline would you mind retesting the threaded IRQ patch? Below is the latest version of it.

Thanks!

Hi, Dmitry.

I tested your patch with threaded IRQ. Because the interrupt of the MAX7359 device is the low level detecting, i should add the IRQF_ONESHOT flag on request_threaded_irq(). If it is added IRQF_ONESHOT flag, the it operates well.

Do you want i send the patch?
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#21 lore raw

Hi Joonyoung,

Quoted 7 lines · Joonyoung Shim

Hi, Dmitry.

I tested your patch with threaded IRQ. Because the interrupt of the MAX7359 device is the low level detecting, i should add the IRQF_ONESHOT flag on request_threaded_irq(). If it is added IRQF_ONESHOT flag, the it operates well.

Thank you for testing.

Quoted 1 line

Do you want i send the patch?

No, I fixed it locally. I took the liberty of marking the patch as "Tested-by" you, I hope you don't mind.

Signature · 1 line
Dmitry
#22 lore raw

2009/9/19 Dmitry Torokhov <[email protected]>:

Quoted 11 lines

Hi Joonyoung,

Quoted 7 lines · Joonyoung Shim

Hi, Dmitry.

I tested your patch with threaded IRQ. Because the interrupt of the MAX7359 device is the low level detecting, i should add the IRQF_ONESHOT flag on request_threaded_irq(). If it is added IRQF_ONESHOT flag, the it operates well.

Quoted 7 lines

Thank you for testing.

Quoted 1 line

Do you want i send the patch?

No, I fixed it locally. I took the liberty of marking the patch as "Tested-by" you, I hope you don't mind.

OK. Thanks.

Signature · 1 line
- Joonyoung Shim