linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts
@ 2017-02-28 22:46 Dmitry Torokhov
  2017-02-28 22:46 ` [PATCH 02/10] Input: eeti_ts - use BIT(n) Dmitry Torokhov
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2017-02-28 22:46 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Haojian Zhuang, Robert Jarzmik, linux-kernel, linux-input

Also rename 'priv' variables to eeti.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

Hi,

This is all is not tested as I do not have the hardware, so if anyone
has raumfeld device that would be awesome.

 drivers/input/touchscreen/eeti_ts.c | 115 ++++++++++++++++++------------------
 1 file changed, 58 insertions(+), 57 deletions(-)

diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index 16023867b9da..74d57ef68663 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -43,7 +43,7 @@ static bool flip_y;
 module_param(flip_y, bool, 0644);
 MODULE_PARM_DESC(flip_y, "flip y coordinate");
 
-struct eeti_ts_priv {
+struct eeti_ts {
 	struct i2c_client *client;
 	struct input_dev *input;
 	struct work_struct work;
@@ -60,25 +60,25 @@ struct eeti_ts_priv {
 #define REPORT_BIT_HAS_PRESSURE	(1 << 6)
 #define REPORT_RES_BITS(v)	(((v) >> 1) + EETI_TS_BITDEPTH)
 
-static inline int eeti_ts_irq_active(struct eeti_ts_priv *priv)
+static inline int eeti_ts_irq_active(struct eeti_ts *eeti)
 {
-	return gpio_get_value(priv->irq_gpio) == priv->irq_active_high;
+	return gpio_get_value(eeti->irq_gpio) == eeti->irq_active_high;
 }
 
 static void eeti_ts_read(struct work_struct *work)
 {
 	char buf[6];
 	unsigned int x, y, res, pressed, to = 100;
-	struct eeti_ts_priv *priv =
-		container_of(work, struct eeti_ts_priv, work);
+	struct eeti_ts *eeti =
+		container_of(work, struct eeti_ts, work);
 
-	mutex_lock(&priv->mutex);
+	mutex_lock(&eeti->mutex);
 
-	while (eeti_ts_irq_active(priv) && --to)
-		i2c_master_recv(priv->client, buf, sizeof(buf));
+	while (eeti_ts_irq_active(eeti) && --to)
+		i2c_master_recv(eeti->client, buf, sizeof(buf));
 
 	if (!to) {
-		dev_err(&priv->client->dev,
+		dev_err(&eeti->client->dev,
 			"unable to clear IRQ - line stuck?\n");
 		goto out;
 	}
@@ -103,62 +103,62 @@ static void eeti_ts_read(struct work_struct *work)
 		y = EETI_MAXVAL - y;
 
 	if (buf[0] & REPORT_BIT_HAS_PRESSURE)
-		input_report_abs(priv->input, ABS_PRESSURE, buf[5]);
+		input_report_abs(eeti->input, ABS_PRESSURE, buf[5]);
 
-	input_report_abs(priv->input, ABS_X, x);
-	input_report_abs(priv->input, ABS_Y, y);
-	input_report_key(priv->input, BTN_TOUCH, !!pressed);
-	input_sync(priv->input);
+	input_report_abs(eeti->input, ABS_X, x);
+	input_report_abs(eeti->input, ABS_Y, y);
+	input_report_key(eeti->input, BTN_TOUCH, !!pressed);
+	input_sync(eeti->input);
 
 out:
-	mutex_unlock(&priv->mutex);
+	mutex_unlock(&eeti->mutex);
 }
 
 static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
 {
-	struct eeti_ts_priv *priv = dev_id;
+	struct eeti_ts *eeti = dev_id;
 
 	 /* postpone I2C transactions as we are atomic */
-	schedule_work(&priv->work);
+	schedule_work(&eeti->work);
 
 	return IRQ_HANDLED;
 }
 
-static void eeti_ts_start(struct eeti_ts_priv *priv)
+static void eeti_ts_start(struct eeti_ts *eeti)
 {
-	enable_irq(priv->irq);
+	enable_irq(eeti->irq);
 
 	/* Read the events once to arm the IRQ */
-	eeti_ts_read(&priv->work);
+	eeti_ts_read(&eeti->work);
 }
 
-static void eeti_ts_stop(struct eeti_ts_priv *priv)
+static void eeti_ts_stop(struct eeti_ts *eeti)
 {
-	disable_irq(priv->irq);
-	cancel_work_sync(&priv->work);
+	disable_irq(eeti->irq);
+	cancel_work_sync(&eeti->work);
 }
 
 static int eeti_ts_open(struct input_dev *dev)
 {
-	struct eeti_ts_priv *priv = input_get_drvdata(dev);
+	struct eeti_ts *eeti = input_get_drvdata(dev);
 
-	eeti_ts_start(priv);
+	eeti_ts_start(eeti);
 
 	return 0;
 }
 
 static void eeti_ts_close(struct input_dev *dev)
 {
-	struct eeti_ts_priv *priv = input_get_drvdata(dev);
+	struct eeti_ts *eeti = input_get_drvdata(dev);
 
-	eeti_ts_stop(priv);
+	eeti_ts_stop(eeti);
 }
 
 static int eeti_ts_probe(struct i2c_client *client,
 				   const struct i2c_device_id *idp)
 {
 	struct eeti_ts_platform_data *pdata = dev_get_platdata(&client->dev);
-	struct eeti_ts_priv *priv;
+	struct eeti_ts *eeti;
 	struct input_dev *input;
 	unsigned int irq_flags;
 	int err = -ENOMEM;
@@ -170,13 +170,14 @@ static int eeti_ts_probe(struct i2c_client *client,
 	 * for interrupts to occur.
 	 */
 
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv) {
+	eeti = kzalloc(sizeof(*eeti), GFP_KERNEL);
+	if (!eeti) {
 		dev_err(&client->dev, "failed to allocate driver data\n");
 		return -ENOMEM;
 	}
 
-	mutex_init(&priv->mutex);
+	mutex_init(&eeti->mutex);
+
 	input = input_allocate_device();
 	if (!input) {
 		dev_err(&client->dev, "Failed to allocate input device.\n");
@@ -196,30 +197,30 @@ static int eeti_ts_probe(struct i2c_client *client,
 	input->open = eeti_ts_open;
 	input->close = eeti_ts_close;
 
-	priv->client = client;
-	priv->input = input;
-	priv->irq_gpio = pdata->irq_gpio;
-	priv->irq = gpio_to_irq(pdata->irq_gpio);
+	eeti->client = client;
+	eeti->input = input;
+	eeti->irq_gpio = pdata->irq_gpio;
+	eeti->irq = gpio_to_irq(pdata->irq_gpio);
 
 	err = gpio_request_one(pdata->irq_gpio, GPIOF_IN, client->name);
 	if (err < 0)
 		goto err1;
 
-	priv->irq_active_high = pdata->irq_active_high;
+	eeti->irq_active_high = pdata->irq_active_high;
 
-	irq_flags = priv->irq_active_high ?
+	irq_flags = eeti->irq_active_high ?
 		IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
 
-	INIT_WORK(&priv->work, eeti_ts_read);
-	i2c_set_clientdata(client, priv);
-	input_set_drvdata(input, priv);
+	INIT_WORK(&eeti->work, eeti_ts_read);
+	i2c_set_clientdata(client, eeti);
+	input_set_drvdata(input, eeti);
 
 	err = input_register_device(input);
 	if (err)
 		goto err2;
 
-	err = request_irq(priv->irq, eeti_ts_isr, irq_flags,
-			  client->name, priv);
+	err = request_irq(eeti->irq, eeti_ts_isr, irq_flags,
+			  client->name, eeti);
 	if (err) {
 		dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
 		goto err3;
@@ -229,7 +230,7 @@ static int eeti_ts_probe(struct i2c_client *client,
 	 * Disable the device for now. It will be enabled once the
 	 * input device is opened.
 	 */
-	eeti_ts_stop(priv);
+	eeti_ts_stop(eeti);
 
 	return 0;
 
@@ -240,23 +241,23 @@ static int eeti_ts_probe(struct i2c_client *client,
 	gpio_free(pdata->irq_gpio);
 err1:
 	input_free_device(input);
-	kfree(priv);
+	kfree(eeti);
 	return err;
 }
 
 static int eeti_ts_remove(struct i2c_client *client)
 {
-	struct eeti_ts_priv *priv = i2c_get_clientdata(client);
+	struct eeti_ts *eeti = i2c_get_clientdata(client);
 
-	free_irq(priv->irq, priv);
+	free_irq(eeti->irq, eeti);
 	/*
 	 * eeti_ts_stop() leaves IRQ disabled. We need to re-enable it
 	 * so that device still works if we reload the driver.
 	 */
-	enable_irq(priv->irq);
+	enable_irq(eeti->irq);
 
-	input_unregister_device(priv->input);
-	kfree(priv);
+	input_unregister_device(eeti->input);
+	kfree(eeti);
 
 	return 0;
 }
@@ -264,18 +265,18 @@ static int eeti_ts_remove(struct i2c_client *client)
 static int __maybe_unused eeti_ts_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	struct eeti_ts_priv *priv = i2c_get_clientdata(client);
-	struct input_dev *input_dev = priv->input;
+	struct eeti_ts *eeti = i2c_get_clientdata(client);
+	struct input_dev *input_dev = eeti->input;
 
 	mutex_lock(&input_dev->mutex);
 
 	if (input_dev->users)
-		eeti_ts_stop(priv);
+		eeti_ts_stop(eeti);
 
 	mutex_unlock(&input_dev->mutex);
 
 	if (device_may_wakeup(&client->dev))
-		enable_irq_wake(priv->irq);
+		enable_irq_wake(eeti->irq);
 
 	return 0;
 }
@@ -283,16 +284,16 @@ static int __maybe_unused eeti_ts_suspend(struct device *dev)
 static int __maybe_unused eeti_ts_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	struct eeti_ts_priv *priv = i2c_get_clientdata(client);
-	struct input_dev *input_dev = priv->input;
+	struct eeti_ts *eeti = i2c_get_clientdata(client);
+	struct input_dev *input_dev = eeti->input;
 
 	if (device_may_wakeup(&client->dev))
-		disable_irq_wake(priv->irq);
+		disable_irq_wake(eeti->irq);
 
 	mutex_lock(&input_dev->mutex);
 
 	if (input_dev->users)
-		eeti_ts_start(priv);
+		eeti_ts_start(eeti);
 
 	mutex_unlock(&input_dev->mutex);
 
-- 
2.11.0.483.g087da7b7c-goog

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

* [PATCH 02/10] Input: eeti_ts - use BIT(n)
  2017-02-28 22:46 [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov
@ 2017-02-28 22:46 ` Dmitry Torokhov
  2017-02-28 22:46 ` [PATCH 03/10] Input: eeti_ts - use get_unaligned_be16() to retrieve data Dmitry Torokhov
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2017-02-28 22:46 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Haojian Zhuang, Robert Jarzmik, linux-kernel, linux-input

Use idiomatic BIT(n) to form single-bit masks.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/eeti_ts.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index 74d57ef68663..26b52496748a 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -54,10 +54,10 @@ struct eeti_ts {
 #define EETI_TS_BITDEPTH	(11)
 #define EETI_MAXVAL		((1 << (EETI_TS_BITDEPTH + 1)) - 1)
 
-#define REPORT_BIT_PRESSED	(1 << 0)
-#define REPORT_BIT_AD0		(1 << 1)
-#define REPORT_BIT_AD1		(1 << 2)
-#define REPORT_BIT_HAS_PRESSURE	(1 << 6)
+#define REPORT_BIT_PRESSED	BIT(0)
+#define REPORT_BIT_AD0		BIT(1)
+#define REPORT_BIT_AD1		BIT(2)
+#define REPORT_BIT_HAS_PRESSURE	BIT(6)
 #define REPORT_RES_BITS(v)	(((v) >> 1) + EETI_TS_BITDEPTH)
 
 static inline int eeti_ts_irq_active(struct eeti_ts *eeti)
-- 
2.11.0.483.g087da7b7c-goog

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

* [PATCH 03/10] Input: eeti_ts - use get_unaligned_be16() to retrieve data
  2017-02-28 22:46 [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov
  2017-02-28 22:46 ` [PATCH 02/10] Input: eeti_ts - use BIT(n) Dmitry Torokhov
