Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1589910 > unrolled thread
| Started by | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| First post | 2017-03-01 01:50 +0100 |
| Last post | 2017-03-01 18:40 +0100 |
| Articles | 6 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-03-01 01:50 +0100
[PATCH 03/10] Input: eeti_ts - use get_unaligned_be16() to retrieve data Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-03-01 02:30 +0100
[PATCH 05/10] Input: eeti-ts - switch to using managed resources Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-03-01 02:40 +0100
[PATCH 10/10] Input: eeti_ts - switch to gpiod API Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-03-01 03:10 +0100
Re: [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Daniel Mack <daniel@zonque.org> - 2017-03-01 12:30 +0100
Re: [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-03-01 18:40 +0100
| From | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| Date | 2017-03-01 01:50 +0100 |
| Subject | [PATCH 01/10] Input: eeti_ts - rename eeti_ts_priv to eeti_ts |
| Message-ID | <tfZdL-2BN-7@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| Date | 2017-03-01 02:30 +0100 |
| Subject | [PATCH 03/10] Input: eeti_ts - use get_unaligned_be16() to retrieve data |
| Message-ID | <tg1fA-3Wb-15@gated-at.bofh.it> |
| In reply to | #1589910 |
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
[toc] | [prev] | [next] | [standalone]
| From | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| Date | 2017-03-01 02:40 +0100 |
| Subject | [PATCH 05/10] Input: eeti-ts - switch to using managed resources |
| Message-ID | <tg1pg-3Zx-9@gated-at.bofh.it> |
| In reply to | #1589910 |
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
[toc] | [prev] | [next] | [standalone]
| From | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| Date | 2017-03-01 03:10 +0100 |
| Subject | [PATCH 10/10] Input: eeti_ts - switch to gpiod API |
| Message-ID | <tg1Si-4t4-7@gated-at.bofh.it> |
| In reply to | #1589910 |
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
[toc] | [prev] | [next] | [standalone]
| From | Daniel Mack <daniel@zonque.org> |
|---|---|
| Date | 2017-03-01 12:30 +0100 |
| Message-ID | <tgaCe-2kf-15@gated-at.bofh.it> |
| In reply to | #1589910 |
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);
>
>
[toc] | [prev] | [next] | [standalone]
| From | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| Date | 2017-03-01 18:40 +0100 |
| Message-ID | <tggoi-6jU-37@gated-at.bofh.it> |
| In reply to | #1590265 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web