@ 2017-02-28 22:46 ` Dmitry Torokhov
  2017-02-28 22:46 ` [PATCH 04/10] Input: eeti_ts - use input_set_capability() Dmitry Torokhov
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2017-02-28 22:46 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Haojian Zhuang, Robert Jarzmik, linux-kernel, linux-input

Instead of manually converting big endian data on wire into host
endianness, let's use helpers to do that for us. It might save us
a few cycles if host endianness matches what's on wire.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/eeti_ts.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index 26b52496748a..0e4b19236d68 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -34,6 +34,7 @@
 #include <linux/gpio.h>
 #include <linux/input/eeti_ts.h>
 #include <linux/slab.h>
+#include <asm/unaligned.h>
 
 static bool flip_x;
 module_param(flip_x, bool, 0644);
@@ -89,8 +90,9 @@ static void eeti_ts_read(struct work_struct *work)
 
 	pressed = buf[0] & REPORT_BIT_PRESSED;
 	res = REPORT_RES_BITS(buf[0] & (REPORT_BIT_AD0 | REPORT_BIT_AD1));
-	x = buf[2] | (buf[1] << 8);
-	y = buf[4] | (buf[3] << 8);
+
+	x = get_unaligned_be16(&buf[1]);
+	y = get_unaligned_be16(&buf[3]);
 
 	/* fix the range to 11 bits */
 	x >>= res - EETI_TS_BITDEPTH;
-- 
2.11.0.483.g087da7b7c-goog

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

* [PATCH 04/10] Input: eeti_ts - use input_set_capability()
  2017-02-28 22:46 [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov
  2017-02-28 22:46 ` [PATCH 02/10] Input: eeti_ts - use BIT(n) Dmitry Torokhov
  2017-02-28 22:46 ` [PATCH 03/10] Input: eeti_ts - use get_unaligned_be16() to retrieve data Dmitry Torokhov
@ 2017-02-28 22:46 ` Dmitry Torokhov
  2017-02-28 22:46 ` [PATCH 05/10] Input: eeti-ts - switch to using managed resources Dmitry Torokhov
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2017-02-28 22:46 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Haojian Zhuang, Robert Jarzmik, linux-kernel, linux-input

Use input_set_capability() instead of manipulating evbit/keybit
masks directly.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/eeti_ts.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index 0e4b19236d68..b472e0e467e8 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -186,8 +186,7 @@ static int eeti_ts_probe(struct i2c_client *client,
 		goto err1;
 	}
 
-	input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-	input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
+	input_set_capability(input, EV_KEY, BTN_TOUCH);
 
 	input_set_abs_params(input, ABS_X, 0, EETI_MAXVAL, 0, 0);
 	input_set_abs_params(input, ABS_Y, 0, EETI_MAXVAL, 0, 0);
-- 
2.11.0.483.g087da7b7c-goog

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

* [PATCH 05/10] Input: eeti-ts - switch to using managed resources
  2017-02-28 22:46 [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov
                   ` (2 preceding siblings ...)
  2017-02-28 22:46 ` [PATCH 04/10] Input: eeti_ts - use input_set_capability() Dmitry Torokhov
@ 2017-02-28 22:46 ` Dmitry Torokhov
  2017-02-28 22:46 ` [PATCH 06/10] Input: eeti_ts - respect interrupt set in client structure Dmitry Torokhov
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2017-02-28 22:46 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Haojian Zhuang, Robert Jarzmik, linux-kernel, linux-input

Using devm_* APIs simpifies error handling and device teardown.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/eeti_ts.c | 70 ++++++++++++-------------------------
 1 file changed, 22 insertions(+), 48 deletions(-)

diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index b472e0e467e8..e99e4fec93f5 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -157,13 +157,14 @@ static void eeti_ts_close(struct input_dev *dev)
 }
 
 static int eeti_ts_probe(struct i2c_client *client,
-				   const struct i2c_device_id *idp)
+			 const struct i2c_device_id *idp)
 {
-	struct eeti_ts_platform_data *pdata = dev_get_platdata(&client->dev);
+	struct device *dev = &client->dev;
+	struct eeti_ts_platform_data *pdata = dev_get_platdata(dev);
 	struct eeti_ts *eeti;
 	struct input_dev *input;
 	unsigned int irq_flags;
-	int err = -ENOMEM;
+	int error;
 
 	/*
 	 * In contrast to what's described in the datasheet, there seems
@@ -172,18 +173,18 @@ static int eeti_ts_probe(struct i2c_client *client,
 	 * for interrupts to occur.
 	 */
 
-	eeti = kzalloc(sizeof(*eeti), GFP_KERNEL);
+	eeti = devm_kzalloc(dev, sizeof(*eeti), GFP_KERNEL);
 	if (!eeti) {
-		dev_err(&client->dev, "failed to allocate driver data\n");
+		dev_err(dev, "failed to allocate driver data\n");
 		return -ENOMEM;
 	}
 
 	mutex_init(&eeti->mutex);
 
-	input = input_allocate_device();
+	input = devm_input_allocate_device(dev);
 	if (!input) {
-		dev_err(&client->dev, "Failed to allocate input device.\n");
-		goto err1;
+		dev_err(dev, "Failed to allocate input device.\n");
+		return -ENOMEM;
 	}
 
 	input_set_capability(input, EV_KEY, BTN_TOUCH);
@@ -194,7 +195,6 @@ static int eeti_ts_probe(struct i2c_client *client,
 
 	input->name = client->name;
 	input->id.bustype = BUS_I2C;
-	input->dev.parent = &client->dev;
 	input->open = eeti_ts_open;
 	input->close = eeti_ts_close;
 
@@ -203,9 +203,10 @@ static int eeti_ts_probe(struct i2c_client *client,
 	eeti->irq_gpio = pdata->irq_gpio;
 	eeti->irq = gpio_to_irq(pdata->irq_gpio);
 
-	err = gpio_request_one(pdata->irq_gpio, GPIOF_IN, client->name);
-	if (err < 0)
-		goto err1;
+	error = devm_gpio_request_one(dev, pdata->irq_gpio, GPIOF_IN,
+				      client->name);
+	if (error)
+		return error;
 
 	eeti->irq_active_high = pdata->irq_active_high;
 
@@ -216,15 +217,16 @@ static int eeti_ts_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, eeti);
 	input_set_drvdata(input, eeti);
 
-	err = input_register_device(input);
-	if (err)
-		goto err2;
+	error = input_register_device(input);
+	if (error)
+		return error;
 
-	err = request_irq(eeti->irq, eeti_ts_isr, irq_flags,
-			  client->name, eeti);
-	if (err) {
-		dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
-		goto err3;
+	error = devm_request_irq(dev, eeti->irq, eeti_ts_isr, irq_flags,
+				 client->name, eeti);
+	if (error) {
+		dev_err(dev, "Unable to request touchscreen IRQ: %d\n",
+			error);
+		return error;
 	}
 
 	/*
@@ -234,33 +236,6 @@ static int eeti_ts_probe(struct i2c_client *client,
 	eeti_ts_stop(eeti);
 
 	return 0;
-
-err3:
-	input_unregister_device(input);
-	input = NULL; /* so we dont try to free it below */
-err2:
-	gpio_free(pdata->irq_gpio);
-err1:
-	input_free_device(input);
-	kfree(eeti);
-	return err;
-}
-
-static int eeti_ts_remove(struct i2c_client *client)
-{
-	struct eeti_ts *eeti = i2c_get_clientdata(client);
-
-	free_irq(eeti->irq, eeti);
-	/*
-	 * eeti_ts_stop() leaves IRQ disabled. We need to re-enable it
-	 * so that device still works if we reload the driver.
-	 */
-	enable_irq(eeti->irq);
-
-	input_unregister_device(eeti->input);
-	kfree(eeti);
-
-	return 0;
 }
 
 static int __maybe_unused eeti_ts_suspend(struct device *dev)
@@ -315,7 +290,6 @@ static struct i2c_driver eeti_ts_driver = {
 		.pm = &eeti_ts_pm,
 	},
 	.probe = eeti_ts_probe,
-	.remove = eeti_ts_remove,
 	.id_table = eeti_ts_id,
 };
 
-- 
2.11.0.483.g087da7b7c-goog

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

* [PATCH 06/10] Input: eeti_ts - respect interrupt set in client structure
  2017-02-28 22:46 [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov
                   ` (3 preceding siblings ...)
  2017-02-28 22:46 ` [PATCH 05/10] Input: eeti-ts - switch to using managed resources Dmitry Torokhov
@ 2017-02-28 22:46 ` Dmitry Torokhov
  2017-02-28 22:46 ` [PATCH 07/10] Input: eeti_ts - use gpio_get_value_cansleep Dmitry Torokhov
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2017-02-28 22:46 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Haojian Zhuang, Robert Jarzmik, linux-kernel, linux-input

Instead of expecting that GPIO is always interrupt source, let's use
interrupt specified in I2C client.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 arch/arm/mach-pxa/raumfeld.c        |  1 +
 drivers/input/touchscreen/eeti_ts.c | 13 ++++++-------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c
index c27ce1f070d2..94df8e23fdb5 100644
--- a/arch/arm/mach-pxa/raumfeld.c
+++ b/arch/arm/mach-pxa/raumfeld.c
@@ -973,6 +973,7 @@ static struct eeti_ts_platform_data eeti_ts_pdata = {
 static struct i2c_board_info raumfeld_controller_i2c_board_info __initdata = {
 	.type	= "eeti_ts",
 	.addr	= 0x0a,
+	.irq	= PXA_GPIO_TO_IRQ(GPIO_TOUCH_IRQ),
 	.platform_data = &eeti_ts_pdata,
 };
 
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index e99e4fec93f5..ac78ac6d4936 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -49,7 +49,7 @@ struct eeti_ts {
 	struct input_dev *input;
 	struct work_struct work;
 	struct mutex mutex;
-	int irq_gpio, irq, irq_active_high;
+	int irq_gpio, irq_active_high;
 };
 
 #define EETI_TS_BITDEPTH	(11)
@@ -128,7 +128,7 @@ static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
 
 static void eeti_ts_start(struct eeti_ts *eeti)
 {
-	enable_irq(eeti->irq);
+	enable_irq(eeti->client->irq);
 
 	/* Read the events once to arm the IRQ */
 	eeti_ts_read(&eeti->work);
@@ -136,7 +136,7 @@ static void eeti_ts_start(struct eeti_ts *eeti)
 
 static void eeti_ts_stop(struct eeti_ts *eeti)
 {
-	disable_irq(eeti->irq);
+	disable_irq(eeti->client->irq);
 	cancel_work_sync(&eeti->work);
 }
 
@@ -201,7 +201,6 @@ static int eeti_ts_probe(struct i2c_client *client,
 	eeti->client = client;
 	eeti->input = input;
 	eeti->irq_gpio = pdata->irq_gpio;
-	eeti->irq = gpio_to_irq(pdata->irq_gpio);
 
 	error = devm_gpio_request_one(dev, pdata->irq_gpio, GPIOF_IN,
 				      client->name);
@@ -221,7 +220,7 @@ static int eeti_ts_probe(struct i2c_client *client,
 	if (error)
 		return error;
 
-	error = devm_request_irq(dev, eeti->irq, eeti_ts_isr, irq_flags,
+	error = devm_request_irq(dev, client->irq, eeti_ts_isr, irq_flags,
 				 client->name, eeti);
 	if (error) {
 		dev_err(dev, "Unable to request touchscreen IRQ: %d\n",
@@ -252,7 +251,7 @@ static int __maybe_unused eeti_ts_suspend(struct device *dev)
 	mutex_unlock(&input_dev->mutex);
 
 	if (device_may_wakeup(&client->dev))
-		enable_irq_wake(eeti->irq);
+		enable_irq_wake(client->irq);
 
 	return 0;
 }
@@ -264,7 +263,7 @@ static int __maybe_unused eeti_ts_resume(struct device *dev)
 	struct input_dev *input_dev = eeti->input;
 
 	if (device_may_wakeup(&client->dev))
-		disable_irq_wake(eeti->irq);
+		disable_irq_wake(client->irq);
 
 	mutex_lock(&input_dev->mutex);
 
-- 
2.11.0.483.g087da7b7c-goog

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

* [PATCH 07/10] Input: eeti_ts - use gpio_get_value_cansleep
  2017-02-28 22:46 [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov
                   ` (4 preceding siblings ...)
  2017-02-28 22:46 ` [PATCH 06/10] Input: eeti_ts - respect interrupt set in client structure Dmitry Torokhov
@ 2017-02-28 22:46 ` Dmitry Torokhov
  2017-02-28 22:46 ` [PATCH 08/10] Input: eeti_ts - switch to using threaded interrupt Dmitry Torokhov
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2017-02-28 22:46 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Haojian Zhuang, Robert Jarzmik, linux-kernel, linux-input

We are reading GPIO state in a non-atomic context (workqueue), so we can
use "cansleep" variant, and thus make the driver available on systems where
GPIO controllers require sleeping when reading GPIO state.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/eeti_ts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index ac78ac6d4936..fc61dbea4736 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -63,7 +63,7 @@ struct eeti_ts {
 
 static inline int eeti_ts_irq_active(struct eeti_ts *eeti)
 {
-	return gpio_get_value(eeti->irq_gpio) == eeti->irq_active_high;
+	return gpio_get_value_cansleep(eeti->irq_gpio) == eeti->irq_active_high;
 }
 
 static void eeti_ts_read(struct work_struct *work)
-- 
2.11.0.483.g087da7b7c-goog

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

* [PATCH 08/10] Input: eeti_ts - switch to using threaded interrupt
  2017-02-28 22:46 [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov
                   ` (5 preceding siblings ...)
  2017-02-28 22:46 ` [PATCH 07/10] Input: eeti_ts - use gpio_get_value_cansleep Dmitry Torokhov
@ 2017-02-28 22:46 ` Dmitry Torokhov
  2017-02-28 22:46 ` [PATCH 09/10] Input: eeti_ts - expect platform code to set interrupt trigger Dmitry Torokhov
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2017-02-28 22:46 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Haojian Zhuang, Robert Jarzmik, linux-kernel, linux-input

Instead of having standard interrupt handler and manually firing work item
to perform I2C reads, let's switch to threaded interrupts, which were
designed specifically for this purpose.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/eeti_ts.c | 79 +++++++++++++++++--------------------
 1 file changed, 36 insertions(+), 43 deletions(-)

diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index fc61dbea4736..ee6b87c606ef 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -47,9 +47,8 @@ MODULE_PARM_DESC(flip_y, "flip y coordinate");
 struct eeti_ts {
 	struct i2c_client *client;
 	struct input_dev *input;
-	struct work_struct work;
-	struct mutex mutex;
 	int irq_gpio, irq_active_high;
+	bool running;
 };
 
 #define EETI_TS_BITDEPTH	(11)
@@ -66,29 +65,11 @@ static inline int eeti_ts_irq_active(struct eeti_ts *eeti)
 	return gpio_get_value_cansleep(eeti->irq_gpio) == eeti->irq_active_high;
 }
 
-static void eeti_ts_read(struct work_struct *work)
+static void eeti_ts_report_event(struct eeti_ts *eeti, u8 *buf)
 {
-	char buf[6];
-	unsigned int x, y, res, pressed, to = 100;
-	struct eeti_ts *eeti =
-		container_of(work, struct eeti_ts, work);
-
-	mutex_lock(&eeti->mutex);
-
-	while (eeti_ts_irq_active(eeti) && --to)
-		i2c_master_recv(eeti->client, buf, sizeof(buf));
-
-	if (!to) {
-		dev_err(&eeti->client->dev,
-			"unable to clear IRQ - line stuck?\n");
-		goto out;
-	}
+	unsigned int res;
+	u16 x, y;
 
-	/* drop non-report packets */
-	if (!(buf[0] & 0x80))
-		goto out;
-
-	pressed = buf[0] & REPORT_BIT_PRESSED;
 	res = REPORT_RES_BITS(buf[0] & (REPORT_BIT_AD0 | REPORT_BIT_AD1));
 
 	x = get_unaligned_be16(&buf[1]);
@@ -109,35 +90,48 @@ static void eeti_ts_read(struct work_struct *work)
 
 	input_report_abs(eeti->input, ABS_X, x);
 	input_report_abs(eeti->input, ABS_Y, y);
-	input_report_key(eeti->input, BTN_TOUCH, !!pressed);
+	input_report_key(eeti->input, BTN_TOUCH, buf[0] & REPORT_BIT_PRESSED);
 	input_sync(eeti->input);
-
-out:
-	mutex_unlock(&eeti->mutex);
 }
 
 static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
 {
 	struct eeti_ts *eeti = dev_id;
+	int len;
+	int error;
+	char buf[6];
 
-	 /* postpone I2C transactions as we are atomic */
-	schedule_work(&eeti->work);
+	do {
+		len = i2c_master_recv(eeti->client, buf, sizeof(buf));
+		if (len != sizeof(buf)) {
+			error = len < 0 ? len : -EIO;
+			dev_err(&eeti->client->dev,
+				"failed to read touchscreen data: %d\n",
+				error);
+			break;
+		}
+
+		if (buf[0] & 0x80) {
+			/* Motion packet */
+			eeti_ts_report_event(eeti, buf);
+		}
+	} while (eeti->running && eeti_ts_irq_active(eeti));
 
 	return IRQ_HANDLED;
 }
 
 static void eeti_ts_start(struct eeti_ts *eeti)
 {
+	eeti->running = true;
+	wmb();
 	enable_irq(eeti->client->irq);
-
-	/* Read the events once to arm the IRQ */
-	eeti_ts_read(&eeti->work);
 }
 
 static void eeti_ts_stop(struct eeti_ts *eeti)
 {
+	eeti->running = false;
+	wmb();
 	disable_irq(eeti->client->irq);
-	cancel_work_sync(&eeti->work);
 }
 
 static int eeti_ts_open(struct input_dev *dev)
@@ -179,8 +173,6 @@ static int eeti_ts_probe(struct i2c_client *client,
 		return -ENOMEM;
 	}
 
-	mutex_init(&eeti->mutex);
-
 	input = devm_input_allocate_device(dev);
 	if (!input) {
 		dev_err(dev, "Failed to allocate input device.\n");
@@ -210,18 +202,15 @@ static int eeti_ts_probe(struct i2c_client *client,
 	eeti->irq_active_high = pdata->irq_active_high;
 
 	irq_flags = eeti->irq_active_high ?
-		IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
+		IRQF_TRIGGER_HIGH : IRQF_TRIGGER_LOW;
 
-	INIT_WORK(&eeti->work, eeti_ts_read);
 	i2c_set_clientdata(client, eeti);
 	input_set_drvdata(input, eeti);
 
-	error = input_register_device(input);
-	if (error)
-		return error;
-
-	error = devm_request_irq(dev, client->irq, eeti_ts_isr, irq_flags,
-				 client->name, eeti);
+	error = devm_request_threaded_irq(dev, client->irq,
+					  NULL, eeti_ts_isr,
+					  irq_flags | IRQF_ONESHOT,
+					  client->name, eeti);
 	if (error) {
 		dev_err(dev, "Unable to request touchscreen IRQ: %d\n",
 			error);
@@ -234,6 +223,10 @@ static int eeti_ts_probe(struct i2c_client *client,
 	 */
 	eeti_ts_stop(eeti);
 
+	error = input_register_device(input);
+	if (error)
+		return error;
+
 	return 0;
 }
 
-- 
2.11.0.483.g087da7b7c-goog

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

* [PATCH 09/10] Input: eeti_ts - expect platform code to set interrupt trigger
  2017-02-28 22:46 [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov
                   ` (6 preceding siblings ...)
  2017-02-28 22:46 ` [PATCH 08/10] Input: eeti_ts - switch to using threaded interrupt Dmitry Torokhov
@ 2017-02-28 22:46 ` Dmitry Torokhov
  2017-02-28 22:46 ` [PATCH 10/10] Input: eeti_ts - switch to gpiod API Dmitry Torokhov
  2017-03-01  9:28 ` [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Daniel Mack
  9 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2017-02-28 22:46 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Haojian Zhuang, Robert Jarzmik, linux-kernel, linux-input

Instead of keying interrupt trigger off GPIO polarity, let's reply on
platform code to set it up properly for us.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 arch/arm/mach-pxa/raumfeld.c        | 8 ++++++++
 drivers/input/touchscreen/eeti_ts.c | 6 +-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c
index 94df8e23fdb5..80b03193799d 100644
--- a/arch/arm/mach-pxa/raumfeld.c
+++ b/arch/arm/mach-pxa/raumfeld.c
@@ -21,6 +21,7 @@
 #include <linux/property.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
+#include <linux/irq.h>
 #include <linux/gpio.h>
 #include <linux/gpio/machine.h>
 #include <linux/smsc911x.h>
@@ -1055,6 +1056,7 @@ static void __init raumfeld_common_init(void)
 
 static void __init __maybe_unused raumfeld_controller_init(void)
 {
+	struct irq_data *irqd;
 	int ret;
 
 	pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_controller_pin_config));
@@ -1065,6 +1067,12 @@ static void __init __maybe_unused raumfeld_controller_init(void)
 	platform_device_register(&rotary_encoder_device);
 
 	spi_register_board_info(ARRAY_AND_SIZE(controller_spi_devices));
+
+	/* Set up touchscreen interrupt */
+	irqd = irq_get_irq_data(PXA_GPIO_TO_IRQ(GPIO_TOUCH_IRQ));
+	if (irqd)
+		irqd_set_trigger_type(irqd, IRQ_TYPE_LEVEL_HIGH);
+
 	i2c_register_board_info(0, &raumfeld_controller_i2c_board_info, 1);
 
 	ret = gpio_request(GPIO_SHUTDOWN_BATT, "battery shutdown");
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index ee6b87c606ef..3627c7b5f5ec 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -157,7 +157,6 @@ static int eeti_ts_probe(struct i2c_client *client,
 	struct eeti_ts_platform_data *pdata = dev_get_platdata(dev);
 	struct eeti_ts *eeti;
 	struct input_dev *input;
-	unsigned int irq_flags;
 	int error;
 
 	/*
@@ -201,15 +200,12 @@ static int eeti_ts_probe(struct i2c_client *client,
 
 	eeti->irq_active_high = pdata->irq_active_high;
 
-	irq_flags = eeti->irq_active_high ?
-		IRQF_TRIGGER_HIGH : IRQF_TRIGGER_LOW;
-
 	i2c_set_clientdata(client, eeti);
 	input_set_drvdata(input, eeti);
 
 	error = devm_request_threaded_irq(dev, client->irq,
 					  NULL, eeti_ts_isr,
-					  irq_flags | IRQF_ONESHOT,
+					  IRQF_ONESHOT,
 					  client->name, eeti);
 	if (error) {
 		dev_err(dev, "Unable to request touchscreen IRQ: %d\n",
-- 
2.11.0.483.g087da7b7c-goog

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

* [PATCH 10/10] Input: eeti_ts - switch to gpiod API
  2017-02-28 22:46 [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov
                   ` (7 preceding siblings ...)
  2017-02-28 22:46 ` [PATCH 09/10] Input: eeti_ts - expect platform code to set interrupt trigger Dmitry Torokhov
@ 2017-02-28 22:46 ` Dmitry Torokhov
  2017-03-01  9:28 ` [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Daniel Mack
  9 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2017-02-28 22:46 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Haojian Zhuang, Robert Jarzmik, linux-kernel, linux-input

gpiod API allows standard way of specifying GPIO polarity and takes it into
account when reading or setting GPIO state. It also allows us to switch to
common way of obtaining GPIO descriptor and away form legacy platform data.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 arch/arm/mach-pxa/raumfeld.c        | 14 +++++++++-----
 drivers/input/touchscreen/eeti_ts.c | 24 +++++++-----------------
 include/linux/input/eeti_ts.h       | 10 ----------
 3 files changed, 16 insertions(+), 32 deletions(-)
 delete mode 100644 include/linux/input/eeti_ts.h

diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c
index 80b03193799d..b0886ef92d8c 100644
--- a/arch/arm/mach-pxa/raumfeld.c
+++ b/arch/arm/mach-pxa/raumfeld.c
@@ -27,7 +27,6 @@
 #include <linux/smsc911x.h>
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
-#include <linux/input/eeti_ts.h>
 #include <linux/leds.h>
 #include <linux/w1-gpio.h>
 #include <linux/sched.h>
@@ -966,16 +965,19 @@ static struct i2c_board_info raumfeld_connector_i2c_board_info __initdata = {
 	.addr	= 0x48,
 };
 
-static struct eeti_ts_platform_data eeti_ts_pdata = {
-	.irq_active_high = 1,
-	.irq_gpio = GPIO_TOUCH_IRQ,
+static struct gpiod_lookup_table raumfeld_controller_gpios_table = {
+	.dev_id = "0-000a",
+	.table = {
+		GPIO_LOOKUP("gpio-pxa",
+			    GPIO_TOUCH_IRQ, "attn", GPIO_ACTIVE_HIGH),
+		{ },
+	},
 };
 
 static struct i2c_board_info raumfeld_controller_i2c_board_info __initdata = {
 	.type	= "eeti_ts",
 	.addr	= 0x0a,
 	.irq	= PXA_GPIO_TO_IRQ(GPIO_TOUCH_IRQ),
-	.platform_data = &eeti_ts_pdata,
 };
 
 static struct platform_device *raumfeld_common_devices[] = {
@@ -1073,6 +1075,8 @@ static void __init __maybe_unused raumfeld_controller_init(void)
 	if (irqd)
 		irqd_set_trigger_type(irqd, IRQ_TYPE_LEVEL_HIGH);
 
+	gpiod_add_lookup_table(&raumfeld_controller_gpios_table);
+
 	i2c_register_board_info(0, &raumfeld_controller_i2c_board_info, 1);
 
 	ret = gpio_request(GPIO_SHUTDOWN_BATT, "battery shutdown");
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index 3627c7b5f5ec..2facad75eb6d 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -31,8 +31,7 @@
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
 #include <linux/timer.h>
-#include <linux/gpio.h>
-#include <linux/input/eeti_ts.h>
+#include <linux/gpio/consumer.h>
 #include <linux/slab.h>
 #include <asm/unaligned.h>
 
@@ -47,7 +46,7 @@ MODULE_PARM_DESC(flip_y, "flip y coordinate");
 struct eeti_ts {
 	struct i2c_client *client;
 	struct input_dev *input;
-	int irq_gpio, irq_active_high;
+	struct gpio_desc *attn_gpio;
 	bool running;
 };
 
@@ -60,11 +59,6 @@ struct eeti_ts {
 #define REPORT_BIT_HAS_PRESSURE	BIT(6)
 #define REPORT_RES_BITS(v)	(((v) >> 1) + EETI_TS_BITDEPTH)
 
-static inline int eeti_ts_irq_active(struct eeti_ts *eeti)
-{
-	return gpio_get_value_cansleep(eeti->irq_gpio) == eeti->irq_active_high;
-}
-
 static void eeti_ts_report_event(struct eeti_ts *eeti, u8 *buf)
 {
 	unsigned int res;
@@ -115,7 +109,8 @@ static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
 			/* Motion packet */
 			eeti_ts_report_event(eeti, buf);
 		}
-	} while (eeti->running && eeti_ts_irq_active(eeti));
+	} while (eeti->running &&
+		 eeti->attn_gpio && gpiod_get_value_cansleep(eeti->attn_gpio));
 
 	return IRQ_HANDLED;
 }
@@ -154,7 +149,6 @@ static int eeti_ts_probe(struct i2c_client *client,
 			 const struct i2c_device_id *idp)
 {
 	struct device *dev = &client->dev;
-	struct eeti_ts_platform_data *pdata = dev_get_platdata(dev);
 	struct eeti_ts *eeti;
 	struct input_dev *input;
 	int error;
@@ -191,14 +185,10 @@ static int eeti_ts_probe(struct i2c_client *client,
 
 	eeti->client = client;
 	eeti->input = input;
-	eeti->irq_gpio = pdata->irq_gpio;
-
-	error = devm_gpio_request_one(dev, pdata->irq_gpio, GPIOF_IN,
-				      client->name);
-	if (error)
-		return error;
 
-	eeti->irq_active_high = pdata->irq_active_high;
+	eeti->attn_gpio = devm_gpiod_get_optional(dev, "attn", GPIOD_IN);
+	if (IS_ERR(eeti->attn_gpio))
+		return PTR_ERR(eeti->attn_gpio);
 
 	i2c_set_clientdata(client, eeti);
 	input_set_drvdata(input, eeti);
diff --git a/include/linux/input/eeti_ts.h b/include/linux/input/eeti_ts.h
deleted file mode 100644
index 16625d799b6f..000000000000
--- a/include/linux/input/eeti_ts.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef LINUX_INPUT_EETI_TS_H
-#define LINUX_INPUT_EETI_TS_H
-
-struct eeti_ts_platform_data {
-	int irq_gpio;
-	unsigned int irq_active_high;
-};
-
-#endif /* LINUX_INPUT_EETI_TS_H */
-
-- 
2.11.0.483.g087da7b7c-goog

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

* Re: [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts
  2017-02-28 22:46 [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov
                   ` (8 preceding siblings ...)
  2017-02-28 22:46 ` [PATCH 10/10] Input: eeti_ts - switch to gpiod API Dmitry Torokhov
@ 2017-03-01  9:28 ` Daniel Mack
  2017-03-01 17:34   ` Dmitry Torokhov
  9 siblings, 1 reply; 12+ messages in thread
From: Daniel Mack @ 2017-03-01  9:28 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Haojian Zhuang, Robert Jarzmik, linux-kernel, linux-input

Hi Dmitry,

On 02/28/2017 11:46 PM, Dmitry Torokhov wrote:
> Also rename 'priv' variables to eeti.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> 
> Hi,
> 
> This is all is not tested as I do not have the hardware, so if anyone
> has raumfeld device that would be awesome.

I have no access to such hardware for the time being, and the platform
does not currently boot a mainline kernel either.

So I think we should just merge this set, the changes to the driver look
all good to me. If, at some point, I manage to revive that hardware, I
can give platform bits a try.

Sorry for not being able to really test this for now.



Thanks,
Daniel



> 
>  drivers/input/touchscreen/eeti_ts.c | 115 ++++++++++++++++++------------------
>  1 file changed, 58 insertions(+), 57 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
> index 16023867b9da..74d57ef68663 100644
> --- a/drivers/input/touchscreen/eeti_ts.c
> +++ b/drivers/input/touchscreen/eeti_ts.c
> @@ -43,7 +43,7 @@ static bool flip_y;
>  module_param(flip_y, bool, 0644);
>  MODULE_PARM_DESC(flip_y, "flip y coordinate");
>  
> -struct eeti_ts_priv {
> +struct eeti_ts {
>  	struct i2c_client *client;
>  	struct input_dev *input;
>  	struct work_struct work;
> @@ -60,25 +60,25 @@ struct eeti_ts_priv {
>  #define REPORT_BIT_HAS_PRESSURE	(1 << 6)
>  #define REPORT_RES_BITS(v)	(((v) >> 1) + EETI_TS_BITDEPTH)
>  
> -static inline int eeti_ts_irq_active(struct eeti_ts_priv *priv)
> +static inline int eeti_ts_irq_active(struct eeti_ts *eeti)
>  {
> -	return gpio_get_value(priv->irq_gpio) == priv->irq_active_high;
> +	return gpio_get_value(eeti->irq_gpio) == eeti->irq_active_high;
>  }
>  
>  static void eeti_ts_read(struct work_struct *work)
>  {
>  	char buf[6];
>  	unsigned int x, y, res, pressed, to = 100;
> -	struct eeti_ts_priv *priv =
> -		container_of(work, struct eeti_ts_priv, work);
> +	struct eeti_ts *eeti =
> +		container_of(work, struct eeti_ts, work);
>  
> -	mutex_lock(&priv->mutex);
> +	mutex_lock(&eeti->mutex);
>  
> -	while (eeti_ts_irq_active(priv) && --to)
> -		i2c_master_recv(priv->client, buf, sizeof(buf));
> +	while (eeti_ts_irq_active(eeti) && --to)
> +		i2c_master_recv(eeti->client, buf, sizeof(buf));
>  
>  	if (!to) {
> -		dev_err(&priv->client->dev,
> +		dev_err(&eeti->client->dev,
>  			"unable to clear IRQ - line stuck?\n");
>  		goto out;
>  	}
> @@ -103,62 +103,62 @@ static void eeti_ts_read(struct work_struct *work)
>  		y = EETI_MAXVAL - y;
>  
>  	if (buf[0] & REPORT_BIT_HAS_PRESSURE)
> -		input_report_abs(priv->input, ABS_PRESSURE, buf[5]);
> +		input_report_abs(eeti->input, ABS_PRESSURE, buf[5]);
>  
> -	input_report_abs(priv->input, ABS_X, x);
> -	input_report_abs(priv->input, ABS_Y, y);
> -	input_report_key(priv->input, BTN_TOUCH, !!pressed);
> -	input_sync(priv->input);
> +	input_report_abs(eeti->input, ABS_X, x);
> +	input_report_abs(eeti->input, ABS_Y, y);
> +	input_report_key(eeti->input, BTN_TOUCH, !!pressed);
> +	input_sync(eeti->input);
>  
>  out:
> -	mutex_unlock(&priv->mutex);
> +	mutex_unlock(&eeti->mutex);
>  }
>  
>  static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
>  {
> -	struct eeti_ts_priv *priv = dev_id;
> +	struct eeti_ts *eeti = dev_id;
>  
>  	 /* postpone I2C transactions as we are atomic */
> -	schedule_work(&priv->work);
> +	schedule_work(&eeti->work);
>  
>  	return IRQ_HANDLED;
>  }
>  
> -static void eeti_ts_start(struct eeti_ts_priv *priv)
> +static void eeti_ts_start(struct eeti_ts *eeti)
>  {
> -	enable_irq(priv->irq);
> +	enable_irq(eeti->irq);
>  
>  	/* Read the events once to arm the IRQ */
> -	eeti_ts_read(&priv->work);
> +	eeti_ts_read(&eeti->work);
>  }
>  
> -static void eeti_ts_stop(struct eeti_ts_priv *priv)
> +static void eeti_ts_stop(struct eeti_ts *eeti)
>  {
> -	disable_irq(priv->irq);
> -	cancel_work_sync(&priv->work);
> +	disable_irq(eeti->irq);
> +	cancel_work_sync(&eeti->work);
>  }
>  
>  static int eeti_ts_open(struct input_dev *dev)
>  {
> -	struct eeti_ts_priv *priv = input_get_drvdata(dev);
> +	struct eeti_ts *eeti = input_get_drvdata(dev);
>  
> -	eeti_ts_start(priv);
> +	eeti_ts_start(eeti);
>  
>  	return 0;
>  }
>  
>  static void eeti_ts_close(struct input_dev *dev)
>  {
> -	struct eeti_ts_priv *priv = input_get_drvdata(dev);
> +	struct eeti_ts *eeti = input_get_drvdata(dev);
>  
> -	eeti_ts_stop(priv);
> +	eeti_ts_stop(eeti);
>  }
>  
>  static int eeti_ts_probe(struct i2c_client *client,
>  				   const struct i2c_device_id *idp)
>  {
>  	struct eeti_ts_platform_data *pdata = dev_get_platdata(&client->dev);
> -	struct eeti_ts_priv *priv;
> +	struct eeti_ts *eeti;
>  	struct input_dev *input;
>  	unsigned int irq_flags;
>  	int err = -ENOMEM;
> @@ -170,13 +170,14 @@ static int eeti_ts_probe(struct i2c_client *client,
>  	 * for interrupts to occur.
>  	 */
>  
> -	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> -	if (!priv) {
> +	eeti = kzalloc(sizeof(*eeti), GFP_KERNEL);
> +	if (!eeti) {
>  		dev_err(&client->dev, "failed to allocate driver data\n");
>  		return -ENOMEM;
>  	}
>  
> -	mutex_init(&priv->mutex);
> +	mutex_init(&eeti->mutex);
> +
>  	input = input_allocate_device();
>  	if (!input) {
>  		dev_err(&client->dev, "Failed to allocate input device.\n");
> @@ -196,30 +197,30 @@ static int eeti_ts_probe(struct i2c_client *client,
>  	input->open = eeti_ts_open;
>  	input->close = eeti_ts_close;
>  
> -	priv->client = client;
> -	priv->input = input;
> -	priv->irq_gpio = pdata->irq_gpio;
> -	priv->irq = gpio_to_irq(pdata->irq_gpio);
> +	eeti->client = client;
> +	eeti->input = input;
> +	eeti->irq_gpio = pdata->irq_gpio;
> +	eeti->irq = gpio_to_irq(pdata->irq_gpio);
>  
>  	err = gpio_request_one(pdata->irq_gpio, GPIOF_IN, client->name);
>  	if (err < 0)
>  		goto err1;
>  
> -	priv->irq_active_high = pdata->irq_active_high;
> +	eeti->irq_active_high = pdata->irq_active_high;
>  
> -	irq_flags = priv->irq_active_high ?
> +	irq_flags = eeti->irq_active_high ?
>  		IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
>  
> -	INIT_WORK(&priv->work, eeti_ts_read);
> -	i2c_set_clientdata(client, priv);
> -	input_set_drvdata(input, priv);
> +	INIT_WORK(&eeti->work, eeti_ts_read);
> +	i2c_set_clientdata(client, eeti);
> +	input_set_drvdata(input, eeti);
>  
>  	err = input_register_device(input);
>  	if (err)
>  		goto err2;
>  
> -	err = request_irq(priv->irq, eeti_ts_isr, irq_flags,
> -			  client->name, priv);
> +	err = request_irq(eeti->irq, eeti_ts_isr, irq_flags,
> +			  client->name, eeti);
>  	if (err) {
>  		dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
>  		goto err3;
> @@ -229,7 +230,7 @@ static int eeti_ts_probe(struct i2c_client *client,
>  	 * Disable the device for now. It will be enabled once the
>  	 * input device is opened.
>  	 */
> -	eeti_ts_stop(priv);
> +	eeti_ts_stop(eeti);
>  
>  	return 0;
>  
> @@ -240,23 +241,23 @@ static int eeti_ts_probe(struct i2c_client *client,
>  	gpio_free(pdata->irq_gpio);
>  err1:
>  	input_free_device(input);
> -	kfree(priv);
> +	kfree(eeti);
>  	return err;
>  }
>  
>  static int eeti_ts_remove(struct i2c_client *client)
>  {
> -	struct eeti_ts_priv *priv = i2c_get_clientdata(client);
> +	struct eeti_ts *eeti = i2c_get_clientdata(client);
>  
> -	free_irq(priv->irq, priv);
> +	free_irq(eeti->irq, eeti);
>  	/*
>  	 * eeti_ts_stop() leaves IRQ disabled. We need to re-enable it
>  	 * so that device still works if we reload the driver.
>  	 */
> -	enable_irq(priv->irq);
> +	enable_irq(eeti->irq);
>  
> -	input_unregister_device(priv->input);
> -	kfree(priv);
> +	input_unregister_device(eeti->input);
> +	kfree(eeti);
>  
>  	return 0;
>  }
> @@ -264,18 +265,18 @@ static int eeti_ts_remove(struct i2c_client *client)
>  static int __maybe_unused eeti_ts_suspend(struct device *dev)
>  {
>  	struct i2c_client *client = to_i2c_client(dev);
> -	struct eeti_ts_priv *priv = i2c_get_clientdata(client);
> -	struct input_dev *input_dev = priv->input;
> +	struct eeti_ts *eeti = i2c_get_clientdata(client);
> +	struct input_dev *input_dev = eeti->input;
>  
>  	mutex_lock(&input_dev->mutex);
>  
>  	if (input_dev->users)
> -		eeti_ts_stop(priv);
> +		eeti_ts_stop(eeti);
>  
>  	mutex_unlock(&input_dev->mutex);
>  
>  	if (device_may_wakeup(&client->dev))
> -		enable_irq_wake(priv->irq);
> +		enable_irq_wake(eeti->irq);
>  
>  	return 0;
>  }
> @@ -283,16 +284,16 @@ static int __maybe_unused eeti_ts_suspend(struct device *dev)
>  static int __maybe_unused eeti_ts_resume(struct device *dev)
>  {
>  	struct i2c_client *client = to_i2c_client(dev);
> -	struct eeti_ts_priv *priv = i2c_get_clientdata(client);
> -	struct input_dev *input_dev = priv->input;
> +	struct eeti_ts *eeti = i2c_get_clientdata(client);
> +	struct input_dev *input_dev = eeti->input;
>  
>  	if (device_may_wakeup(&client->dev))
> -		disable_irq_wake(priv->irq);
> +		disable_irq_wake(eeti->irq);
>  
>  	mutex_lock(&input_dev->mutex);
>  
>  	if (input_dev->users)
> -		eeti_ts_start(priv);
> +		eeti_ts_start(eeti);
>  
>  	mutex_unlock(&input_dev->mutex);
>  
> 

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

* Re: [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts
  2017-03-01  9:28 ` [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Daniel Mack
@ 2017-03-01 17:34   ` Dmitry Torokhov
  0 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2017-03-01 17:34 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Haojian Zhuang, Robert Jarzmik, linux-kernel, linux-input

On Wed, Mar 01, 2017 at 10:28:14AM +0100, Daniel Mack wrote:
> Hi Dmitry,
> 
> On 02/28/2017 11:46 PM, Dmitry Torokhov wrote:
> > Also rename 'priv' variables to eeti.
> > 
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> > 
> > Hi,
> > 
> > This is all is not tested as I do not have the hardware, so if anyone
> > has raumfeld device that would be awesome.
> 
> I have no access to such hardware for the time being, and the platform
> does not currently boot a mainline kernel either.
> 
> So I think we should just merge this set, the changes to the driver look
> all good to me. If, at some point, I manage to revive that hardware, I
> can give platform bits a try.

OK, I'll be putting you as reviewed-by then.

Thank you for taking a look.

-- 
Dmitry

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

end of thread, other threads:[~2017-03-01 17:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-28 22:46 [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov
2017-02-28 22:46 ` [PATCH 02/10] Input: eeti_ts - use BIT(n) Dmitry Torokhov
2017-02-28 22:46 ` [PATCH 03/10] Input: eeti_ts - use get_unaligned_be16() to retrieve data Dmitry Torokhov
2017-02-28 22:46 ` [PATCH 04/10] Input: eeti_ts - use input_set_capability() Dmitry Torokhov
2017-02-28 22:46 ` [PATCH 05/10] Input: eeti-ts - switch to using managed resources Dmitry Torokhov
2017-02-28 22:46 ` [PATCH 06/10] Input: eeti_ts - respect interrupt set in client structure Dmitry Torokhov
2017-02-28 22:46 ` [PATCH 07/10] Input: eeti_ts - use gpio_get_value_cansleep Dmitry Torokhov
2017-02-28 22:46 ` [PATCH 08/10] Input: eeti_ts - switch to using threaded interrupt Dmitry Torokhov
2017-02-28 22:46 ` [PATCH 09/10] Input: eeti_ts - expect platform code to set interrupt trigger Dmitry Torokhov
2017-02-28 22:46 ` [PATCH 10/10] Input: eeti_ts - switch to gpiod API Dmitry Torokhov
2017-03-01  9:28 ` [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Daniel Mack
2017-03-01 17:34   ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).