All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support
@ 2014-01-24  0:00 Courtney Cavin
  2014-01-24  0:00 ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Courtney Cavin
                   ` (2 more replies)
  0 siblings, 3 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

This is an attempt to get this driver closer to being in an upstream-able form.
In the process, this drops legacy callback methods for managing power and GPIO
configuration, in favor of the already existing frameworks.  Most of this
series is cleanup, but there are a few intermixed bug fixes to make it all
work.

This patch series is based off of the synaptics-rmi4 branch merged into
Linus' 3.13.  A tree is available at [1].

This was tested on Synaptics TM2281-001 & TM2282-001.

[1] http://github.com/courtc/linux.git
	tag for-input/synaptics-rmi4

Courtney Cavin (15):
  Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
  Input: synaptics-rmi4 - don't kfree devm_ alloced memory
  Input: synaptics-rmi4 - don't free devices directly
  Input: synaptics-rmi4 - remove sensor name from platform data
  Input: synaptics-rmi4 - remove gpio handling and polling
  Input: synaptics-rmi4 - remove platform suspend callbacks
  Input: synaptics-rmi4 - remove remaining debugfs code
  Input: synaptics-rmi4 - cleanup platform data
  Input: synaptics-rmi4 - remove unused defines and variables
  Input: synaptics-rmi4 - add devicetree support
  Input: synaptics-rmi4 - add regulator support
  Input: synaptics-rmi4 - don't immediately set page on probe
  Input: synaptics-rmi4 - properly set F01 container on PDT scan
  Input: synaptics-rmi4 - ensure we have IRQs before reading status
  Input: synaptics-rmi4 - correct RMI4 spec url

 Documentation/devicetree/bindings/input/rmi4.txt   | 117 +++++
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 drivers/input/rmi4/Kconfig                         |   1 -
 drivers/input/rmi4/rmi_bus.c                       | 131 +-----
 drivers/input/rmi4/rmi_bus.h                       |  18 +-
 drivers/input/rmi4/rmi_driver.c                    | 321 +++++--------
 drivers/input/rmi4/rmi_driver.h                    |  33 +-
 drivers/input/rmi4/rmi_f01.c                       | 163 ++++---
 drivers/input/rmi4/rmi_f11.c                       | 523 ++++++---------------
 drivers/input/rmi4/rmi_i2c.c                       |  55 +--
 include/linux/rmi.h                                | 219 ++-------
 11 files changed, 551 insertions(+), 1031 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/rmi4.txt

-- 
1.8.1.5


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

* [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
  2014-01-24  0:00 [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support Courtney Cavin
@ 2014-01-24  0:00 ` Courtney Cavin
  2014-01-24  0:00   ` [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory Courtney Cavin
  2014-02-04 23:08   ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Christopher Heiny
  2014-01-24  0:06 ` [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support Courtney Cavin
  2014-01-24 23:24 ` Christopher Heiny
  2 siblings, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/rmi_bus.c    |  4 ++--
 drivers/input/rmi4/rmi_bus.h    |  2 +-
 drivers/input/rmi4/rmi_driver.c | 17 ++++++++++++-----
 drivers/input/rmi4/rmi_f11.c    |  4 +++-
 4 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index 96a76e7..8a939f3 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -37,7 +37,7 @@ static void rmi_release_device(struct device *dev)
 	kfree(rmi_dev);
 }
 
-struct device_type rmi_device_type = {
+static struct device_type rmi_device_type = {
 	.name		= "rmi_sensor",
 	.release	= rmi_release_device,
 };
@@ -145,7 +145,7 @@ static void rmi_release_function(struct device *dev)
 	kfree(fn);
 }
 
-struct device_type rmi_function_type = {
+static struct device_type rmi_function_type = {
 	.name		= "rmi_function",
 	.release	= rmi_release_function,
 };
diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
index decb479..2bad2ed 100644
--- a/drivers/input/rmi4/rmi_bus.h
+++ b/drivers/input/rmi4/rmi_bus.h
@@ -103,7 +103,7 @@ int __must_check __rmi_register_function_handler(struct rmi_function_handler *,
 #define rmi_register_function_handler(handler) \
 	__rmi_register_function_handler(handler, THIS_MODULE, KBUILD_MODNAME)
 
-void rmi_unregister_function_handler(struct rmi_function_handler *);
+void rmi_unregister_function_handler(struct rmi_function_handler *handler);
 
 /**
  * struct rmi_driver - driver for an RMI4 sensor on the RMI bus.
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 3483e5b..5c6379c 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -32,6 +32,8 @@
 #include "rmi_bus.h"
 #include "rmi_driver.h"
 
+#define RMI4_MAX_N_IRQS 256
+
 #define HAS_NONSTANDARD_PDT_MASK 0x40
 #define RMI4_MAX_PAGE 0xff
 #define RMI4_PAGE_SIZE 0x100
@@ -260,7 +262,7 @@ static void process_one_interrupt(struct rmi_function *fn,
 		unsigned long *irq_status, struct rmi_driver_data *data)
 {
 	struct rmi_function_handler *fh;
-	DECLARE_BITMAP(irq_bits, data->num_of_irq_regs);
+	DECLARE_BITMAP(irq_bits, RMI4_MAX_N_IRQS);
 
 	if (!fn || !fn->dev.driver)
 		return;
@@ -325,7 +327,7 @@ static int process_interrupt_requests(struct rmi_device *rmi_dev)
 static int rmi_driver_set_input_params(struct rmi_device *rmi_dev,
 				struct input_dev *input)
 {
-	// FIXME: set up parent
+	/* FIXME: set up parent */
 	input->name = SYNAPTICS_INPUT_DEVICE_NAME;
 	input->id.vendor  = SYNAPTICS_VENDOR_ID;
 	input->id.bustype = BUS_RMI;
@@ -466,7 +468,7 @@ static int rmi_driver_reset_handler(struct rmi_device *rmi_dev)
 /*
  * Construct a function's IRQ mask. This should be called once and stored.
  */
-int rmi_driver_irq_get_mask(struct rmi_device *rmi_dev,
+static int rmi_driver_irq_get_mask(struct rmi_device *rmi_dev,
 		struct rmi_function *fn) {
 	int i;
 	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
@@ -665,7 +667,7 @@ static int rmi_scan_pdt(struct rmi_device *rmi_dev)
 					pdt_entry.function_number, page);
 			done = false;
 
-			// XXX need to make sure we create F01 first...
+			/* XXX need to make sure we create F01 first... */
 			retval = create_function(rmi_dev,
 					&pdt_entry, &irq_count, page_start);
 
@@ -674,6 +676,11 @@ static int rmi_scan_pdt(struct rmi_device *rmi_dev)
 		}
 		done = done || data->f01_bootloader_mode;
 	}
+	if (irq_count > RMI4_MAX_N_IRQS) {
+		dev_err(dev, "Too many IRQs specified\n");
+		retval = -EINVAL;
+		goto error_exit;
+	}
 	data->irq_count = irq_count;
 	data->num_of_irq_regs = (irq_count + 7) / 8;
 	dev_dbg(dev, "%s: Done with PDT scan.\n", __func__);
@@ -953,7 +960,7 @@ static int rmi_driver_probe(struct device *dev)
 	return retval;
 }
 
-struct rmi_driver rmi_physical_driver = {
+static struct rmi_driver rmi_physical_driver = {
 	.driver = {
 		.owner	= THIS_MODULE,
 		.name	= "rmi_physical",
diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
index c2be9de..4e0a296 100644
--- a/drivers/input/rmi4/rmi_f11.c
+++ b/drivers/input/rmi4/rmi_f11.c
@@ -610,6 +610,8 @@ static void rmi_f11_abs_pos_report(struct f11_data *f11,
 	int temp;
 	u8 abs_base = n_finger * RMI_F11_ABS_BYTES;
 
+	orient = z = w_min = w_max = 0;
+
 	if (finger_state) {
 		x = (data->abs_pos[abs_base] << 4) |
 			(data->abs_pos[abs_base + 2] & 0x0F);
@@ -1413,7 +1415,7 @@ static int rmi_f11_config(struct rmi_function *fn)
 	return 0;
 }
 
-int rmi_f11_attention(struct rmi_function *fn,
+static int rmi_f11_attention(struct rmi_function *fn,
 						unsigned long *irq_bits)
 {
 	struct rmi_device *rmi_dev = fn->rmi_dev;
-- 
1.8.1.5


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

* [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory
  2014-01-24  0:00 ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Courtney Cavin
@ 2014-01-24  0:00   ` Courtney Cavin
  2014-01-24  0:00     ` [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly Courtney Cavin
  2014-02-04 23:08     ` [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory Christopher Heiny
  2014-02-04 23:08   ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Christopher Heiny
  1 sibling, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/rmi_f01.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
index cf1081f..98bc65a9 100644
--- a/drivers/input/rmi4/rmi_f01.c
+++ b/drivers/input/rmi4/rmi_f01.c
@@ -390,7 +390,7 @@ static int rmi_f01_initialize(struct rmi_function *fn)
 	return 0;
 
  error_exit:
-	kfree(data);
+	devm_kfree(&fn->dev, data);
 	return error;
 }
 
-- 
1.8.1.5


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

* [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly
  2014-01-24  0:00   ` [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory Courtney Cavin
@ 2014-01-24  0:00     ` Courtney Cavin
  2014-01-24  0:00       ` [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data Courtney Cavin
  2014-02-04 23:08       ` [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly Christopher Heiny
  2014-02-04 23:08     ` [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory Christopher Heiny
  1 sibling, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

Devices use a kobject to manage references, do not delete the memory
while still referenced.  Instead, call put_device() to release the
reference.

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/rmi_bus.c    | 8 +++++---
 drivers/input/rmi4/rmi_driver.c | 6 +-----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index 8a939f3..cd7bfbd 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -94,8 +94,7 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
 		return -EINVAL;
 	}
 
-	rmi_dev = devm_kzalloc(xport->dev,
-				sizeof(struct rmi_device), GFP_KERNEL);
+	rmi_dev = kzalloc(sizeof(struct rmi_device), GFP_KERNEL);
 	if (!rmi_dev)
 		return -ENOMEM;
 
@@ -112,8 +111,10 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
 	rmi_physical_setup_debugfs(rmi_dev);
 
 	error = device_register(&rmi_dev->dev);
-	if (error)
+	if (error) {
+		put_device(&rmi_dev->dev);
 		return error;
+	}
 
 	dev_dbg(xport->dev, "%s: Registered %s as %s.\n", __func__,
 		pdata->sensor_name, dev_name(&rmi_dev->dev));
@@ -240,6 +241,7 @@ int rmi_register_function(struct rmi_function *fn)
 		dev_err(&rmi_dev->dev,
 			"Failed device_register function device %s\n",
 			dev_name(&fn->dev));
+		put_device(&fn->dev);
 		goto error_exit;
 	}
 
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 5c6379c..4965589 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -557,15 +557,11 @@ static int create_function(struct rmi_device *rmi_dev,
 
 	error = rmi_register_function(fn);
 	if (error)
-		goto err_free_mem;
+		return error;
 
 	list_add_tail(&fn->node, &data->function_list);
 
 	return 0;
-
-err_free_mem:
-	kfree(fn);
-	return error;
 }
 
 /*
-- 
1.8.1.5


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

* [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data
  2014-01-24  0:00     ` [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly Courtney Cavin
@ 2014-01-24  0:00       ` Courtney Cavin
  2014-01-24  0:00         ` [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling Courtney Cavin
  2014-02-04 23:08         ` [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data Christopher Heiny
  2014-02-04 23:08       ` [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly Christopher Heiny
  1 sibling, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

The driver/device already has a name, no need for another one.

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/rmi_bus.c    | 4 ++--
 drivers/input/rmi4/rmi_driver.c | 7 ++-----
 drivers/input/rmi4/rmi_f11.c    | 3 +--
 drivers/input/rmi4/rmi_i2c.c    | 3 +--
 include/linux/rmi.h             | 4 ----
 5 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index cd7bfbd..fd14acb 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -116,8 +116,8 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
 		return error;
 	}
 
-	dev_dbg(xport->dev, "%s: Registered %s as %s.\n", __func__,
-		pdata->sensor_name, dev_name(&rmi_dev->dev));
+	dev_dbg(xport->dev, "%s: Registered %s\n", __func__,
+		dev_name(&rmi_dev->dev));
 
 	return 0;
 }
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 4965589..5fb582c 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -531,12 +531,10 @@ static int create_function(struct rmi_device *rmi_dev,
 {
 	struct device *dev = &rmi_dev->dev;
 	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
-	struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
 	struct rmi_function *fn;
 	int error;
 
-	dev_dbg(dev, "Initializing F%02X for %s.\n",
-		pdt->function_number, pdata->sensor_name);
+	dev_dbg(dev, "Initializing F%02X\n", pdt->function_number);
 
 	fn = kzalloc(sizeof(struct rmi_function), GFP_KERNEL);
 	if (!fn) {
@@ -822,8 +820,7 @@ static int rmi_driver_probe(struct device *dev)
 
 	retval = rmi_scan_pdt(rmi_dev);
 	if (retval) {
-		dev_err(dev, "PDT scan for %s failed with code %d.\n",
-			pdata->sensor_name, retval);
+		dev_err(dev, "PDT scan failed with code %d.\n", retval);
 		goto err_free_data;
 	}
 
diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
index 4e0a296..553afd8 100644
--- a/drivers/input/rmi4/rmi_f11.c
+++ b/drivers/input/rmi4/rmi_f11.c
@@ -1182,8 +1182,7 @@ static int rmi_f11_initialize(struct rmi_function *fn)
 	struct f11_2d_sensor *sensor;
 	u8 buf;
 
-	dev_dbg(&fn->dev, "Initializing F11 values for %s.\n",
-		 pdata->sensor_name);
+	dev_dbg(&fn->dev, "Initializing F11 values.\n");
 
 	/*
 	** init instance data, fill in values and create any sysfs files
diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
index 24d8a04..910f05c 100644
--- a/drivers/input/rmi4/rmi_i2c.c
+++ b/drivers/input/rmi4/rmi_i2c.c
@@ -196,8 +196,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
-	dev_dbg(&client->dev, "Probing %s at %#02x (GPIO %d).\n",
-		pdata->sensor_name ? pdata->sensor_name : "-no name-",
+	dev_dbg(&client->dev, "Probing %#02x (GPIO %d).\n",
 		client->addr, pdata->attn_gpio);
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
diff --git a/include/linux/rmi.h b/include/linux/rmi.h
index 735e978..65b59b5 100644
--- a/include/linux/rmi.h
+++ b/include/linux/rmi.h
@@ -194,8 +194,6 @@ struct rmi_device_platform_data_spi {
 /**
  * struct rmi_device_platform_data - system specific configuration info.
  *
- * @sensor_name - this is used for various diagnostic messages.
- *
  * @firmware_name - if specified will override default firmware name,
  * for reflashing.
  *
@@ -247,8 +245,6 @@ struct rmi_device_platform_data_spi {
  * functions.
  */
 struct rmi_device_platform_data {
-	char *sensor_name;	/* Used for diagnostics. */
-
 	int attn_gpio;
 	enum rmi_attn_polarity attn_polarity;
 	bool level_triggered;
-- 
1.8.1.5


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

* [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling
  2014-01-24  0:00       ` [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data Courtney Cavin
@ 2014-01-24  0:00         ` Courtney Cavin
  2014-01-24  0:00           ` [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks Courtney Cavin
  2014-02-04 23:08           ` [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling Christopher Heiny
  2014-02-04 23:08         ` [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data Christopher Heiny
  1 sibling, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

Since all the configuration needed for an irq can be provided in other
ways, remove all gpio->irq functionality. This cleans up the code quite
a bit.

This also gets rid of polling functionality, as this should be done
elsewhere if absolutely needed.

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/rmi_driver.c | 143 +++++-----------------------------------
 drivers/input/rmi4/rmi_driver.h |   7 --
 drivers/input/rmi4/rmi_i2c.c    |  24 +------
 include/linux/rmi.h             |  31 +--------
 4 files changed, 20 insertions(+), 185 deletions(-)

diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 5fb582c..780742f 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -20,7 +20,6 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/fs.h>
-#include <linux/gpio.h>
 #include <linux/kconfig.h>
 #include <linux/list.h>
 #include <linux/module.h>
@@ -50,74 +49,17 @@ static irqreturn_t rmi_irq_thread(int irq, void *p)
 	struct rmi_transport_dev *xport = p;
 	struct rmi_device *rmi_dev = xport->rmi_dev;
 	struct rmi_driver *driver = rmi_dev->driver;
-	struct rmi_device_platform_data *pdata = xport->dev->platform_data;
 	struct rmi_driver_data *data;
 
 	data = dev_get_drvdata(&rmi_dev->dev);
-
-	if (IRQ_DEBUG(data))
-		dev_dbg(xport->dev, "ATTN gpio, value: %d.\n",
-				gpio_get_value(pdata->attn_gpio));
-
-	if (gpio_get_value(pdata->attn_gpio) == pdata->attn_polarity) {
-		data->attn_count++;
-		if (driver && driver->irq_handler && rmi_dev)
-			driver->irq_handler(rmi_dev, irq);
-	}
+	if (driver && driver->irq_handler && rmi_dev)
+		driver->irq_handler(rmi_dev, irq);
 
 	return IRQ_HANDLED;
 }
 
 static int process_interrupt_requests(struct rmi_device *rmi_dev);
 
-static void rmi_poll_work(struct work_struct *work)
-{
-	struct rmi_driver_data *data =
-			container_of(work, struct rmi_driver_data, poll_work);
-	struct rmi_device *rmi_dev = data->rmi_dev;
-
-	process_interrupt_requests(rmi_dev);
-}
-
-/*
- * This is the timer function for polling - it simply has to schedule work
- * and restart the timer.
- */
-static enum hrtimer_restart rmi_poll_timer(struct hrtimer *timer)
-{
-	struct rmi_driver_data *data =
-			container_of(timer, struct rmi_driver_data, poll_timer);
-
-	if (!data->enabled)
-		return HRTIMER_NORESTART;
-	if (!work_pending(&data->poll_work))
-		schedule_work(&data->poll_work);
-	hrtimer_start(&data->poll_timer, data->poll_interval, HRTIMER_MODE_REL);
-	return HRTIMER_NORESTART;
-}
-
-static int enable_polling(struct rmi_device *rmi_dev)
-{
-	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
-
-	dev_dbg(&rmi_dev->dev, "Polling enabled.\n");
-	INIT_WORK(&data->poll_work, rmi_poll_work);
-	hrtimer_init(&data->poll_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	data->poll_timer.function = rmi_poll_timer;
-	hrtimer_start(&data->poll_timer, data->poll_interval, HRTIMER_MODE_REL);
-
-	return 0;
-}
-
-static void disable_polling(struct rmi_device *rmi_dev)
-{
-	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
-
-	dev_dbg(&rmi_dev->dev, "Polling disabled.\n");
-	hrtimer_cancel(&data->poll_timer);
-	cancel_work_sync(&data->poll_work);
-}
-
 static void disable_sensor(struct rmi_device *rmi_dev)
 {
 	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
@@ -125,9 +67,6 @@ static void disable_sensor(struct rmi_device *rmi_dev)
 	if (!data->enabled)
 		return;
 
-	if (!data->irq)
-		disable_polling(rmi_dev);
-
 	if (rmi_dev->xport->ops->disable_device)
 		rmi_dev->xport->ops->disable_device(rmi_dev->xport);
 
@@ -155,20 +94,14 @@ static int enable_sensor(struct rmi_device *rmi_dev)
 	}
 
 	xport = rmi_dev->xport;
-	if (data->irq) {
-		retval = request_threaded_irq(data->irq,
-				xport->hard_irq ? xport->hard_irq : NULL,
-				xport->irq_thread ?
-					xport->irq_thread : rmi_irq_thread,
-				data->irq_flags,
-				dev_name(&rmi_dev->dev), xport);
-		if (retval)
-			return retval;
-	} else {
-		retval = enable_polling(rmi_dev);
-		if (retval < 0)
-			return retval;
-	}
+	retval = request_threaded_irq(data->irq,
+			xport->hard_irq ? xport->hard_irq : NULL,
+			xport->irq_thread ?
+				xport->irq_thread : rmi_irq_thread,
+			IRQF_ONESHOT,
+			dev_name(&rmi_dev->dev), xport);
+	if (retval)
+		return retval;
 
 	data->enabled = true;
 
@@ -751,16 +684,9 @@ static SIMPLE_DEV_PM_OPS(rmi_driver_pm, rmi_driver_suspend, rmi_driver_resume);
 static int rmi_driver_remove(struct device *dev)
 {
 	struct rmi_device *rmi_dev = to_rmi_device(dev);
-	const struct rmi_device_platform_data *pdata =
-					to_rmi_platform_data(rmi_dev);
-	const struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
-
 	disable_sensor(rmi_dev);
 	rmi_free_function_list(rmi_dev);
 
-	if (data->gpio_held)
-		gpio_free(pdata->attn_gpio);
-
 	return 0;
 }
 
@@ -895,51 +821,12 @@ static int rmi_driver_probe(struct device *dev)
 		mutex_init(&data->suspend_mutex);
 	}
 
-	if (gpio_is_valid(pdata->attn_gpio)) {
-		static const char GPIO_LABEL[] = "attn";
-		unsigned long gpio_flags = GPIOF_DIR_IN;
-
-		data->irq = gpio_to_irq(pdata->attn_gpio);
-		if (pdata->level_triggered) {
-			data->irq_flags = IRQF_ONESHOT |
-				((pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH)
-				? IRQF_TRIGGER_HIGH : IRQF_TRIGGER_LOW);
-		} else {
-			data->irq_flags =
-				(pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH)
-				? IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
-		}
+	data->irq = pdata->irq;
+	if (data->irq < 0) {
+		dev_err(dev, "Failed to get attn IRQ.\n");
+		retval = data->irq;
+		goto err_free_data;
 
-		if (IS_ENABLED(CONFIG_RMI4_DEV))
-			gpio_flags |= GPIOF_EXPORT;
-
-		retval = gpio_request_one(pdata->attn_gpio, gpio_flags,
-					  GPIO_LABEL);
-		if (retval) {
-			dev_warn(dev, "WARNING: Failed to request ATTN gpio %d, code=%d.\n",
-				 pdata->attn_gpio, retval);
-			retval = 0;
-		} else {
-			dev_info(dev, "Obtained ATTN gpio %d.\n",
-					pdata->attn_gpio);
-			data->gpio_held = true;
-			if (IS_ENABLED(CONFIG_RMI4_DEV)) {
-				retval = gpio_export_link(dev,
-						GPIO_LABEL, pdata->attn_gpio);
-				if (retval) {
-					dev_warn(dev,
-						"WARNING: Failed to symlink ATTN gpio!\n");
-					retval = 0;
-				} else {
-					dev_info(dev, "Exported ATTN gpio %d.",
-						pdata->attn_gpio);
-				}
-			}
-		}
-	} else {
-		data->poll_interval = ktime_set(0,
-			(pdata->poll_interval_ms ? pdata->poll_interval_ms :
-			DEFAULT_POLL_INTERVAL_MS) * 1000 * 1000);
 	}
 
 	if (data->f01_container->dev.driver) {
diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
index 4f44a54..aef5521 100644
--- a/drivers/input/rmi4/rmi_driver.h
+++ b/drivers/input/rmi4/rmi_driver.h
@@ -39,9 +39,7 @@ struct rmi_driver_data {
 
 	u32 attn_count;
 	u32 irq_debug;	/* Should be bool, but debugfs wants u32 */
-	bool gpio_held;
 	int irq;
-	int irq_flags;
 	int num_of_irq_regs;
 	int irq_count;
 	unsigned long *irq_status;
@@ -50,11 +48,6 @@ struct rmi_driver_data {
 	bool irq_stored;
 	struct mutex irq_mutex;
 
-	/* Following are used when polling. */
-	struct hrtimer poll_timer;
-	struct work_struct poll_work;
-	ktime_t poll_interval;
-
 	struct mutex pdt_mutex;
 	u8 pdt_props;
 	u8 bsr;
diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
index 910f05c..aebf974 100644
--- a/drivers/input/rmi4/rmi_i2c.c
+++ b/drivers/input/rmi4/rmi_i2c.c
@@ -196,8 +196,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
-	dev_dbg(&client->dev, "Probing %#02x (GPIO %d).\n",
-		client->addr, pdata->attn_gpio);
+	dev_dbg(&client->dev, "Probing %#02x.\n", client->addr);
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
 		dev_err(&client->dev,
@@ -205,15 +204,6 @@ static int rmi_i2c_probe(struct i2c_client *client,
 		return -ENODEV;
 	}
 
-	if (pdata->gpio_config) {
-		retval = pdata->gpio_config(pdata->gpio_data, true);
-		if (retval < 0) {
-			dev_err(&client->dev, "Failed to configure GPIOs, code: %d.\n",
-				retval);
-			return retval;
-		}
-	}
-
 	rmi_i2c = devm_kzalloc(&client->dev, sizeof(struct rmi_i2c_xport),
 				GFP_KERNEL);
 	if (!rmi_i2c)
@@ -240,7 +230,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
 	if (retval) {
 		dev_err(&client->dev, "Failed to register transport driver at 0x%.2X.\n",
 			client->addr);
-		goto err_gpio;
+		goto err;
 	}
 
 	i2c_set_clientdata(client, rmi_i2c);
@@ -249,24 +239,16 @@ static int rmi_i2c_probe(struct i2c_client *client,
 			client->addr);
 	return 0;
 
-err_gpio:
-	if (pdata->gpio_config)
-		pdata->gpio_config(pdata->gpio_data, false);
-
+err:
 	return retval;
 }
 
 static int rmi_i2c_remove(struct i2c_client *client)
 {
-	const struct rmi_device_platform_data *pdata =
-				dev_get_platdata(&client->dev);
 	struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client);
 
 	rmi_unregister_transport_device(&rmi_i2c->xport);
 
-	if (pdata->gpio_config)
-		pdata->gpio_config(pdata->gpio_data, false);
-
 	return 0;
 }
 
diff --git a/include/linux/rmi.h b/include/linux/rmi.h
index 65b59b5..326e741 100644
--- a/include/linux/rmi.h
+++ b/include/linux/rmi.h
@@ -23,11 +23,6 @@
 #include <linux/wait.h>
 #include <linux/debugfs.h>
 
-enum rmi_attn_polarity {
-	RMI_ATTN_ACTIVE_LOW = 0,
-	RMI_ATTN_ACTIVE_HIGH = 1
-};
-
 /**
  * struct rmi_f11_axis_alignment - target axis alignment
  * @swap_axes: set to TRUE if desired to swap x- and y-axis
@@ -194,25 +189,10 @@ struct rmi_device_platform_data_spi {
 /**
  * struct rmi_device_platform_data - system specific configuration info.
  *
+ * @irq - attention IRQ
  * @firmware_name - if specified will override default firmware name,
  * for reflashing.
  *
- * @attn_gpio - the index of a GPIO that will be used to provide the ATTN
- * interrupt from the touch sensor.
- * @attn_polarity - indicates whether ATTN is active high or low.
- * @level_triggered - by default, the driver uses edge triggered interrupts.
- * However, this can cause problems with suspend/resume on some platforms.  In
- * that case, set this to 1 to use level triggered interrupts.
- * @gpio_config - a routine that will be called when the driver is loaded to
- * perform any platform specific GPIO configuration, and when it is unloaded
- * for GPIO de-configuration.  This is typically used to configure the ATTN
- * GPIO and the I2C or SPI pins, if necessary.
- * @gpio_data - platform specific data to be passed to the GPIO configuration
- * function.
- *
- * @poll_interval_ms - the time in milliseconds between reads of the interrupt
- * status register.  This is ignored if attn_gpio is non-zero.
- *
  * @reset_delay_ms - after issuing a reset command to the touch sensor, the
  * driver waits a few milliseconds to give the firmware a chance to
  * to re-initialize.  You can override the default wait period here.
@@ -245,14 +225,7 @@ struct rmi_device_platform_data_spi {
  * functions.
  */
 struct rmi_device_platform_data {
-	int attn_gpio;
-	enum rmi_attn_polarity attn_polarity;
-	bool level_triggered;
-	void *gpio_data;
-	int (*gpio_config)(void *gpio_data, bool configure);
-
-	int poll_interval_ms;
-
+	int irq;
 	int reset_delay_ms;
 
 	struct rmi_device_platform_data_spi spi_data;
-- 
1.8.1.5


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

* [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks
  2014-01-24  0:00         ` [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling Courtney Cavin
@ 2014-01-24  0:00           ` Courtney Cavin
  2014-01-24  0:00             ` [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code Courtney Cavin
  2014-02-04 23:09             ` [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks Christopher Heiny
  2014-02-04 23:08           ` [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling Christopher Heiny
  1 sibling, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

These are unnecessary and ugly. Remove them, and all related code.

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/rmi_driver.c | 57 ++---------------------------------------
 drivers/input/rmi4/rmi_driver.h | 10 --------
 include/linux/rmi.h             | 20 ---------------
 3 files changed, 2 insertions(+), 85 deletions(-)

diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 780742f..691b6fb 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -621,60 +621,16 @@ error_exit:
 #ifdef CONFIG_PM_SLEEP
 static int rmi_driver_suspend(struct device *dev)
 {
-	struct rmi_driver_data *data;
-	int retval = 0;
 	struct rmi_device *rmi_dev = to_rmi_device(dev);
 
-	data = dev_get_drvdata(&rmi_dev->dev);
-
-	mutex_lock(&data->suspend_mutex);
-
-	if (data->pre_suspend) {
-		retval = data->pre_suspend(data->pm_data);
-		if (retval)
-			goto exit;
-	}
-
 	disable_sensor(rmi_dev);
-
-	if (data->post_suspend)
-		retval = data->post_suspend(data->pm_data);
-
-exit:
-	mutex_unlock(&data->suspend_mutex);
-	return retval;
+	return 0;
 }
 
 static int rmi_driver_resume(struct device *dev)
 {
-	struct rmi_driver_data *data;
-	int retval = 0;
 	struct rmi_device *rmi_dev = to_rmi_device(dev);
-
-	data = dev_get_drvdata(&rmi_dev->dev);
-	mutex_lock(&data->suspend_mutex);
-
-	if (data->pre_resume) {
-		retval = data->pre_resume(data->pm_data);
-		if (retval)
-			goto exit;
-	}
-
-	retval = enable_sensor(rmi_dev);
-	if (retval)
-		goto exit;
-
-
-	if (data->post_resume) {
-		retval = data->post_resume(data->pm_data);
-		if (retval)
-			goto exit;
-	}
-
-	data->suspended = false;
-exit:
-	mutex_unlock(&data->suspend_mutex);
-	return retval;
+	return enable_sensor(rmi_dev);
 }
 
 #endif /* CONFIG_PM_SLEEP */
@@ -811,15 +767,6 @@ static int rmi_driver_probe(struct device *dev)
 		retval = -ENOMEM;
 		goto err_free_data;
 	}
-	if (IS_ENABLED(CONFIG_PM)) {
-		data->pm_data = pdata->pm_data;
-		data->pre_suspend = pdata->pre_suspend;
-		data->post_suspend = pdata->post_suspend;
-		data->pre_resume = pdata->pre_resume;
-		data->post_resume = pdata->post_resume;
-
-		mutex_init(&data->suspend_mutex);
-	}
 
 	data->irq = pdata->irq;
 	if (data->irq < 0) {
diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
index aef5521..f28166f 100644
--- a/drivers/input/rmi4/rmi_driver.h
+++ b/drivers/input/rmi4/rmi_driver.h
@@ -53,16 +53,6 @@ struct rmi_driver_data {
 	u8 bsr;
 
 	bool enabled;
-#ifdef CONFIG_PM_SLEEP
-	bool suspended;
-	struct mutex suspend_mutex;
-
-	void *pm_data;
-	int (*pre_suspend) (const void *pm_data);
-	int (*post_suspend) (const void *pm_data);
-	int (*pre_resume) (const void *pm_data);
-	int (*post_resume) (const void *pm_data);
-#endif
 
 #ifdef CONFIG_RMI4_DEBUG
 	struct dentry *debugfs_delay;
diff --git a/include/linux/rmi.h b/include/linux/rmi.h
index 326e741..41c2c04 100644
--- a/include/linux/rmi.h
+++ b/include/linux/rmi.h
@@ -204,8 +204,6 @@ struct rmi_device_platform_data_spi {
  * @f11_rezero_wait - if non-zero, this is how may milliseconds the F11 2D
  * sensor will wait before being be rezeroed on exit from suspend.  If
  * this value is zero, the F11 2D sensor will not be rezeroed on resume.
- * @pre_suspend - this will be called before any other suspend operations are
- * done.
  * @power_management - overrides default touch sensor doze mode settings (see
  * above)
  * @f19_button_map - provide initial input subsystem key mappings for F19.
@@ -213,16 +211,6 @@ struct rmi_device_platform_data_spi {
  * @gpioled_map - provides initial settings for GPIOs and LEDs controlled by
  * F30.
  * @f41_button_map - provide initial input subsystem key mappings for F41.
- *
- * @post_suspend - this will be called after all suspend operations are
- * completed.  This is the ONLY safe place to power off an RMI sensor
- * during the suspend process.
- * @pre_resume - this is called before any other resume operations.  If you
- * powered off the RMI4 sensor in post_suspend(), then you MUST power it back
- * here, and you MUST wait an appropriate time for the ASIC to come up
- * (100ms to 200ms, depending on the sensor) before returning.
- * @pm_data - this will be passed to the various (pre|post)_(suspend/resume)
- * functions.
  */
 struct rmi_device_platform_data {
 	int irq;
@@ -242,14 +230,6 @@ struct rmi_device_platform_data {
 #ifdef CONFIG_RMI4_FWLIB
 	char *firmware_name;
 #endif
-
-#ifdef	CONFIG_PM
-	void *pm_data;
-	int (*pre_suspend) (const void *pm_data);
-	int (*post_suspend) (const void *pm_data);
-	int (*pre_resume) (const void *pm_data);
-	int (*post_resume) (const void *pm_data);
-#endif
 };
 
 /**
-- 
1.8.1.5


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

* [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code
  2014-01-24  0:00           ` [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks Courtney Cavin
@ 2014-01-24  0:00             ` Courtney Cavin
  2014-01-24  0:00               ` [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data Courtney Cavin
  2014-02-04 23:09               ` [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code Christopher Heiny
  2014-02-04 23:09             ` [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks Christopher Heiny
  1 sibling, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

As most of this code was already removed, the remainder does nothing.
Remove it.

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/Kconfig      |   1 -
 drivers/input/rmi4/rmi_bus.c    | 103 ----------------------------------------
 drivers/input/rmi4/rmi_bus.h    |  12 -----
 drivers/input/rmi4/rmi_driver.c |   3 --
 drivers/input/rmi4/rmi_driver.h |  12 -----
 drivers/input/rmi4/rmi_f11.c    |   2 +-
 include/linux/rmi.h             |   7 ++-
 7 files changed, 4 insertions(+), 136 deletions(-)

diff --git a/drivers/input/rmi4/Kconfig b/drivers/input/rmi4/Kconfig
index d0c7b6e..22d5599 100644
--- a/drivers/input/rmi4/Kconfig
+++ b/drivers/input/rmi4/Kconfig
@@ -14,7 +14,6 @@ config RMI4_CORE
 config RMI4_DEBUG
 	bool "RMI4 Debugging"
 	depends on RMI4_CORE
-	select DEBUG_FS
 	help
 	  Say Y here to enable debug feature in the RMI4 driver.
 
diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index fd14acb..a51e6b4 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -15,14 +15,9 @@
 #include <linux/rmi.h>
 #include <linux/slab.h>
 #include <linux/types.h>
-#include <linux/debugfs.h>
 #include "rmi_bus.h"
 #include "rmi_driver.h"
 
-#ifdef CONFIG_RMI4_DEBUG
-static struct dentry *rmi_debugfs_root;
-#endif
-
 /*
  * RMI Physical devices
  *
@@ -47,34 +42,6 @@ bool rmi_is_physical_device(struct device *dev)
 	return dev->type == &rmi_device_type;
 }
 
-#ifdef CONFIG_RMI4_DEBUG
-
-static void rmi_physical_setup_debugfs(struct rmi_device *rmi_dev)
-{
-	rmi_dev->debugfs_root = debugfs_create_dir(dev_name(&rmi_dev->dev),
-						   rmi_debugfs_root);
-	if (!rmi_dev->debugfs_root)
-		dev_warn(&rmi_dev->dev, "Failed to create debugfs root.\n");
-}
-
-static void rmi_physical_teardown_debugfs(struct rmi_device *rmi_dev)
-{
-	if (rmi_dev->debugfs_root)
-		debugfs_remove_recursive(rmi_dev->debugfs_root);
-}
-
-#else
-
-static void rmi_physical_setup_debugfs(struct rmi_device *rmi_dev)
-{
-}
-
-static void rmi_physical_teardown_debugfs(struct rmi_device *rmi_dev)
-{
-}
-
-#endif
-
 /**
  * rmi_register_transport_device - register a transport device connection
  * on the RMI bus.  Transport drivers provide communication from the devices
@@ -108,8 +75,6 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
 
 	xport->rmi_dev = rmi_dev;
 
-	rmi_physical_setup_debugfs(rmi_dev);
-
 	error = device_register(&rmi_dev->dev);
 	if (error) {
 		put_device(&rmi_dev->dev);
@@ -132,7 +97,6 @@ void rmi_unregister_transport_device(struct rmi_transport_dev *xport)
 {
 	struct rmi_device *rmi_dev = xport->rmi_dev;
 
-	rmi_physical_teardown_debugfs(rmi_dev);
 	device_unregister(&rmi_dev->dev);
 }
 EXPORT_SYMBOL(rmi_unregister_transport_device);
@@ -156,37 +120,6 @@ bool rmi_is_function_device(struct device *dev)
 	return dev->type == &rmi_function_type;
 }
 
-#ifdef CONFIG_RMI4_DEBUG
-
-static void rmi_function_setup_debugfs(struct rmi_function *fn)
-{
-	char dirname[12];
-
-	snprintf(dirname, sizeof(dirname), "F%02X", fn->fd.function_number);
-	fn->debugfs_root = debugfs_create_dir(dirname,
-					      fn->rmi_dev->debugfs_root);
-	if (!fn->debugfs_root)
-		dev_warn(&fn->dev, "Failed to create debugfs dir.\n");
-}
-
-static void rmi_function_teardown_debugfs(struct rmi_function *fn)
-{
-	if (fn->debugfs_root)
-		debugfs_remove_recursive(fn->debugfs_root);
-}
-
-#else
-
-static void rmi_function_setup_debugfs(struct rmi_function *fn)
-{
-}
-
-static void rmi_function_teardown_debugfs(struct rmi_function *fn)
-{
-}
-
-#endif
-
 static int rmi_function_match(struct device *dev, struct device_driver *drv)
 {
 	struct rmi_function_handler *handler = to_rmi_function_handler(drv);
@@ -234,8 +167,6 @@ int rmi_register_function(struct rmi_function *fn)
 	fn->dev.type = &rmi_function_type;
 	fn->dev.bus = &rmi_bus_type;
 
-	rmi_function_setup_debugfs(fn);
-
 	error = device_register(&fn->dev);
 	if (error) {
 		dev_err(&rmi_dev->dev,
@@ -250,13 +181,11 @@ int rmi_register_function(struct rmi_function *fn)
 	return 0;
 
 error_exit:
-	rmi_function_teardown_debugfs(fn);
 	return error;
 }
 
 void rmi_unregister_function(struct rmi_function *fn)
 {
-	rmi_function_teardown_debugfs(fn);
 	device_unregister(&fn->dev);
 }
 
@@ -325,34 +254,6 @@ struct bus_type rmi_bus_type = {
 	.name		= "rmi",
 };
 
-#ifdef CONFIG_RMI4_DEBUG
-
-static void rmi_bus_setup_debugfs(void)
-{
-	rmi_debugfs_root = debugfs_create_dir(rmi_bus_type.name, NULL);
-	if (!rmi_debugfs_root)
-		pr_err("%s: Failed to create debugfs root\n",
-		       __func__);
-}
-
-static void rmi_bus_teardown_debugfs(void)
-{
-	if (rmi_debugfs_root)
-		debugfs_remove_recursive(rmi_debugfs_root);
-}
-
-#else
-
-static void rmi_bus_setup_debugfs(void)
-{
-}
-
-static void rmi_bus_teardown_debugfs(void)
-{
-}
-
-#endif
-
 static int __init rmi_bus_init(void)
 {
 	int error;
@@ -364,8 +265,6 @@ static int __init rmi_bus_init(void)
 		return error;
 	}
 
-	rmi_bus_setup_debugfs();
-
 	error = rmi_register_f01_handler();
 	if (error) {
 		pr_err("%s: error registering the RMI F01 handler: %d\n",
@@ -385,7 +284,6 @@ static int __init rmi_bus_init(void)
 err_unregister_f01:
 	rmi_unregister_f01_handler();
 err_unregister_bus:
-	rmi_bus_teardown_debugfs();
 	bus_unregister(&rmi_bus_type);
 	return error;
 }
@@ -400,7 +298,6 @@ static void __exit rmi_bus_exit(void)
 
 	rmi_unregister_physical_driver();
 	rmi_unregister_f01_handler();
-	rmi_bus_teardown_debugfs();
 	bus_unregister(&rmi_bus_type);
 }
 module_exit(rmi_bus_exit);
diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
index 2bad2ed..62fd544 100644
--- a/drivers/input/rmi4/rmi_bus.h
+++ b/drivers/input/rmi4/rmi_bus.h
@@ -19,7 +19,6 @@
 #include <linux/stat.h>
 #include <linux/types.h>
 #include <linux/wait.h>
-#include <linux/debugfs.h>
 #include <linux/rmi.h>
 
 struct rmi_device;
@@ -39,7 +38,6 @@ struct rmi_device;
  * @data: Private data pointer
  *
  * @node: entry in device's list of functions
- * @debugfs_root: used during debugging
  */
 struct rmi_function {
 	struct rmi_function_descriptor fd;
@@ -50,10 +48,6 @@ struct rmi_function {
 	unsigned long *irq_mask;
 	void *data;
 	struct list_head node;
-
-#ifdef CONFIG_RMI4_DEBUG
-	struct dentry *debugfs_root;
-#endif
 };
 
 #define to_rmi_function(d)	container_of(d, struct rmi_function, dev)
@@ -208,8 +202,6 @@ struct rmi_transport_ops {
  * @number: Unique number for the device on the bus.
  * @driver: Pointer to associated driver
  * @xport: Pointer to the transport interface
- * @debugfs_root: base for this particular sensor device.
- *
  */
 struct rmi_device {
 	struct device dev;
@@ -217,10 +209,6 @@ struct rmi_device {
 
 	struct rmi_driver *driver;
 	struct rmi_transport_dev *xport;
-
-#ifdef CONFIG_RMI4_DEBUG
-	struct dentry *debugfs_root;
-#endif
 };
 
 #define to_rmi_device(d) container_of(d, struct rmi_device, dev)
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 691b6fb..e44eff7 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -16,7 +16,6 @@
 
 #include <linux/kernel.h>
 #include <linux/bitmap.h>
-#include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/fs.h>
@@ -42,8 +41,6 @@
 
 #define DEFAULT_POLL_INTERVAL_MS	13
 
-#define IRQ_DEBUG(data) (IS_ENABLED(CONFIG_RMI4_DEBUG) && data->irq_debug)
-
 static irqreturn_t rmi_irq_thread(int irq, void *p)
 {
 	struct rmi_transport_dev *xport = p;
diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
index f28166f..eafbdb3 100644
--- a/drivers/input/rmi4/rmi_driver.h
+++ b/drivers/input/rmi4/rmi_driver.h
@@ -38,7 +38,6 @@ struct rmi_driver_data {
 	bool f01_bootloader_mode;
 
 	u32 attn_count;
-	u32 irq_debug;	/* Should be bool, but debugfs wants u32 */
 	int irq;
 	int num_of_irq_regs;
 	int irq_count;
@@ -54,17 +53,6 @@ struct rmi_driver_data {
 
 	bool enabled;
 
-#ifdef CONFIG_RMI4_DEBUG
-	struct dentry *debugfs_delay;
-	struct dentry *debugfs_xport;
-	struct dentry *debugfs_reg_ctl;
-	struct dentry *debugfs_reg;
-	struct dentry *debugfs_irq;
-	struct dentry *debugfs_attn_count;
-	u16 reg_debug_addr;
-	u8 reg_debug_size;
-#endif
-
 	void *data;
 };
 
diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
index 553afd8..87d85ab 100644
--- a/drivers/input/rmi4/rmi_f11.c
+++ b/drivers/input/rmi4/rmi_f11.c
@@ -515,7 +515,7 @@ struct f11_2d_sensor {
 	u8 *data_pkt;
 	int pkt_size;
 	u8 sensor_index;
-	u32 type_a;	/* boolean but debugfs API requires u32 */
+	bool type_a;
 	enum rmi_f11_sensor_type sensor_type;
 	struct input_dev *input;
 	struct input_dev *mouse_input;
diff --git a/include/linux/rmi.h b/include/linux/rmi.h
index 41c2c04..f3775eb 100644
--- a/include/linux/rmi.h
+++ b/include/linux/rmi.h
@@ -21,7 +21,6 @@
 #include <linux/stat.h>
 #include <linux/types.h>
 #include <linux/wait.h>
-#include <linux/debugfs.h>
 
 /**
  * struct rmi_f11_axis_alignment - target axis alignment
@@ -42,9 +41,9 @@
  *               automatically enabled for this sensor.
  */
 struct rmi_f11_2d_axis_alignment {
-	u32 swap_axes;	/* boolean, but u32 is needed by debugfs API */
-	u32 flip_x;	/* boolean */
-	u32 flip_y;	/* boolean */
+	bool swap_axes;
+	bool flip_x;
+	bool flip_y;
 	u16 clip_x_low;
 	u16 clip_y_low;
 	u16 clip_x_high;
-- 
1.8.1.5


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

* [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data
  2014-01-24  0:00             ` [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code Courtney Cavin
@ 2014-01-24  0:00               ` Courtney Cavin
  2014-01-24  0:00                 ` [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables Courtney Cavin
  2014-02-04 23:10                 ` [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data Christopher Heiny
  2014-02-04 23:09               ` [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code Christopher Heiny
  1 sibling, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

Update platform data documentation and remove unneeded/unused stuff in
platform data.

If these items are needed at some later point, they should be added
then.  Until that point, we should unclutter the code.

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/rmi_f11.c |  14 ++--
 include/linux/rmi.h          | 157 ++++++++++---------------------------------
 2 files changed, 40 insertions(+), 131 deletions(-)

diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
index 87d85ab..9d94b1a 100644
--- a/drivers/input/rmi4/rmi_f11.c
+++ b/drivers/input/rmi4/rmi_f11.c
@@ -1109,7 +1109,7 @@ static void f11_set_abs_params(struct rmi_function *fn)
 	/* We assume touchscreen unless demonstrably a touchpad or specified
 	 * as a touchpad in the platform data
 	 */
-	if (sensor->sensor_type == rmi_f11_sensor_touchpad ||
+	if (sensor->sensor_type == RMI_F11_SENSOR_INDIRECT ||
 			(sensor->sens_query.has_info2 &&
 				!sensor->sens_query.is_clear))
 		input_flags = INPUT_PROP_POINTER;
@@ -1192,7 +1192,7 @@ static int rmi_f11_initialize(struct rmi_function *fn)
 		return -ENOMEM;
 
 	fn->data = f11;
-	f11->rezero_wait_ms = pdata->f11_rezero_wait;
+	f11->rezero_wait_ms = pdata->f11_sensor_data.rezero_wait;
 
 	query_base_addr = fn->fd.query_base_addr;
 	control_base_addr = fn->fd.control_base_addr;
@@ -1225,13 +1225,9 @@ static int rmi_f11_initialize(struct rmi_function *fn)
 		return rc;
 	}
 
-	if (pdata->f11_sensor_data) {
-		sensor->axis_align =
-			pdata->f11_sensor_data->axis_align;
-		sensor->type_a = pdata->f11_sensor_data->type_a;
-		sensor->sensor_type =
-				pdata->f11_sensor_data->sensor_type;
-	}
+	sensor->axis_align = pdata->f11_sensor_data.axis_align;
+	sensor->type_a = pdata->f11_sensor_data.type_a;
+	sensor->sensor_type = pdata->f11_sensor_data.sensor_type;
 
 	rc = rmi_read_block(rmi_dev,
 		control_base_addr + F11_CTRL_SENSOR_MAX_X_POS_OFFSET,
diff --git a/include/linux/rmi.h b/include/linux/rmi.h
index f3775eb..60ddd98 100644
--- a/include/linux/rmi.h
+++ b/include/linux/rmi.h
@@ -37,8 +37,8 @@
  *               the specified value
  * @offset_x - this value will be added to all reported X coordinates
  * @offset_y - this value will be added to all reported Y coordinates
- * @rel_report_enabled - if set to true, the relative reporting will be
- *               automatically enabled for this sensor.
+ * @delta_x_threshold - delta X movement required before reporting event
+ * @delta_y_threshold - delta Y movement required before reporting event
  */
 struct rmi_f11_2d_axis_alignment {
 	bool swap_axes;
@@ -57,34 +57,36 @@ struct rmi_f11_2d_axis_alignment {
 /** This is used to override any hints an F11 2D sensor might have provided
  * as to what type of sensor it is.
  *
- * @rmi_f11_sensor_default - do not override, determine from F11_2D_QUERY14 if
- * available.
- * @rmi_f11_sensor_touchscreen - treat the sensor as a touchscreen (direct
- * pointing).
- * @rmi_f11_sensor_touchpad - thread the sensor as a touchpad (indirect
- * pointing).
+ * @RMI_F11_SENSOR_DEFAULT - determine from F11_2D_QUERY14 if available.
+ * @RMI_F11_SENSOR_DIRECT - direct pointing sensor (e.g. touchscreen)
+ * @RMI_F11_SENSOR_INDIRECT - indirect pointing sensor (e.g touchpad)
  */
 enum rmi_f11_sensor_type {
-	rmi_f11_sensor_default = 0,
-	rmi_f11_sensor_touchscreen,
-	rmi_f11_sensor_touchpad
+	RMI_F11_SENSOR_DEFAULT = 0,
+	RMI_F11_SENSOR_DIRECT,
+	RMI_F11_SENSOR_INDIRECT
 };
 
 /**
  * struct rmi_f11_sensor_data - overrides defaults for a single F11 2D sensor.
+ *
  * @axis_align - provides axis alignment overrides (see above).
  * @type_a - all modern RMI F11 firmwares implement Multifinger Type B
- * protocol.  Set this to true to force MF Type A behavior, in case you find
- * an older sensor.
+ *           protocol.  Set this to true to force MF Type A behavior, in case
+ *           you find an older sensor.
  * @sensor_type - Forces the driver to treat the sensor as an indirect
- * pointing device (touchpad) rather than a direct pointing device
- * (touchscreen).  This is useful when F11_2D_QUERY14 register is not
- * available.
+ *                pointing device (touchpad) rather than a direct pointing
+ *                device (touchscreen).  This is useful when F11_2D_QUERY14
+ *                register is not available.
+ * @rezero_wait - if non-zero, this is how may milliseconds the sensor will
+ *                wait before being be re-zeroed on exit from suspend.  If this
+ *                value is zero, the sensor will not be re-zeroed on resume.
  */
 struct rmi_f11_sensor_data {
 	struct rmi_f11_2d_axis_alignment axis_align;
 	bool type_a;
 	enum rmi_f11_sensor_type sensor_type;
+	u16 rezero_wait;
 };
 
 /**
@@ -98,20 +100,22 @@ enum rmi_f01_nosleep {
 };
 
 /**
- * struct rmi_f01_power_management -When non-zero, these values will be written
- * to the touch sensor to override the default firmware settigns.  For a
- * detailed explanation of what each field does, see the corresponding
- * documention in the RMI4 specification.
+ * struct rmi_f01_power_management - touch sensor power settings
+ *
+ * When non-zero, these values will be written to the touch sensor to override
+ * the default firmware settings.  For a detailed explanation of what each
+ * field does, see the corresponding documentation in the RMI4 specification.
  *
  * @nosleep - specifies whether the device is permitted to sleep or doze (that
- * is, enter a temporary low power state) when no fingers are touching the
- * sensor.
+ *            is, enter a temporary low power state) when no fingers are
+ *            touching the sensor.
  * @wakeup_threshold - controls the capacitance threshold at which the touch
- * sensor will decide to wake up from that low power state.
+ *                     sensor will decide to wake up from that low power state.
  * @doze_holdoff - controls how long the touch sensor waits after the last
- * finger lifts before entering the doze state, in units of 100ms.
+ *                 finger lifts before entering the doze state, in units of
+ *                 100ms.
  * @doze_interval - controls the interval between checks for finger presence
- * when the touch sensor is in doze mode, in units of 10ms.
+ *                  when the touch sensor is in doze mode, in units of 10ms.
  */
 struct rmi_f01_power_management {
 	enum rmi_f01_nosleep nosleep;
@@ -121,114 +125,23 @@ struct rmi_f01_power_management {
 };
 
 /**
- * struct rmi_button_map - used to specify the initial input subsystem key
- * event codes to be generated by buttons (or button like entities) on the
- * touch sensor.
- * @nbuttons - length of the button map.
- * @map - the key event codes for the corresponding buttons on the touch
- * sensor.
- */
-struct rmi_button_map {
-	u8 nbuttons;
-	u8 *map;
-};
-
-struct rmi_f30_gpioled_map {
-	u8 ngpioleds;
-	u8 *map;
-};
-
-/**
- * struct rmi_device_platform_data_spi - provides parameters used in SPI
- * communications.  All Synaptics SPI products support a standard SPI
- * interface; some also support what is called SPI V2 mode, depending on
- * firmware and/or ASIC limitations.  In V2 mode, the touch sensor can
- * support shorter delays during certain operations, and these are specified
- * separately from the standard mode delays.
- *
- * @block_delay - for standard SPI transactions consisting of both a read and
- * write operation, the delay (in microseconds) between the read and write
- * operations.
- * @split_read_block_delay_us - for V2 SPI transactions consisting of both a
- * read and write operation, the delay (in microseconds) between the read and
- * write operations.
- * @read_delay_us - the delay between each byte of a read operation in normal
- * SPI mode.
- * @write_delay_us - the delay between each byte of a write operation in normal
- * SPI mode.
- * @split_read_byte_delay_us - the delay between each byte of a read operation
- * in V2 mode.
- * @pre_delay_us - the delay before the start of a SPI transaction.  This is
- * typically useful in conjunction with custom chip select assertions (see
- * below).
- * @post_delay_us - the delay after the completion of an SPI transaction.  This
- * is typically useful in conjunction with custom chip select assertions (see
- * below).
- * @cs_assert - For systems where the SPI subsystem does not control the CS/SSB
- * line, or where such control is broken, you can provide a custom routine to
- * handle a GPIO as CS/SSB.  This routine will be called at the beginning and
- * end of each SPI transaction.  The RMI SPI implementation will wait
- * pre_delay_us after this routine returns before starting the SPI transfer;
- * and post_delay_us after completion of the SPI transfer(s) before calling it
- * with assert==FALSE.
- */
-struct rmi_device_platform_data_spi {
-	u32 block_delay_us;
-	u32 split_read_block_delay_us;
-	u32 read_delay_us;
-	u32 write_delay_us;
-	u32 split_read_byte_delay_us;
-	u32 pre_delay_us;
-	u32 post_delay_us;
-
-	void *cs_assert_data;
-	int (*cs_assert) (const void *cs_assert_data, const bool assert);
-};
-
-/**
  * struct rmi_device_platform_data - system specific configuration info.
  *
  * @irq - attention IRQ
- * @firmware_name - if specified will override default firmware name,
- * for reflashing.
- *
  * @reset_delay_ms - after issuing a reset command to the touch sensor, the
- * driver waits a few milliseconds to give the firmware a chance to
- * to re-initialize.  You can override the default wait period here.
- *
- * @spi_data - override default settings for SPI delays and SSB management (see
- * above).
- *
+ *                   driver waits a few milliseconds to give the firmware a
+ *                   chance to to re-initialize.  You can override the default
+ *                   wait period here.
  * @f11_sensor_data - platform data for the F11 2D sensor.
- * @f11_rezero_wait - if non-zero, this is how may milliseconds the F11 2D
- * sensor will wait before being be rezeroed on exit from suspend.  If
- * this value is zero, the F11 2D sensor will not be rezeroed on resume.
- * @power_management - overrides default touch sensor doze mode settings (see
- * above)
- * @f19_button_map - provide initial input subsystem key mappings for F19.
- * @f1a_button_map - provide initial input subsystem key mappings for F1A.
- * @gpioled_map - provides initial settings for GPIOs and LEDs controlled by
- * F30.
- * @f41_button_map - provide initial input subsystem key mappings for F41.
+ * @power_management - touch sensor power settings (see above)
  */
 struct rmi_device_platform_data {
 	int irq;
-	int reset_delay_ms;
-
-	struct rmi_device_platform_data_spi spi_data;
+	u32 reset_delay_ms;
 
 	/* function handler pdata */
-	struct rmi_f11_sensor_data *f11_sensor_data;
-	u16 f11_rezero_wait;
+	struct rmi_f11_sensor_data f11_sensor_data;
 	struct rmi_f01_power_management power_management;
-	struct rmi_button_map *f19_button_map;
-	struct rmi_button_map *f1a_button_map;
-	struct rmi_f30_gpioled_map *gpioled_map;
-	struct rmi_button_map *f41_button_map;
-
-#ifdef CONFIG_RMI4_FWLIB
-	char *firmware_name;
-#endif
 };
 
 /**
-- 
1.8.1.5


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

* [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables
  2014-01-24  0:00               ` [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data Courtney Cavin
@ 2014-01-24  0:00                 ` Courtney Cavin
  2014-01-24  0:00                   ` [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support Courtney Cavin
  2014-02-04 23:10                   ` [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables Christopher Heiny
  2014-02-04 23:10                 ` [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data Christopher Heiny
  1 sibling, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

This is neither a library nor documentation, so it doesn't need to
contain all of the information available.  Remove most of the unused
struct members and defines.  If they are need to implement some
functionality at a later point, they can be added back at that point.

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/rmi_bus.h    |   1 -
 drivers/input/rmi4/rmi_driver.c |   3 -
 drivers/input/rmi4/rmi_f01.c    |  40 -----
 drivers/input/rmi4/rmi_f11.c    | 375 ----------------------------------------
 4 files changed, 419 deletions(-)

diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
index 62fd544..a21e4c4 100644
--- a/drivers/input/rmi4/rmi_bus.h
+++ b/drivers/input/rmi4/rmi_bus.h
@@ -278,7 +278,6 @@ static inline int rmi_write_block(struct rmi_device *d, u16 addr,
 
 int rmi_register_transport_device(struct rmi_transport_dev *xport);
 void rmi_unregister_transport_device(struct rmi_transport_dev *xport);
-int rmi_for_each_dev(void *data, int (*func)(struct device *dev, void *data));
 
 /**
  * module_rmi_driver() - Helper macro for registering a function driver
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index e44eff7..9ec7b93 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -32,15 +32,12 @@
 
 #define RMI4_MAX_N_IRQS 256
 
-#define HAS_NONSTANDARD_PDT_MASK 0x40
 #define RMI4_MAX_PAGE 0xff
 #define RMI4_PAGE_SIZE 0x100
 
 #define RMI_DEVICE_RESET_CMD	0x01
 #define DEFAULT_RESET_DELAY_MS	100
 
-#define DEFAULT_POLL_INTERVAL_MS	13
-
 static irqreturn_t rmi_irq_thread(int irq, void *p)
 {
 	struct rmi_transport_dev *xport = p;
diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
index 98bc65a9..4cb9fcb 100644
--- a/drivers/input/rmi4/rmi_f01.c
+++ b/drivers/input/rmi4/rmi_f01.c
@@ -15,27 +15,11 @@
 #include "rmi_driver.h"
 
 #define RMI_PRODUCT_ID_LENGTH    10
-#define RMI_PRODUCT_INFO_LENGTH   2
-
-#define RMI_DATE_CODE_LENGTH      3
-
-#define PRODUCT_ID_OFFSET 0x10
-#define PRODUCT_INFO_OFFSET 0x1E
-
-
-/* Force a firmware reset of the sensor */
-#define RMI_F01_CMD_DEVICE_RESET	1
 
 /* Various F01_RMI_QueryX bits */
-
-#define RMI_F01_QRY1_CUSTOM_MAP		(1 << 0)
-#define RMI_F01_QRY1_NON_COMPLIANT	(1 << 1)
 #define RMI_F01_QRY1_HAS_LTS		(1 << 2)
-#define RMI_F01_QRY1_HAS_SENSOR_ID	(1 << 3)
-#define RMI_F01_QRY1_HAS_CHARGER_INP	(1 << 4)
 #define RMI_F01_QRY1_HAS_ADJ_DOZE	(1 << 5)
 #define RMI_F01_QRY1_HAS_ADJ_DOZE_HOFF	(1 << 6)
-#define RMI_F01_QRY1_HAS_PROPS_2	(1 << 7)
 
 #define RMI_F01_QRY5_YEAR_MASK		0x1f
 #define RMI_F01_QRY6_MONTH_MASK		0x0f
@@ -52,7 +36,6 @@ struct f01_basic_properties {
 	bool has_adjustable_doze_holdoff;
 	char dom[11]; /* YYYY/MM/DD + '\0' */
 	u8 product_id[RMI_PRODUCT_ID_LENGTH + 1];
-	u16 productinfo;
 };
 
 /* F01 device status bits */
@@ -87,19 +70,6 @@ struct f01_basic_properties {
 #define RMI_F01_CRTL0_NOSLEEP_BIT	(1 << 2)
 
 /*
- * When this bit is set, the touch controller employs a noise-filtering
- * algorithm designed for use with a connected battery charger.
- */
-#define RMI_F01_CRTL0_CHARGER_BIT	(1 << 5)
-
-/*
- * Sets the report rate for the device. The effect of this setting is
- * highly product dependent. Check the spec sheet for your particular
- * touch sensor.
- */
-#define RMI_F01_CRTL0_REPORTRATE_BIT	(1 << 6)
-
-/*
  * Written by the host as an indicator that the device has been
  * successfully configured.
  */
@@ -127,7 +97,6 @@ struct f01_data {
 	struct f01_basic_properties properties;
 
 	struct f01_device_control device_control;
-	struct mutex control_mutex;
 
 	u8 device_status;
 
@@ -135,11 +104,9 @@ struct f01_data {
 	u16 doze_interval_addr;
 	u16 wakeup_threshold_addr;
 	u16 doze_holdoff_addr;
-	int irq_count;
 	int num_of_irq_regs;
 
 #ifdef CONFIG_PM_SLEEP
-	bool suspended;
 	bool old_nosleep;
 #endif
 };
@@ -199,10 +166,6 @@ static int rmi_f01_read_properties(struct rmi_device *rmi_dev,
 		RMI_PRODUCT_ID_LENGTH);
 	props->product_id[RMI_PRODUCT_ID_LENGTH] = '\0';
 
-	props->productinfo =
-			((basic_query[2] & RMI_F01_QRY2_PRODINFO_MASK) << 7) |
-			(basic_query[3] & RMI_F01_QRY2_PRODINFO_MASK);
-
 	return 0;
 }
 
@@ -216,8 +179,6 @@ static int rmi_f01_initialize(struct rmi_function *fn)
 	struct f01_data *data = fn->data;
 	struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
 
-	mutex_init(&data->control_mutex);
-
 	/*
 	 * Set the configured bit and (optionally) other important stuff
 	 * in the device control register.
@@ -263,7 +224,6 @@ static int rmi_f01_initialize(struct rmi_function *fn)
 		return error;
 	}
 
-	data->irq_count = driver_data->irq_count;
 	data->num_of_irq_regs = driver_data->num_of_irq_regs;
 	ctrl_base_addr += sizeof(u8);
 
diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
index 9d94b1a..b114f25 100644
--- a/drivers/input/rmi4/rmi_f11.c
+++ b/drivers/input/rmi4/rmi_f11.c
@@ -7,8 +7,6 @@
  * the Free Software Foundation.
  */
 
-#define FUNCTION_DATA f11_data
-
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/device.h>
@@ -19,9 +17,6 @@
 #include <linux/slab.h>
 #include "rmi_driver.h"
 
-#define F11_MAX_NUM_OF_FINGERS		10
-#define F11_MAX_NUM_OF_TOUCH_SHAPES	16
-
 #define F11_REL_POS_MIN		-128
 #define F11_REL_POS_MAX		127
 
@@ -30,14 +25,12 @@
 #define F11_CTRL_SENSOR_MAX_X_POS_OFFSET	6
 #define F11_CTRL_SENSOR_MAX_Y_POS_OFFSET	8
 
-#define DEFAULT_XY_MAX 9999
 #define DEFAULT_MAX_ABS_MT_PRESSURE 255
 #define DEFAULT_MAX_ABS_MT_TOUCH 15
 #define DEFAULT_MAX_ABS_MT_ORIENTATION 1
 #define DEFAULT_MIN_ABS_MT_TRACKING_ID 1
 #define DEFAULT_MAX_ABS_MT_TRACKING_ID 10
 #define NAME_BUFFER_SIZE 256
-#define FUNCTION_NUMBER 0x11
 
 /** A note about RMI4 F11 register structure.
  *
@@ -81,108 +74,37 @@
 #define RMI_F11_HAS_QUERY28             (1 << 7)
 
 /** Defs for Query 1 */
-
 #define RMI_F11_NR_FINGERS_MASK 0x07
 #define RMI_F11_HAS_REL                 (1 << 3)
 #define RMI_F11_HAS_ABS                 (1 << 4)
 #define RMI_F11_HAS_GESTURES            (1 << 5)
-#define RMI_F11_HAS_SENSITIVITY_ADJ     (1 << 6)
-#define RMI_F11_CONFIGURABLE            (1 << 7)
-
-/** Defs for Query 2, 3, and 4. */
-#define RMI_F11_NR_ELECTRODES_MASK      0x7F
 
 /** Defs for Query 5 */
-
-#define RMI_F11_ABS_DATA_SIZE_MASK      0x03
-#define RMI_F11_HAS_ANCHORED_FINGER     (1 << 2)
-#define RMI_F11_HAS_ADJ_HYST            (1 << 3)
-#define RMI_F11_HAS_DRIBBLE             (1 << 4)
-#define RMI_F11_HAS_BENDING_CORRECTION  (1 << 5)
-#define RMI_F11_HAS_LARGE_OBJECT_SUPPRESSION    (1 << 6)
 #define RMI_F11_HAS_JITTER_FILTER       (1 << 7)
 
 /** Defs for Query 7 */
-#define RMI_F11_HAS_SINGLE_TAP                  (1 << 0)
-#define RMI_F11_HAS_TAP_AND_HOLD                (1 << 1)
-#define RMI_F11_HAS_DOUBLE_TAP                  (1 << 2)
-#define RMI_F11_HAS_EARLY_TAP                   (1 << 3)
 #define RMI_F11_HAS_FLICK                       (1 << 4)
-#define RMI_F11_HAS_PRESS                       (1 << 5)
 #define RMI_F11_HAS_PINCH                       (1 << 6)
-#define RMI_F11_HAS_CHIRAL                      (1 << 7)
 
 /** Defs for Query 8 */
-#define RMI_F11_HAS_PALM_DET                    (1 << 0)
 #define RMI_F11_HAS_ROTATE                      (1 << 1)
 #define RMI_F11_HAS_TOUCH_SHAPES                (1 << 2)
-#define RMI_F11_HAS_SCROLL_ZONES                (1 << 3)
-#define RMI_F11_HAS_INDIVIDUAL_SCROLL_ZONES     (1 << 4)
-#define RMI_F11_HAS_MF_SCROLL                   (1 << 5)
-#define RMI_F11_HAS_MF_EDGE_MOTION              (1 << 6)
-#define RMI_F11_HAS_MF_SCROLL_INERTIA           (1 << 7)
 
 /** Defs for Query 9. */
 #define RMI_F11_HAS_PEN                         (1 << 0)
-#define RMI_F11_HAS_PROXIMITY                   (1 << 1)
-#define RMI_F11_HAS_PALM_DET_SENSITIVITY        (1 << 2)
-#define RMI_F11_HAS_SUPPRESS_ON_PALM_DETECT     (1 << 3)
-#define RMI_F11_HAS_TWO_PEN_THRESHOLDS          (1 << 4)
-#define RMI_F11_HAS_CONTACT_GEOMETRY            (1 << 5)
-#define RMI_F11_HAS_PEN_HOVER_DISCRIMINATION    (1 << 6)
-#define RMI_F11_HAS_PEN_FILTERS                 (1 << 7)
 
 /** Defs for Query 10. */
 #define RMI_F11_NR_TOUCH_SHAPES_MASK            0x1F
 
-/** Defs for Query 11 */
-
-#define RMI_F11_HAS_Z_TUNING                    (1 << 0)
-#define RMI_F11_HAS_ALGORITHM_SELECTION         (1 << 1)
-#define RMI_F11_HAS_W_TUNING                    (1 << 2)
-#define RMI_F11_HAS_PITCH_INFO                  (1 << 3)
-#define RMI_F11_HAS_FINGER_SIZE                 (1 << 4)
-#define RMI_F11_HAS_SEGMENTATION_AGGRESSIVENESS (1 << 5)
-#define RMI_F11_HAS_XY_CLIP                     (1 << 6)
-#define RMI_F11_HAS_DRUMMING_FILTER             (1 << 7)
-
 /** Defs for Query 12. */
-
-#define RMI_F11_HAS_GAPLESS_FINGER              (1 << 0)
-#define RMI_F11_HAS_GAPLESS_FINGER_TUNING       (1 << 1)
-#define RMI_F11_HAS_8BIT_W                      (1 << 2)
-#define RMI_F11_HAS_ADJUSTABLE_MAPPING          (1 << 3)
 #define RMI_F11_HAS_INFO2                       (1 << 4)
-#define RMI_F11_HAS_PHYSICAL_PROPS              (1 << 5)
-#define RMI_F11_HAS_FINGER_LIMIT                (1 << 6)
-#define RMI_F11_HAS_LINEAR_COEFF                (1 << 7)
-
-/** Defs for Query 13. */
-
-#define RMI_F11_JITTER_WINDOW_MASK              0x1F
-#define RMI_F11_JITTER_FILTER_MASK              0x60
-#define RMI_F11_JITTER_FILTER_SHIFT             5
 
 /** Defs for Query 14. */
-#define RMI_F11_LIGHT_CONTROL_MASK              0x03
 #define RMI_F11_IS_CLEAR                        (1 << 2)
-#define RMI_F11_CLICKPAD_PROPS_MASK             0x18
-#define RMI_F11_CLICKPAD_PROPS_SHIFT            3
-#define RMI_F11_MOUSE_BUTTONS_MASK              0x60
-#define RMI_F11_MOUSE_BUTTONS_SHIFT             5
-#define RMI_F11_HAS_ADVANCED_GESTURES           (1 << 7)
 
 #define RMI_F11_QUERY_SIZE                      4
 #define RMI_F11_QUERY_GESTURE_SIZE              2
 
-#define F11_LIGHT_CTL_NONE 0x00
-#define F11_LUXPAD	   0x01
-#define F11_DUAL_MODE      0x02
-
-#define F11_NOT_CLICKPAD     0x00
-#define F11_HINGED_CLICKPAD  0x01
-#define F11_UNIFORM_CLICKPAD 0x02
-
 /**
  * Query registers 1 through 4 are always present.
  *
@@ -191,55 +113,18 @@
  * @has_rel - the sensor supports relative motion reporting.
  * @has_abs - the sensor supports absolute poition reporting.
  * @has_gestures - the sensor supports gesture reporting.
- * @has_sensitivity_adjust - the sensor supports a global sensitivity
- * adjustment.
- * @configurable - the sensor supports various configuration options.
- * @num_of_x_electrodes -  the maximum number of electrodes the 2-D sensor
- * supports on the X axis.
- * @num_of_y_electrodes -  the maximum number of electrodes the 2-D sensor
- * supports on the Y axis.
- * @max_electrodes - the total number of X and Y electrodes that may be
- * configured.
  *
  * Query 5 is present if the has_abs bit is set.
  *
- * @abs_data_size - describes the format of data reported by the absolute
- * data source.  Only one format (the kind used here) is supported at this
- * time.
- * @has_anchored_finger - then the sensor supports the high-precision second
- * finger tracking provided by the manual tracking and motion sensitivity
- * options.
- * @has_adjust_hyst - the difference between the finger release threshold and
- * the touch threshold.
- * @has_dribble - the sensor supports the generation of dribble interrupts,
- * which may be enabled or disabled with the dribble control bit.
- * @has_bending_correction - Bending related data registers 28 and 36, and
- * control register 52..57 are present.
- * @has_large_object_suppression - control register 58 and data register 28
- * exist.
  * @has_jitter_filter - query 13 and control 73..76 exist.
  *
  * Gesture information queries 7 and 8 are present if has_gestures bit is set.
  *
- * @has_single_tap - a basic single-tap gesture is supported.
- * @has_tap_n_hold - tap-and-hold gesture is supported.
- * @has_double_tap - double-tap gesture is supported.
- * @has_early_tap - early tap is supported and reported as soon as the finger
- * lifts for any tap event that could be interpreted as either a single tap
- * or as the first tap of a double-tap or tap-and-hold gesture.
  * @has_flick - flick detection is supported.
- * @has_press - press gesture reporting is supported.
  * @has_pinch - pinch gesture detection is supported.
- * @has_palm_det - the 2-D sensor notifies the host whenever a large conductive
- * object such as a palm or a cheek touches the 2-D sensor.
  * @has_rotate - rotation gesture detection is supported.
  * @has_touch_shapes - TouchShapes are supported.  A TouchShape is a fixed
  * rectangular area on the sensor that behaves like a capacitive button.
- * @has_scroll_zones - scrolling areas near the sensor edges are supported.
- * @has_individual_scroll_zones - if 1, then 4 scroll zones are supported;
- * if 0, then only two are supported.
- * @has_mf_scroll - the multifinger_scrolling bit will be set when
- * more than one finger is involved in a scrolling action.
  *
  * Convenience for checking bytes in the gesture info registers.  This is done
  * often enough that we put it here to declutter the conditionals
@@ -251,68 +136,21 @@
  *
  * @has_pen - detection of a stylus is supported and registers F11_2D_Ctrl20
  * and F11_2D_Ctrl21 exist.
- * @has_proximity - detection of fingers near the sensor is supported and
- * registers F11_2D_Ctrl22 through F11_2D_Ctrl26 exist.
- * @has_palm_det_sensitivity -  the sensor supports the palm detect sensitivity
- * feature and register F11_2D_Ctrl27 exists.
- * @has_two_pen_thresholds - is has_pen is also set, then F11_2D_Ctrl35 exists.
- * @has_contact_geometry - the sensor supports the use of contact geometry to
- * map absolute X and Y target positions and registers F11_2D_Data18
- * through F11_2D_Data27 exist.
  *
  * Touch shape info (query 10) is present if has_touch_shapes is set.
  *
  * @nr_touch_shapes - the total number of touch shapes supported.
  *
  * Query 11 is present if the has_query11 bit is set in query 0.
- *
- * @has_z_tuning - if set, the sensor supports Z tuning and registers
- * F11_2D_Ctrl29 through F11_2D_Ctrl33 exist.
- * @has_algorithm_selection - controls choice of noise suppression algorithm
- * @has_w_tuning - the sensor supports Wx and Wy scaling and registers
- * F11_2D_Ctrl36 through F11_2D_Ctrl39 exist.
- * @has_pitch_info - the X and Y pitches of the sensor electrodes can be
- * configured and registers F11_2D_Ctrl40 and F11_2D_Ctrl41 exist.
- * @has_finger_size -  the default finger width settings for the
- * sensor can be configured and registers F11_2D_Ctrl42 through F11_2D_Ctrl44
- * exist.
- * @has_segmentation_aggressiveness - the sensor’s ability to distinguish
- * multiple objects close together can be configured and register F11_2D_Ctrl45
- * exists.
- * @has_XY_clip -  the inactive outside borders of the sensor can be
- * configured and registers F11_2D_Ctrl46 through F11_2D_Ctrl49 exist.
- * @has_drumming_filter - the sensor can be configured to distinguish
- * between a fast flick and a quick drumming movement and registers
- * F11_2D_Ctrl50 and F11_2D_Ctrl51 exist.
- *
  * Query 12 is present if hasQuery12 bit is set.
  *
- * @has_gapless_finger - control registers relating to gapless finger are
- * present.
- * @has_gapless_finger_tuning - additional control and data registers relating
- * to gapless finger are present.
- * @has_8bit_w - larger W value reporting is supported.
- * @has_adjustable_mapping - TBD
  * @has_info2 - the general info query14 is present
- * @has_physical_props - additional queries describing the physical properties
- * of the sensor are present.
- * @has_finger_limit - indicates that F11 Ctrl 80 exists.
- * @has_linear_coeff - indicates that F11 Ctrl 81 exists.
  *
  * Query 13 is present if Query 5's has_jitter_filter bit is set.
- * @jitter_window_size - used by Design Studio 4.
- * @jitter_filter_type - used by Design Studio 4.
- *
  * Query 14 is present if query 12's has_general_info2 flag is set.
  *
- * @light_control - Indicates what light/led control features are present, if
- * any.
  * @is_clear - if set, this is a clear sensor (indicating direct pointing
  * application), otherwise it's opaque (indicating indirect pointing).
- * @clickpad_props - specifies if this is a clickpad, and if so what sort of
- * mechanism it uses
- * @mouse_buttons - specifies the number of mouse buttons present (if any).
- * @has_advanced_gestures - advanced driver gestures are supported.
  */
 struct f11_2d_sensor_queries {
 	/* query1 */
@@ -320,112 +158,34 @@ struct f11_2d_sensor_queries {
 	bool has_rel;
 	bool has_abs;
 	bool has_gestures;
-	bool has_sensitivity_adjust;
-	bool configurable;
-
-	/* query2 */
-	u8 nr_x_electrodes;
 
-	/* query3 */
-	u8 nr_y_electrodes;
-
-	/* query4 */
-	u8 max_electrodes;
-
-	/* query5 */
-	u8 abs_data_size;
-	bool has_anchored_finger;
-	bool has_adj_hyst;
-	bool has_dribble;
-	bool has_bending_correction;
-	bool has_large_object_suppression;
 	bool has_jitter_filter;
 
 	u8 f11_2d_query6;
 
 	/* query 7 */
-	bool has_single_tap;
-	bool has_tap_n_hold;
-	bool has_double_tap;
-	bool has_early_tap;
 	bool has_flick;
-	bool has_press;
 	bool has_pinch;
-	bool has_chiral;
-
 	bool query7_nonzero;
 
 	/* query 8 */
-	bool has_palm_det;
 	bool has_rotate;
 	bool has_touch_shapes;
-	bool has_scroll_zones;
-	bool has_individual_scroll_zones;
-	bool has_mf_scroll;
-	bool has_mf_edge_motion;
-	bool has_mf_scroll_inertia;
-
 	bool query8_nonzero;
 
 	/* Query 9 */
 	bool has_pen;
-	bool has_proximity;
-	bool has_palm_det_sensitivity;
-	bool has_suppress_on_palm_detect;
-	bool has_two_pen_thresholds;
-	bool has_contact_geometry;
-	bool has_pen_hover_discrimination;
-	bool has_pen_filters;
 
 	/* Query 10 */
 	u8 nr_touch_shapes;
 
-	/* Query 11. */
-	bool has_z_tuning;
-	bool has_algorithm_selection;
-	bool has_w_tuning;
-	bool has_pitch_info;
-	bool has_finger_size;
-	bool has_segmentation_aggressiveness;
-	bool has_XY_clip;
-	bool has_drumming_filter;
-
 	/* Query 12 */
-	bool has_gapless_finger;
-	bool has_gapless_finger_tuning;
-	bool has_8bit_w;
-	bool has_adjustable_mapping;
 	bool has_info2;
-	bool has_physical_props;
-	bool has_finger_limit;
-	bool has_linear_coeff_2;
-
-	/* Query 13 */
-	u8 jitter_window_size;
-	u8 jitter_filter_type;
 
 	/* Query 14 */
-	u8 light_control;
 	bool is_clear;
-	u8 clickpad_props;
-	u8 mouse_buttons;
-	bool has_advanced_gestures;
 };
 
-/* Defs for Ctrl0. */
-#define RMI_F11_REPORT_MODE_MASK        0x07
-#define RMI_F11_ABS_POS_FILT            (1 << 3)
-#define RMI_F11_REL_POS_FILT            (1 << 4)
-#define RMI_F11_REL_BALLISTICS          (1 << 5)
-#define RMI_F11_DRIBBLE                 (1 << 6)
-#define RMI_F11_REPORT_BEYOND_CLIP      (1 << 7)
-
-/* Defs for Ctrl1. */
-#define RMI_F11_PALM_DETECT_THRESH_MASK 0x0F
-#define RMI_F11_MOTION_SENSITIVITY_MASK 0x30
-#define RMI_F11_MANUAL_TRACKING         (1 << 6)
-#define RMI_F11_MANUAL_TRACKED_FINGER   (1 << 7)
-
 #define RMI_F11_DELTA_X_THRESHOLD       2
 #define RMI_F11_DELTA_Y_THRESHOLD       3
 
@@ -439,24 +199,6 @@ struct f11_2d_ctrl {
 #define RMI_F11_ABS_BYTES 5
 #define RMI_F11_REL_BYTES 2
 
-/* Defs for Data 8 */
-
-#define RMI_F11_SINGLE_TAP              (1 << 0)
-#define RMI_F11_TAP_AND_HOLD            (1 << 1)
-#define RMI_F11_DOUBLE_TAP              (1 << 2)
-#define RMI_F11_EARLY_TAP               (1 << 3)
-#define RMI_F11_FLICK                   (1 << 4)
-#define RMI_F11_PRESS                   (1 << 5)
-#define RMI_F11_PINCH                   (1 << 6)
-
-/* Defs for Data 9 */
-
-#define RMI_F11_PALM_DETECT                     (1 << 0)
-#define RMI_F11_ROTATE                          (1 << 1)
-#define RMI_F11_SHAPE                           (1 << 2)
-#define RMI_F11_SCROLLZONE                      (1 << 3)
-#define RMI_F11_GESTURE_FINGER_COUNT_MASK       0x70
-
 /** Handy pointers into our data buffer.
  *
  * @f_state - start of finger state registers.
@@ -467,8 +209,6 @@ struct f11_2d_ctrl {
  * @pinch   - pinch motion register (if present).
  * @flick   - flick distance X & Y, flick time (if present).
  * @rotate  - rotate motion and finger separation.
- * @multi_scroll - chiral deltas for X and Y (if present).
- * @scroll_zones - scroll deltas for 4 regions (if present).
  */
 struct f11_2d_data {
 	u8	*f_state;
@@ -480,8 +220,6 @@ struct f11_2d_data {
 	u8	*flick;
 	u8	*rotate;
 	u8	*shapes;
-	s8	*multi_scroll;
-	s8	*scroll_zones;
 };
 
 /**
@@ -495,7 +233,6 @@ struct f11_2d_data {
  * @nbr_fingers - How many fingers can this sensor report?
  * @data_pkt - buffer for data reported by this sensor.
  * @pkt_size - number of bytes in that buffer.
- * @sensor_index - identifies this particular 2D touch sensor
  * @type_a - some early RMI4 2D sensors do not reliably track the finger
  * position when two fingers are on the device.  When this is true, we
  * assume we have one of those sensors and report events appropriately.
@@ -514,7 +251,6 @@ struct f11_2d_sensor {
 	u8 nbr_fingers;
 	u8 *data_pkt;
 	int pkt_size;
-	u8 sensor_index;
 	bool type_a;
 	enum rmi_f11_sensor_type sensor_type;
 	struct input_dev *input;
@@ -529,7 +265,6 @@ struct f11_2d_sensor {
  *
  * @dev_query - F11 device specific query registers.
  * @dev_controls - F11 device specific control registers.
- * @dev_controls_mutex - lock for the control registers.
  * @rezero_wait_ms - if nonzero, upon resume we will wait this many
  * milliseconds before rezeroing the sensor(s).  This is useful in systems with
  * poor electrical behavior on resume, where the initial calibration of the
@@ -543,7 +278,6 @@ struct f11_data {
 	bool has_query27;
 	bool has_query28;
 	struct f11_2d_ctrl dev_controls;
-	struct mutex dev_controls_mutex;
 	u16 rezero_wait_ms;
 	struct f11_2d_sensor sensor;
 };
@@ -871,16 +605,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
 	sensor_query->has_rel = !!(query_buf[0] & RMI_F11_HAS_REL);
 	sensor_query->has_abs = !!(query_buf[0] & RMI_F11_HAS_ABS);
 	sensor_query->has_gestures = !!(query_buf[0] & RMI_F11_HAS_GESTURES);
-	sensor_query->has_sensitivity_adjust =
-		!!(query_buf[0] && RMI_F11_HAS_SENSITIVITY_ADJ);
-	sensor_query->configurable = !!(query_buf[0] & RMI_F11_CONFIGURABLE);
-
-	sensor_query->nr_x_electrodes =
-				query_buf[1] & RMI_F11_NR_ELECTRODES_MASK;
-	sensor_query->nr_y_electrodes =
-				query_buf[2] & RMI_F11_NR_ELECTRODES_MASK;
-	sensor_query->max_electrodes =
-				query_buf[3] & RMI_F11_NR_ELECTRODES_MASK;
 
 	query_size = RMI_F11_QUERY_SIZE;
 
@@ -889,18 +613,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
 		if (rc < 0)
 			return rc;
 
-		sensor_query->abs_data_size =
-			query_buf[0] & RMI_F11_ABS_DATA_SIZE_MASK;
-		sensor_query->has_anchored_finger =
-			!!(query_buf[0] & RMI_F11_HAS_ANCHORED_FINGER);
-		sensor_query->has_adj_hyst =
-			!!(query_buf[0] & RMI_F11_HAS_ADJ_HYST);
-		sensor_query->has_dribble =
-			!!(query_buf[0] & RMI_F11_HAS_DRIBBLE);
-		sensor_query->has_bending_correction =
-			!!(query_buf[0] & RMI_F11_HAS_BENDING_CORRECTION);
-		sensor_query->has_large_object_suppression =
-		!!(query_buf[0] && RMI_F11_HAS_LARGE_OBJECT_SUPPRESSION);
 		sensor_query->has_jitter_filter =
 			!!(query_buf[0] & RMI_F11_HAS_JITTER_FILTER);
 		query_size++;
@@ -920,40 +632,16 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
 		if (rc < 0)
 			return rc;
 
-		sensor_query->has_single_tap =
-			!!(query_buf[0] & RMI_F11_HAS_SINGLE_TAP);
-		sensor_query->has_tap_n_hold =
-			!!(query_buf[0] & RMI_F11_HAS_TAP_AND_HOLD);
-		sensor_query->has_double_tap =
-			!!(query_buf[0] & RMI_F11_HAS_DOUBLE_TAP);
-		sensor_query->has_early_tap =
-			!!(query_buf[0] & RMI_F11_HAS_EARLY_TAP);
 		sensor_query->has_flick =
 			!!(query_buf[0] & RMI_F11_HAS_FLICK);
-		sensor_query->has_press =
-			!!(query_buf[0] & RMI_F11_HAS_PRESS);
 		sensor_query->has_pinch =
 			!!(query_buf[0] & RMI_F11_HAS_PINCH);
-		sensor_query->has_chiral =
-			!!(query_buf[0] & RMI_F11_HAS_CHIRAL);
 
 		/* query 8 */
-		sensor_query->has_palm_det =
-			!!(query_buf[1] & RMI_F11_HAS_PALM_DET);
 		sensor_query->has_rotate =
 			!!(query_buf[1] & RMI_F11_HAS_ROTATE);
 		sensor_query->has_touch_shapes =
 			!!(query_buf[1] & RMI_F11_HAS_TOUCH_SHAPES);
-		sensor_query->has_scroll_zones =
-			!!(query_buf[1] & RMI_F11_HAS_SCROLL_ZONES);
-		sensor_query->has_individual_scroll_zones =
-			!!(query_buf[1] & RMI_F11_HAS_INDIVIDUAL_SCROLL_ZONES);
-		sensor_query->has_mf_scroll =
-			!!(query_buf[1] & RMI_F11_HAS_MF_SCROLL);
-		sensor_query->has_mf_edge_motion =
-			!!(query_buf[1] & RMI_F11_HAS_MF_EDGE_MOTION);
-		sensor_query->has_mf_scroll_inertia =
-			!!(query_buf[1] & RMI_F11_HAS_MF_SCROLL_INERTIA);
 
 		sensor_query->query7_nonzero = !!(query_buf[0]);
 		sensor_query->query8_nonzero = !!(query_buf[1]);
@@ -968,20 +656,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
 
 		sensor_query->has_pen =
 			!!(query_buf[0] & RMI_F11_HAS_PEN);
-		sensor_query->has_proximity =
-			!!(query_buf[0] & RMI_F11_HAS_PROXIMITY);
-		sensor_query->has_palm_det_sensitivity =
-			!!(query_buf[0] & RMI_F11_HAS_PALM_DET_SENSITIVITY);
-		sensor_query->has_suppress_on_palm_detect =
-			!!(query_buf[0] & RMI_F11_HAS_SUPPRESS_ON_PALM_DETECT);
-		sensor_query->has_two_pen_thresholds =
-			!!(query_buf[0] & RMI_F11_HAS_TWO_PEN_THRESHOLDS);
-		sensor_query->has_contact_geometry =
-			!!(query_buf[0] & RMI_F11_HAS_CONTACT_GEOMETRY);
-		sensor_query->has_pen_hover_discrimination =
-			!!(query_buf[0] & RMI_F11_HAS_PEN_HOVER_DISCRIMINATION);
-		sensor_query->has_pen_filters =
-			!!(query_buf[0] & RMI_F11_HAS_PEN_FILTERS);
 
 		query_size++;
 	}
@@ -1002,24 +676,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
 		if (rc < 0)
 			return rc;
 
-		sensor_query->has_z_tuning =
-			!!(query_buf[0] & RMI_F11_HAS_Z_TUNING);
-		sensor_query->has_algorithm_selection =
-			!!(query_buf[0] & RMI_F11_HAS_ALGORITHM_SELECTION);
-		sensor_query->has_w_tuning =
-			!!(query_buf[0] & RMI_F11_HAS_W_TUNING);
-		sensor_query->has_pitch_info =
-			!!(query_buf[0] & RMI_F11_HAS_PITCH_INFO);
-		sensor_query->has_finger_size =
-			!!(query_buf[0] & RMI_F11_HAS_FINGER_SIZE);
-		sensor_query->has_segmentation_aggressiveness =
-			!!(query_buf[0] &
-				RMI_F11_HAS_SEGMENTATION_AGGRESSIVENESS);
-		sensor_query->has_XY_clip =
-			!!(query_buf[0] & RMI_F11_HAS_XY_CLIP);
-		sensor_query->has_drumming_filter =
-			!!(query_buf[0] & RMI_F11_HAS_DRUMMING_FILTER);
-
 		query_size++;
 	}
 
@@ -1028,22 +684,8 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
 		if (rc < 0)
 			return rc;
 
-		sensor_query->has_gapless_finger =
-			!!(query_buf[0] & RMI_F11_HAS_GAPLESS_FINGER);
-		sensor_query->has_gapless_finger_tuning =
-			!!(query_buf[0] & RMI_F11_HAS_GAPLESS_FINGER_TUNING);
-		sensor_query->has_8bit_w =
-			!!(query_buf[0] & RMI_F11_HAS_8BIT_W);
-		sensor_query->has_adjustable_mapping =
-			!!(query_buf[0] & RMI_F11_HAS_ADJUSTABLE_MAPPING);
 		sensor_query->has_info2 =
 			!!(query_buf[0] & RMI_F11_HAS_INFO2);
-		sensor_query->has_physical_props =
-			!!(query_buf[0] & RMI_F11_HAS_PHYSICAL_PROPS);
-		sensor_query->has_finger_limit =
-			!!(query_buf[0] & RMI_F11_HAS_FINGER_LIMIT);
-		sensor_query->has_linear_coeff_2 =
-			!!(query_buf[0] & RMI_F11_HAS_LINEAR_COEFF);
 
 		query_size++;
 	}
@@ -1053,12 +695,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
 		if (rc < 0)
 			return rc;
 
-		sensor_query->jitter_window_size = query_buf[0] &
-			RMI_F11_JITTER_WINDOW_MASK;
-		sensor_query->jitter_filter_type = (query_buf[0] &
-			RMI_F11_JITTER_FILTER_MASK) >>
-			RMI_F11_JITTER_FILTER_SHIFT;
-
 		query_size++;
 	}
 
@@ -1067,18 +703,8 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
 		if (rc < 0)
 			return rc;
 
-		sensor_query->light_control =
-			query_buf[0] & RMI_F11_LIGHT_CONTROL_MASK;
 		sensor_query->is_clear =
 			!!(query_buf[0] & RMI_F11_IS_CLEAR);
-		sensor_query->clickpad_props =
-			(query_buf[0] & RMI_F11_CLICKPAD_PROPS_MASK) >>
-			RMI_F11_CLICKPAD_PROPS_SHIFT;
-		sensor_query->mouse_buttons =
-			(query_buf[0] & RMI_F11_MOUSE_BUTTONS_MASK) >>
-			RMI_F11_MOUSE_BUTTONS_SHIFT;
-		sensor_query->has_advanced_gestures =
-			!!(query_buf[0] & RMI_F11_HAS_ADVANCED_GESTURES);
 
 		query_size++;
 	}
@@ -1276,7 +902,6 @@ static int rmi_f11_initialize(struct rmi_function *fn)
 				rc);
 	}
 
-	mutex_init(&f11->dev_controls_mutex);
 	return 0;
 }
 
-- 
1.8.1.5

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

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

* [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support
  2014-01-24  0:00                 ` [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables Courtney Cavin
@ 2014-01-24  0:00                   ` Courtney Cavin
  2014-01-24  0:00                     ` [PATCH 11/15] Input: synaptics-rmi4 - add regulator support Courtney Cavin
  2014-02-04 23:10                     ` [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support Christopher Heiny
  2014-02-04 23:10                   ` [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables Christopher Heiny
  1 sibling, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 Documentation/devicetree/bindings/input/rmi4.txt   | 107 +++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 drivers/input/rmi4/rmi_bus.c                       |  12 +-
 drivers/input/rmi4/rmi_bus.h                       |   3 +-
 drivers/input/rmi4/rmi_driver.c                    |  44 +++++--
 drivers/input/rmi4/rmi_f01.c                       | 107 +++++++++++++++--
 drivers/input/rmi4/rmi_f11.c                       | 133 ++++++++++++++++++++-
 drivers/input/rmi4/rmi_i2c.c                       |  19 +--
 8 files changed, 388 insertions(+), 38 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/rmi4.txt

diff --git a/Documentation/devicetree/bindings/input/rmi4.txt b/Documentation/devicetree/bindings/input/rmi4.txt
new file mode 100644
index 0000000..fff9db7
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/rmi4.txt
@@ -0,0 +1,107 @@
+Synaptics RMI4-based input device binding
+
+PROPERTIES
+
+compatible:
+	Usage: required
+	Type: string, must be "syn,rmi_i2c"
+
+interrupts:
+	Usage: required
+	Type: <prop-encoded-array>
+	Desc: See devicetree/bindings/interrupt-controller/interrupts.txt;
+		Trigger sense required in mask
+
+syn,reset-delay:
+	Usage: optional (default: 100)
+	Type: u32, milliseconds
+	Desc: Delay after issuing a reset
+
+syn,power-no-sleep:
+	Usage: optional, mutually exclusive with syn,power-sleep
+		(default: chip-specific)
+	Type: boolean
+	Desc: Disable sleep mode
+
+syn,power-sleep:
+	Usage: optional, mutually exclusive with syn,power-no-sleep
+		(default: chip-specific)
+	Type: boolean
+	Desc: Enable sleep mode
+
+syn,power-wakeup-thresh:
+	Usage: optional (default: chip-specific)
+	Type: u32, chip-specific unit [0-255]
+	Desc: Capacitance threshold at which device should wake
+
+syn,power-doze-holdoff:
+	Usage: optional (default: chip-specific)
+	Type: u32, milliseconds [0-25500]
+	Desc: Idle delay before entering sleep mode
+
+syn,power-doze-interval:
+	Usage: optional (default: chip-specific)
+	Type: u32, milliseconds [0-2550]
+	Desc: Interval between checks for idle
+
+syn,2d-rezero-wait:
+	Usage: optional (default: no re-zeroing)
+	Type: u32, milliseconds [0-65535]
+	Desc: Delay after resume to re-zero sensor
+
+syn,2d-axis-swap:
+	Usage: optional (default: false)
+	Type: boolean
+	Desc: Swap X and Y axis
+
+syn,2d-flip-x:
+	Usage: optional (default: false)
+	Type: boolean
+	Desc: Invert X axis
+
+syn,2d-flip-y:
+	Usage: optional (default: false)
+	Type: boolean
+	Desc: Invert Y axis
+
+syn,2d-clip-range:
+	Usage: optional (default: clip disabled)
+	Type: u32 array (<top left bottom right>) [0-65535]
+	Usage: Clip values outside this range
+
+syn,2d-offset:
+	Usage: optional (default: offset disabled)
+	Type: u32 array (<X-offset Y-offset>) [0-65535]
+	Usage: Add offset values to reported events
+
+syn,2d-delta-thresh:
+	Usage: optional (default: chip-specific)
+	Type: u32 array (<X-delta Y-delta>) [0-255]
+	Usage: Minimum delta before event is reported
+
+syn,2d-sensor-type:
+	Usage: optional (default: chip-specific)
+	Type: string, "indirect" or "direct"
+	Usage: Set screen type for event reporting
+
+syn,2d-type-a:
+	Usage: optional (default: false)
+	Type: boolean
+	Usage: Sensor supports only Multifinger Type A protocol
+
+EXAMPLE
+
+i2c@0 {
+	compatible = "...";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	synaptics_rmi4@2c {
+		compatible = "syn,rmi_i2c";
+		reg = <0x2c>;
+
+		interrupts = <61 IRQ_TYPE_EDGE_FALLING>;
+
+		syn,2d-clip-range = <0 0 1919 1079>;
+	};
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index edbb8d8..3388986 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -72,6 +72,7 @@ snps 	Synopsys, Inc.
 st	STMicroelectronics
 ste	ST-Ericsson
 stericsson	ST-Ericsson
+syn	Synaptics, Inc.
 ti	Texas Instruments
 toshiba	Toshiba Corporation
 toumaz	Toumaz
diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index a51e6b4..57de579 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -52,14 +52,11 @@ bool rmi_is_physical_device(struct device *dev)
 int rmi_register_transport_device(struct rmi_transport_dev *xport)
 {
 	static atomic_t transport_device_count = ATOMIC_INIT(0);
-	struct rmi_device_platform_data *pdata = xport->dev->platform_data;
 	struct rmi_device *rmi_dev;
 	int error;
 
-	if (!pdata) {
-		dev_err(xport->dev, "no platform data!\n");
-		return -EINVAL;
-	}
+	if (unlikely(!rmi_bus_type.p))
+		return -EPROBE_DEFER;
 
 	rmi_dev = kzalloc(sizeof(struct rmi_device), GFP_KERNEL);
 	if (!rmi_dev)
@@ -70,8 +67,10 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
 
 	dev_set_name(&rmi_dev->dev, "sensor%02d", rmi_dev->number);
 
+	rmi_dev->dev.parent = xport->dev;
 	rmi_dev->dev.bus = &rmi_bus_type;
 	rmi_dev->dev.type = &rmi_device_type;
+	rmi_dev->dev.of_node = xport->dev->of_node;
 
 	xport->rmi_dev = rmi_dev;
 
@@ -206,6 +205,9 @@ int __rmi_register_function_handler(struct rmi_function_handler *handler,
 	struct device_driver *driver = &handler->driver;
 	int error;
 
+	if (WARN_ON(unlikely(!rmi_bus_type.p)))
+		return -EAGAIN;
+
 	driver->bus = &rmi_bus_type;
 	driver->owner = owner;
 	driver->mod_name = mod_name;
diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
index a21e4c4..51f9372 100644
--- a/drivers/input/rmi4/rmi_bus.h
+++ b/drivers/input/rmi4/rmi_bus.h
@@ -212,7 +212,8 @@ struct rmi_device {
 };
 
 #define to_rmi_device(d) container_of(d, struct rmi_device, dev)
-#define to_rmi_platform_data(d) ((d)->xport->dev->platform_data)
+#define to_rmi_xport_device(d) ((d)->xport->dev)
+#define to_rmi_platform_data(d) (dev_get_platdata(to_rmi_xport_device(d)))
 
 bool rmi_is_physical_device(struct device *dev);
 
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 9ec7b93..92415ce 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -26,6 +26,8 @@
 #include <linux/rmi.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/of_irq.h>
+#include <linux/of.h>
 #include <uapi/linux/input.h>
 #include "rmi_bus.h"
 #include "rmi_driver.h"
@@ -498,7 +500,7 @@ static int create_function(struct rmi_device *rmi_dev,
  * We have to do this before actually building the PDT because the reflash
  * updates (if any) might cause various registers to move around.
  */
-static int rmi_initial_reset(struct rmi_device *rmi_dev)
+static int rmi_initial_reset(struct rmi_device *rmi_dev, u32 reset_delay)
 {
 	struct pdt_entry pdt_entry;
 	int page;
@@ -507,8 +509,6 @@ static int rmi_initial_reset(struct rmi_device *rmi_dev)
 	bool has_f01 = false;
 	int i;
 	int retval;
-	const struct rmi_device_platform_data *pdata =
-			to_rmi_platform_data(rmi_dev);
 
 	dev_dbg(dev, "Initial reset.\n");
 
@@ -538,7 +538,7 @@ static int rmi_initial_reset(struct rmi_device *rmi_dev)
 						retval);
 					return retval;
 				}
-				mdelay(pdata->reset_delay_ms);
+				mdelay(reset_delay);
 				done = true;
 				has_f01 = true;
 				break;
@@ -648,6 +648,8 @@ static int rmi_driver_probe(struct device *dev)
 	struct rmi_device_platform_data *pdata;
 	int retval = 0;
 	struct rmi_device *rmi_dev;
+	unsigned int irq;
+	u32 reset_delay;
 
 	dev_dbg(dev, "%s: Starting probe.\n", __func__);
 
@@ -661,6 +663,28 @@ static int rmi_driver_probe(struct device *dev)
 	rmi_dev->driver = rmi_driver;
 
 	pdata = to_rmi_platform_data(rmi_dev);
+	if (pdata == NULL) {
+#ifdef CONFIG_OF
+		const char *p;
+
+		p = "syn,reset-delay";
+		retval = of_property_read_u32(dev->of_node, p, &reset_delay);
+		if (retval && retval != -EINVAL) {
+			dev_err(dev, "Invalid '%s' property\n", p);
+			return -EINVAL;
+		}
+		if (retval == -EINVAL)
+			reset_delay = 0;
+
+		irq = irq_of_parse_and_map(dev->of_node, 0);
+#else
+		dev_err(dev, "No pdata\n");
+		return -EINVAL;
+#endif
+	} else {
+		reset_delay = pdata->reset_delay_ms;
+		irq = pdata->irq;
+	}
 
 	data = devm_kzalloc(dev, sizeof(struct rmi_driver_data), GFP_KERNEL);
 	if (!data) {
@@ -688,9 +712,9 @@ static int rmi_driver_probe(struct device *dev)
 	 * and leave the customer's device unusable.  So we warn them, and
 	 * continue processing.
 	 */
-	if (!pdata->reset_delay_ms)
-		pdata->reset_delay_ms = DEFAULT_RESET_DELAY_MS;
-	retval = rmi_initial_reset(rmi_dev);
+	if (!reset_delay)
+		reset_delay = DEFAULT_RESET_DELAY_MS;
+	retval = rmi_initial_reset(rmi_dev, reset_delay);
 	if (retval)
 		dev_warn(dev, "RMI initial reset failed! Continuing in spite of this.\n");
 
@@ -762,10 +786,10 @@ static int rmi_driver_probe(struct device *dev)
 		goto err_free_data;
 	}
 
-	data->irq = pdata->irq;
-	if (data->irq < 0) {
+	data->irq = irq;
+	if (data->irq < 0 || data->irq == NO_IRQ) {
 		dev_err(dev, "Failed to get attn IRQ.\n");
-		retval = data->irq;
+		retval = -EINVAL;
 		goto err_free_data;
 
 	}
diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
index 4cb9fcb..22b57f2 100644
--- a/drivers/input/rmi4/rmi_f01.c
+++ b/drivers/input/rmi4/rmi_f01.c
@@ -12,6 +12,7 @@
 #include <linux/rmi.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/of.h>
 #include "rmi_driver.h"
 
 #define RMI_PRODUCT_ID_LENGTH    10
@@ -169,15 +170,104 @@ static int rmi_f01_read_properties(struct rmi_device *rmi_dev,
 	return 0;
 }
 
+#ifdef CONFIG_OF
+static int rmi_f01_of_parse(struct device *dev,
+		struct rmi_f01_power_management *cdata)
+{
+	bool sleep, nosleep;
+	const char *p;
+	u32 val;
+	int rc;
+
+	if (dev->of_node == NULL)
+		return -EINVAL;
+
+	memset(cdata, 0, sizeof(*cdata));
+
+	sleep = of_property_read_bool(dev->of_node, "syn,power-sleep");
+	nosleep = of_property_read_bool(dev->of_node, "syn,power-nosleep");
+	if (sleep && nosleep) {
+		dev_err(dev, "'syn,power-sleep' and 'syn,power-nosleep' are mutually exclusive\n");
+		return -EINVAL;
+	}
+	if (sleep)
+		cdata->nosleep = RMI_F01_NOSLEEP_OFF;
+	else if (nosleep)
+		cdata->nosleep = RMI_F01_NOSLEEP_ON;
+
+	p = "syn,power-wakeup-thresh";
+	rc = of_property_read_u32(dev->of_node, p, &val);
+	if (rc && rc != -EINVAL) {
+		dev_err(dev, "Invalid '%s' property\n", p);
+		return rc;
+	}
+	if (rc != -EINVAL) {
+		if (val & ~0xff) {
+			dev_err(dev, "'%s' out of range [0-255]\n", p);
+			return -EINVAL;
+		}
+		cdata->wakeup_threshold = val;
+	}
+
+	p = "syn,power-doze-holdoff";
+	rc = of_property_read_u32(dev->of_node, p, &val);
+	if (rc && rc != -EINVAL) {
+		dev_err(dev, "Invalid '%s' property\n", p);
+		return rc;
+	}
+	if (rc != -EINVAL) {
+		if (val > 25500) {
+			dev_err(dev, "'%s' out of range [0-25500]ms\n", p);
+			return -EINVAL;
+		}
+		cdata->doze_holdoff = (val + 50) / 100;
+	}
+
+	p = "syn,power-doze-interval";
+	rc = of_property_read_u32(dev->of_node, p, &val);
+	if (rc && rc != -EINVAL) {
+		dev_err(dev, "Invalid '%s' property\n", p);
+		return rc;
+	}
+	if (rc != -EINVAL) {
+		if (val > 2550) {
+			dev_err(dev, "'%s' out of range [0-2550]ms\n", p);
+			return -EINVAL;
+		}
+		cdata->doze_interval = (val + 5) / 10;
+	}
+
+	return 0;
+}
+#else
+static int rmi_f01_of_parse(struct device *dev,
+		struct rmi_f01_power_management *cdata)
+{
+	return -EINVAL;
+}
+#endif
+
 static int rmi_f01_initialize(struct rmi_function *fn)
 {
 	u8 temp;
 	int error;
 	u16 ctrl_base_addr;
+	struct rmi_f01_power_management cdata;
 	struct rmi_device *rmi_dev = fn->rmi_dev;
+	struct device *dev = to_rmi_xport_device(rmi_dev);
 	struct rmi_driver_data *driver_data = dev_get_drvdata(&rmi_dev->dev);
 	struct f01_data *data = fn->data;
-	struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
+	struct rmi_device_platform_data *pdata = dev_get_platdata(dev);
+
+	if (pdata != NULL) {
+		cdata = pdata->power_management;
+	} else {
+		error = rmi_f01_of_parse(dev, &cdata);
+		if (error) {
+			dev_err(dev, "Unable to parse DT data\n");
+			return error;
+		}
+	}
 
 	/*
 	 * Set the configured bit and (optionally) other important stuff
@@ -191,7 +281,7 @@ static int rmi_f01_initialize(struct rmi_function *fn)
 		dev_err(&fn->dev, "Failed to read F01 control.\n");
 		return error;
 	}
-	switch (pdata->power_management.nosleep) {
+	switch (cdata.nosleep) {
 	case RMI_F01_NOSLEEP_DEFAULT:
 		break;
 	case RMI_F01_NOSLEEP_OFF:
@@ -262,9 +352,9 @@ static int rmi_f01_initialize(struct rmi_function *fn)
 		data->doze_interval_addr = ctrl_base_addr;
 		ctrl_base_addr++;
 
-		if (pdata->power_management.doze_interval) {
+		if (cdata.doze_interval) {
 			data->device_control.doze_interval =
-				pdata->power_management.doze_interval;
+				cdata.doze_interval;
 			error = rmi_write(rmi_dev, data->doze_interval_addr,
 					data->device_control.doze_interval);
 			if (error < 0) {
@@ -283,9 +373,9 @@ static int rmi_f01_initialize(struct rmi_function *fn)
 		data->wakeup_threshold_addr = ctrl_base_addr;
 		ctrl_base_addr++;
 
-		if (pdata->power_management.wakeup_threshold) {
+		if (cdata.wakeup_threshold) {
 			data->device_control.wakeup_threshold =
-				pdata->power_management.wakeup_threshold;
+				cdata.wakeup_threshold;
 			error = rmi_write(rmi_dev, data->wakeup_threshold_addr,
 					data->device_control.wakeup_threshold);
 			if (error < 0) {
@@ -306,9 +396,8 @@ static int rmi_f01_initialize(struct rmi_function *fn)
 		data->doze_holdoff_addr = ctrl_base_addr;
 		ctrl_base_addr++;
 
-		if (pdata->power_management.doze_holdoff) {
-			data->device_control.doze_holdoff =
-				pdata->power_management.doze_holdoff;
+		if (cdata.doze_holdoff) {
+			data->device_control.doze_holdoff = cdata.doze_holdoff;
 			error = rmi_write(rmi_dev, data->doze_holdoff_addr,
 					data->device_control.doze_holdoff);
 			if (error < 0) {
diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
index b114f25..837b6e7 100644
--- a/drivers/input/rmi4/rmi_f11.c
+++ b/drivers/input/rmi4/rmi_f11.c
@@ -13,6 +13,7 @@
 #include <linux/input.h>
 #include <linux/input/mt.h>
 #include <linux/kconfig.h>
+#include <linux/of.h>
 #include <linux/rmi.h>
 #include <linux/slab.h>
 #include "rmi_driver.h"
@@ -794,9 +795,120 @@ static void f11_set_abs_params(struct rmi_function *fn)
 				     0, MT_TOOL_FINGER, 0, 0);
 }
 
+#ifdef CONFIG_OF
+static int rmi_f11_of_parse(struct device *dev,
+		struct rmi_f11_sensor_data *cdata)
+{
+	const char *type;
+	const char *p;
+	u32 a[4];
+	int rc;
+
+	if (dev->of_node == NULL)
+		return -EINVAL;
+
+	memset(cdata, 0, sizeof(*cdata));
+
+	p = "syn,2d-rezero-wait";
+	rc = of_property_read_u32(dev->of_node, p, &a[0]);
+	if (rc && rc != -EINVAL) {
+		dev_err(dev, "Invalid '%s' property\n", p);
+		return rc;
+	}
+	if (rc != -EINVAL) {
+		if (a[0] & ~0xffff) {
+			dev_err(dev, "'%s' value out of range [0-65535]\n", p);
+			return -EINVAL;
+		}
+		cdata->rezero_wait = a[0];
+	}
+
+	cdata->type_a = of_property_read_bool(dev->of_node, "syn,2d-type-a");
+	cdata->axis_align.swap_axes = of_property_read_bool(dev->of_node,
+			"syn,2d-axis-swap");
+	cdata->axis_align.flip_x = of_property_read_bool(dev->of_node,
+			"syn,2d-flip-x");
+	cdata->axis_align.flip_y = of_property_read_bool(dev->of_node,
+			"syn,2d-flip-y");
+
+	p = "syn-2d-clip-range";
+	rc = of_property_read_u32_array(dev->of_node, p, a, 4);
+	if (rc && rc != -EINVAL) {
+		dev_err(dev, "Invalid '%s' property\n", p);
+		return rc;
+	}
+	if (rc != -EINVAL) {
+		if ((a[0] | a[1] | a[2] | a[3]) & ~0xffff) {
+			dev_err(dev, "'%s' values out of range [0-65535]\n", p);
+			return -EINVAL;
+		}
+		cdata->axis_align.clip_x_low = a[0];
+		cdata->axis_align.clip_y_low = a[1];
+		cdata->axis_align.clip_x_high = a[2];
+		cdata->axis_align.clip_y_high = a[3];
+	}
+
+	p = "syn-2d-offset";
+	rc = of_property_read_u32_array(dev->of_node, p, a, 2);
+	if (rc && rc != -EINVAL) {
+		dev_err(dev, "Invalid '%s' property\n", p);
+		return rc;
+	}
+	if (rc != -EINVAL) {
+		if ((a[0] | a[1]) & ~0xffff) {
+			dev_err(dev, "'%s' values out of range [0-65535]\n", p);
+			return -EINVAL;
+		}
+		cdata->axis_align.offset_x = a[0];
+		cdata->axis_align.offset_y = a[1];
+	}
+
+	p = "syn,2d-delta-thresh";
+	rc = of_property_read_u32_array(dev->of_node, p, a, 2);
+	if (rc && rc != -EINVAL) {
+		dev_err(dev, "Invalid '%s' property\n", p);
+		return rc;
+	}
+	if (rc != -EINVAL) {
+		if ((a[0] | a[1]) & ~0xff) {
+			dev_err(dev, "'%s' values out of range [0-255]\n", p);
+			return -EINVAL;
+		}
+		cdata->axis_align.delta_x_threshold = a[0];
+		cdata->axis_align.delta_y_threshold = a[1];
+	}
+
+	p = "syn,2d-sensor-type";
+	rc = of_property_read_string(dev->of_node, p, &type);
+	if (rc && rc != -EINVAL) {
+		dev_err(dev, "Invalid '%s' property\n", p);
+		return rc;
+	}
+	if (rc != -EINVAL) {
+		if (!strcmp(type, "direct")) {
+			cdata->sensor_type = RMI_F11_SENSOR_DIRECT;
+		} else if (!strcmp(type, "indirect")) {
+			cdata->sensor_type = RMI_F11_SENSOR_INDIRECT;
+		} else {
+			dev_err(dev, "'%s' must be one of: \"indirect\", \"direct\"\n", p);
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+#else
+static int rmi_f11_of_parse(struct device *dev,
+		struct rmi_f11_sensor_data *cdata)
+{
+	return -EINVAL;
+}
+#endif
+
 static int rmi_f11_initialize(struct rmi_function *fn)
 {
 	struct rmi_device *rmi_dev = fn->rmi_dev;
+	struct device *dev = to_rmi_xport_device(rmi_dev);
 	struct f11_data *f11;
 	struct f11_2d_ctrl *ctrl;
 	u8 query_offset;
@@ -804,12 +916,23 @@ static int rmi_f11_initialize(struct rmi_function *fn)
 	u16 control_base_addr;
 	u16 max_x_pos, max_y_pos, temp;
 	int rc;
-	struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
+	struct rmi_device_platform_data *pdata = dev_get_platdata(dev);
+	struct rmi_f11_sensor_data cdata;
 	struct f11_2d_sensor *sensor;
 	u8 buf;
 
 	dev_dbg(&fn->dev, "Initializing F11 values.\n");
 
+	if (pdata != NULL) {
+		cdata = pdata->f11_sensor_data;
+	} else {
+		rc = rmi_f11_of_parse(dev, &cdata);
+		if (rc) {
+			dev_err(dev, "Unable to parse DT data\n");
+			return rc;
+		}
+	}
+
 	/*
 	** init instance data, fill in values and create any sysfs files
 	*/
@@ -818,7 +941,7 @@ static int rmi_f11_initialize(struct rmi_function *fn)
 		return -ENOMEM;
 
 	fn->data = f11;
-	f11->rezero_wait_ms = pdata->f11_sensor_data.rezero_wait;
+	f11->rezero_wait_ms = cdata.rezero_wait;
 
 	query_base_addr = fn->fd.query_base_addr;
 	control_base_addr = fn->fd.control_base_addr;
@@ -851,9 +974,9 @@ static int rmi_f11_initialize(struct rmi_function *fn)
 		return rc;
 	}
 
-	sensor->axis_align = pdata->f11_sensor_data.axis_align;
-	sensor->type_a = pdata->f11_sensor_data.type_a;
-	sensor->sensor_type = pdata->f11_sensor_data.sensor_type;
+	sensor->axis_align = cdata.axis_align;
+	sensor->type_a = cdata.type_a;
+	sensor->sensor_type = cdata.sensor_type;
 
 	rc = rmi_read_block(rmi_dev,
 		control_base_addr + F11_CTRL_SENSOR_MAX_X_POS_OFFSET,
diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
index aebf974..377d4cc 100644
--- a/drivers/input/rmi4/rmi_i2c.c
+++ b/drivers/input/rmi4/rmi_i2c.c
@@ -186,16 +186,9 @@ static const struct rmi_transport_ops rmi_i2c_ops = {
 static int rmi_i2c_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
-	const struct rmi_device_platform_data *pdata =
-				dev_get_platdata(&client->dev);
 	struct rmi_i2c_xport *rmi_i2c;
 	int retval;
 
-	if (!pdata) {
-		dev_err(&client->dev, "no platform data\n");
-		return -EINVAL;
-	}
-
 	dev_dbg(&client->dev, "Probing %#02x.\n", client->addr);
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
@@ -258,10 +251,20 @@ static const struct i2c_device_id rmi_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, rmi_id);
 
+#ifdef CONFIG_OF
+static struct of_device_id rmi_match_table[] = {
+	{ .compatible = "syn,rmi_i2c", },
+	{ },
+};
+#else
+#define rmi_match_table NULL
+#endif
+
 static struct i2c_driver rmi_i2c_driver = {
 	.driver = {
 		.owner	= THIS_MODULE,
-		.name	= "rmi_i2c"
+		.name	= "rmi_i2c",
+		.of_match_table = rmi_match_table,
 	},
 	.id_table	= rmi_id,
 	.probe		= rmi_i2c_probe,
-- 
1.8.1.5


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

* [PATCH 11/15] Input: synaptics-rmi4 - add regulator support
  2014-01-24  0:00                   ` [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support Courtney Cavin
@ 2014-01-24  0:00                     ` Courtney Cavin
  2014-01-24  0:00                       ` [PATCH 12/15] Input: synaptics-rmi4 - don't immediately set page on probe Courtney Cavin
  2014-02-04 23:10                       ` [PATCH 11/15] Input: synaptics-rmi4 - add regulator support Christopher Heiny
  2014-02-04 23:10                     ` [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support Christopher Heiny
  1 sibling, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

Add support for VDD and VIO power supplies.  Since we may need a delay
after turning on the chip, adjust code to manage that.  This removes the
scanning for active interrupts on resume, as we should get an interrupt
when the chip is ready.

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 Documentation/devicetree/bindings/input/rmi4.txt | 10 +++++
 drivers/input/rmi4/rmi_driver.c                  | 53 +++++++++++++++++++++++-
 drivers/input/rmi4/rmi_driver.h                  |  4 ++
 3 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/input/rmi4.txt b/Documentation/devicetree/bindings/input/rmi4.txt
index fff9db7..d41beac 100644
--- a/Documentation/devicetree/bindings/input/rmi4.txt
+++ b/Documentation/devicetree/bindings/input/rmi4.txt
@@ -12,6 +12,16 @@ interrupts:
 	Desc: See devicetree/bindings/interrupt-controller/interrupts.txt;
 		Trigger sense required in mask
 
+vdd-supply:
+	Usage: optional (default: no regulator)
+	Type: <prop-encoded-array>
+	Desc: VDD power supply; See devicetree/bindings/regulator/regulator.txt
+
+vio-supply:
+	Usage: optional (default: no regulator)
+	Type: <prop-encoded-array>
+	Desc: VIO power supply; See devicetree/bindings/regulator/regulator.txt
+
 syn,reset-delay:
 	Usage: optional (default: 100)
 	Type: u32, milliseconds
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 92415ce..52345ae 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -28,6 +28,7 @@
 #include <linux/uaccess.h>
 #include <linux/of_irq.h>
 #include <linux/of.h>
+#include <linux/regulator/consumer.h>
 #include <uapi/linux/input.h>
 #include "rmi_bus.h"
 #include "rmi_driver.h"
@@ -101,7 +102,7 @@ static int enable_sensor(struct rmi_device *rmi_dev)
 
 	data->enabled = true;
 
-	return process_interrupt_requests(rmi_dev);
+	return 0;
 }
 
 static void rmi_free_function_list(struct rmi_device *rmi_dev)
@@ -616,14 +617,29 @@ error_exit:
 static int rmi_driver_suspend(struct device *dev)
 {
 	struct rmi_device *rmi_dev = to_rmi_device(dev);
+	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
 
 	disable_sensor(rmi_dev);
+
+	regulator_disable(data->vio);
+	regulator_disable(data->vdd);
+
 	return 0;
 }
 
 static int rmi_driver_resume(struct device *dev)
 {
 	struct rmi_device *rmi_dev = to_rmi_device(dev);
+	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
+	int retval;
+
+	retval = regulator_enable(data->vdd);
+	if (retval)
+		return retval;
+	retval = regulator_enable(data->vio);
+	if (retval)
+		return retval;
+
 	return enable_sensor(rmi_dev);
 }
 
@@ -634,7 +650,12 @@ static SIMPLE_DEV_PM_OPS(rmi_driver_pm, rmi_driver_suspend, rmi_driver_resume);
 static int rmi_driver_remove(struct device *dev)
 {
 	struct rmi_device *rmi_dev = to_rmi_device(dev);
+	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
+
 	disable_sensor(rmi_dev);
+
+	regulator_disable(data->vio);
+	regulator_disable(data->vdd);
 	rmi_free_function_list(rmi_dev);
 
 	return 0;
@@ -649,6 +670,7 @@ static int rmi_driver_probe(struct device *dev)
 	int retval = 0;
 	struct rmi_device *rmi_dev;
 	unsigned int irq;
+	bool delay_start = false;
 	u32 reset_delay;
 
 	dev_dbg(dev, "%s: Starting probe.\n", __func__);
@@ -696,6 +718,33 @@ static int rmi_driver_probe(struct device *dev)
 	dev_set_drvdata(&rmi_dev->dev, data);
 	mutex_init(&data->pdt_mutex);
 
+	data->vdd = devm_regulator_get_optional(dev, "vdd");
+	if (IS_ERR(data->vdd)) {
+		dev_err(dev, "Failed to get regulator 'vdd'\n");
+		return PTR_ERR(data->vdd);
+	}
+	data->vio = devm_regulator_get_optional(dev, "vio");
+	if (IS_ERR(data->vio)) {
+		dev_err(dev, "Failed to get regulator 'vio'\n");
+		return PTR_ERR(data->vio);
+	}
+
+	if (data->vdd && !regulator_is_enabled(data->vdd))
+		delay_start = true;
+	if (data->vio && !regulator_is_enabled(data->vio))
+		delay_start = true;
+
+	retval = regulator_enable(data->vdd);
+	if (retval) {
+		dev_err(dev, "Failed to enable regulator\n");
+		return retval;
+	}
+	retval = regulator_enable(data->vio);
+	if (retval) {
+		dev_err(dev, "Failed to enable regulator\n");
+		return retval;
+	}
+
 	/*
 	 * Right before a warm boot, the sensor might be in some unusual state,
 	 * such as F54 diagnostics, or F34 bootloader mode.  In order to clear
@@ -714,6 +763,8 @@ static int rmi_driver_probe(struct device *dev)
 	 */
 	if (!reset_delay)
 		reset_delay = DEFAULT_RESET_DELAY_MS;
+	if (delay_start)
+		mdelay(reset_delay);
 	retval = rmi_initial_reset(rmi_dev, reset_delay);
 	if (retval)
 		dev_warn(dev, "RMI initial reset failed! Continuing in spite of this.\n");
diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
index eafbdb3..d553722 100644
--- a/drivers/input/rmi4/rmi_driver.h
+++ b/drivers/input/rmi4/rmi_driver.h
@@ -29,9 +29,13 @@
 
 #define RMI_PDT_PROPS_HAS_BSR 0x02
 
+struct regulator;
+
 struct rmi_driver_data {
 	struct list_head function_list;
 
+	struct regulator *vdd;
+	struct regulator *vio;
 	struct rmi_device *rmi_dev;
 
 	struct rmi_function *f01_container;
-- 
1.8.1.5


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

* [PATCH 12/15] Input: synaptics-rmi4 - don't immediately set page on probe
  2014-01-24  0:00                     ` [PATCH 11/15] Input: synaptics-rmi4 - add regulator support Courtney Cavin
@ 2014-01-24  0:00                       ` Courtney Cavin
  2014-01-24  0:00                         ` [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan Courtney Cavin
  2014-02-04 23:10                       ` [PATCH 11/15] Input: synaptics-rmi4 - add regulator support Christopher Heiny
  1 sibling, 1 reply; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

Since at the point of I2C probe, we cannot know if the voltage
regulators are on, wait until the physical driver requests a read before
setting the page.

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/rmi_i2c.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
index 377d4cc..50ed5fd 100644
--- a/drivers/input/rmi4/rmi_i2c.c
+++ b/drivers/input/rmi4/rmi_i2c.c
@@ -209,15 +209,8 @@ static int rmi_i2c_probe(struct i2c_client *client,
 	rmi_i2c->xport.proto_name = "i2c";
 	rmi_i2c->xport.ops = &rmi_i2c_ops;
 
-	/*
-	 * Setting the page to zero will (a) make sure the PSR is in a
-	 * known state, and (b) make sure we can talk to the device.
-	 */
-	retval = rmi_set_page(rmi_i2c, 0);
-	if (retval) {
-		dev_err(&client->dev, "Failed to set page select to 0.\n");
-		return retval;
-	}
+	/* make sure we set the page on the first write */
+	rmi_i2c->page = -1;
 
 	retval = rmi_register_transport_device(&rmi_i2c->xport);
 	if (retval) {
-- 
1.8.1.5


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

* [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan
  2014-01-24  0:00                       ` [PATCH 12/15] Input: synaptics-rmi4 - don't immediately set page on probe Courtney Cavin
@ 2014-01-24  0:00                         ` Courtney Cavin
  2014-01-24  0:00                           ` [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status Courtney Cavin
  2014-02-04 23:10                           ` [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan Christopher Heiny
  0 siblings, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/rmi_driver.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 52345ae..9d8d6ec 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -488,6 +488,8 @@ static int create_function(struct rmi_device *rmi_dev,
 		return error;
 
 	list_add_tail(&fn->node, &data->function_list);
+	if (pdt->function_number == 0x01)
+		data->f01_container = fn;
 
 	return 0;
 }
-- 
1.8.1.5


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

* [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status
  2014-01-24  0:00                         ` [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan Courtney Cavin
@ 2014-01-24  0:00                           ` Courtney Cavin
  2014-01-24  0:00                             ` [PATCH 15/15] Input: synaptics-rmi4 - correct RMI4 spec url Courtney Cavin
  2014-02-04 23:10                             ` [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status Christopher Heiny
  2014-02-04 23:10                           ` [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan Christopher Heiny
  1 sibling, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/rmi_f01.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
index 22b57f2..06fc5bc 100644
--- a/drivers/input/rmi4/rmi_f01.c
+++ b/drivers/input/rmi4/rmi_f01.c
@@ -318,13 +318,15 @@ static int rmi_f01_initialize(struct rmi_function *fn)
 	ctrl_base_addr += sizeof(u8);
 
 	data->interrupt_enable_addr = ctrl_base_addr;
-	error = rmi_read_block(rmi_dev, ctrl_base_addr,
-				data->device_control.interrupt_enable,
-				sizeof(u8) * (data->num_of_irq_regs));
-	if (error < 0) {
-		dev_err(&fn->dev,
-			"Failed to read F01 control interrupt enable register.\n");
-		goto error_exit;
+	if (data->num_of_irq_regs > 0) {
+		error = rmi_read_block(rmi_dev, ctrl_base_addr,
+					data->device_control.interrupt_enable,
+					sizeof(u8) * (data->num_of_irq_regs));
+		if (error < 0) {
+			dev_err(&fn->dev,
+				"Failed to read F01 control interrupt enable register.\n");
+			goto error_exit;
+		}
 	}
 
 	ctrl_base_addr += data->num_of_irq_regs;
-- 
1.8.1.5


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

* [PATCH 15/15] Input: synaptics-rmi4 - correct RMI4 spec url
  2014-01-24  0:00                           ` [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status Courtney Cavin
@ 2014-01-24  0:00                             ` Courtney Cavin
  2014-02-04 23:10                               ` Christopher Heiny
  2014-02-04 23:10                             ` [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status Christopher Heiny
  1 sibling, 1 reply; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:00 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

Cc: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
---
 drivers/input/rmi4/rmi_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 9d8d6ec..9d845a4 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -7,7 +7,7 @@
  * The RMI4 specification can be found here (URL split for line length):
  *
  * http://www.synaptics.com/sites/default/files/
- *      511-000136-01-Rev-E-RMI4%20Intrfacing%20Guide.pdf
+ *      511-000136-01-Rev-E-RMI4-Interfacing-Guide.pdf
  *
  * 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
-- 
1.8.1.5


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

* Re: [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support
  2014-01-24  0:00 [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support Courtney Cavin
  2014-01-24  0:00 ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Courtney Cavin
@ 2014-01-24  0:06 ` Courtney Cavin
  2014-01-24 23:24 ` Christopher Heiny
  2 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-24  0:06 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, cheiny

On Fri, Jan 24, 2014 at 01:00:08AM +0100, Courtney Cavin wrote:
> This is an attempt to get this driver closer to being in an upstream-able form.
> In the process, this drops legacy callback methods for managing power and GPIO
> configuration, in favor of the already existing frameworks.  Most of this
> series is cleanup, but there are a few intermixed bug fixes to make it all
> work.
> 
> This patch series is based off of the synaptics-rmi4 branch merged into
> Linus' 3.13.  A tree is available at [1].
> 
> This was tested on Synaptics TM2281-001 & TM2282-001.
> 
> [1] http://github.com/courtc/linux.git
> 	tag for-input/synaptics-rmi4
> 
> Courtney Cavin (15):
>   Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
>   Input: synaptics-rmi4 - don't kfree devm_ alloced memory
>   Input: synaptics-rmi4 - don't free devices directly
>   Input: synaptics-rmi4 - remove sensor name from platform data
>   Input: synaptics-rmi4 - remove gpio handling and polling
>   Input: synaptics-rmi4 - remove platform suspend callbacks
>   Input: synaptics-rmi4 - remove remaining debugfs code
>   Input: synaptics-rmi4 - cleanup platform data
>   Input: synaptics-rmi4 - remove unused defines and variables
>   Input: synaptics-rmi4 - add devicetree support
>   Input: synaptics-rmi4 - add regulator support
>   Input: synaptics-rmi4 - don't immediately set page on probe
>   Input: synaptics-rmi4 - properly set F01 container on PDT scan
>   Input: synaptics-rmi4 - ensure we have IRQs before reading status
>   Input: synaptics-rmi4 - correct RMI4 spec url
> 
>  Documentation/devicetree/bindings/input/rmi4.txt   | 117 +++++
>  .../devicetree/bindings/vendor-prefixes.txt        |   1 +
>  drivers/input/rmi4/Kconfig                         |   1 -
>  drivers/input/rmi4/rmi_bus.c                       | 131 +-----
>  drivers/input/rmi4/rmi_bus.h                       |  18 +-
>  drivers/input/rmi4/rmi_driver.c                    | 321 +++++--------
>  drivers/input/rmi4/rmi_driver.h                    |  33 +-
>  drivers/input/rmi4/rmi_f01.c                       | 163 ++++---
>  drivers/input/rmi4/rmi_f11.c                       | 523 ++++++---------------
>  drivers/input/rmi4/rmi_i2c.c                       |  55 +--
>  include/linux/rmi.h                                | 219 ++-------
>  11 files changed, 551 insertions(+), 1031 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/input/rmi4.txt

Oh no!  Terribly sorry about the threading.  Somehow my gitconfig
'chainreplyto' setting was reset to 'true'.  It won't happen again ...
hopefully.

-Courtney

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

* Re: [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support
  2014-01-24  0:00 [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support Courtney Cavin
  2014-01-24  0:00 ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Courtney Cavin
  2014-01-24  0:06 ` [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support Courtney Cavin
@ 2014-01-24 23:24 ` Christopher Heiny
  2014-01-25  1:08   ` Courtney Cavin
  2 siblings, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-01-24 23:24 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> This is an attempt to get this driver closer to being in an upstream-able form.
> In the process, this drops legacy callback methods for managing power and GPIO
> configuration, in favor of the already existing frameworks.  Most of this
> series is cleanup, but there are a few intermixed bug fixes to make it all
> work.

Hi Courtney!

Thanks for the extensive patches.  There's a great deal of cool stuff in 
there that we're really happy to see (as in "buy Courtney a beer! No, 
make it two beers!" levels of happy).  We really want to get the driver 
upstream, and your improvements will help a lot.  The device tree work 
looks to be particularly helpful.

Unfortunately some of your cleanup is too aggressive, and winds up 
breaking code outside of the current patch submissions.  The current 
patch codebase is significantly reduced in size in order to be more 
manageable, but there's a non-trivial amount of production code outside 
that codebase that depends on things like the current GPIO/IRQ handling, 
the debugfs infrastructure, platform suspend/resume, and so on.  This 
code will be submitted after the core of the driver is upstreamed. 
Tearing out the supporting code now and then putting it all back later 
just makes more work for all concerned.

Additionally, some of your changes are redundant to, or in conflict 
with, patches submitted over the past few weeks.  Have you been 
following that series and discussions relating to them?  It would 
probably be more efficient for you to offer comments on those patches, 
rather than submitting conflicting work.

We'll be going over the new feature and bug fix parts of this patch 
series, and will send comments in the next couple of workdays.

				Thanks,
					Chris

>
> This patch series is based off of the synaptics-rmi4 branch merged into
> Linus' 3.13.  A tree is available at [1].
>
> This was tested on Synaptics TM2281-001 & TM2282-001.
>
> [1] http://github.com/courtc/linux.git
> 	tag for-input/synaptics-rmi4
>
> Courtney Cavin (15):
>    Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
>    Input: synaptics-rmi4 - don't kfree devm_ alloced memory
>    Input: synaptics-rmi4 - don't free devices directly
>    Input: synaptics-rmi4 - remove sensor name from platform data
>    Input: synaptics-rmi4 - remove gpio handling and polling
>    Input: synaptics-rmi4 - remove platform suspend callbacks
>    Input: synaptics-rmi4 - remove remaining debugfs code
>    Input: synaptics-rmi4 - cleanup platform data
>    Input: synaptics-rmi4 - remove unused defines and variables
>    Input: synaptics-rmi4 - add devicetree support
>    Input: synaptics-rmi4 - add regulator support
>    Input: synaptics-rmi4 - don't immediately set page on probe
>    Input: synaptics-rmi4 - properly set F01 container on PDT scan
>    Input: synaptics-rmi4 - ensure we have IRQs before reading status
>    Input: synaptics-rmi4 - correct RMI4 spec url
>
>   Documentation/devicetree/bindings/input/rmi4.txt   | 117 +++++
>   .../devicetree/bindings/vendor-prefixes.txt        |   1 +
>   drivers/input/rmi4/Kconfig                         |   1 -
>   drivers/input/rmi4/rmi_bus.c                       | 131 +-----
>   drivers/input/rmi4/rmi_bus.h                       |  18 +-
>   drivers/input/rmi4/rmi_driver.c                    | 321 +++++--------
>   drivers/input/rmi4/rmi_driver.h                    |  33 +-
>   drivers/input/rmi4/rmi_f01.c                       | 163 ++++---
>   drivers/input/rmi4/rmi_f11.c                       | 523 ++++++---------------
>   drivers/input/rmi4/rmi_i2c.c                       |  55 +--
>   include/linux/rmi.h                                | 219 ++-------
>   11 files changed, 551 insertions(+), 1031 deletions(-)
>   create mode 100644 Documentation/devicetree/bindings/input/rmi4.txt
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support
  2014-01-24 23:24 ` Christopher Heiny
@ 2014-01-25  1:08   ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-01-25  1:08 UTC (permalink / raw)
  To: Christopher Heiny; +Cc: linux-input, dmitry.torokhov

On Sat, Jan 25, 2014 at 12:24:27AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > This is an attempt to get this driver closer to being in an upstream-able form.
> > In the process, this drops legacy callback methods for managing power and GPIO
> > configuration, in favor of the already existing frameworks.  Most of this
> > series is cleanup, but there are a few intermixed bug fixes to make it all
> > work.
> 
> Hi Courtney!
> 
> Thanks for the extensive patches.  There's a great deal of cool stuff in 
> there that we're really happy to see (as in "buy Courtney a beer! No, 
> make it two beers!" levels of happy).  We really want to get the driver 
> upstream, and your improvements will help a lot.  The device tree work 
> looks to be particularly helpful.
> 

Thanks. Glad to help!

> Unfortunately some of your cleanup is too aggressive, and winds up 
> breaking code outside of the current patch submissions.  The current 
> patch codebase is significantly reduced in size in order to be more 
> manageable, but there's a non-trivial amount of production code outside 
> that codebase that depends on things like the current GPIO/IRQ handling, 
> the debugfs infrastructure, platform suspend/resume, and so on.  This 
> code will be submitted after the core of the driver is upstreamed. 
> Tearing out the supporting code now and then putting it all back later 
> just makes more work for all concerned.

I can definitely understand that some of your production code must
manage older kernels and alternative features.  The problem I see here is
that the driver will never get upstreamed with the GPIO/IRQ handling and
unused variables in the first place.  It is unnecessary in mainline, and
therefore should not exist in mainline.  I am not the maintainer though,
so... Dmitry should probably chime in on this.

> 
> Additionally, some of your changes are redundant to, or in conflict 
> with, patches submitted over the past few weeks.  Have you been 
> following that series and discussions relating to them?  It would 
> probably be more efficient for you to offer comments on those patches, 
> rather than submitting conflicting work.
> 

I did not see any specific logical conflicts other than saving the F01
container, which was needed for testing, and was independent of IRQ
counting.  Other than that, there should only need to be rebasing
one-way or the other.  I am simply basing my patches off of what exists
in the tree, which prevents awkward patch-series dependencies.

I did look at your patches, but didn't comment because I had nothing to
say.  I'll be sure to participate in patch discussions if I have
something to add.

... and after double checking, I just noticed that 1/15 conflicts
with your PDT scan cleanup, as we both have C++ comment style cleanup.
Whoops.

> We'll be going over the new feature and bug fix parts of this patch 
> series, and will send comments in the next couple of workdays.
> 
> 				Thanks,
> 					Chris
> 

I'm looking forward to some comments.

-Courtney

> >
> > This patch series is based off of the synaptics-rmi4 branch merged into
> > Linus' 3.13.  A tree is available at [1].
> >
> > This was tested on Synaptics TM2281-001 & TM2282-001.
> >
> > [1] http://github.com/courtc/linux.git
> > 	tag for-input/synaptics-rmi4
> >
> > Courtney Cavin (15):
> >    Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
> >    Input: synaptics-rmi4 - don't kfree devm_ alloced memory
> >    Input: synaptics-rmi4 - don't free devices directly
> >    Input: synaptics-rmi4 - remove sensor name from platform data
> >    Input: synaptics-rmi4 - remove gpio handling and polling
> >    Input: synaptics-rmi4 - remove platform suspend callbacks
> >    Input: synaptics-rmi4 - remove remaining debugfs code
> >    Input: synaptics-rmi4 - cleanup platform data
> >    Input: synaptics-rmi4 - remove unused defines and variables
> >    Input: synaptics-rmi4 - add devicetree support
> >    Input: synaptics-rmi4 - add regulator support
> >    Input: synaptics-rmi4 - don't immediately set page on probe
> >    Input: synaptics-rmi4 - properly set F01 container on PDT scan
> >    Input: synaptics-rmi4 - ensure we have IRQs before reading status
> >    Input: synaptics-rmi4 - correct RMI4 spec url
> >
> >   Documentation/devicetree/bindings/input/rmi4.txt   | 117 +++++
> >   .../devicetree/bindings/vendor-prefixes.txt        |   1 +
> >   drivers/input/rmi4/Kconfig                         |   1 -
> >   drivers/input/rmi4/rmi_bus.c                       | 131 +-----
> >   drivers/input/rmi4/rmi_bus.h                       |  18 +-
> >   drivers/input/rmi4/rmi_driver.c                    | 321 +++++--------
> >   drivers/input/rmi4/rmi_driver.h                    |  33 +-
> >   drivers/input/rmi4/rmi_f01.c                       | 163 ++++---
> >   drivers/input/rmi4/rmi_f11.c                       | 523 ++++++---------------
> >   drivers/input/rmi4/rmi_i2c.c                       |  55 +--
> >   include/linux/rmi.h                                | 219 ++-------
> >   11 files changed, 551 insertions(+), 1031 deletions(-)
> >   create mode 100644 Documentation/devicetree/bindings/input/rmi4.txt
> >
> 
> 
> -- 
> 
> Christopher Heiny
> Senior Staff Firmware Engineer
> Synaptics Incorporated

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

* Re: [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
  2014-01-24  0:00 ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Courtney Cavin
  2014-01-24  0:00   ` [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory Courtney Cavin
@ 2014-02-04 23:08   ` Christopher Heiny
  2014-02-05  2:26     ` Courtney Cavin
  2014-02-06  1:09     ` Dmitry Torokhov
  1 sibling, 2 replies; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:08 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
>   drivers/input/rmi4/rmi_bus.c    |  4 ++--
>   drivers/input/rmi4/rmi_bus.h    |  2 +-
>   drivers/input/rmi4/rmi_driver.c | 17 ++++++++++++-----
>   drivers/input/rmi4/rmi_f11.c    |  4 +++-
>   4 files changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> index 96a76e7..8a939f3 100644
> --- a/drivers/input/rmi4/rmi_bus.c
> +++ b/drivers/input/rmi4/rmi_bus.c
> @@ -37,7 +37,7 @@ static void rmi_release_device(struct device *dev)
>   	kfree(rmi_dev);
>   }
>
> -struct device_type rmi_device_type = {
> +static struct device_type rmi_device_type = {
>   	.name		= "rmi_sensor",
>   	.release	= rmi_release_device,
>   };

This struct is used by diagnostic modules to identify sensor devices, so 
it cannot be static.

> @@ -145,7 +145,7 @@ static void rmi_release_function(struct device *dev)
>   	kfree(fn);
>   }
>
> -struct device_type rmi_function_type = {
> +static struct device_type rmi_function_type = {
>   	.name		= "rmi_function",
>   	.release	= rmi_release_function,
>   };

This struct is used by diagnostic modules to identify function devices, 
so it cannot be static.

> diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
> index decb479..2bad2ed 100644
> --- a/drivers/input/rmi4/rmi_bus.h
> +++ b/drivers/input/rmi4/rmi_bus.h
> @@ -103,7 +103,7 @@ int __must_check __rmi_register_function_handler(struct rmi_function_handler *,
>   #define rmi_register_function_handler(handler) \
>   	__rmi_register_function_handler(handler, THIS_MODULE, KBUILD_MODNAME)
>
> -void rmi_unregister_function_handler(struct rmi_function_handler *);
> +void rmi_unregister_function_handler(struct rmi_function_handler *handler);
>
>   /**
>    * struct rmi_driver - driver for an RMI4 sensor on the RMI bus.
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 3483e5b..5c6379c 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -32,6 +32,8 @@
>   #include "rmi_bus.h"
>   #include "rmi_driver.h"
>
> +#define RMI4_MAX_N_IRQS 256

I see what you're trying to do here, but the IRQ counting patch 
submitted previously does this in a more efficient way, though at a 
slight cost in compute time during initialization.

> +
>   #define HAS_NONSTANDARD_PDT_MASK 0x40
>   #define RMI4_MAX_PAGE 0xff
>   #define RMI4_PAGE_SIZE 0x100
> @@ -260,7 +262,7 @@ static void process_one_interrupt(struct rmi_function *fn,
>   		unsigned long *irq_status, struct rmi_driver_data *data)
>   {
>   	struct rmi_function_handler *fh;
> -	DECLARE_BITMAP(irq_bits, data->num_of_irq_regs);
> +	DECLARE_BITMAP(irq_bits, RMI4_MAX_N_IRQS);
>
>   	if (!fn || !fn->dev.driver)
>   		return;
> @@ -325,7 +327,7 @@ static int process_interrupt_requests(struct rmi_device *rmi_dev)
>   static int rmi_driver_set_input_params(struct rmi_device *rmi_dev,
>   				struct input_dev *input)
>   {
> -	// FIXME: set up parent
> +	/* FIXME: set up parent */
>   	input->name = SYNAPTICS_INPUT_DEVICE_NAME;
>   	input->id.vendor  = SYNAPTICS_VENDOR_ID;
>   	input->id.bustype = BUS_RMI;
> @@ -466,7 +468,7 @@ static int rmi_driver_reset_handler(struct rmi_device *rmi_dev)
>   /*
>    * Construct a function's IRQ mask. This should be called once and stored.
>    */
> -int rmi_driver_irq_get_mask(struct rmi_device *rmi_dev,
> +static int rmi_driver_irq_get_mask(struct rmi_device *rmi_dev,
>   		struct rmi_function *fn) {
>   	int i;
>   	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> @@ -665,7 +667,7 @@ static int rmi_scan_pdt(struct rmi_device *rmi_dev)
>   					pdt_entry.function_number, page);
>   			done = false;
>
> -			// XXX need to make sure we create F01 first...
> +			/* XXX need to make sure we create F01 first... */
>   			retval = create_function(rmi_dev,
>   					&pdt_entry, &irq_count, page_start);
>
> @@ -674,6 +676,11 @@ static int rmi_scan_pdt(struct rmi_device *rmi_dev)
>   		}
>   		done = done || data->f01_bootloader_mode;
>   	}
> +	if (irq_count > RMI4_MAX_N_IRQS) {
> +		dev_err(dev, "Too many IRQs specified\n");
> +		retval = -EINVAL;
> +		goto error_exit;
> +	}
>   	data->irq_count = irq_count;
>   	data->num_of_irq_regs = (irq_count + 7) / 8;
>   	dev_dbg(dev, "%s: Done with PDT scan.\n", __func__);
> @@ -953,7 +960,7 @@ static int rmi_driver_probe(struct device *dev)
>   	return retval;
>   }
>
> -struct rmi_driver rmi_physical_driver = {
> +static struct rmi_driver rmi_physical_driver = {
>   	.driver = {
>   		.owner	= THIS_MODULE,
>   		.name	= "rmi_physical",
> diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> index c2be9de..4e0a296 100644
> --- a/drivers/input/rmi4/rmi_f11.c
> +++ b/drivers/input/rmi4/rmi_f11.c
> @@ -610,6 +610,8 @@ static void rmi_f11_abs_pos_report(struct f11_data *f11,
>   	int temp;
>   	u8 abs_base = n_finger * RMI_F11_ABS_BYTES;
>
> +	orient = z = w_min = w_max = 0;
> +
>   	if (finger_state) {
>   		x = (data->abs_pos[abs_base] << 4) |
>   			(data->abs_pos[abs_base + 2] & 0x0F);
> @@ -1413,7 +1415,7 @@ static int rmi_f11_config(struct rmi_function *fn)
>   	return 0;
>   }
>
> -int rmi_f11_attention(struct rmi_function *fn,
> +static int rmi_f11_attention(struct rmi_function *fn,
>   						unsigned long *irq_bits)
>   {
>   	struct rmi_device *rmi_dev = fn->rmi_dev;
>


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

* Re: [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory
  2014-01-24  0:00   ` [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory Courtney Cavin
  2014-01-24  0:00     ` [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly Courtney Cavin
@ 2014-02-04 23:08     ` Christopher Heiny
  2014-02-05  2:27       ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:08 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>

This is redundant with patch code submitted 2013/01/22.  See here:
     http://www.spinics.net/lists/linux-input/msg29280.html

and in any case, Dmitry has submitted a more thorough tidy up here:
     http://www.spinics.net/lists/linux-input/msg29323.html

> ---
>   drivers/input/rmi4/rmi_f01.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
> index cf1081f..98bc65a9 100644
> --- a/drivers/input/rmi4/rmi_f01.c
> +++ b/drivers/input/rmi4/rmi_f01.c
> @@ -390,7 +390,7 @@ static int rmi_f01_initialize(struct rmi_function *fn)
>   	return 0;
>
>    error_exit:
> -	kfree(data);
> +	devm_kfree(&fn->dev, data);
>   	return error;
>   }
>
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly
  2014-01-24  0:00     ` [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly Courtney Cavin
  2014-01-24  0:00       ` [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data Courtney Cavin
@ 2014-02-04 23:08       ` Christopher Heiny
  2014-02-05  2:28         ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:08 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> Devices use a kobject to manage references, do not delete the memory
> while still referenced.  Instead, call put_device() to release the
> reference.

This is an interesting idea, but it should be done consistently for all 
the device types.

>
> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
>   drivers/input/rmi4/rmi_bus.c    | 8 +++++---
>   drivers/input/rmi4/rmi_driver.c | 6 +-----
>   2 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> index 8a939f3..cd7bfbd 100644
> --- a/drivers/input/rmi4/rmi_bus.c
> +++ b/drivers/input/rmi4/rmi_bus.c
> @@ -94,8 +94,7 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
>   		return -EINVAL;
>   	}
>
> -	rmi_dev = devm_kzalloc(xport->dev,
> -				sizeof(struct rmi_device), GFP_KERNEL);
> +	rmi_dev = kzalloc(sizeof(struct rmi_device), GFP_KERNEL);
>   	if (!rmi_dev)
>   		return -ENOMEM;
>
> @@ -112,8 +111,10 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
>   	rmi_physical_setup_debugfs(rmi_dev);
>
>   	error = device_register(&rmi_dev->dev);
> -	if (error)
> +	if (error) {
> +		put_device(&rmi_dev->dev);
>   		return error;
> +	}
>
>   	dev_dbg(xport->dev, "%s: Registered %s as %s.\n", __func__,
>   		pdata->sensor_name, dev_name(&rmi_dev->dev));
> @@ -240,6 +241,7 @@ int rmi_register_function(struct rmi_function *fn)
>   		dev_err(&rmi_dev->dev,
>   			"Failed device_register function device %s\n",
>   			dev_name(&fn->dev));
> +		put_device(&fn->dev);
>   		goto error_exit;
>   	}
>
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 5c6379c..4965589 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -557,15 +557,11 @@ static int create_function(struct rmi_device *rmi_dev,
>
>   	error = rmi_register_function(fn);
>   	if (error)
> -		goto err_free_mem;
> +		return error;
>
>   	list_add_tail(&fn->node, &data->function_list);
>
>   	return 0;
> -
> -err_free_mem:
> -	kfree(fn);
> -	return error;
>   }
>
>   /*
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data
  2014-01-24  0:00       ` [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data Courtney Cavin
  2014-01-24  0:00         ` [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling Courtney Cavin
@ 2014-02-04 23:08         ` Christopher Heiny
  2014-02-05  2:30           ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:08 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> The driver/device already has a name, no need for another one.

This is extremely useful in initial system bring up on systems with more 
than one RMI4 sensor.  We'd prefer to keep this.

>
> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
>   drivers/input/rmi4/rmi_bus.c    | 4 ++--
>   drivers/input/rmi4/rmi_driver.c | 7 ++-----
>   drivers/input/rmi4/rmi_f11.c    | 3 +--
>   drivers/input/rmi4/rmi_i2c.c    | 3 +--
>   include/linux/rmi.h             | 4 ----
>   5 files changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> index cd7bfbd..fd14acb 100644
> --- a/drivers/input/rmi4/rmi_bus.c
> +++ b/drivers/input/rmi4/rmi_bus.c
> @@ -116,8 +116,8 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
>   		return error;
>   	}
>
> -	dev_dbg(xport->dev, "%s: Registered %s as %s.\n", __func__,
> -		pdata->sensor_name, dev_name(&rmi_dev->dev));
> +	dev_dbg(xport->dev, "%s: Registered %s\n", __func__,
> +		dev_name(&rmi_dev->dev));
>
>   	return 0;
>   }
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 4965589..5fb582c 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -531,12 +531,10 @@ static int create_function(struct rmi_device *rmi_dev,
>   {
>   	struct device *dev = &rmi_dev->dev;
>   	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> -	struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
>   	struct rmi_function *fn;
>   	int error;
>
> -	dev_dbg(dev, "Initializing F%02X for %s.\n",
> -		pdt->function_number, pdata->sensor_name);
> +	dev_dbg(dev, "Initializing F%02X\n", pdt->function_number);
>
>   	fn = kzalloc(sizeof(struct rmi_function), GFP_KERNEL);
>   	if (!fn) {
> @@ -822,8 +820,7 @@ static int rmi_driver_probe(struct device *dev)
>
>   	retval = rmi_scan_pdt(rmi_dev);
>   	if (retval) {
> -		dev_err(dev, "PDT scan for %s failed with code %d.\n",
> -			pdata->sensor_name, retval);
> +		dev_err(dev, "PDT scan failed with code %d.\n", retval);
>   		goto err_free_data;
>   	}
>
> diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> index 4e0a296..553afd8 100644
> --- a/drivers/input/rmi4/rmi_f11.c
> +++ b/drivers/input/rmi4/rmi_f11.c
> @@ -1182,8 +1182,7 @@ static int rmi_f11_initialize(struct rmi_function *fn)
>   	struct f11_2d_sensor *sensor;
>   	u8 buf;
>
> -	dev_dbg(&fn->dev, "Initializing F11 values for %s.\n",
> -		 pdata->sensor_name);
> +	dev_dbg(&fn->dev, "Initializing F11 values.\n");
>
>   	/*
>   	** init instance data, fill in values and create any sysfs files
> diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
> index 24d8a04..910f05c 100644
> --- a/drivers/input/rmi4/rmi_i2c.c
> +++ b/drivers/input/rmi4/rmi_i2c.c
> @@ -196,8 +196,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
>   		return -EINVAL;
>   	}
>
> -	dev_dbg(&client->dev, "Probing %s at %#02x (GPIO %d).\n",
> -		pdata->sensor_name ? pdata->sensor_name : "-no name-",
> +	dev_dbg(&client->dev, "Probing %#02x (GPIO %d).\n",
>   		client->addr, pdata->attn_gpio);
>
>   	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
> diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> index 735e978..65b59b5 100644
> --- a/include/linux/rmi.h
> +++ b/include/linux/rmi.h
> @@ -194,8 +194,6 @@ struct rmi_device_platform_data_spi {
>   /**
>    * struct rmi_device_platform_data - system specific configuration info.
>    *
> - * @sensor_name - this is used for various diagnostic messages.
> - *
>    * @firmware_name - if specified will override default firmware name,
>    * for reflashing.
>    *
> @@ -247,8 +245,6 @@ struct rmi_device_platform_data_spi {
>    * functions.
>    */
>   struct rmi_device_platform_data {
> -	char *sensor_name;	/* Used for diagnostics. */
> -
>   	int attn_gpio;
>   	enum rmi_attn_polarity attn_polarity;
>   	bool level_triggered;
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling
  2014-01-24  0:00         ` [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling Courtney Cavin
  2014-01-24  0:00           ` [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks Courtney Cavin
@ 2014-02-04 23:08           ` Christopher Heiny
  2014-02-05  2:31             ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:08 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> Since all the configuration needed for an irq can be provided in other
> ways, remove all gpio->irq functionality. This cleans up the code quite
> a bit.

In certain diagnostic modes, we need to be able to release the IRQ so 
the GPIO can be monitored from userspace.  This patch removes that 
capability.

> This also gets rid of polling functionality, as this should be done
> elsewhere if absolutely needed.

As mentioned in previous patch discussions, the polling functionality is 
quite useful during new system integration, so we need to retain that. 
If you have a proposal for where else it could be done, we'd certainly 
entertain a patch that implements that.

					Thanks,
						Chris

>
> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
>   drivers/input/rmi4/rmi_driver.c | 143 +++++-----------------------------------
>   drivers/input/rmi4/rmi_driver.h |   7 --
>   drivers/input/rmi4/rmi_i2c.c    |  24 +------
>   include/linux/rmi.h             |  31 +--------
>   4 files changed, 20 insertions(+), 185 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 5fb582c..780742f 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -20,7 +20,6 @@
>   #include <linux/delay.h>
>   #include <linux/device.h>
>   #include <linux/fs.h>
> -#include <linux/gpio.h>
>   #include <linux/kconfig.h>
>   #include <linux/list.h>
>   #include <linux/module.h>
> @@ -50,74 +49,17 @@ static irqreturn_t rmi_irq_thread(int irq, void *p)
>   	struct rmi_transport_dev *xport = p;
>   	struct rmi_device *rmi_dev = xport->rmi_dev;
>   	struct rmi_driver *driver = rmi_dev->driver;
> -	struct rmi_device_platform_data *pdata = xport->dev->platform_data;
>   	struct rmi_driver_data *data;
>
>   	data = dev_get_drvdata(&rmi_dev->dev);
> -
> -	if (IRQ_DEBUG(data))
> -		dev_dbg(xport->dev, "ATTN gpio, value: %d.\n",
> -				gpio_get_value(pdata->attn_gpio));
> -
> -	if (gpio_get_value(pdata->attn_gpio) == pdata->attn_polarity) {
> -		data->attn_count++;
> -		if (driver && driver->irq_handler && rmi_dev)
> -			driver->irq_handler(rmi_dev, irq);
> -	}
> +	if (driver && driver->irq_handler && rmi_dev)
> +		driver->irq_handler(rmi_dev, irq);
>
>   	return IRQ_HANDLED;
>   }
>
>   static int process_interrupt_requests(struct rmi_device *rmi_dev);
>
> -static void rmi_poll_work(struct work_struct *work)
> -{
> -	struct rmi_driver_data *data =
> -			container_of(work, struct rmi_driver_data, poll_work);
> -	struct rmi_device *rmi_dev = data->rmi_dev;
> -
> -	process_interrupt_requests(rmi_dev);
> -}
> -
> -/*
> - * This is the timer function for polling - it simply has to schedule work
> - * and restart the timer.
> - */
> -static enum hrtimer_restart rmi_poll_timer(struct hrtimer *timer)
> -{
> -	struct rmi_driver_data *data =
> -			container_of(timer, struct rmi_driver_data, poll_timer);
> -
> -	if (!data->enabled)
> -		return HRTIMER_NORESTART;
> -	if (!work_pending(&data->poll_work))
> -		schedule_work(&data->poll_work);
> -	hrtimer_start(&data->poll_timer, data->poll_interval, HRTIMER_MODE_REL);
> -	return HRTIMER_NORESTART;
> -}
> -
> -static int enable_polling(struct rmi_device *rmi_dev)
> -{
> -	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> -
> -	dev_dbg(&rmi_dev->dev, "Polling enabled.\n");
> -	INIT_WORK(&data->poll_work, rmi_poll_work);
> -	hrtimer_init(&data->poll_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> -	data->poll_timer.function = rmi_poll_timer;
> -	hrtimer_start(&data->poll_timer, data->poll_interval, HRTIMER_MODE_REL);
> -
> -	return 0;
> -}
> -
> -static void disable_polling(struct rmi_device *rmi_dev)
> -{
> -	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> -
> -	dev_dbg(&rmi_dev->dev, "Polling disabled.\n");
> -	hrtimer_cancel(&data->poll_timer);
> -	cancel_work_sync(&data->poll_work);
> -}
> -
>   static void disable_sensor(struct rmi_device *rmi_dev)
>   {
>   	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> @@ -125,9 +67,6 @@ static void disable_sensor(struct rmi_device *rmi_dev)
>   	if (!data->enabled)
>   		return;
>
> -	if (!data->irq)
> -		disable_polling(rmi_dev);
> -
>   	if (rmi_dev->xport->ops->disable_device)
>   		rmi_dev->xport->ops->disable_device(rmi_dev->xport);
>
> @@ -155,20 +94,14 @@ static int enable_sensor(struct rmi_device *rmi_dev)
>   	}
>
>   	xport = rmi_dev->xport;
> -	if (data->irq) {
> -		retval = request_threaded_irq(data->irq,
> -				xport->hard_irq ? xport->hard_irq : NULL,
> -				xport->irq_thread ?
> -					xport->irq_thread : rmi_irq_thread,
> -				data->irq_flags,
> -				dev_name(&rmi_dev->dev), xport);
> -		if (retval)
> -			return retval;
> -	} else {
> -		retval = enable_polling(rmi_dev);
> -		if (retval < 0)
> -			return retval;
> -	}
> +	retval = request_threaded_irq(data->irq,
> +			xport->hard_irq ? xport->hard_irq : NULL,
> +			xport->irq_thread ?
> +				xport->irq_thread : rmi_irq_thread,
> +			IRQF_ONESHOT,
> +			dev_name(&rmi_dev->dev), xport);
> +	if (retval)
> +		return retval;
>
>   	data->enabled = true;
>
> @@ -751,16 +684,9 @@ static SIMPLE_DEV_PM_OPS(rmi_driver_pm, rmi_driver_suspend, rmi_driver_resume);
>   static int rmi_driver_remove(struct device *dev)
>   {
>   	struct rmi_device *rmi_dev = to_rmi_device(dev);
> -	const struct rmi_device_platform_data *pdata =
> -					to_rmi_platform_data(rmi_dev);
> -	const struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> -
>   	disable_sensor(rmi_dev);
>   	rmi_free_function_list(rmi_dev);
>
> -	if (data->gpio_held)
> -		gpio_free(pdata->attn_gpio);
> -
>   	return 0;
>   }
>
> @@ -895,51 +821,12 @@ static int rmi_driver_probe(struct device *dev)
>   		mutex_init(&data->suspend_mutex);
>   	}
>
> -	if (gpio_is_valid(pdata->attn_gpio)) {
> -		static const char GPIO_LABEL[] = "attn";
> -		unsigned long gpio_flags = GPIOF_DIR_IN;
> -
> -		data->irq = gpio_to_irq(pdata->attn_gpio);
> -		if (pdata->level_triggered) {
> -			data->irq_flags = IRQF_ONESHOT |
> -				((pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH)
> -				? IRQF_TRIGGER_HIGH : IRQF_TRIGGER_LOW);
> -		} else {
> -			data->irq_flags =
> -				(pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH)
> -				? IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
> -		}
> +	data->irq = pdata->irq;
> +	if (data->irq < 0) {
> +		dev_err(dev, "Failed to get attn IRQ.\n");
> +		retval = data->irq;
> +		goto err_free_data;
>
> -		if (IS_ENABLED(CONFIG_RMI4_DEV))
> -			gpio_flags |= GPIOF_EXPORT;
> -
> -		retval = gpio_request_one(pdata->attn_gpio, gpio_flags,
> -					  GPIO_LABEL);
> -		if (retval) {
> -			dev_warn(dev, "WARNING: Failed to request ATTN gpio %d, code=%d.\n",
> -				 pdata->attn_gpio, retval);
> -			retval = 0;
> -		} else {
> -			dev_info(dev, "Obtained ATTN gpio %d.\n",
> -					pdata->attn_gpio);
> -			data->gpio_held = true;
> -			if (IS_ENABLED(CONFIG_RMI4_DEV)) {
> -				retval = gpio_export_link(dev,
> -						GPIO_LABEL, pdata->attn_gpio);
> -				if (retval) {
> -					dev_warn(dev,
> -						"WARNING: Failed to symlink ATTN gpio!\n");
> -					retval = 0;
> -				} else {
> -					dev_info(dev, "Exported ATTN gpio %d.",
> -						pdata->attn_gpio);
> -				}
> -			}
> -		}
> -	} else {
> -		data->poll_interval = ktime_set(0,
> -			(pdata->poll_interval_ms ? pdata->poll_interval_ms :
> -			DEFAULT_POLL_INTERVAL_MS) * 1000 * 1000);
>   	}
>
>   	if (data->f01_container->dev.driver) {
> diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
> index 4f44a54..aef5521 100644
> --- a/drivers/input/rmi4/rmi_driver.h
> +++ b/drivers/input/rmi4/rmi_driver.h
> @@ -39,9 +39,7 @@ struct rmi_driver_data {
>
>   	u32 attn_count;
>   	u32 irq_debug;	/* Should be bool, but debugfs wants u32 */
> -	bool gpio_held;
>   	int irq;
> -	int irq_flags;
>   	int num_of_irq_regs;
>   	int irq_count;
>   	unsigned long *irq_status;
> @@ -50,11 +48,6 @@ struct rmi_driver_data {
>   	bool irq_stored;
>   	struct mutex irq_mutex;
>
> -	/* Following are used when polling. */
> -	struct hrtimer poll_timer;
> -	struct work_struct poll_work;
> -	ktime_t poll_interval;
> -
>   	struct mutex pdt_mutex;
>   	u8 pdt_props;
>   	u8 bsr;
> diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
> index 910f05c..aebf974 100644
> --- a/drivers/input/rmi4/rmi_i2c.c
> +++ b/drivers/input/rmi4/rmi_i2c.c
> @@ -196,8 +196,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
>   		return -EINVAL;
>   	}
>
> -	dev_dbg(&client->dev, "Probing %#02x (GPIO %d).\n",
> -		client->addr, pdata->attn_gpio);
> +	dev_dbg(&client->dev, "Probing %#02x.\n", client->addr);
>
>   	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
>   		dev_err(&client->dev,
> @@ -205,15 +204,6 @@ static int rmi_i2c_probe(struct i2c_client *client,
>   		return -ENODEV;
>   	}
>
> -	if (pdata->gpio_config) {
> -		retval = pdata->gpio_config(pdata->gpio_data, true);
> -		if (retval < 0) {
> -			dev_err(&client->dev, "Failed to configure GPIOs, code: %d.\n",
> -				retval);
> -			return retval;
> -		}
> -	}
> -
>   	rmi_i2c = devm_kzalloc(&client->dev, sizeof(struct rmi_i2c_xport),
>   				GFP_KERNEL);
>   	if (!rmi_i2c)
> @@ -240,7 +230,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
>   	if (retval) {
>   		dev_err(&client->dev, "Failed to register transport driver at 0x%.2X.\n",
>   			client->addr);
> -		goto err_gpio;
> +		goto err;
>   	}
>
>   	i2c_set_clientdata(client, rmi_i2c);
> @@ -249,24 +239,16 @@ static int rmi_i2c_probe(struct i2c_client *client,
>   			client->addr);
>   	return 0;
>
> -err_gpio:
> -	if (pdata->gpio_config)
> -		pdata->gpio_config(pdata->gpio_data, false);
> -
> +err:
>   	return retval;
>   }
>
>   static int rmi_i2c_remove(struct i2c_client *client)
>   {
> -	const struct rmi_device_platform_data *pdata =
> -				dev_get_platdata(&client->dev);
>   	struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client);
>
>   	rmi_unregister_transport_device(&rmi_i2c->xport);
>
> -	if (pdata->gpio_config)
> -		pdata->gpio_config(pdata->gpio_data, false);
> -
>   	return 0;
>   }
>
> diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> index 65b59b5..326e741 100644
> --- a/include/linux/rmi.h
> +++ b/include/linux/rmi.h
> @@ -23,11 +23,6 @@
>   #include <linux/wait.h>
>   #include <linux/debugfs.h>
>
> -enum rmi_attn_polarity {
> -	RMI_ATTN_ACTIVE_LOW = 0,
> -	RMI_ATTN_ACTIVE_HIGH = 1
> -};
> -
>   /**
>    * struct rmi_f11_axis_alignment - target axis alignment
>    * @swap_axes: set to TRUE if desired to swap x- and y-axis
> @@ -194,25 +189,10 @@ struct rmi_device_platform_data_spi {
>   /**
>    * struct rmi_device_platform_data - system specific configuration info.
>    *
> + * @irq - attention IRQ
>    * @firmware_name - if specified will override default firmware name,
>    * for reflashing.
>    *
> - * @attn_gpio - the index of a GPIO that will be used to provide the ATTN
> - * interrupt from the touch sensor.
> - * @attn_polarity - indicates whether ATTN is active high or low.
> - * @level_triggered - by default, the driver uses edge triggered interrupts.
> - * However, this can cause problems with suspend/resume on some platforms.  In
> - * that case, set this to 1 to use level triggered interrupts.
> - * @gpio_config - a routine that will be called when the driver is loaded to
> - * perform any platform specific GPIO configuration, and when it is unloaded
> - * for GPIO de-configuration.  This is typically used to configure the ATTN
> - * GPIO and the I2C or SPI pins, if necessary.
> - * @gpio_data - platform specific data to be passed to the GPIO configuration
> - * function.
> - *
> - * @poll_interval_ms - the time in milliseconds between reads of the interrupt
> - * status register.  This is ignored if attn_gpio is non-zero.
> - *
>    * @reset_delay_ms - after issuing a reset command to the touch sensor, the
>    * driver waits a few milliseconds to give the firmware a chance to
>    * to re-initialize.  You can override the default wait period here.
> @@ -245,14 +225,7 @@ struct rmi_device_platform_data_spi {
>    * functions.
>    */
>   struct rmi_device_platform_data {
> -	int attn_gpio;
> -	enum rmi_attn_polarity attn_polarity;
> -	bool level_triggered;
> -	void *gpio_data;
> -	int (*gpio_config)(void *gpio_data, bool configure);
> -
> -	int poll_interval_ms;
> -
> +	int irq;
>   	int reset_delay_ms;
>
>   	struct rmi_device_platform_data_spi spi_data;
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks
  2014-01-24  0:00           ` [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks Courtney Cavin
  2014-01-24  0:00             ` [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code Courtney Cavin
@ 2014-02-04 23:09             ` Christopher Heiny
  2014-02-05  2:32               ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:09 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> These are unnecessary and ugly. Remove them, and all related code.

Ugly though they might be, on a number of hardware implementations they 
are quite necessary in order to provide hooks to handle hardware 
specific suspend/resume activities relating to power management and 
device configuration.  Your subsequent patch relating to the VIO/VDD 
regulators might eventually render these obsolete, but in the meantime 
let's not kill them off while they're still useful.

>
> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
>   drivers/input/rmi4/rmi_driver.c | 57 ++---------------------------------------
>   drivers/input/rmi4/rmi_driver.h | 10 --------
>   include/linux/rmi.h             | 20 ---------------
>   3 files changed, 2 insertions(+), 85 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 780742f..691b6fb 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -621,60 +621,16 @@ error_exit:
>   #ifdef CONFIG_PM_SLEEP
>   static int rmi_driver_suspend(struct device *dev)
>   {
> -	struct rmi_driver_data *data;
> -	int retval = 0;
>   	struct rmi_device *rmi_dev = to_rmi_device(dev);
>
> -	data = dev_get_drvdata(&rmi_dev->dev);
> -
> -	mutex_lock(&data->suspend_mutex);
> -
> -	if (data->pre_suspend) {
> -		retval = data->pre_suspend(data->pm_data);
> -		if (retval)
> -			goto exit;
> -	}
> -
>   	disable_sensor(rmi_dev);
> -
> -	if (data->post_suspend)
> -		retval = data->post_suspend(data->pm_data);
> -
> -exit:
> -	mutex_unlock(&data->suspend_mutex);
> -	return retval;
> +	return 0;
>   }
>
>   static int rmi_driver_resume(struct device *dev)
>   {
> -	struct rmi_driver_data *data;
> -	int retval = 0;
>   	struct rmi_device *rmi_dev = to_rmi_device(dev);
> -
> -	data = dev_get_drvdata(&rmi_dev->dev);
> -	mutex_lock(&data->suspend_mutex);
> -
> -	if (data->pre_resume) {
> -		retval = data->pre_resume(data->pm_data);
> -		if (retval)
> -			goto exit;
> -	}
> -
> -	retval = enable_sensor(rmi_dev);
> -	if (retval)
> -		goto exit;
> -
> -
> -	if (data->post_resume) {
> -		retval = data->post_resume(data->pm_data);
> -		if (retval)
> -			goto exit;
> -	}
> -
> -	data->suspended = false;
> -exit:
> -	mutex_unlock(&data->suspend_mutex);
> -	return retval;
> +	return enable_sensor(rmi_dev);
>   }
>
>   #endif /* CONFIG_PM_SLEEP */
> @@ -811,15 +767,6 @@ static int rmi_driver_probe(struct device *dev)
>   		retval = -ENOMEM;
>   		goto err_free_data;
>   	}
> -	if (IS_ENABLED(CONFIG_PM)) {
> -		data->pm_data = pdata->pm_data;
> -		data->pre_suspend = pdata->pre_suspend;
> -		data->post_suspend = pdata->post_suspend;
> -		data->pre_resume = pdata->pre_resume;
> -		data->post_resume = pdata->post_resume;
> -
> -		mutex_init(&data->suspend_mutex);
> -	}
>
>   	data->irq = pdata->irq;
>   	if (data->irq < 0) {
> diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
> index aef5521..f28166f 100644
> --- a/drivers/input/rmi4/rmi_driver.h
> +++ b/drivers/input/rmi4/rmi_driver.h
> @@ -53,16 +53,6 @@ struct rmi_driver_data {
>   	u8 bsr;
>
>   	bool enabled;
> -#ifdef CONFIG_PM_SLEEP
> -	bool suspended;
> -	struct mutex suspend_mutex;
> -
> -	void *pm_data;
> -	int (*pre_suspend) (const void *pm_data);
> -	int (*post_suspend) (const void *pm_data);
> -	int (*pre_resume) (const void *pm_data);
> -	int (*post_resume) (const void *pm_data);
> -#endif
>
>   #ifdef CONFIG_RMI4_DEBUG
>   	struct dentry *debugfs_delay;
> diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> index 326e741..41c2c04 100644
> --- a/include/linux/rmi.h
> +++ b/include/linux/rmi.h
> @@ -204,8 +204,6 @@ struct rmi_device_platform_data_spi {
>    * @f11_rezero_wait - if non-zero, this is how may milliseconds the F11 2D
>    * sensor will wait before being be rezeroed on exit from suspend.  If
>    * this value is zero, the F11 2D sensor will not be rezeroed on resume.
> - * @pre_suspend - this will be called before any other suspend operations are
> - * done.
>    * @power_management - overrides default touch sensor doze mode settings (see
>    * above)
>    * @f19_button_map - provide initial input subsystem key mappings for F19.
> @@ -213,16 +211,6 @@ struct rmi_device_platform_data_spi {
>    * @gpioled_map - provides initial settings for GPIOs and LEDs controlled by
>    * F30.
>    * @f41_button_map - provide initial input subsystem key mappings for F41.
> - *
> - * @post_suspend - this will be called after all suspend operations are
> - * completed.  This is the ONLY safe place to power off an RMI sensor
> - * during the suspend process.
> - * @pre_resume - this is called before any other resume operations.  If you
> - * powered off the RMI4 sensor in post_suspend(), then you MUST power it back
> - * here, and you MUST wait an appropriate time for the ASIC to come up
> - * (100ms to 200ms, depending on the sensor) before returning.
> - * @pm_data - this will be passed to the various (pre|post)_(suspend/resume)
> - * functions.
>    */
>   struct rmi_device_platform_data {
>   	int irq;
> @@ -242,14 +230,6 @@ struct rmi_device_platform_data {
>   #ifdef CONFIG_RMI4_FWLIB
>   	char *firmware_name;
>   #endif
> -
> -#ifdef	CONFIG_PM
> -	void *pm_data;
> -	int (*pre_suspend) (const void *pm_data);
> -	int (*post_suspend) (const void *pm_data);
> -	int (*pre_resume) (const void *pm_data);
> -	int (*post_resume) (const void *pm_data);
> -#endif
>   };
>
>   /**
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code
  2014-01-24  0:00             ` [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code Courtney Cavin
  2014-01-24  0:00               ` [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data Courtney Cavin
@ 2014-02-04 23:09               ` Christopher Heiny
  2014-02-05  2:33                 ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:09 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> As most of this code was already removed, the remainder does nothing.
> Remove it.

Actually, the code does something.  The functionality that it supports 
is not currently being submitted as patches in order to keep the working 
set size down.  We're trying to keep the submitted code consistent with 
the production, since that makes it easier to develop the patches and 
keeps the patches similar to the code that is used in production.

>
> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
>   drivers/input/rmi4/Kconfig      |   1 -
>   drivers/input/rmi4/rmi_bus.c    | 103 ----------------------------------------
>   drivers/input/rmi4/rmi_bus.h    |  12 -----
>   drivers/input/rmi4/rmi_driver.c |   3 --
>   drivers/input/rmi4/rmi_driver.h |  12 -----
>   drivers/input/rmi4/rmi_f11.c    |   2 +-
>   include/linux/rmi.h             |   7 ++-
>   7 files changed, 4 insertions(+), 136 deletions(-)
>
> diff --git a/drivers/input/rmi4/Kconfig b/drivers/input/rmi4/Kconfig
> index d0c7b6e..22d5599 100644
> --- a/drivers/input/rmi4/Kconfig
> +++ b/drivers/input/rmi4/Kconfig
> @@ -14,7 +14,6 @@ config RMI4_CORE
>   config RMI4_DEBUG
>   	bool "RMI4 Debugging"
>   	depends on RMI4_CORE
> -	select DEBUG_FS
>   	help
>   	  Say Y here to enable debug feature in the RMI4 driver.
>
> diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> index fd14acb..a51e6b4 100644
> --- a/drivers/input/rmi4/rmi_bus.c
> +++ b/drivers/input/rmi4/rmi_bus.c
> @@ -15,14 +15,9 @@
>   #include <linux/rmi.h>
>   #include <linux/slab.h>
>   #include <linux/types.h>
> -#include <linux/debugfs.h>
>   #include "rmi_bus.h"
>   #include "rmi_driver.h"
>
> -#ifdef CONFIG_RMI4_DEBUG
> -static struct dentry *rmi_debugfs_root;
> -#endif
> -
>   /*
>    * RMI Physical devices
>    *
> @@ -47,34 +42,6 @@ bool rmi_is_physical_device(struct device *dev)
>   	return dev->type == &rmi_device_type;
>   }
>
> -#ifdef CONFIG_RMI4_DEBUG
> -
> -static void rmi_physical_setup_debugfs(struct rmi_device *rmi_dev)
> -{
> -	rmi_dev->debugfs_root = debugfs_create_dir(dev_name(&rmi_dev->dev),
> -						   rmi_debugfs_root);
> -	if (!rmi_dev->debugfs_root)
> -		dev_warn(&rmi_dev->dev, "Failed to create debugfs root.\n");
> -}
> -
> -static void rmi_physical_teardown_debugfs(struct rmi_device *rmi_dev)
> -{
> -	if (rmi_dev->debugfs_root)
> -		debugfs_remove_recursive(rmi_dev->debugfs_root);
> -}
> -
> -#else
> -
> -static void rmi_physical_setup_debugfs(struct rmi_device *rmi_dev)
> -{
> -}
> -
> -static void rmi_physical_teardown_debugfs(struct rmi_device *rmi_dev)
> -{
> -}
> -
> -#endif
> -
>   /**
>    * rmi_register_transport_device - register a transport device connection
>    * on the RMI bus.  Transport drivers provide communication from the devices
> @@ -108,8 +75,6 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
>
>   	xport->rmi_dev = rmi_dev;
>
> -	rmi_physical_setup_debugfs(rmi_dev);
> -
>   	error = device_register(&rmi_dev->dev);
>   	if (error) {
>   		put_device(&rmi_dev->dev);
> @@ -132,7 +97,6 @@ void rmi_unregister_transport_device(struct rmi_transport_dev *xport)
>   {
>   	struct rmi_device *rmi_dev = xport->rmi_dev;
>
> -	rmi_physical_teardown_debugfs(rmi_dev);
>   	device_unregister(&rmi_dev->dev);
>   }
>   EXPORT_SYMBOL(rmi_unregister_transport_device);
> @@ -156,37 +120,6 @@ bool rmi_is_function_device(struct device *dev)
>   	return dev->type == &rmi_function_type;
>   }
>
> -#ifdef CONFIG_RMI4_DEBUG
> -
> -static void rmi_function_setup_debugfs(struct rmi_function *fn)
> -{
> -	char dirname[12];
> -
> -	snprintf(dirname, sizeof(dirname), "F%02X", fn->fd.function_number);
> -	fn->debugfs_root = debugfs_create_dir(dirname,
> -					      fn->rmi_dev->debugfs_root);
> -	if (!fn->debugfs_root)
> -		dev_warn(&fn->dev, "Failed to create debugfs dir.\n");
> -}
> -
> -static void rmi_function_teardown_debugfs(struct rmi_function *fn)
> -{
> -	if (fn->debugfs_root)
> -		debugfs_remove_recursive(fn->debugfs_root);
> -}
> -
> -#else
> -
> -static void rmi_function_setup_debugfs(struct rmi_function *fn)
> -{
> -}
> -
> -static void rmi_function_teardown_debugfs(struct rmi_function *fn)
> -{
> -}
> -
> -#endif
> -
>   static int rmi_function_match(struct device *dev, struct device_driver *drv)
>   {
>   	struct rmi_function_handler *handler = to_rmi_function_handler(drv);
> @@ -234,8 +167,6 @@ int rmi_register_function(struct rmi_function *fn)
>   	fn->dev.type = &rmi_function_type;
>   	fn->dev.bus = &rmi_bus_type;
>
> -	rmi_function_setup_debugfs(fn);
> -
>   	error = device_register(&fn->dev);
>   	if (error) {
>   		dev_err(&rmi_dev->dev,
> @@ -250,13 +181,11 @@ int rmi_register_function(struct rmi_function *fn)
>   	return 0;
>
>   error_exit:
> -	rmi_function_teardown_debugfs(fn);
>   	return error;
>   }
>
>   void rmi_unregister_function(struct rmi_function *fn)
>   {
> -	rmi_function_teardown_debugfs(fn);
>   	device_unregister(&fn->dev);
>   }
>
> @@ -325,34 +254,6 @@ struct bus_type rmi_bus_type = {
>   	.name		= "rmi",
>   };
>
> -#ifdef CONFIG_RMI4_DEBUG
> -
> -static void rmi_bus_setup_debugfs(void)
> -{
> -	rmi_debugfs_root = debugfs_create_dir(rmi_bus_type.name, NULL);
> -	if (!rmi_debugfs_root)
> -		pr_err("%s: Failed to create debugfs root\n",
> -		       __func__);
> -}
> -
> -static void rmi_bus_teardown_debugfs(void)
> -{
> -	if (rmi_debugfs_root)
> -		debugfs_remove_recursive(rmi_debugfs_root);
> -}
> -
> -#else
> -
> -static void rmi_bus_setup_debugfs(void)
> -{
> -}
> -
> -static void rmi_bus_teardown_debugfs(void)
> -{
> -}
> -
> -#endif
> -
>   static int __init rmi_bus_init(void)
>   {
>   	int error;
> @@ -364,8 +265,6 @@ static int __init rmi_bus_init(void)
>   		return error;
>   	}
>
> -	rmi_bus_setup_debugfs();
> -
>   	error = rmi_register_f01_handler();
>   	if (error) {
>   		pr_err("%s: error registering the RMI F01 handler: %d\n",
> @@ -385,7 +284,6 @@ static int __init rmi_bus_init(void)
>   err_unregister_f01:
>   	rmi_unregister_f01_handler();
>   err_unregister_bus:
> -	rmi_bus_teardown_debugfs();
>   	bus_unregister(&rmi_bus_type);
>   	return error;
>   }
> @@ -400,7 +298,6 @@ static void __exit rmi_bus_exit(void)
>
>   	rmi_unregister_physical_driver();
>   	rmi_unregister_f01_handler();
> -	rmi_bus_teardown_debugfs();
>   	bus_unregister(&rmi_bus_type);
>   }
>   module_exit(rmi_bus_exit);
> diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
> index 2bad2ed..62fd544 100644
> --- a/drivers/input/rmi4/rmi_bus.h
> +++ b/drivers/input/rmi4/rmi_bus.h
> @@ -19,7 +19,6 @@
>   #include <linux/stat.h>
>   #include <linux/types.h>
>   #include <linux/wait.h>
> -#include <linux/debugfs.h>
>   #include <linux/rmi.h>
>
>   struct rmi_device;
> @@ -39,7 +38,6 @@ struct rmi_device;
>    * @data: Private data pointer
>    *
>    * @node: entry in device's list of functions
> - * @debugfs_root: used during debugging
>    */
>   struct rmi_function {
>   	struct rmi_function_descriptor fd;
> @@ -50,10 +48,6 @@ struct rmi_function {
>   	unsigned long *irq_mask;
>   	void *data;
>   	struct list_head node;
> -
> -#ifdef CONFIG_RMI4_DEBUG
> -	struct dentry *debugfs_root;
> -#endif
>   };
>
>   #define to_rmi_function(d)	container_of(d, struct rmi_function, dev)
> @@ -208,8 +202,6 @@ struct rmi_transport_ops {
>    * @number: Unique number for the device on the bus.
>    * @driver: Pointer to associated driver
>    * @xport: Pointer to the transport interface
> - * @debugfs_root: base for this particular sensor device.
> - *
>    */
>   struct rmi_device {
>   	struct device dev;
> @@ -217,10 +209,6 @@ struct rmi_device {
>
>   	struct rmi_driver *driver;
>   	struct rmi_transport_dev *xport;
> -
> -#ifdef CONFIG_RMI4_DEBUG
> -	struct dentry *debugfs_root;
> -#endif
>   };
>
>   #define to_rmi_device(d) container_of(d, struct rmi_device, dev)
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 691b6fb..e44eff7 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -16,7 +16,6 @@
>
>   #include <linux/kernel.h>
>   #include <linux/bitmap.h>
> -#include <linux/debugfs.h>
>   #include <linux/delay.h>
>   #include <linux/device.h>
>   #include <linux/fs.h>
> @@ -42,8 +41,6 @@
>
>   #define DEFAULT_POLL_INTERVAL_MS	13
>
> -#define IRQ_DEBUG(data) (IS_ENABLED(CONFIG_RMI4_DEBUG) && data->irq_debug)
> -
>   static irqreturn_t rmi_irq_thread(int irq, void *p)
>   {
>   	struct rmi_transport_dev *xport = p;
> diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
> index f28166f..eafbdb3 100644
> --- a/drivers/input/rmi4/rmi_driver.h
> +++ b/drivers/input/rmi4/rmi_driver.h
> @@ -38,7 +38,6 @@ struct rmi_driver_data {
>   	bool f01_bootloader_mode;
>
>   	u32 attn_count;
> -	u32 irq_debug;	/* Should be bool, but debugfs wants u32 */
>   	int irq;
>   	int num_of_irq_regs;
>   	int irq_count;
> @@ -54,17 +53,6 @@ struct rmi_driver_data {
>
>   	bool enabled;
>
> -#ifdef CONFIG_RMI4_DEBUG
> -	struct dentry *debugfs_delay;
> -	struct dentry *debugfs_xport;
> -	struct dentry *debugfs_reg_ctl;
> -	struct dentry *debugfs_reg;
> -	struct dentry *debugfs_irq;
> -	struct dentry *debugfs_attn_count;
> -	u16 reg_debug_addr;
> -	u8 reg_debug_size;
> -#endif
> -
>   	void *data;
>   };
>
> diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> index 553afd8..87d85ab 100644
> --- a/drivers/input/rmi4/rmi_f11.c
> +++ b/drivers/input/rmi4/rmi_f11.c
> @@ -515,7 +515,7 @@ struct f11_2d_sensor {
>   	u8 *data_pkt;
>   	int pkt_size;
>   	u8 sensor_index;
> -	u32 type_a;	/* boolean but debugfs API requires u32 */
> +	bool type_a;
>   	enum rmi_f11_sensor_type sensor_type;
>   	struct input_dev *input;
>   	struct input_dev *mouse_input;
> diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> index 41c2c04..f3775eb 100644
> --- a/include/linux/rmi.h
> +++ b/include/linux/rmi.h
> @@ -21,7 +21,6 @@
>   #include <linux/stat.h>
>   #include <linux/types.h>
>   #include <linux/wait.h>
> -#include <linux/debugfs.h>
>
>   /**
>    * struct rmi_f11_axis_alignment - target axis alignment
> @@ -42,9 +41,9 @@
>    *               automatically enabled for this sensor.
>    */
>   struct rmi_f11_2d_axis_alignment {
> -	u32 swap_axes;	/* boolean, but u32 is needed by debugfs API */
> -	u32 flip_x;	/* boolean */
> -	u32 flip_y;	/* boolean */
> +	bool swap_axes;
> +	bool flip_x;
> +	bool flip_y;
>   	u16 clip_x_low;
>   	u16 clip_y_low;
>   	u16 clip_x_high;
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data
  2014-01-24  0:00               ` [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data Courtney Cavin
  2014-01-24  0:00                 ` [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables Courtney Cavin
@ 2014-02-04 23:10                 ` Christopher Heiny
  2014-02-05  2:34                   ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:10 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> Update platform data documentation and remove unneeded/unused stuff in
> platform data.
>
> If these items are needed at some later point, they should be added
> then.  Until that point, we should unclutter the code.

Taking them out to "unclutter the code" and then putting them back 
(which will be required almost immediately) is just busy work.  It would 
probably be better to concentrate on constructive changes.

>
> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
>   drivers/input/rmi4/rmi_f11.c |  14 ++--
>   include/linux/rmi.h          | 157 ++++++++++---------------------------------
>   2 files changed, 40 insertions(+), 131 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> index 87d85ab..9d94b1a 100644
> --- a/drivers/input/rmi4/rmi_f11.c
> +++ b/drivers/input/rmi4/rmi_f11.c
> @@ -1109,7 +1109,7 @@ static void f11_set_abs_params(struct rmi_function *fn)
>   	/* We assume touchscreen unless demonstrably a touchpad or specified
>   	 * as a touchpad in the platform data
>   	 */
> -	if (sensor->sensor_type == rmi_f11_sensor_touchpad ||
> +	if (sensor->sensor_type == RMI_F11_SENSOR_INDIRECT ||
>   			(sensor->sens_query.has_info2 &&
>   				!sensor->sens_query.is_clear))
>   		input_flags = INPUT_PROP_POINTER;
> @@ -1192,7 +1192,7 @@ static int rmi_f11_initialize(struct rmi_function *fn)
>   		return -ENOMEM;
>
>   	fn->data = f11;
> -	f11->rezero_wait_ms = pdata->f11_rezero_wait;
> +	f11->rezero_wait_ms = pdata->f11_sensor_data.rezero_wait;
>
>   	query_base_addr = fn->fd.query_base_addr;
>   	control_base_addr = fn->fd.control_base_addr;
> @@ -1225,13 +1225,9 @@ static int rmi_f11_initialize(struct rmi_function *fn)
>   		return rc;
>   	}
>
> -	if (pdata->f11_sensor_data) {
> -		sensor->axis_align =
> -			pdata->f11_sensor_data->axis_align;
> -		sensor->type_a = pdata->f11_sensor_data->type_a;
> -		sensor->sensor_type =
> -				pdata->f11_sensor_data->sensor_type;
> -	}
> +	sensor->axis_align = pdata->f11_sensor_data.axis_align;
> +	sensor->type_a = pdata->f11_sensor_data.type_a;
> +	sensor->sensor_type = pdata->f11_sensor_data.sensor_type;
>
>   	rc = rmi_read_block(rmi_dev,
>   		control_base_addr + F11_CTRL_SENSOR_MAX_X_POS_OFFSET,
> diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> index f3775eb..60ddd98 100644
> --- a/include/linux/rmi.h
> +++ b/include/linux/rmi.h
> @@ -37,8 +37,8 @@
>    *               the specified value
>    * @offset_x - this value will be added to all reported X coordinates
>    * @offset_y - this value will be added to all reported Y coordinates
> - * @rel_report_enabled - if set to true, the relative reporting will be
> - *               automatically enabled for this sensor.
> + * @delta_x_threshold - delta X movement required before reporting event
> + * @delta_y_threshold - delta Y movement required before reporting event
>    */
>   struct rmi_f11_2d_axis_alignment {
>   	bool swap_axes;
> @@ -57,34 +57,36 @@ struct rmi_f11_2d_axis_alignment {
>   /** This is used to override any hints an F11 2D sensor might have provided
>    * as to what type of sensor it is.
>    *
> - * @rmi_f11_sensor_default - do not override, determine from F11_2D_QUERY14 if
> - * available.
> - * @rmi_f11_sensor_touchscreen - treat the sensor as a touchscreen (direct
> - * pointing).
> - * @rmi_f11_sensor_touchpad - thread the sensor as a touchpad (indirect
> - * pointing).
> + * @RMI_F11_SENSOR_DEFAULT - determine from F11_2D_QUERY14 if available.
> + * @RMI_F11_SENSOR_DIRECT - direct pointing sensor (e.g. touchscreen)
> + * @RMI_F11_SENSOR_INDIRECT - indirect pointing sensor (e.g touchpad)
>    */
>   enum rmi_f11_sensor_type {
> -	rmi_f11_sensor_default = 0,
> -	rmi_f11_sensor_touchscreen,
> -	rmi_f11_sensor_touchpad
> +	RMI_F11_SENSOR_DEFAULT = 0,
> +	RMI_F11_SENSOR_DIRECT,
> +	RMI_F11_SENSOR_INDIRECT
>   };
>
>   /**
>    * struct rmi_f11_sensor_data - overrides defaults for a single F11 2D sensor.
> + *
>    * @axis_align - provides axis alignment overrides (see above).
>    * @type_a - all modern RMI F11 firmwares implement Multifinger Type B
> - * protocol.  Set this to true to force MF Type A behavior, in case you find
> - * an older sensor.
> + *           protocol.  Set this to true to force MF Type A behavior, in case
> + *           you find an older sensor.
>    * @sensor_type - Forces the driver to treat the sensor as an indirect
> - * pointing device (touchpad) rather than a direct pointing device
> - * (touchscreen).  This is useful when F11_2D_QUERY14 register is not
> - * available.
> + *                pointing device (touchpad) rather than a direct pointing
> + *                device (touchscreen).  This is useful when F11_2D_QUERY14
> + *                register is not available.
> + * @rezero_wait - if non-zero, this is how may milliseconds the sensor will
> + *                wait before being be re-zeroed on exit from suspend.  If this
> + *                value is zero, the sensor will not be re-zeroed on resume.
>    */
>   struct rmi_f11_sensor_data {
>   	struct rmi_f11_2d_axis_alignment axis_align;
>   	bool type_a;
>   	enum rmi_f11_sensor_type sensor_type;
> +	u16 rezero_wait;
>   };
>
>   /**
> @@ -98,20 +100,22 @@ enum rmi_f01_nosleep {
>   };
>
>   /**
> - * struct rmi_f01_power_management -When non-zero, these values will be written
> - * to the touch sensor to override the default firmware settigns.  For a
> - * detailed explanation of what each field does, see the corresponding
> - * documention in the RMI4 specification.
> + * struct rmi_f01_power_management - touch sensor power settings
> + *
> + * When non-zero, these values will be written to the touch sensor to override
> + * the default firmware settings.  For a detailed explanation of what each
> + * field does, see the corresponding documentation in the RMI4 specification.
>    *
>    * @nosleep - specifies whether the device is permitted to sleep or doze (that
> - * is, enter a temporary low power state) when no fingers are touching the
> - * sensor.
> + *            is, enter a temporary low power state) when no fingers are
> + *            touching the sensor.
>    * @wakeup_threshold - controls the capacitance threshold at which the touch
> - * sensor will decide to wake up from that low power state.
> + *                     sensor will decide to wake up from that low power state.
>    * @doze_holdoff - controls how long the touch sensor waits after the last
> - * finger lifts before entering the doze state, in units of 100ms.
> + *                 finger lifts before entering the doze state, in units of
> + *                 100ms.
>    * @doze_interval - controls the interval between checks for finger presence
> - * when the touch sensor is in doze mode, in units of 10ms.
> + *                  when the touch sensor is in doze mode, in units of 10ms.
>    */
>   struct rmi_f01_power_management {
>   	enum rmi_f01_nosleep nosleep;
> @@ -121,114 +125,23 @@ struct rmi_f01_power_management {
>   };
>
>   /**
> - * struct rmi_button_map - used to specify the initial input subsystem key
> - * event codes to be generated by buttons (or button like entities) on the
> - * touch sensor.
> - * @nbuttons - length of the button map.
> - * @map - the key event codes for the corresponding buttons on the touch
> - * sensor.
> - */
> -struct rmi_button_map {
> -	u8 nbuttons;
> -	u8 *map;
> -};
> -
> -struct rmi_f30_gpioled_map {
> -	u8 ngpioleds;
> -	u8 *map;
> -};
> -
> -/**
> - * struct rmi_device_platform_data_spi - provides parameters used in SPI
> - * communications.  All Synaptics SPI products support a standard SPI
> - * interface; some also support what is called SPI V2 mode, depending on
> - * firmware and/or ASIC limitations.  In V2 mode, the touch sensor can
> - * support shorter delays during certain operations, and these are specified
> - * separately from the standard mode delays.
> - *
> - * @block_delay - for standard SPI transactions consisting of both a read and
> - * write operation, the delay (in microseconds) between the read and write
> - * operations.
> - * @split_read_block_delay_us - for V2 SPI transactions consisting of both a
> - * read and write operation, the delay (in microseconds) between the read and
> - * write operations.
> - * @read_delay_us - the delay between each byte of a read operation in normal
> - * SPI mode.
> - * @write_delay_us - the delay between each byte of a write operation in normal
> - * SPI mode.
> - * @split_read_byte_delay_us - the delay between each byte of a read operation
> - * in V2 mode.
> - * @pre_delay_us - the delay before the start of a SPI transaction.  This is
> - * typically useful in conjunction with custom chip select assertions (see
> - * below).
> - * @post_delay_us - the delay after the completion of an SPI transaction.  This
> - * is typically useful in conjunction with custom chip select assertions (see
> - * below).
> - * @cs_assert - For systems where the SPI subsystem does not control the CS/SSB
> - * line, or where such control is broken, you can provide a custom routine to
> - * handle a GPIO as CS/SSB.  This routine will be called at the beginning and
> - * end of each SPI transaction.  The RMI SPI implementation will wait
> - * pre_delay_us after this routine returns before starting the SPI transfer;
> - * and post_delay_us after completion of the SPI transfer(s) before calling it
> - * with assert==FALSE.
> - */
> -struct rmi_device_platform_data_spi {
> -	u32 block_delay_us;
> -	u32 split_read_block_delay_us;
> -	u32 read_delay_us;
> -	u32 write_delay_us;
> -	u32 split_read_byte_delay_us;
> -	u32 pre_delay_us;
> -	u32 post_delay_us;
> -
> -	void *cs_assert_data;
> -	int (*cs_assert) (const void *cs_assert_data, const bool assert);
> -};
> -
> -/**
>    * struct rmi_device_platform_data - system specific configuration info.
>    *
>    * @irq - attention IRQ
> - * @firmware_name - if specified will override default firmware name,
> - * for reflashing.
> - *
>    * @reset_delay_ms - after issuing a reset command to the touch sensor, the
> - * driver waits a few milliseconds to give the firmware a chance to
> - * to re-initialize.  You can override the default wait period here.
> - *
> - * @spi_data - override default settings for SPI delays and SSB management (see
> - * above).
> - *
> + *                   driver waits a few milliseconds to give the firmware a
> + *                   chance to to re-initialize.  You can override the default
> + *                   wait period here.
>    * @f11_sensor_data - platform data for the F11 2D sensor.
> - * @f11_rezero_wait - if non-zero, this is how may milliseconds the F11 2D
> - * sensor will wait before being be rezeroed on exit from suspend.  If
> - * this value is zero, the F11 2D sensor will not be rezeroed on resume.
> - * @power_management - overrides default touch sensor doze mode settings (see
> - * above)
> - * @f19_button_map - provide initial input subsystem key mappings for F19.
> - * @f1a_button_map - provide initial input subsystem key mappings for F1A.
> - * @gpioled_map - provides initial settings for GPIOs and LEDs controlled by
> - * F30.
> - * @f41_button_map - provide initial input subsystem key mappings for F41.
> + * @power_management - touch sensor power settings (see above)
>    */
>   struct rmi_device_platform_data {
>   	int irq;
> -	int reset_delay_ms;
> -
> -	struct rmi_device_platform_data_spi spi_data;
> +	u32 reset_delay_ms;
>
>   	/* function handler pdata */
> -	struct rmi_f11_sensor_data *f11_sensor_data;
> -	u16 f11_rezero_wait;
> +	struct rmi_f11_sensor_data f11_sensor_data;
>   	struct rmi_f01_power_management power_management;
> -	struct rmi_button_map *f19_button_map;
> -	struct rmi_button_map *f1a_button_map;
> -	struct rmi_f30_gpioled_map *gpioled_map;
> -	struct rmi_button_map *f41_button_map;
> -
> -#ifdef CONFIG_RMI4_FWLIB
> -	char *firmware_name;
> -#endif
>   };
>
>   /**
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables
  2014-01-24  0:00                 ` [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables Courtney Cavin
  2014-01-24  0:00                   ` [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support Courtney Cavin
@ 2014-02-04 23:10                   ` Christopher Heiny
  2014-02-05  2:35                     ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:10 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> This is neither a library nor documentation, so it doesn't need to
> contain all of the information available.  Remove most of the unused
> struct members and defines.  If they are need to implement some
> functionality at a later point, they can be added back at that point.

Taking things out only to re-add them later is not productive.  Let's 
concentrate on substantive changes to the code, please.



> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
>   drivers/input/rmi4/rmi_bus.h    |   1 -
>   drivers/input/rmi4/rmi_driver.c |   3 -
>   drivers/input/rmi4/rmi_f01.c    |  40 -----
>   drivers/input/rmi4/rmi_f11.c    | 375 ----------------------------------------
>   4 files changed, 419 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
> index 62fd544..a21e4c4 100644
> --- a/drivers/input/rmi4/rmi_bus.h
> +++ b/drivers/input/rmi4/rmi_bus.h
> @@ -278,7 +278,6 @@ static inline int rmi_write_block(struct rmi_device *d, u16 addr,
>
>   int rmi_register_transport_device(struct rmi_transport_dev *xport);
>   void rmi_unregister_transport_device(struct rmi_transport_dev *xport);
> -int rmi_for_each_dev(void *data, int (*func)(struct device *dev, void *data));
>
>   /**
>    * module_rmi_driver() - Helper macro for registering a function driver
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index e44eff7..9ec7b93 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -32,15 +32,12 @@
>
>   #define RMI4_MAX_N_IRQS 256
>
> -#define HAS_NONSTANDARD_PDT_MASK 0x40
>   #define RMI4_MAX_PAGE 0xff
>   #define RMI4_PAGE_SIZE 0x100
>
>   #define RMI_DEVICE_RESET_CMD	0x01
>   #define DEFAULT_RESET_DELAY_MS	100
>
> -#define DEFAULT_POLL_INTERVAL_MS	13
> -
>   static irqreturn_t rmi_irq_thread(int irq, void *p)
>   {
>   	struct rmi_transport_dev *xport = p;
> diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
> index 98bc65a9..4cb9fcb 100644
> --- a/drivers/input/rmi4/rmi_f01.c
> +++ b/drivers/input/rmi4/rmi_f01.c
> @@ -15,27 +15,11 @@
>   #include "rmi_driver.h"
>
>   #define RMI_PRODUCT_ID_LENGTH    10
> -#define RMI_PRODUCT_INFO_LENGTH   2
> -
> -#define RMI_DATE_CODE_LENGTH      3
> -
> -#define PRODUCT_ID_OFFSET 0x10
> -#define PRODUCT_INFO_OFFSET 0x1E
> -
> -
> -/* Force a firmware reset of the sensor */
> -#define RMI_F01_CMD_DEVICE_RESET	1
>
>   /* Various F01_RMI_QueryX bits */
> -
> -#define RMI_F01_QRY1_CUSTOM_MAP		(1 << 0)
> -#define RMI_F01_QRY1_NON_COMPLIANT	(1 << 1)
>   #define RMI_F01_QRY1_HAS_LTS		(1 << 2)
> -#define RMI_F01_QRY1_HAS_SENSOR_ID	(1 << 3)
> -#define RMI_F01_QRY1_HAS_CHARGER_INP	(1 << 4)
>   #define RMI_F01_QRY1_HAS_ADJ_DOZE	(1 << 5)
>   #define RMI_F01_QRY1_HAS_ADJ_DOZE_HOFF	(1 << 6)
> -#define RMI_F01_QRY1_HAS_PROPS_2	(1 << 7)
>
>   #define RMI_F01_QRY5_YEAR_MASK		0x1f
>   #define RMI_F01_QRY6_MONTH_MASK		0x0f
> @@ -52,7 +36,6 @@ struct f01_basic_properties {
>   	bool has_adjustable_doze_holdoff;
>   	char dom[11]; /* YYYY/MM/DD + '\0' */
>   	u8 product_id[RMI_PRODUCT_ID_LENGTH + 1];
> -	u16 productinfo;
>   };
>
>   /* F01 device status bits */
> @@ -87,19 +70,6 @@ struct f01_basic_properties {
>   #define RMI_F01_CRTL0_NOSLEEP_BIT	(1 << 2)
>
>   /*
> - * When this bit is set, the touch controller employs a noise-filtering
> - * algorithm designed for use with a connected battery charger.
> - */
> -#define RMI_F01_CRTL0_CHARGER_BIT	(1 << 5)
> -
> -/*
> - * Sets the report rate for the device. The effect of this setting is
> - * highly product dependent. Check the spec sheet for your particular
> - * touch sensor.
> - */
> -#define RMI_F01_CRTL0_REPORTRATE_BIT	(1 << 6)
> -
> -/*
>    * Written by the host as an indicator that the device has been
>    * successfully configured.
>    */
> @@ -127,7 +97,6 @@ struct f01_data {
>   	struct f01_basic_properties properties;
>
>   	struct f01_device_control device_control;
> -	struct mutex control_mutex;
>
>   	u8 device_status;
>
> @@ -135,11 +104,9 @@ struct f01_data {
>   	u16 doze_interval_addr;
>   	u16 wakeup_threshold_addr;
>   	u16 doze_holdoff_addr;
> -	int irq_count;
>   	int num_of_irq_regs;
>
>   #ifdef CONFIG_PM_SLEEP
> -	bool suspended;
>   	bool old_nosleep;
>   #endif
>   };
> @@ -199,10 +166,6 @@ static int rmi_f01_read_properties(struct rmi_device *rmi_dev,
>   		RMI_PRODUCT_ID_LENGTH);
>   	props->product_id[RMI_PRODUCT_ID_LENGTH] = '\0';
>
> -	props->productinfo =
> -			((basic_query[2] & RMI_F01_QRY2_PRODINFO_MASK) << 7) |
> -			(basic_query[3] & RMI_F01_QRY2_PRODINFO_MASK);
> -
>   	return 0;
>   }
>
> @@ -216,8 +179,6 @@ static int rmi_f01_initialize(struct rmi_function *fn)
>   	struct f01_data *data = fn->data;
>   	struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
>
> -	mutex_init(&data->control_mutex);
> -
>   	/*
>   	 * Set the configured bit and (optionally) other important stuff
>   	 * in the device control register.
> @@ -263,7 +224,6 @@ static int rmi_f01_initialize(struct rmi_function *fn)
>   		return error;
>   	}
>
> -	data->irq_count = driver_data->irq_count;
>   	data->num_of_irq_regs = driver_data->num_of_irq_regs;
>   	ctrl_base_addr += sizeof(u8);
>
> diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> index 9d94b1a..b114f25 100644
> --- a/drivers/input/rmi4/rmi_f11.c
> +++ b/drivers/input/rmi4/rmi_f11.c
> @@ -7,8 +7,6 @@
>    * the Free Software Foundation.
>    */
>
> -#define FUNCTION_DATA f11_data
> -
>   #include <linux/kernel.h>
>   #include <linux/delay.h>
>   #include <linux/device.h>
> @@ -19,9 +17,6 @@
>   #include <linux/slab.h>
>   #include "rmi_driver.h"
>
> -#define F11_MAX_NUM_OF_FINGERS		10
> -#define F11_MAX_NUM_OF_TOUCH_SHAPES	16
> -
>   #define F11_REL_POS_MIN		-128
>   #define F11_REL_POS_MAX		127
>
> @@ -30,14 +25,12 @@
>   #define F11_CTRL_SENSOR_MAX_X_POS_OFFSET	6
>   #define F11_CTRL_SENSOR_MAX_Y_POS_OFFSET	8
>
> -#define DEFAULT_XY_MAX 9999
>   #define DEFAULT_MAX_ABS_MT_PRESSURE 255
>   #define DEFAULT_MAX_ABS_MT_TOUCH 15
>   #define DEFAULT_MAX_ABS_MT_ORIENTATION 1
>   #define DEFAULT_MIN_ABS_MT_TRACKING_ID 1
>   #define DEFAULT_MAX_ABS_MT_TRACKING_ID 10
>   #define NAME_BUFFER_SIZE 256
> -#define FUNCTION_NUMBER 0x11
>
>   /** A note about RMI4 F11 register structure.
>    *
> @@ -81,108 +74,37 @@
>   #define RMI_F11_HAS_QUERY28             (1 << 7)
>
>   /** Defs for Query 1 */
> -
>   #define RMI_F11_NR_FINGERS_MASK 0x07
>   #define RMI_F11_HAS_REL                 (1 << 3)
>   #define RMI_F11_HAS_ABS                 (1 << 4)
>   #define RMI_F11_HAS_GESTURES            (1 << 5)
> -#define RMI_F11_HAS_SENSITIVITY_ADJ     (1 << 6)
> -#define RMI_F11_CONFIGURABLE            (1 << 7)
> -
> -/** Defs for Query 2, 3, and 4. */
> -#define RMI_F11_NR_ELECTRODES_MASK      0x7F
>
>   /** Defs for Query 5 */
> -
> -#define RMI_F11_ABS_DATA_SIZE_MASK      0x03
> -#define RMI_F11_HAS_ANCHORED_FINGER     (1 << 2)
> -#define RMI_F11_HAS_ADJ_HYST            (1 << 3)
> -#define RMI_F11_HAS_DRIBBLE             (1 << 4)
> -#define RMI_F11_HAS_BENDING_CORRECTION  (1 << 5)
> -#define RMI_F11_HAS_LARGE_OBJECT_SUPPRESSION    (1 << 6)
>   #define RMI_F11_HAS_JITTER_FILTER       (1 << 7)
>
>   /** Defs for Query 7 */
> -#define RMI_F11_HAS_SINGLE_TAP                  (1 << 0)
> -#define RMI_F11_HAS_TAP_AND_HOLD                (1 << 1)
> -#define RMI_F11_HAS_DOUBLE_TAP                  (1 << 2)
> -#define RMI_F11_HAS_EARLY_TAP                   (1 << 3)
>   #define RMI_F11_HAS_FLICK                       (1 << 4)
> -#define RMI_F11_HAS_PRESS                       (1 << 5)
>   #define RMI_F11_HAS_PINCH                       (1 << 6)
> -#define RMI_F11_HAS_CHIRAL                      (1 << 7)
>
>   /** Defs for Query 8 */
> -#define RMI_F11_HAS_PALM_DET                    (1 << 0)
>   #define RMI_F11_HAS_ROTATE                      (1 << 1)
>   #define RMI_F11_HAS_TOUCH_SHAPES                (1 << 2)
> -#define RMI_F11_HAS_SCROLL_ZONES                (1 << 3)
> -#define RMI_F11_HAS_INDIVIDUAL_SCROLL_ZONES     (1 << 4)
> -#define RMI_F11_HAS_MF_SCROLL                   (1 << 5)
> -#define RMI_F11_HAS_MF_EDGE_MOTION              (1 << 6)
> -#define RMI_F11_HAS_MF_SCROLL_INERTIA           (1 << 7)
>
>   /** Defs for Query 9. */
>   #define RMI_F11_HAS_PEN                         (1 << 0)
> -#define RMI_F11_HAS_PROXIMITY                   (1 << 1)
> -#define RMI_F11_HAS_PALM_DET_SENSITIVITY        (1 << 2)
> -#define RMI_F11_HAS_SUPPRESS_ON_PALM_DETECT     (1 << 3)
> -#define RMI_F11_HAS_TWO_PEN_THRESHOLDS          (1 << 4)
> -#define RMI_F11_HAS_CONTACT_GEOMETRY            (1 << 5)
> -#define RMI_F11_HAS_PEN_HOVER_DISCRIMINATION    (1 << 6)
> -#define RMI_F11_HAS_PEN_FILTERS                 (1 << 7)
>
>   /** Defs for Query 10. */
>   #define RMI_F11_NR_TOUCH_SHAPES_MASK            0x1F
>
> -/** Defs for Query 11 */
> -
> -#define RMI_F11_HAS_Z_TUNING                    (1 << 0)
> -#define RMI_F11_HAS_ALGORITHM_SELECTION         (1 << 1)
> -#define RMI_F11_HAS_W_TUNING                    (1 << 2)
> -#define RMI_F11_HAS_PITCH_INFO                  (1 << 3)
> -#define RMI_F11_HAS_FINGER_SIZE                 (1 << 4)
> -#define RMI_F11_HAS_SEGMENTATION_AGGRESSIVENESS (1 << 5)
> -#define RMI_F11_HAS_XY_CLIP                     (1 << 6)
> -#define RMI_F11_HAS_DRUMMING_FILTER             (1 << 7)
> -
>   /** Defs for Query 12. */
> -
> -#define RMI_F11_HAS_GAPLESS_FINGER              (1 << 0)
> -#define RMI_F11_HAS_GAPLESS_FINGER_TUNING       (1 << 1)
> -#define RMI_F11_HAS_8BIT_W                      (1 << 2)
> -#define RMI_F11_HAS_ADJUSTABLE_MAPPING          (1 << 3)
>   #define RMI_F11_HAS_INFO2                       (1 << 4)
> -#define RMI_F11_HAS_PHYSICAL_PROPS              (1 << 5)
> -#define RMI_F11_HAS_FINGER_LIMIT                (1 << 6)
> -#define RMI_F11_HAS_LINEAR_COEFF                (1 << 7)
> -
> -/** Defs for Query 13. */
> -
> -#define RMI_F11_JITTER_WINDOW_MASK              0x1F
> -#define RMI_F11_JITTER_FILTER_MASK              0x60
> -#define RMI_F11_JITTER_FILTER_SHIFT             5
>
>   /** Defs for Query 14. */
> -#define RMI_F11_LIGHT_CONTROL_MASK              0x03
>   #define RMI_F11_IS_CLEAR                        (1 << 2)
> -#define RMI_F11_CLICKPAD_PROPS_MASK             0x18
> -#define RMI_F11_CLICKPAD_PROPS_SHIFT            3
> -#define RMI_F11_MOUSE_BUTTONS_MASK              0x60
> -#define RMI_F11_MOUSE_BUTTONS_SHIFT             5
> -#define RMI_F11_HAS_ADVANCED_GESTURES           (1 << 7)
>
>   #define RMI_F11_QUERY_SIZE                      4
>   #define RMI_F11_QUERY_GESTURE_SIZE              2
>
> -#define F11_LIGHT_CTL_NONE 0x00
> -#define F11_LUXPAD	   0x01
> -#define F11_DUAL_MODE      0x02
> -
> -#define F11_NOT_CLICKPAD     0x00
> -#define F11_HINGED_CLICKPAD  0x01
> -#define F11_UNIFORM_CLICKPAD 0x02
> -
>   /**
>    * Query registers 1 through 4 are always present.
>    *
> @@ -191,55 +113,18 @@
>    * @has_rel - the sensor supports relative motion reporting.
>    * @has_abs - the sensor supports absolute poition reporting.
>    * @has_gestures - the sensor supports gesture reporting.
> - * @has_sensitivity_adjust - the sensor supports a global sensitivity
> - * adjustment.
> - * @configurable - the sensor supports various configuration options.
> - * @num_of_x_electrodes -  the maximum number of electrodes the 2-D sensor
> - * supports on the X axis.
> - * @num_of_y_electrodes -  the maximum number of electrodes the 2-D sensor
> - * supports on the Y axis.
> - * @max_electrodes - the total number of X and Y electrodes that may be
> - * configured.
>    *
>    * Query 5 is present if the has_abs bit is set.
>    *
> - * @abs_data_size - describes the format of data reported by the absolute
> - * data source.  Only one format (the kind used here) is supported at this
> - * time.
> - * @has_anchored_finger - then the sensor supports the high-precision second
> - * finger tracking provided by the manual tracking and motion sensitivity
> - * options.
> - * @has_adjust_hyst - the difference between the finger release threshold and
> - * the touch threshold.
> - * @has_dribble - the sensor supports the generation of dribble interrupts,
> - * which may be enabled or disabled with the dribble control bit.
> - * @has_bending_correction - Bending related data registers 28 and 36, and
> - * control register 52..57 are present.
> - * @has_large_object_suppression - control register 58 and data register 28
> - * exist.
>    * @has_jitter_filter - query 13 and control 73..76 exist.
>    *
>    * Gesture information queries 7 and 8 are present if has_gestures bit is set.
>    *
> - * @has_single_tap - a basic single-tap gesture is supported.
> - * @has_tap_n_hold - tap-and-hold gesture is supported.
> - * @has_double_tap - double-tap gesture is supported.
> - * @has_early_tap - early tap is supported and reported as soon as the finger
> - * lifts for any tap event that could be interpreted as either a single tap
> - * or as the first tap of a double-tap or tap-and-hold gesture.
>    * @has_flick - flick detection is supported.
> - * @has_press - press gesture reporting is supported.
>    * @has_pinch - pinch gesture detection is supported.
> - * @has_palm_det - the 2-D sensor notifies the host whenever a large conductive
> - * object such as a palm or a cheek touches the 2-D sensor.
>    * @has_rotate - rotation gesture detection is supported.
>    * @has_touch_shapes - TouchShapes are supported.  A TouchShape is a fixed
>    * rectangular area on the sensor that behaves like a capacitive button.
> - * @has_scroll_zones - scrolling areas near the sensor edges are supported.
> - * @has_individual_scroll_zones - if 1, then 4 scroll zones are supported;
> - * if 0, then only two are supported.
> - * @has_mf_scroll - the multifinger_scrolling bit will be set when
> - * more than one finger is involved in a scrolling action.
>    *
>    * Convenience for checking bytes in the gesture info registers.  This is done
>    * often enough that we put it here to declutter the conditionals
> @@ -251,68 +136,21 @@
>    *
>    * @has_pen - detection of a stylus is supported and registers F11_2D_Ctrl20
>    * and F11_2D_Ctrl21 exist.
> - * @has_proximity - detection of fingers near the sensor is supported and
> - * registers F11_2D_Ctrl22 through F11_2D_Ctrl26 exist.
> - * @has_palm_det_sensitivity -  the sensor supports the palm detect sensitivity
> - * feature and register F11_2D_Ctrl27 exists.
> - * @has_two_pen_thresholds - is has_pen is also set, then F11_2D_Ctrl35 exists.
> - * @has_contact_geometry - the sensor supports the use of contact geometry to
> - * map absolute X and Y target positions and registers F11_2D_Data18
> - * through F11_2D_Data27 exist.
>    *
>    * Touch shape info (query 10) is present if has_touch_shapes is set.
>    *
>    * @nr_touch_shapes - the total number of touch shapes supported.
>    *
>    * Query 11 is present if the has_query11 bit is set in query 0.
> - *
> - * @has_z_tuning - if set, the sensor supports Z tuning and registers
> - * F11_2D_Ctrl29 through F11_2D_Ctrl33 exist.
> - * @has_algorithm_selection - controls choice of noise suppression algorithm
> - * @has_w_tuning - the sensor supports Wx and Wy scaling and registers
> - * F11_2D_Ctrl36 through F11_2D_Ctrl39 exist.
> - * @has_pitch_info - the X and Y pitches of the sensor electrodes can be
> - * configured and registers F11_2D_Ctrl40 and F11_2D_Ctrl41 exist.
> - * @has_finger_size -  the default finger width settings for the
> - * sensor can be configured and registers F11_2D_Ctrl42 through F11_2D_Ctrl44
> - * exist.
> - * @has_segmentation_aggressiveness - the sensor’s ability to distinguish
> - * multiple objects close together can be configured and register F11_2D_Ctrl45
> - * exists.
> - * @has_XY_clip -  the inactive outside borders of the sensor can be
> - * configured and registers F11_2D_Ctrl46 through F11_2D_Ctrl49 exist.
> - * @has_drumming_filter - the sensor can be configured to distinguish
> - * between a fast flick and a quick drumming movement and registers
> - * F11_2D_Ctrl50 and F11_2D_Ctrl51 exist.
> - *
>    * Query 12 is present if hasQuery12 bit is set.
>    *
> - * @has_gapless_finger - control registers relating to gapless finger are
> - * present.
> - * @has_gapless_finger_tuning - additional control and data registers relating
> - * to gapless finger are present.
> - * @has_8bit_w - larger W value reporting is supported.
> - * @has_adjustable_mapping - TBD
>    * @has_info2 - the general info query14 is present
> - * @has_physical_props - additional queries describing the physical properties
> - * of the sensor are present.
> - * @has_finger_limit - indicates that F11 Ctrl 80 exists.
> - * @has_linear_coeff - indicates that F11 Ctrl 81 exists.
>    *
>    * Query 13 is present if Query 5's has_jitter_filter bit is set.
> - * @jitter_window_size - used by Design Studio 4.
> - * @jitter_filter_type - used by Design Studio 4.
> - *
>    * Query 14 is present if query 12's has_general_info2 flag is set.
>    *
> - * @light_control - Indicates what light/led control features are present, if
> - * any.
>    * @is_clear - if set, this is a clear sensor (indicating direct pointing
>    * application), otherwise it's opaque (indicating indirect pointing).
> - * @clickpad_props - specifies if this is a clickpad, and if so what sort of
> - * mechanism it uses
> - * @mouse_buttons - specifies the number of mouse buttons present (if any).
> - * @has_advanced_gestures - advanced driver gestures are supported.
>    */
>   struct f11_2d_sensor_queries {
>   	/* query1 */
> @@ -320,112 +158,34 @@ struct f11_2d_sensor_queries {
>   	bool has_rel;
>   	bool has_abs;
>   	bool has_gestures;
> -	bool has_sensitivity_adjust;
> -	bool configurable;
> -
> -	/* query2 */
> -	u8 nr_x_electrodes;
>
> -	/* query3 */
> -	u8 nr_y_electrodes;
> -
> -	/* query4 */
> -	u8 max_electrodes;
> -
> -	/* query5 */
> -	u8 abs_data_size;
> -	bool has_anchored_finger;
> -	bool has_adj_hyst;
> -	bool has_dribble;
> -	bool has_bending_correction;
> -	bool has_large_object_suppression;
>   	bool has_jitter_filter;
>
>   	u8 f11_2d_query6;
>
>   	/* query 7 */
> -	bool has_single_tap;
> -	bool has_tap_n_hold;
> -	bool has_double_tap;
> -	bool has_early_tap;
>   	bool has_flick;
> -	bool has_press;
>   	bool has_pinch;
> -	bool has_chiral;
> -
>   	bool query7_nonzero;
>
>   	/* query 8 */
> -	bool has_palm_det;
>   	bool has_rotate;
>   	bool has_touch_shapes;
> -	bool has_scroll_zones;
> -	bool has_individual_scroll_zones;
> -	bool has_mf_scroll;
> -	bool has_mf_edge_motion;
> -	bool has_mf_scroll_inertia;
> -
>   	bool query8_nonzero;
>
>   	/* Query 9 */
>   	bool has_pen;
> -	bool has_proximity;
> -	bool has_palm_det_sensitivity;
> -	bool has_suppress_on_palm_detect;
> -	bool has_two_pen_thresholds;
> -	bool has_contact_geometry;
> -	bool has_pen_hover_discrimination;
> -	bool has_pen_filters;
>
>   	/* Query 10 */
>   	u8 nr_touch_shapes;
>
> -	/* Query 11. */
> -	bool has_z_tuning;
> -	bool has_algorithm_selection;
> -	bool has_w_tuning;
> -	bool has_pitch_info;
> -	bool has_finger_size;
> -	bool has_segmentation_aggressiveness;
> -	bool has_XY_clip;
> -	bool has_drumming_filter;
> -
>   	/* Query 12 */
> -	bool has_gapless_finger;
> -	bool has_gapless_finger_tuning;
> -	bool has_8bit_w;
> -	bool has_adjustable_mapping;
>   	bool has_info2;
> -	bool has_physical_props;
> -	bool has_finger_limit;
> -	bool has_linear_coeff_2;
> -
> -	/* Query 13 */
> -	u8 jitter_window_size;
> -	u8 jitter_filter_type;
>
>   	/* Query 14 */
> -	u8 light_control;
>   	bool is_clear;
> -	u8 clickpad_props;
> -	u8 mouse_buttons;
> -	bool has_advanced_gestures;
>   };
>
> -/* Defs for Ctrl0. */
> -#define RMI_F11_REPORT_MODE_MASK        0x07
> -#define RMI_F11_ABS_POS_FILT            (1 << 3)
> -#define RMI_F11_REL_POS_FILT            (1 << 4)
> -#define RMI_F11_REL_BALLISTICS          (1 << 5)
> -#define RMI_F11_DRIBBLE                 (1 << 6)
> -#define RMI_F11_REPORT_BEYOND_CLIP      (1 << 7)
> -
> -/* Defs for Ctrl1. */
> -#define RMI_F11_PALM_DETECT_THRESH_MASK 0x0F
> -#define RMI_F11_MOTION_SENSITIVITY_MASK 0x30
> -#define RMI_F11_MANUAL_TRACKING         (1 << 6)
> -#define RMI_F11_MANUAL_TRACKED_FINGER   (1 << 7)
> -
>   #define RMI_F11_DELTA_X_THRESHOLD       2
>   #define RMI_F11_DELTA_Y_THRESHOLD       3
>
> @@ -439,24 +199,6 @@ struct f11_2d_ctrl {
>   #define RMI_F11_ABS_BYTES 5
>   #define RMI_F11_REL_BYTES 2
>
> -/* Defs for Data 8 */
> -
> -#define RMI_F11_SINGLE_TAP              (1 << 0)
> -#define RMI_F11_TAP_AND_HOLD            (1 << 1)
> -#define RMI_F11_DOUBLE_TAP              (1 << 2)
> -#define RMI_F11_EARLY_TAP               (1 << 3)
> -#define RMI_F11_FLICK                   (1 << 4)
> -#define RMI_F11_PRESS                   (1 << 5)
> -#define RMI_F11_PINCH                   (1 << 6)
> -
> -/* Defs for Data 9 */
> -
> -#define RMI_F11_PALM_DETECT                     (1 << 0)
> -#define RMI_F11_ROTATE                          (1 << 1)
> -#define RMI_F11_SHAPE                           (1 << 2)
> -#define RMI_F11_SCROLLZONE                      (1 << 3)
> -#define RMI_F11_GESTURE_FINGER_COUNT_MASK       0x70
> -
>   /** Handy pointers into our data buffer.
>    *
>    * @f_state - start of finger state registers.
> @@ -467,8 +209,6 @@ struct f11_2d_ctrl {
>    * @pinch   - pinch motion register (if present).
>    * @flick   - flick distance X & Y, flick time (if present).
>    * @rotate  - rotate motion and finger separation.
> - * @multi_scroll - chiral deltas for X and Y (if present).
> - * @scroll_zones - scroll deltas for 4 regions (if present).
>    */
>   struct f11_2d_data {
>   	u8	*f_state;
> @@ -480,8 +220,6 @@ struct f11_2d_data {
>   	u8	*flick;
>   	u8	*rotate;
>   	u8	*shapes;
> -	s8	*multi_scroll;
> -	s8	*scroll_zones;
>   };
>
>   /**
> @@ -495,7 +233,6 @@ struct f11_2d_data {
>    * @nbr_fingers - How many fingers can this sensor report?
>    * @data_pkt - buffer for data reported by this sensor.
>    * @pkt_size - number of bytes in that buffer.
> - * @sensor_index - identifies this particular 2D touch sensor
>    * @type_a - some early RMI4 2D sensors do not reliably track the finger
>    * position when two fingers are on the device.  When this is true, we
>    * assume we have one of those sensors and report events appropriately.
> @@ -514,7 +251,6 @@ struct f11_2d_sensor {
>   	u8 nbr_fingers;
>   	u8 *data_pkt;
>   	int pkt_size;
> -	u8 sensor_index;
>   	bool type_a;
>   	enum rmi_f11_sensor_type sensor_type;
>   	struct input_dev *input;
> @@ -529,7 +265,6 @@ struct f11_2d_sensor {
>    *
>    * @dev_query - F11 device specific query registers.
>    * @dev_controls - F11 device specific control registers.
> - * @dev_controls_mutex - lock for the control registers.
>    * @rezero_wait_ms - if nonzero, upon resume we will wait this many
>    * milliseconds before rezeroing the sensor(s).  This is useful in systems with
>    * poor electrical behavior on resume, where the initial calibration of the
> @@ -543,7 +278,6 @@ struct f11_data {
>   	bool has_query27;
>   	bool has_query28;
>   	struct f11_2d_ctrl dev_controls;
> -	struct mutex dev_controls_mutex;
>   	u16 rezero_wait_ms;
>   	struct f11_2d_sensor sensor;
>   };
> @@ -871,16 +605,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
>   	sensor_query->has_rel = !!(query_buf[0] & RMI_F11_HAS_REL);
>   	sensor_query->has_abs = !!(query_buf[0] & RMI_F11_HAS_ABS);
>   	sensor_query->has_gestures = !!(query_buf[0] & RMI_F11_HAS_GESTURES);
> -	sensor_query->has_sensitivity_adjust =
> -		!!(query_buf[0] && RMI_F11_HAS_SENSITIVITY_ADJ);
> -	sensor_query->configurable = !!(query_buf[0] & RMI_F11_CONFIGURABLE);
> -
> -	sensor_query->nr_x_electrodes =
> -				query_buf[1] & RMI_F11_NR_ELECTRODES_MASK;
> -	sensor_query->nr_y_electrodes =
> -				query_buf[2] & RMI_F11_NR_ELECTRODES_MASK;
> -	sensor_query->max_electrodes =
> -				query_buf[3] & RMI_F11_NR_ELECTRODES_MASK;
>
>   	query_size = RMI_F11_QUERY_SIZE;
>
> @@ -889,18 +613,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
>   		if (rc < 0)
>   			return rc;
>
> -		sensor_query->abs_data_size =
> -			query_buf[0] & RMI_F11_ABS_DATA_SIZE_MASK;
> -		sensor_query->has_anchored_finger =
> -			!!(query_buf[0] & RMI_F11_HAS_ANCHORED_FINGER);
> -		sensor_query->has_adj_hyst =
> -			!!(query_buf[0] & RMI_F11_HAS_ADJ_HYST);
> -		sensor_query->has_dribble =
> -			!!(query_buf[0] & RMI_F11_HAS_DRIBBLE);
> -		sensor_query->has_bending_correction =
> -			!!(query_buf[0] & RMI_F11_HAS_BENDING_CORRECTION);
> -		sensor_query->has_large_object_suppression =
> -		!!(query_buf[0] && RMI_F11_HAS_LARGE_OBJECT_SUPPRESSION);
>   		sensor_query->has_jitter_filter =
>   			!!(query_buf[0] & RMI_F11_HAS_JITTER_FILTER);
>   		query_size++;
> @@ -920,40 +632,16 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
>   		if (rc < 0)
>   			return rc;
>
> -		sensor_query->has_single_tap =
> -			!!(query_buf[0] & RMI_F11_HAS_SINGLE_TAP);
> -		sensor_query->has_tap_n_hold =
> -			!!(query_buf[0] & RMI_F11_HAS_TAP_AND_HOLD);
> -		sensor_query->has_double_tap =
> -			!!(query_buf[0] & RMI_F11_HAS_DOUBLE_TAP);
> -		sensor_query->has_early_tap =
> -			!!(query_buf[0] & RMI_F11_HAS_EARLY_TAP);
>   		sensor_query->has_flick =
>   			!!(query_buf[0] & RMI_F11_HAS_FLICK);
> -		sensor_query->has_press =
> -			!!(query_buf[0] & RMI_F11_HAS_PRESS);
>   		sensor_query->has_pinch =
>   			!!(query_buf[0] & RMI_F11_HAS_PINCH);
> -		sensor_query->has_chiral =
> -			!!(query_buf[0] & RMI_F11_HAS_CHIRAL);
>
>   		/* query 8 */
> -		sensor_query->has_palm_det =
> -			!!(query_buf[1] & RMI_F11_HAS_PALM_DET);
>   		sensor_query->has_rotate =
>   			!!(query_buf[1] & RMI_F11_HAS_ROTATE);
>   		sensor_query->has_touch_shapes =
>   			!!(query_buf[1] & RMI_F11_HAS_TOUCH_SHAPES);
> -		sensor_query->has_scroll_zones =
> -			!!(query_buf[1] & RMI_F11_HAS_SCROLL_ZONES);
> -		sensor_query->has_individual_scroll_zones =
> -			!!(query_buf[1] & RMI_F11_HAS_INDIVIDUAL_SCROLL_ZONES);
> -		sensor_query->has_mf_scroll =
> -			!!(query_buf[1] & RMI_F11_HAS_MF_SCROLL);
> -		sensor_query->has_mf_edge_motion =
> -			!!(query_buf[1] & RMI_F11_HAS_MF_EDGE_MOTION);
> -		sensor_query->has_mf_scroll_inertia =
> -			!!(query_buf[1] & RMI_F11_HAS_MF_SCROLL_INERTIA);
>
>   		sensor_query->query7_nonzero = !!(query_buf[0]);
>   		sensor_query->query8_nonzero = !!(query_buf[1]);
> @@ -968,20 +656,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
>
>   		sensor_query->has_pen =
>   			!!(query_buf[0] & RMI_F11_HAS_PEN);
> -		sensor_query->has_proximity =
> -			!!(query_buf[0] & RMI_F11_HAS_PROXIMITY);
> -		sensor_query->has_palm_det_sensitivity =
> -			!!(query_buf[0] & RMI_F11_HAS_PALM_DET_SENSITIVITY);
> -		sensor_query->has_suppress_on_palm_detect =
> -			!!(query_buf[0] & RMI_F11_HAS_SUPPRESS_ON_PALM_DETECT);
> -		sensor_query->has_two_pen_thresholds =
> -			!!(query_buf[0] & RMI_F11_HAS_TWO_PEN_THRESHOLDS);
> -		sensor_query->has_contact_geometry =
> -			!!(query_buf[0] & RMI_F11_HAS_CONTACT_GEOMETRY);
> -		sensor_query->has_pen_hover_discrimination =
> -			!!(query_buf[0] & RMI_F11_HAS_PEN_HOVER_DISCRIMINATION);
> -		sensor_query->has_pen_filters =
> -			!!(query_buf[0] & RMI_F11_HAS_PEN_FILTERS);
>
>   		query_size++;
>   	}
> @@ -1002,24 +676,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
>   		if (rc < 0)
>   			return rc;
>
> -		sensor_query->has_z_tuning =
> -			!!(query_buf[0] & RMI_F11_HAS_Z_TUNING);
> -		sensor_query->has_algorithm_selection =
> -			!!(query_buf[0] & RMI_F11_HAS_ALGORITHM_SELECTION);
> -		sensor_query->has_w_tuning =
> -			!!(query_buf[0] & RMI_F11_HAS_W_TUNING);
> -		sensor_query->has_pitch_info =
> -			!!(query_buf[0] & RMI_F11_HAS_PITCH_INFO);
> -		sensor_query->has_finger_size =
> -			!!(query_buf[0] & RMI_F11_HAS_FINGER_SIZE);
> -		sensor_query->has_segmentation_aggressiveness =
> -			!!(query_buf[0] &
> -				RMI_F11_HAS_SEGMENTATION_AGGRESSIVENESS);
> -		sensor_query->has_XY_clip =
> -			!!(query_buf[0] & RMI_F11_HAS_XY_CLIP);
> -		sensor_query->has_drumming_filter =
> -			!!(query_buf[0] & RMI_F11_HAS_DRUMMING_FILTER);
> -
>   		query_size++;
>   	}
>
> @@ -1028,22 +684,8 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
>   		if (rc < 0)
>   			return rc;
>
> -		sensor_query->has_gapless_finger =
> -			!!(query_buf[0] & RMI_F11_HAS_GAPLESS_FINGER);
> -		sensor_query->has_gapless_finger_tuning =
> -			!!(query_buf[0] & RMI_F11_HAS_GAPLESS_FINGER_TUNING);
> -		sensor_query->has_8bit_w =
> -			!!(query_buf[0] & RMI_F11_HAS_8BIT_W);
> -		sensor_query->has_adjustable_mapping =
> -			!!(query_buf[0] & RMI_F11_HAS_ADJUSTABLE_MAPPING);
>   		sensor_query->has_info2 =
>   			!!(query_buf[0] & RMI_F11_HAS_INFO2);
> -		sensor_query->has_physical_props =
> -			!!(query_buf[0] & RMI_F11_HAS_PHYSICAL_PROPS);
> -		sensor_query->has_finger_limit =
> -			!!(query_buf[0] & RMI_F11_HAS_FINGER_LIMIT);
> -		sensor_query->has_linear_coeff_2 =
> -			!!(query_buf[0] & RMI_F11_HAS_LINEAR_COEFF);
>
>   		query_size++;
>   	}
> @@ -1053,12 +695,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
>   		if (rc < 0)
>   			return rc;
>
> -		sensor_query->jitter_window_size = query_buf[0] &
> -			RMI_F11_JITTER_WINDOW_MASK;
> -		sensor_query->jitter_filter_type = (query_buf[0] &
> -			RMI_F11_JITTER_FILTER_MASK) >>
> -			RMI_F11_JITTER_FILTER_SHIFT;
> -
>   		query_size++;
>   	}
>
> @@ -1067,18 +703,8 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
>   		if (rc < 0)
>   			return rc;
>
> -		sensor_query->light_control =
> -			query_buf[0] & RMI_F11_LIGHT_CONTROL_MASK;
>   		sensor_query->is_clear =
>   			!!(query_buf[0] & RMI_F11_IS_CLEAR);
> -		sensor_query->clickpad_props =
> -			(query_buf[0] & RMI_F11_CLICKPAD_PROPS_MASK) >>
> -			RMI_F11_CLICKPAD_PROPS_SHIFT;
> -		sensor_query->mouse_buttons =
> -			(query_buf[0] & RMI_F11_MOUSE_BUTTONS_MASK) >>
> -			RMI_F11_MOUSE_BUTTONS_SHIFT;
> -		sensor_query->has_advanced_gestures =
> -			!!(query_buf[0] & RMI_F11_HAS_ADVANCED_GESTURES);
>
>   		query_size++;
>   	}
> @@ -1276,7 +902,6 @@ static int rmi_f11_initialize(struct rmi_function *fn)
>   				rc);
>   	}
>
> -	mutex_init(&f11->dev_controls_mutex);
>   	return 0;
>   }
>
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support
  2014-01-24  0:00                   ` [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support Courtney Cavin
  2014-01-24  0:00                     ` [PATCH 11/15] Input: synaptics-rmi4 - add regulator support Courtney Cavin
@ 2014-02-04 23:10                     ` Christopher Heiny
  2014-02-05  2:37                       ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:10 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:

This is pretty interesting, and looks potentially useful.  I'm not very 
familiar with OF/DT structures, though.  What happens if there are two 
different RMI4 devices in the system, each of which has its own platform 
settings?

> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
>   Documentation/devicetree/bindings/input/rmi4.txt   | 107 +++++++++++++++++
>   .../devicetree/bindings/vendor-prefixes.txt        |   1 +
>   drivers/input/rmi4/rmi_bus.c                       |  12 +-
>   drivers/input/rmi4/rmi_bus.h                       |   3 +-
>   drivers/input/rmi4/rmi_driver.c                    |  44 +++++--
>   drivers/input/rmi4/rmi_f01.c                       | 107 +++++++++++++++--
>   drivers/input/rmi4/rmi_f11.c                       | 133 ++++++++++++++++++++-
>   drivers/input/rmi4/rmi_i2c.c                       |  19 +--
>   8 files changed, 388 insertions(+), 38 deletions(-)
>   create mode 100644 Documentation/devicetree/bindings/input/rmi4.txt
>
> diff --git a/Documentation/devicetree/bindings/input/rmi4.txt b/Documentation/devicetree/bindings/input/rmi4.txt
> new file mode 100644
> index 0000000..fff9db7
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/rmi4.txt
> @@ -0,0 +1,107 @@
> +Synaptics RMI4-based input device binding
> +
> +PROPERTIES
> +
> +compatible:
> +	Usage: required
> +	Type: string, must be "syn,rmi_i2c"
> +
> +interrupts:
> +	Usage: required
> +	Type: <prop-encoded-array>
> +	Desc: See devicetree/bindings/interrupt-controller/interrupts.txt;
> +		Trigger sense required in mask
> +
> +syn,reset-delay:
> +	Usage: optional (default: 100)
> +	Type: u32, milliseconds
> +	Desc: Delay after issuing a reset
> +
> +syn,power-no-sleep:
> +	Usage: optional, mutually exclusive with syn,power-sleep
> +		(default: chip-specific)
> +	Type: boolean
> +	Desc: Disable sleep mode
> +
> +syn,power-sleep:
> +	Usage: optional, mutually exclusive with syn,power-no-sleep
> +		(default: chip-specific)
> +	Type: boolean
> +	Desc: Enable sleep mode
> +
> +syn,power-wakeup-thresh:
> +	Usage: optional (default: chip-specific)
> +	Type: u32, chip-specific unit [0-255]
> +	Desc: Capacitance threshold at which device should wake
> +
> +syn,power-doze-holdoff:
> +	Usage: optional (default: chip-specific)
> +	Type: u32, milliseconds [0-25500]
> +	Desc: Idle delay before entering sleep mode
> +
> +syn,power-doze-interval:
> +	Usage: optional (default: chip-specific)
> +	Type: u32, milliseconds [0-2550]
> +	Desc: Interval between checks for idle
> +
> +syn,2d-rezero-wait:
> +	Usage: optional (default: no re-zeroing)
> +	Type: u32, milliseconds [0-65535]
> +	Desc: Delay after resume to re-zero sensor
> +
> +syn,2d-axis-swap:
> +	Usage: optional (default: false)
> +	Type: boolean
> +	Desc: Swap X and Y axis
> +
> +syn,2d-flip-x:
> +	Usage: optional (default: false)
> +	Type: boolean
> +	Desc: Invert X axis
> +
> +syn,2d-flip-y:
> +	Usage: optional (default: false)
> +	Type: boolean
> +	Desc: Invert Y axis
> +
> +syn,2d-clip-range:
> +	Usage: optional (default: clip disabled)
> +	Type: u32 array (<top left bottom right>) [0-65535]
> +	Usage: Clip values outside this range
> +
> +syn,2d-offset:
> +	Usage: optional (default: offset disabled)
> +	Type: u32 array (<X-offset Y-offset>) [0-65535]
> +	Usage: Add offset values to reported events
> +
> +syn,2d-delta-thresh:
> +	Usage: optional (default: chip-specific)
> +	Type: u32 array (<X-delta Y-delta>) [0-255]
> +	Usage: Minimum delta before event is reported
> +
> +syn,2d-sensor-type:
> +	Usage: optional (default: chip-specific)
> +	Type: string, "indirect" or "direct"
> +	Usage: Set screen type for event reporting
> +
> +syn,2d-type-a:
> +	Usage: optional (default: false)
> +	Type: boolean
> +	Usage: Sensor supports only Multifinger Type A protocol
> +
> +EXAMPLE
> +
> +i2c@0 {
> +	compatible = "...";
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	synaptics_rmi4@2c {
> +		compatible = "syn,rmi_i2c";
> +		reg = <0x2c>;
> +
> +		interrupts = <61 IRQ_TYPE_EDGE_FALLING>;
> +
> +		syn,2d-clip-range = <0 0 1919 1079>;
> +	};
> +};
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index edbb8d8..3388986 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -72,6 +72,7 @@ snps 	Synopsys, Inc.
>   st	STMicroelectronics
>   ste	ST-Ericsson
>   stericsson	ST-Ericsson
> +syn	Synaptics, Inc.
>   ti	Texas Instruments
>   toshiba	Toshiba Corporation
>   toumaz	Toumaz
> diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> index a51e6b4..57de579 100644
> --- a/drivers/input/rmi4/rmi_bus.c
> +++ b/drivers/input/rmi4/rmi_bus.c
> @@ -52,14 +52,11 @@ bool rmi_is_physical_device(struct device *dev)
>   int rmi_register_transport_device(struct rmi_transport_dev *xport)
>   {
>   	static atomic_t transport_device_count = ATOMIC_INIT(0);
> -	struct rmi_device_platform_data *pdata = xport->dev->platform_data;
>   	struct rmi_device *rmi_dev;
>   	int error;
>
> -	if (!pdata) {
> -		dev_err(xport->dev, "no platform data!\n");
> -		return -EINVAL;
> -	}
> +	if (unlikely(!rmi_bus_type.p))
> +		return -EPROBE_DEFER;
>
>   	rmi_dev = kzalloc(sizeof(struct rmi_device), GFP_KERNEL);
>   	if (!rmi_dev)
> @@ -70,8 +67,10 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
>
>   	dev_set_name(&rmi_dev->dev, "sensor%02d", rmi_dev->number);
>
> +	rmi_dev->dev.parent = xport->dev;
>   	rmi_dev->dev.bus = &rmi_bus_type;
>   	rmi_dev->dev.type = &rmi_device_type;
> +	rmi_dev->dev.of_node = xport->dev->of_node;
>
>   	xport->rmi_dev = rmi_dev;
>
> @@ -206,6 +205,9 @@ int __rmi_register_function_handler(struct rmi_function_handler *handler,
>   	struct device_driver *driver = &handler->driver;
>   	int error;
>
> +	if (WARN_ON(unlikely(!rmi_bus_type.p)))
> +		return -EAGAIN;
> +
>   	driver->bus = &rmi_bus_type;
>   	driver->owner = owner;
>   	driver->mod_name = mod_name;
> diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
> index a21e4c4..51f9372 100644
> --- a/drivers/input/rmi4/rmi_bus.h
> +++ b/drivers/input/rmi4/rmi_bus.h
> @@ -212,7 +212,8 @@ struct rmi_device {
>   };
>
>   #define to_rmi_device(d) container_of(d, struct rmi_device, dev)
> -#define to_rmi_platform_data(d) ((d)->xport->dev->platform_data)
> +#define to_rmi_xport_device(d) ((d)->xport->dev)
> +#define to_rmi_platform_data(d) (dev_get_platdata(to_rmi_xport_device(d)))
>
>   bool rmi_is_physical_device(struct device *dev);
>
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 9ec7b93..92415ce 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -26,6 +26,8 @@
>   #include <linux/rmi.h>
>   #include <linux/slab.h>
>   #include <linux/uaccess.h>
> +#include <linux/of_irq.h>
> +#include <linux/of.h>
>   #include <uapi/linux/input.h>
>   #include "rmi_bus.h"
>   #include "rmi_driver.h"
> @@ -498,7 +500,7 @@ static int create_function(struct rmi_device *rmi_dev,
>    * We have to do this before actually building the PDT because the reflash
>    * updates (if any) might cause various registers to move around.
>    */
> -static int rmi_initial_reset(struct rmi_device *rmi_dev)
> +static int rmi_initial_reset(struct rmi_device *rmi_dev, u32 reset_delay)
>   {
>   	struct pdt_entry pdt_entry;
>   	int page;
> @@ -507,8 +509,6 @@ static int rmi_initial_reset(struct rmi_device *rmi_dev)
>   	bool has_f01 = false;
>   	int i;
>   	int retval;
> -	const struct rmi_device_platform_data *pdata =
> -			to_rmi_platform_data(rmi_dev);
>
>   	dev_dbg(dev, "Initial reset.\n");
>
> @@ -538,7 +538,7 @@ static int rmi_initial_reset(struct rmi_device *rmi_dev)
>   						retval);
>   					return retval;
>   				}
> -				mdelay(pdata->reset_delay_ms);
> +				mdelay(reset_delay);
>   				done = true;
>   				has_f01 = true;
>   				break;
> @@ -648,6 +648,8 @@ static int rmi_driver_probe(struct device *dev)
>   	struct rmi_device_platform_data *pdata;
>   	int retval = 0;
>   	struct rmi_device *rmi_dev;
> +	unsigned int irq;
> +	u32 reset_delay;
>
>   	dev_dbg(dev, "%s: Starting probe.\n", __func__);
>
> @@ -661,6 +663,28 @@ static int rmi_driver_probe(struct device *dev)
>   	rmi_dev->driver = rmi_driver;
>
>   	pdata = to_rmi_platform_data(rmi_dev);
> +	if (pdata == NULL) {
> +#ifdef CONFIG_OF
> +		const char *p;
> +
> +		p = "syn,reset-delay";
> +		retval = of_property_read_u32(dev->of_node, p, &reset_delay);
> +		if (retval && retval != -EINVAL) {
> +			dev_err(dev, "Invalid '%s' property\n", p);
> +			return -EINVAL;
> +		}
> +		if (retval == -EINVAL)
> +			reset_delay = 0;
> +
> +		irq = irq_of_parse_and_map(dev->of_node, 0);
> +#else
> +		dev_err(dev, "No pdata\n");
> +		return -EINVAL;
> +#endif
> +	} else {
> +		reset_delay = pdata->reset_delay_ms;
> +		irq = pdata->irq;
> +	}
>
>   	data = devm_kzalloc(dev, sizeof(struct rmi_driver_data), GFP_KERNEL);
>   	if (!data) {
> @@ -688,9 +712,9 @@ static int rmi_driver_probe(struct device *dev)
>   	 * and leave the customer's device unusable.  So we warn them, and
>   	 * continue processing.
>   	 */
> -	if (!pdata->reset_delay_ms)
> -		pdata->reset_delay_ms = DEFAULT_RESET_DELAY_MS;
> -	retval = rmi_initial_reset(rmi_dev);
> +	if (!reset_delay)
> +		reset_delay = DEFAULT_RESET_DELAY_MS;
> +	retval = rmi_initial_reset(rmi_dev, reset_delay);
>   	if (retval)
>   		dev_warn(dev, "RMI initial reset failed! Continuing in spite of this.\n");
>
> @@ -762,10 +786,10 @@ static int rmi_driver_probe(struct device *dev)
>   		goto err_free_data;
>   	}
>
> -	data->irq = pdata->irq;
> -	if (data->irq < 0) {
> +	data->irq = irq;
> +	if (data->irq < 0 || data->irq == NO_IRQ) {
>   		dev_err(dev, "Failed to get attn IRQ.\n");
> -		retval = data->irq;
> +		retval = -EINVAL;
>   		goto err_free_data;
>
>   	}
> diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
> index 4cb9fcb..22b57f2 100644
> --- a/drivers/input/rmi4/rmi_f01.c
> +++ b/drivers/input/rmi4/rmi_f01.c
> @@ -12,6 +12,7 @@
>   #include <linux/rmi.h>
>   #include <linux/slab.h>
>   #include <linux/uaccess.h>
> +#include <linux/of.h>
>   #include "rmi_driver.h"
>
>   #define RMI_PRODUCT_ID_LENGTH    10
> @@ -169,15 +170,104 @@ static int rmi_f01_read_properties(struct rmi_device *rmi_dev,
>   	return 0;
>   }
>
> +#ifdef CONFIG_OF
> +static int rmi_f01_of_parse(struct device *dev,
> +		struct rmi_f01_power_management *cdata)
> +{
> +	bool sleep, nosleep;
> +	const char *p;
> +	u32 val;
> +	int rc;
> +
> +	if (dev->of_node == NULL)
> +		return -EINVAL;
> +
> +	memset(cdata, 0, sizeof(*cdata));
> +
> +	sleep = of_property_read_bool(dev->of_node, "syn,power-sleep");
> +	nosleep = of_property_read_bool(dev->of_node, "syn,power-nosleep");
> +	if (sleep && nosleep) {
> +		dev_err(dev, "'syn,power-sleep' and 'syn,power-nosleep' are mutually exclusive\n");
> +		return -EINVAL;
> +	}
> +	if (sleep)
> +		cdata->nosleep = RMI_F01_NOSLEEP_OFF;
> +	else if (nosleep)
> +		cdata->nosleep = RMI_F01_NOSLEEP_ON;
> +
> +	p = "syn,power-wakeup-thresh";
> +	rc = of_property_read_u32(dev->of_node, p, &val);
> +	if (rc && rc != -EINVAL) {
> +		dev_err(dev, "Invalid '%s' property\n", p);
> +		return rc;
> +	}
> +	if (rc != -EINVAL) {
> +		if (val & ~0xff) {
> +			dev_err(dev, "'%s' out of range [0-255]\n", p);
> +			return -EINVAL;
> +		}
> +		cdata->wakeup_threshold = val;
> +	}
> +
> +	p = "syn,power-doze-holdoff";
> +	rc = of_property_read_u32(dev->of_node, p, &val);
> +	if (rc && rc != -EINVAL) {
> +		dev_err(dev, "Invalid '%s' property\n", p);
> +		return rc;
> +	}
> +	if (rc != -EINVAL) {
> +		if (val > 25500) {
> +			dev_err(dev, "'%s' out of range [0-25500]ms\n", p);
> +			return -EINVAL;
> +		}
> +		cdata->doze_holdoff = (val + 50) / 100;
> +	}
> +
> +	p = "syn,power-doze-interval";
> +	rc = of_property_read_u32(dev->of_node, p, &val);
> +	if (rc && rc != -EINVAL) {
> +		dev_err(dev, "Invalid '%s' property\n", p);
> +		return rc;
> +	}
> +	if (rc != -EINVAL) {
> +		if (val > 2550) {
> +			dev_err(dev, "'%s' out of range [0-2550]ms\n", p);
> +			return -EINVAL;
> +		}
> +		cdata->doze_interval = (val + 5) / 10;
> +	}
> +
> +	return 0;
> +}
> +#else
> +static int rmi_f01_of_parse(struct device *dev,
> +		struct rmi_f01_power_management *cdata)
> +{
> +	return -EINVAL;
> +}
> +#endif
> +
>   static int rmi_f01_initialize(struct rmi_function *fn)
>   {
>   	u8 temp;
>   	int error;
>   	u16 ctrl_base_addr;
> +	struct rmi_f01_power_management cdata;
>   	struct rmi_device *rmi_dev = fn->rmi_dev;
> +	struct device *dev = to_rmi_xport_device(rmi_dev);
>   	struct rmi_driver_data *driver_data = dev_get_drvdata(&rmi_dev->dev);
>   	struct f01_data *data = fn->data;
> -	struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
> +	struct rmi_device_platform_data *pdata = dev_get_platdata(dev);
> +
> +	if (pdata != NULL) {
> +		cdata = pdata->power_management;
> +	} else {
> +		error = rmi_f01_of_parse(dev, &cdata);
> +		if (error) {
> +			dev_err(dev, "Unable to parse DT data\n");
> +			return error;
> +		}
> +	}
>
>   	/*
>   	 * Set the configured bit and (optionally) other important stuff
> @@ -191,7 +281,7 @@ static int rmi_f01_initialize(struct rmi_function *fn)
>   		dev_err(&fn->dev, "Failed to read F01 control.\n");
>   		return error;
>   	}
> -	switch (pdata->power_management.nosleep) {
> +	switch (cdata.nosleep) {
>   	case RMI_F01_NOSLEEP_DEFAULT:
>   		break;
>   	case RMI_F01_NOSLEEP_OFF:
> @@ -262,9 +352,9 @@ static int rmi_f01_initialize(struct rmi_function *fn)
>   		data->doze_interval_addr = ctrl_base_addr;
>   		ctrl_base_addr++;
>
> -		if (pdata->power_management.doze_interval) {
> +		if (cdata.doze_interval) {
>   			data->device_control.doze_interval =
> -				pdata->power_management.doze_interval;
> +				cdata.doze_interval;
>   			error = rmi_write(rmi_dev, data->doze_interval_addr,
>   					data->device_control.doze_interval);
>   			if (error < 0) {
> @@ -283,9 +373,9 @@ static int rmi_f01_initialize(struct rmi_function *fn)
>   		data->wakeup_threshold_addr = ctrl_base_addr;
>   		ctrl_base_addr++;
>
> -		if (pdata->power_management.wakeup_threshold) {
> +		if (cdata.wakeup_threshold) {
>   			data->device_control.wakeup_threshold =
> -				pdata->power_management.wakeup_threshold;
> +				cdata.wakeup_threshold;
>   			error = rmi_write(rmi_dev, data->wakeup_threshold_addr,
>   					data->device_control.wakeup_threshold);
>   			if (error < 0) {
> @@ -306,9 +396,8 @@ static int rmi_f01_initialize(struct rmi_function *fn)
>   		data->doze_holdoff_addr = ctrl_base_addr;
>   		ctrl_base_addr++;
>
> -		if (pdata->power_management.doze_holdoff) {
> -			data->device_control.doze_holdoff =
> -				pdata->power_management.doze_holdoff;
> +		if (cdata.doze_holdoff) {
> +			data->device_control.doze_holdoff = cdata.doze_holdoff;
>   			error = rmi_write(rmi_dev, data->doze_holdoff_addr,
>   					data->device_control.doze_holdoff);
>   			if (error < 0) {
> diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> index b114f25..837b6e7 100644
> --- a/drivers/input/rmi4/rmi_f11.c
> +++ b/drivers/input/rmi4/rmi_f11.c
> @@ -13,6 +13,7 @@
>   #include <linux/input.h>
>   #include <linux/input/mt.h>
>   #include <linux/kconfig.h>
> +#include <linux/of.h>
>   #include <linux/rmi.h>
>   #include <linux/slab.h>
>   #include "rmi_driver.h"
> @@ -794,9 +795,120 @@ static void f11_set_abs_params(struct rmi_function *fn)
>   				     0, MT_TOOL_FINGER, 0, 0);
>   }
>
> +#ifdef CONFIG_OF
> +static int rmi_f11_of_parse(struct device *dev,
> +		struct rmi_f11_sensor_data *cdata)
> +{
> +	const char *type;
> +	const char *p;
> +	u32 a[4];
> +	int rc;
> +
> +	if (dev->of_node == NULL)
> +		return -EINVAL;
> +
> +	memset(cdata, 0, sizeof(*cdata));
> +
> +	p = "syn,2d-rezero-wait";
> +	rc = of_property_read_u32(dev->of_node, p, &a[0]);
> +	if (rc && rc != -EINVAL) {
> +		dev_err(dev, "Invalid '%s' property\n", p);
> +		return rc;
> +	}
> +	if (rc != -EINVAL) {
> +		if (a[0] & ~0xffff) {
> +			dev_err(dev, "'%s' value out of range [0-65535]\n", p);
> +			return -EINVAL;
> +		}
> +		cdata->rezero_wait = a[0];
> +	}
> +
> +	cdata->type_a = of_property_read_bool(dev->of_node, "syn,2d-type-a");
> +	cdata->axis_align.swap_axes = of_property_read_bool(dev->of_node,
> +			"syn,2d-axis-swap");
> +	cdata->axis_align.flip_x = of_property_read_bool(dev->of_node,
> +			"syn,2d-flip-x");
> +	cdata->axis_align.flip_y = of_property_read_bool(dev->of_node,
> +			"syn,2d-flip-y");
> +
> +	p = "syn-2d-clip-range";
> +	rc = of_property_read_u32_array(dev->of_node, p, a, 4);
> +	if (rc && rc != -EINVAL) {
> +		dev_err(dev, "Invalid '%s' property\n", p);
> +		return rc;
> +	}
> +	if (rc != -EINVAL) {
> +		if ((a[0] | a[1] | a[2] | a[3]) & ~0xffff) {
> +			dev_err(dev, "'%s' values out of range [0-65535]\n", p);
> +			return -EINVAL;
> +		}
> +		cdata->axis_align.clip_x_low = a[0];
> +		cdata->axis_align.clip_y_low = a[1];
> +		cdata->axis_align.clip_x_high = a[2];
> +		cdata->axis_align.clip_y_high = a[3];
> +	}
> +
> +	p = "syn-2d-offset";
> +	rc = of_property_read_u32_array(dev->of_node, p, a, 2);
> +	if (rc && rc != -EINVAL) {
> +		dev_err(dev, "Invalid '%s' property\n", p);
> +		return rc;
> +	}
> +	if (rc != -EINVAL) {
> +		if ((a[0] | a[1]) & ~0xffff) {
> +			dev_err(dev, "'%s' values out of range [0-65535]\n", p);
> +			return -EINVAL;
> +		}
> +		cdata->axis_align.offset_x = a[0];
> +		cdata->axis_align.offset_y = a[1];
> +	}
> +
> +	p = "syn,2d-delta-thresh";
> +	rc = of_property_read_u32_array(dev->of_node, p, a, 2);
> +	if (rc && rc != -EINVAL) {
> +		dev_err(dev, "Invalid '%s' property\n", p);
> +		return rc;
> +	}
> +	if (rc != -EINVAL) {
> +		if ((a[0] | a[1]) & ~0xff) {
> +			dev_err(dev, "'%s' values out of range [0-255]\n", p);
> +			return -EINVAL;
> +		}
> +		cdata->axis_align.delta_x_threshold = a[0];
> +		cdata->axis_align.delta_y_threshold = a[1];
> +	}
> +
> +	p = "syn,2d-sensor-type";
> +	rc = of_property_read_string(dev->of_node, p, &type);
> +	if (rc && rc != -EINVAL) {
> +		dev_err(dev, "Invalid '%s' property\n", p);
> +		return rc;
> +	}
> +	if (rc != -EINVAL) {
> +		if (!strcmp(type, "direct")) {
> +			cdata->sensor_type = RMI_F11_SENSOR_DIRECT;
> +		} else if (!strcmp(type, "indirect")) {
> +			cdata->sensor_type = RMI_F11_SENSOR_INDIRECT;
> +		} else {
> +			dev_err(dev, "'%s' must be one of: \"indirect\", \"direct\"\n", p);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	return 0;
> +}
> +#else
> +static int rmi_f11_of_parse(struct device *dev,
> +		struct rmi_f11_sensor_data *cdata)
> +{
> +	return -EINVAL;
> +}
> +#endif
> +
>   static int rmi_f11_initialize(struct rmi_function *fn)
>   {
>   	struct rmi_device *rmi_dev = fn->rmi_dev;
> +	struct device *dev = to_rmi_xport_device(rmi_dev);
>   	struct f11_data *f11;
>   	struct f11_2d_ctrl *ctrl;
>   	u8 query_offset;
> @@ -804,12 +916,23 @@ static int rmi_f11_initialize(struct rmi_function *fn)
>   	u16 control_base_addr;
>   	u16 max_x_pos, max_y_pos, temp;
>   	int rc;
> -	struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
> +	struct rmi_device_platform_data *pdata = dev_get_platdata(dev);
> +	struct rmi_f11_sensor_data cdata;
>   	struct f11_2d_sensor *sensor;
>   	u8 buf;
>
>   	dev_dbg(&fn->dev, "Initializing F11 values.\n");
>
> +	if (pdata != NULL) {
> +		cdata = pdata->f11_sensor_data;
> +	} else {
> +		rc = rmi_f11_of_parse(dev, &cdata);
> +		if (rc) {
> +			dev_err(dev, "Unable to parse DT data\n");
> +			return rc;
> +		}
> +	}
> +
>   	/*
>   	** init instance data, fill in values and create any sysfs files
>   	*/
> @@ -818,7 +941,7 @@ static int rmi_f11_initialize(struct rmi_function *fn)
>   		return -ENOMEM;
>
>   	fn->data = f11;
> -	f11->rezero_wait_ms = pdata->f11_sensor_data.rezero_wait;
> +	f11->rezero_wait_ms = cdata.rezero_wait;
>
>   	query_base_addr = fn->fd.query_base_addr;
>   	control_base_addr = fn->fd.control_base_addr;
> @@ -851,9 +974,9 @@ static int rmi_f11_initialize(struct rmi_function *fn)
>   		return rc;
>   	}
>
> -	sensor->axis_align = pdata->f11_sensor_data.axis_align;
> -	sensor->type_a = pdata->f11_sensor_data.type_a;
> -	sensor->sensor_type = pdata->f11_sensor_data.sensor_type;
> +	sensor->axis_align = cdata.axis_align;
> +	sensor->type_a = cdata.type_a;
> +	sensor->sensor_type = cdata.sensor_type;
>
>   	rc = rmi_read_block(rmi_dev,
>   		control_base_addr + F11_CTRL_SENSOR_MAX_X_POS_OFFSET,
> diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
> index aebf974..377d4cc 100644
> --- a/drivers/input/rmi4/rmi_i2c.c
> +++ b/drivers/input/rmi4/rmi_i2c.c
> @@ -186,16 +186,9 @@ static const struct rmi_transport_ops rmi_i2c_ops = {
>   static int rmi_i2c_probe(struct i2c_client *client,
>   			 const struct i2c_device_id *id)
>   {
> -	const struct rmi_device_platform_data *pdata =
> -				dev_get_platdata(&client->dev);
>   	struct rmi_i2c_xport *rmi_i2c;
>   	int retval;
>
> -	if (!pdata) {
> -		dev_err(&client->dev, "no platform data\n");
> -		return -EINVAL;
> -	}
> -
>   	dev_dbg(&client->dev, "Probing %#02x.\n", client->addr);
>
>   	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
> @@ -258,10 +251,20 @@ static const struct i2c_device_id rmi_id[] = {
>   };
>   MODULE_DEVICE_TABLE(i2c, rmi_id);
>
> +#ifdef CONFIG_OF
> +static struct of_device_id rmi_match_table[] = {
> +	{ .compatible = "syn,rmi_i2c", },
> +	{ },
> +};
> +#else
> +#define rmi_match_table NULL
> +#endif
> +
>   static struct i2c_driver rmi_i2c_driver = {
>   	.driver = {
>   		.owner	= THIS_MODULE,
> -		.name	= "rmi_i2c"
> +		.name	= "rmi_i2c",
> +		.of_match_table = rmi_match_table,
>   	},
>   	.id_table	= rmi_id,
>   	.probe		= rmi_i2c_probe,
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 11/15] Input: synaptics-rmi4 - add regulator support
  2014-01-24  0:00                     ` [PATCH 11/15] Input: synaptics-rmi4 - add regulator support Courtney Cavin
  2014-01-24  0:00                       ` [PATCH 12/15] Input: synaptics-rmi4 - don't immediately set page on probe Courtney Cavin
@ 2014-02-04 23:10                       ` Christopher Heiny
  2014-02-05  2:38                         ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:10 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> Add support for VDD and VIO power supplies.  Since we may need a delay
> after turning on the chip, adjust code to manage that.  This removes the
> scanning for active interrupts on resume, as we should get an interrupt
> when the chip is ready.

This looks potentially useful.  But what happens in devices where you 
want to power the touch sensor on at initial boot, but need to leave it 
power on during suspend/resume states?  Also, how does this work when 
there are multiple RMI4 sensors in the system?

See also comments below.

> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
>   Documentation/devicetree/bindings/input/rmi4.txt | 10 +++++
>   drivers/input/rmi4/rmi_driver.c                  | 53 +++++++++++++++++++++++-
>   drivers/input/rmi4/rmi_driver.h                  |  4 ++
>   3 files changed, 66 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/input/rmi4.txt b/Documentation/devicetree/bindings/input/rmi4.txt
> index fff9db7..d41beac 100644
> --- a/Documentation/devicetree/bindings/input/rmi4.txt
> +++ b/Documentation/devicetree/bindings/input/rmi4.txt
> @@ -12,6 +12,16 @@ interrupts:
>   	Desc: See devicetree/bindings/interrupt-controller/interrupts.txt;
>   		Trigger sense required in mask
>
> +vdd-supply:
> +	Usage: optional (default: no regulator)
> +	Type: <prop-encoded-array>
> +	Desc: VDD power supply; See devicetree/bindings/regulator/regulator.txt
> +
> +vio-supply:
> +	Usage: optional (default: no regulator)
> +	Type: <prop-encoded-array>
> +	Desc: VIO power supply; See devicetree/bindings/regulator/regulator.txt
> +
>   syn,reset-delay:
>   	Usage: optional (default: 100)
>   	Type: u32, milliseconds
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 92415ce..52345ae 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -28,6 +28,7 @@
>   #include <linux/uaccess.h>
>   #include <linux/of_irq.h>
>   #include <linux/of.h>
> +#include <linux/regulator/consumer.h>
>   #include <uapi/linux/input.h>
>   #include "rmi_bus.h"
>   #include "rmi_driver.h"
> @@ -101,7 +102,7 @@ static int enable_sensor(struct rmi_device *rmi_dev)
>
>   	data->enabled = true;
>
> -	return process_interrupt_requests(rmi_dev);
> +	return 0;

enable_sensor() and disable_sensor() may be called in a variety of 
contexts, and there may be pending interrupts at the time 
enable_sensor() is called.

>   }
>
>   static void rmi_free_function_list(struct rmi_device *rmi_dev)
> @@ -616,14 +617,29 @@ error_exit:
>   static int rmi_driver_suspend(struct device *dev)
>   {
>   	struct rmi_device *rmi_dev = to_rmi_device(dev);
> +	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
>
>   	disable_sensor(rmi_dev);
> +
> +	regulator_disable(data->vio);
> +	regulator_disable(data->vdd);
> +
>   	return 0;
>   }
>
>   static int rmi_driver_resume(struct device *dev)
>   {
>   	struct rmi_device *rmi_dev = to_rmi_device(dev);
> +	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> +	int retval;
> +
> +	retval = regulator_enable(data->vdd);
> +	if (retval)
> +		return retval;
> +	retval = regulator_enable(data->vio);
> +	if (retval)
> +		return retval;

If you've toggled power to the sensor, you may need to do a reset wait 
here, just like you did on initialization.

> +
>   	return enable_sensor(rmi_dev);
>   }
>
> @@ -634,7 +650,12 @@ static SIMPLE_DEV_PM_OPS(rmi_driver_pm, rmi_driver_suspend, rmi_driver_resume);
>   static int rmi_driver_remove(struct device *dev)
>   {
>   	struct rmi_device *rmi_dev = to_rmi_device(dev);
> +	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> +
>   	disable_sensor(rmi_dev);
> +
> +	regulator_disable(data->vio);
> +	regulator_disable(data->vdd);
>   	rmi_free_function_list(rmi_dev);
>
>   	return 0;
> @@ -649,6 +670,7 @@ static int rmi_driver_probe(struct device *dev)
>   	int retval = 0;
>   	struct rmi_device *rmi_dev;
>   	unsigned int irq;
> +	bool delay_start = false;
>   	u32 reset_delay;
>
>   	dev_dbg(dev, "%s: Starting probe.\n", __func__);
> @@ -696,6 +718,33 @@ static int rmi_driver_probe(struct device *dev)
>   	dev_set_drvdata(&rmi_dev->dev, data);
>   	mutex_init(&data->pdt_mutex);
>
> +	data->vdd = devm_regulator_get_optional(dev, "vdd");
> +	if (IS_ERR(data->vdd)) {
> +		dev_err(dev, "Failed to get regulator 'vdd'\n");
> +		return PTR_ERR(data->vdd);
> +	}
> +	data->vio = devm_regulator_get_optional(dev, "vio");
> +	if (IS_ERR(data->vio)) {
> +		dev_err(dev, "Failed to get regulator 'vio'\n");
> +		return PTR_ERR(data->vio);
> +	}
> +
> +	if (data->vdd && !regulator_is_enabled(data->vdd))
> +		delay_start = true;
> +	if (data->vio && !regulator_is_enabled(data->vio))
> +		delay_start = true;
> +
> +	retval = regulator_enable(data->vdd);
> +	if (retval) {
> +		dev_err(dev, "Failed to enable regulator\n");
> +		return retval;
> +	}
> +	retval = regulator_enable(data->vio);
> +	if (retval) {
> +		dev_err(dev, "Failed to enable regulator\n");
> +		return retval;
> +	}
> +
>   	/*
>   	 * Right before a warm boot, the sensor might be in some unusual state,
>   	 * such as F54 diagnostics, or F34 bootloader mode.  In order to clear
> @@ -714,6 +763,8 @@ static int rmi_driver_probe(struct device *dev)
>   	 */
>   	if (!reset_delay)
>   		reset_delay = DEFAULT_RESET_DELAY_MS;
> +	if (delay_start)
> +		mdelay(reset_delay);
>   	retval = rmi_initial_reset(rmi_dev, reset_delay);
>   	if (retval)
>   		dev_warn(dev, "RMI initial reset failed! Continuing in spite of this.\n");
> diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
> index eafbdb3..d553722 100644
> --- a/drivers/input/rmi4/rmi_driver.h
> +++ b/drivers/input/rmi4/rmi_driver.h
> @@ -29,9 +29,13 @@
>
>   #define RMI_PDT_PROPS_HAS_BSR 0x02
>
> +struct regulator;
> +
>   struct rmi_driver_data {
>   	struct list_head function_list;
>
> +	struct regulator *vdd;
> +	struct regulator *vio;
>   	struct rmi_device *rmi_dev;
>
>   	struct rmi_function *f01_container;
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan
  2014-01-24  0:00                         ` [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan Courtney Cavin
  2014-01-24  0:00                           ` [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status Courtney Cavin
@ 2014-02-04 23:10                           ` Christopher Heiny
  2014-02-05  2:39                             ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:10 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:

Although necessary, this is redundant to changes already submitted.

> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
>   drivers/input/rmi4/rmi_driver.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 52345ae..9d8d6ec 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -488,6 +488,8 @@ static int create_function(struct rmi_device *rmi_dev,
>   		return error;
>
>   	list_add_tail(&fn->node, &data->function_list);
> +	if (pdt->function_number == 0x01)
> +		data->f01_container = fn;
>
>   	return 0;
>   }
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status
  2014-01-24  0:00                           ` [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status Courtney Cavin
  2014-01-24  0:00                             ` [PATCH 15/15] Input: synaptics-rmi4 - correct RMI4 spec url Courtney Cavin
@ 2014-02-04 23:10                             ` Christopher Heiny
  2014-02-05  2:40                               ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:10 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
>   drivers/input/rmi4/rmi_f01.c | 16 +++++++++-------
>   1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
> index 22b57f2..06fc5bc 100644
> --- a/drivers/input/rmi4/rmi_f01.c
> +++ b/drivers/input/rmi4/rmi_f01.c
> @@ -318,13 +318,15 @@ static int rmi_f01_initialize(struct rmi_function *fn)
>   	ctrl_base_addr += sizeof(u8);
>
>   	data->interrupt_enable_addr = ctrl_base_addr;
> -	error = rmi_read_block(rmi_dev, ctrl_base_addr,
> -				data->device_control.interrupt_enable,
> -				sizeof(u8) * (data->num_of_irq_regs));
> -	if (error < 0) {
> -		dev_err(&fn->dev,
> -			"Failed to read F01 control interrupt enable register.\n");
> -		goto error_exit;
> +	if (data->num_of_irq_regs > 0) {
> +		error = rmi_read_block(rmi_dev, ctrl_base_addr,
> +					data->device_control.interrupt_enable,
> +					sizeof(u8) * (data->num_of_irq_regs));
> +		if (error < 0) {
> +			dev_err(&fn->dev,
> +				"Failed to read F01 control interrupt enable register.\n");
> +			goto error_exit;
> +		}

If we don't know the number of IRQ registers at this point, we're 
basically screwed, as most of the control register positions will be 
known correctly.  The previously submitted IRQ counting patch ensures 
that number of IRQ registers is know by this point - if they aren't, 
then we should probably fail entirely rather than just muddling along.

>   	}
>
>   	ctrl_base_addr += data->num_of_irq_regs;
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 15/15] Input: synaptics-rmi4 - correct RMI4 spec url
  2014-01-24  0:00                             ` [PATCH 15/15] Input: synaptics-rmi4 - correct RMI4 spec url Courtney Cavin
@ 2014-02-04 23:10                               ` Christopher Heiny
  2014-02-06  1:14                                 ` Dmitry Torokhov
  0 siblings, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-04 23:10 UTC (permalink / raw)
  To: Courtney Cavin, linux-input; +Cc: dmitry.torokhov

On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> Cc: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>

Acked-by: Christopher Heiny <cheiny@synaptics.com>

> ---
>   drivers/input/rmi4/rmi_driver.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 9d8d6ec..9d845a4 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -7,7 +7,7 @@
>    * The RMI4 specification can be found here (URL split for line length):
>    *
>    * http://www.synaptics.com/sites/default/files/
> - *      511-000136-01-Rev-E-RMI4%20Intrfacing%20Guide.pdf
> + *      511-000136-01-Rev-E-RMI4-Interfacing-Guide.pdf
>    *
>    * 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
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
  2014-02-04 23:08   ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Christopher Heiny
@ 2014-02-05  2:26     ` Courtney Cavin
  2014-02-06  1:09     ` Dmitry Torokhov
  1 sibling, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:26 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:08:12AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> >   drivers/input/rmi4/rmi_bus.c    |  4 ++--
> >   drivers/input/rmi4/rmi_bus.h    |  2 +-
> >   drivers/input/rmi4/rmi_driver.c | 17 ++++++++++++-----
> >   drivers/input/rmi4/rmi_f11.c    |  4 +++-
> >   4 files changed, 18 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> > index 96a76e7..8a939f3 100644
> > --- a/drivers/input/rmi4/rmi_bus.c
> > +++ b/drivers/input/rmi4/rmi_bus.c
> > @@ -37,7 +37,7 @@ static void rmi_release_device(struct device *dev)
> >   	kfree(rmi_dev);
> >   }
> >
> > -struct device_type rmi_device_type = {
> > +static struct device_type rmi_device_type = {
> >   	.name		= "rmi_sensor",
> >   	.release	= rmi_release_device,
> >   };
> 
> This struct is used by diagnostic modules to identify sensor devices, so 
> it cannot be static.
> 

Why is this not exposed in a header file then?  It does not appear to be
needed by anything in-tree, so I don't see a reason for keeping it in
the global namespace.  Especially if it isn't exposed anywhere.

> > @@ -145,7 +145,7 @@ static void rmi_release_function(struct device *dev)
> >   	kfree(fn);
> >   }
> >
> > -struct device_type rmi_function_type = {
> > +static struct device_type rmi_function_type = {
> >   	.name		= "rmi_function",
> >   	.release	= rmi_release_function,
> >   };
> 
> This struct is used by diagnostic modules to identify function devices, 
> so it cannot be static.
> 

Same.

> > diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
> > index decb479..2bad2ed 100644
> > --- a/drivers/input/rmi4/rmi_bus.h
> > +++ b/drivers/input/rmi4/rmi_bus.h
> > @@ -103,7 +103,7 @@ int __must_check __rmi_register_function_handler(struct rmi_function_handler *,
> >   #define rmi_register_function_handler(handler) \
> >   	__rmi_register_function_handler(handler, THIS_MODULE, KBUILD_MODNAME)
> >
> > -void rmi_unregister_function_handler(struct rmi_function_handler *);
> > +void rmi_unregister_function_handler(struct rmi_function_handler *handler);
> >
> >   /**
> >    * struct rmi_driver - driver for an RMI4 sensor on the RMI bus.
> > diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> > index 3483e5b..5c6379c 100644
> > --- a/drivers/input/rmi4/rmi_driver.c
> > +++ b/drivers/input/rmi4/rmi_driver.c
> > @@ -32,6 +32,8 @@
> >   #include "rmi_bus.h"
> >   #include "rmi_driver.h"
> >
> > +#define RMI4_MAX_N_IRQS 256
> 
> I see what you're trying to do here, but the IRQ counting patch 
> submitted previously does this in a more efficient way, though at a 
> slight cost in compute time during initialization.
> 

What I'm trying to do here is get rid of dynamic stack allocation in
process_one_interrupt(), which sparse seems to hate.  Ideally though these
bitmaps should all be statically sized.  It would be very unusual to have
enough functions & IRQs within each function to reach 256 IRQs.

> > +
> >   #define HAS_NONSTANDARD_PDT_MASK 0x40
> >   #define RMI4_MAX_PAGE 0xff
> >   #define RMI4_PAGE_SIZE 0x100
> > @@ -260,7 +262,7 @@ static void process_one_interrupt(struct rmi_function *fn,
> >   		unsigned long *irq_status, struct rmi_driver_data *data)
> >   {
> >   	struct rmi_function_handler *fh;
> > -	DECLARE_BITMAP(irq_bits, data->num_of_irq_regs);
> > +	DECLARE_BITMAP(irq_bits, RMI4_MAX_N_IRQS);
> >
> >   	if (!fn || !fn->dev.driver)
> >   		return;
> > @@ -325,7 +327,7 @@ static int process_interrupt_requests(struct rmi_device *rmi_dev)
> >   static int rmi_driver_set_input_params(struct rmi_device *rmi_dev,
> >   				struct input_dev *input)
> >   {
> > -	// FIXME: set up parent
> > +	/* FIXME: set up parent */
> >   	input->name = SYNAPTICS_INPUT_DEVICE_NAME;
> >   	input->id.vendor  = SYNAPTICS_VENDOR_ID;
> >   	input->id.bustype = BUS_RMI;
> > @@ -466,7 +468,7 @@ static int rmi_driver_reset_handler(struct rmi_device *rmi_dev)
> >   /*
> >    * Construct a function's IRQ mask. This should be called once and stored.
> >    */
> > -int rmi_driver_irq_get_mask(struct rmi_device *rmi_dev,
> > +static int rmi_driver_irq_get_mask(struct rmi_device *rmi_dev,
> >   		struct rmi_function *fn) {
> >   	int i;
> >   	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> > @@ -665,7 +667,7 @@ static int rmi_scan_pdt(struct rmi_device *rmi_dev)
> >   					pdt_entry.function_number, page);
> >   			done = false;
> >
> > -			// XXX need to make sure we create F01 first...
> > +			/* XXX need to make sure we create F01 first... */
> >   			retval = create_function(rmi_dev,
> >   					&pdt_entry, &irq_count, page_start);
> >
> > @@ -674,6 +676,11 @@ static int rmi_scan_pdt(struct rmi_device *rmi_dev)
> >   		}
> >   		done = done || data->f01_bootloader_mode;
> >   	}
> > +	if (irq_count > RMI4_MAX_N_IRQS) {
> > +		dev_err(dev, "Too many IRQs specified\n");
> > +		retval = -EINVAL;
> > +		goto error_exit;
> > +	}
> >   	data->irq_count = irq_count;
> >   	data->num_of_irq_regs = (irq_count + 7) / 8;
> >   	dev_dbg(dev, "%s: Done with PDT scan.\n", __func__);
> > @@ -953,7 +960,7 @@ static int rmi_driver_probe(struct device *dev)
> >   	return retval;
> >   }
> >
> > -struct rmi_driver rmi_physical_driver = {
> > +static struct rmi_driver rmi_physical_driver = {
> >   	.driver = {
> >   		.owner	= THIS_MODULE,
> >   		.name	= "rmi_physical",
> > diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> > index c2be9de..4e0a296 100644
> > --- a/drivers/input/rmi4/rmi_f11.c
> > +++ b/drivers/input/rmi4/rmi_f11.c
> > @@ -610,6 +610,8 @@ static void rmi_f11_abs_pos_report(struct f11_data *f11,
> >   	int temp;
> >   	u8 abs_base = n_finger * RMI_F11_ABS_BYTES;
> >
> > +	orient = z = w_min = w_max = 0;
> > +
> >   	if (finger_state) {
> >   		x = (data->abs_pos[abs_base] << 4) |
> >   			(data->abs_pos[abs_base + 2] & 0x0F);
> > @@ -1413,7 +1415,7 @@ static int rmi_f11_config(struct rmi_function *fn)
> >   	return 0;
> >   }
> >
> > -int rmi_f11_attention(struct rmi_function *fn,
> > +static int rmi_f11_attention(struct rmi_function *fn,
> >   						unsigned long *irq_bits)
> >   {
> >   	struct rmi_device *rmi_dev = fn->rmi_dev;
> >
> 

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

* Re: [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory
  2014-02-04 23:08     ` [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory Christopher Heiny
@ 2014-02-05  2:27       ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:27 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:08:19AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> 
> This is redundant with patch code submitted 2013/01/22.  See here:
>      http://www.spinics.net/lists/linux-input/msg29280.html
> 
> and in any case, Dmitry has submitted a more thorough tidy up here:
>      http://www.spinics.net/lists/linux-input/msg29323.html
> 

Neither of these two patches resolve the issue here, which is that you
should not directly free the memory allocated by devm_kzalloc() in
rmi_f01_alloc_memory().

> > ---
> >   drivers/input/rmi4/rmi_f01.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
> > index cf1081f..98bc65a9 100644
> > --- a/drivers/input/rmi4/rmi_f01.c
> > +++ b/drivers/input/rmi4/rmi_f01.c
> > @@ -390,7 +390,7 @@ static int rmi_f01_initialize(struct rmi_function *fn)
> >   	return 0;
> >
> >    error_exit:
> > -	kfree(data);
> > +	devm_kfree(&fn->dev, data);
> >   	return error;
> >   }
> >
> >

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

* Re: [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly
  2014-02-04 23:08       ` [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly Christopher Heiny
@ 2014-02-05  2:28         ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:28 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:08:24AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > Devices use a kobject to manage references, do not delete the memory
> > while still referenced.  Instead, call put_device() to release the
> > reference.
> 
> This is an interesting idea, but it should be done consistently for all 
> the device types.
> 

This is not an idea, just a bugfix.  The kernel will segfault on failure
in which results in the kfree().  I didn't notice any other
device_register() calls which have this particular issue, but I might
have missed something.

> >
> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> >   drivers/input/rmi4/rmi_bus.c    | 8 +++++---
> >   drivers/input/rmi4/rmi_driver.c | 6 +-----
> >   2 files changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> > index 8a939f3..cd7bfbd 100644
> > --- a/drivers/input/rmi4/rmi_bus.c
> > +++ b/drivers/input/rmi4/rmi_bus.c
> > @@ -94,8 +94,7 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
> >   		return -EINVAL;
> >   	}
> >
> > -	rmi_dev = devm_kzalloc(xport->dev,
> > -				sizeof(struct rmi_device), GFP_KERNEL);
> > +	rmi_dev = kzalloc(sizeof(struct rmi_device), GFP_KERNEL);
> >   	if (!rmi_dev)
> >   		return -ENOMEM;
> >
> > @@ -112,8 +111,10 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
> >   	rmi_physical_setup_debugfs(rmi_dev);
> >
> >   	error = device_register(&rmi_dev->dev);
> > -	if (error)
> > +	if (error) {
> > +		put_device(&rmi_dev->dev);
> >   		return error;
> > +	}
> >
> >   	dev_dbg(xport->dev, "%s: Registered %s as %s.\n", __func__,
> >   		pdata->sensor_name, dev_name(&rmi_dev->dev));
> > @@ -240,6 +241,7 @@ int rmi_register_function(struct rmi_function *fn)
> >   		dev_err(&rmi_dev->dev,
> >   			"Failed device_register function device %s\n",
> >   			dev_name(&fn->dev));
> > +		put_device(&fn->dev);
> >   		goto error_exit;
> >   	}
> >
> > diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> > index 5c6379c..4965589 100644
> > --- a/drivers/input/rmi4/rmi_driver.c
> > +++ b/drivers/input/rmi4/rmi_driver.c
> > @@ -557,15 +557,11 @@ static int create_function(struct rmi_device *rmi_dev,
> >
> >   	error = rmi_register_function(fn);
> >   	if (error)
> > -		goto err_free_mem;
> > +		return error;
> >
> >   	list_add_tail(&fn->node, &data->function_list);
> >
> >   	return 0;
> > -
> > -err_free_mem:
> > -	kfree(fn);
> > -	return error;
> >   }
> >
> >   /*
> >

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

* Re: [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data
  2014-02-04 23:08         ` [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data Christopher Heiny
@ 2014-02-05  2:30           ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:30 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:08:29AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > The driver/device already has a name, no need for another one.
> 
> This is extremely useful in initial system bring up on systems with more 
> than one RMI4 sensor.  We'd prefer to keep this.
> 

While I understand that this may be useful, IMO it is the wrong way to do
things.  Instead, one should name the devices something useful rather
than "sensor%02d".  Then all the dev_(err|dbg) printouts would already
have the name in the log.

> >
> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> >   drivers/input/rmi4/rmi_bus.c    | 4 ++--
> >   drivers/input/rmi4/rmi_driver.c | 7 ++-----
> >   drivers/input/rmi4/rmi_f11.c    | 3 +--
> >   drivers/input/rmi4/rmi_i2c.c    | 3 +--
> >   include/linux/rmi.h             | 4 ----
> >   5 files changed, 6 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> > index cd7bfbd..fd14acb 100644
> > --- a/drivers/input/rmi4/rmi_bus.c
> > +++ b/drivers/input/rmi4/rmi_bus.c
> > @@ -116,8 +116,8 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
> >   		return error;
> >   	}
> >
> > -	dev_dbg(xport->dev, "%s: Registered %s as %s.\n", __func__,
> > -		pdata->sensor_name, dev_name(&rmi_dev->dev));
> > +	dev_dbg(xport->dev, "%s: Registered %s\n", __func__,
> > +		dev_name(&rmi_dev->dev));
> >
> >   	return 0;
> >   }
> > diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> > index 4965589..5fb582c 100644
> > --- a/drivers/input/rmi4/rmi_driver.c
> > +++ b/drivers/input/rmi4/rmi_driver.c
> > @@ -531,12 +531,10 @@ static int create_function(struct rmi_device *rmi_dev,
> >   {
> >   	struct device *dev = &rmi_dev->dev;
> >   	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> > -	struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
> >   	struct rmi_function *fn;
> >   	int error;
> >
> > -	dev_dbg(dev, "Initializing F%02X for %s.\n",
> > -		pdt->function_number, pdata->sensor_name);
> > +	dev_dbg(dev, "Initializing F%02X\n", pdt->function_number);
> >
> >   	fn = kzalloc(sizeof(struct rmi_function), GFP_KERNEL);
> >   	if (!fn) {
> > @@ -822,8 +820,7 @@ static int rmi_driver_probe(struct device *dev)
> >
> >   	retval = rmi_scan_pdt(rmi_dev);
> >   	if (retval) {
> > -		dev_err(dev, "PDT scan for %s failed with code %d.\n",
> > -			pdata->sensor_name, retval);
> > +		dev_err(dev, "PDT scan failed with code %d.\n", retval);
> >   		goto err_free_data;
> >   	}
> >
> > diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> > index 4e0a296..553afd8 100644
> > --- a/drivers/input/rmi4/rmi_f11.c
> > +++ b/drivers/input/rmi4/rmi_f11.c
> > @@ -1182,8 +1182,7 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> >   	struct f11_2d_sensor *sensor;
> >   	u8 buf;
> >
> > -	dev_dbg(&fn->dev, "Initializing F11 values for %s.\n",
> > -		 pdata->sensor_name);
> > +	dev_dbg(&fn->dev, "Initializing F11 values.\n");
> >
> >   	/*
> >   	** init instance data, fill in values and create any sysfs files
> > diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
> > index 24d8a04..910f05c 100644
> > --- a/drivers/input/rmi4/rmi_i2c.c
> > +++ b/drivers/input/rmi4/rmi_i2c.c
> > @@ -196,8 +196,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
> >   		return -EINVAL;
> >   	}
> >
> > -	dev_dbg(&client->dev, "Probing %s at %#02x (GPIO %d).\n",
> > -		pdata->sensor_name ? pdata->sensor_name : "-no name-",
> > +	dev_dbg(&client->dev, "Probing %#02x (GPIO %d).\n",
> >   		client->addr, pdata->attn_gpio);
> >
> >   	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
> > diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> > index 735e978..65b59b5 100644
> > --- a/include/linux/rmi.h
> > +++ b/include/linux/rmi.h
> > @@ -194,8 +194,6 @@ struct rmi_device_platform_data_spi {
> >   /**
> >    * struct rmi_device_platform_data - system specific configuration info.
> >    *
> > - * @sensor_name - this is used for various diagnostic messages.
> > - *
> >    * @firmware_name - if specified will override default firmware name,
> >    * for reflashing.
> >    *
> > @@ -247,8 +245,6 @@ struct rmi_device_platform_data_spi {
> >    * functions.
> >    */
> >   struct rmi_device_platform_data {
> > -	char *sensor_name;	/* Used for diagnostics. */
> > -
> >   	int attn_gpio;
> >   	enum rmi_attn_polarity attn_polarity;
> >   	bool level_triggered;
> >

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

* Re: [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling
  2014-02-04 23:08           ` [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling Christopher Heiny
@ 2014-02-05  2:31             ` Courtney Cavin
  2014-02-06  9:28               ` Linus Walleij
  2014-02-06 20:05               ` Christopher Heiny
  0 siblings, 2 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:31 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:08:35AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > Since all the configuration needed for an irq can be provided in other
> > ways, remove all gpio->irq functionality. This cleans up the code quite
> > a bit.
>
> In certain diagnostic modes, we need to be able to release the IRQ so
> the GPIO can be monitored from userspace.  This patch removes that
> capability.
>

Polling a GPIO from userspace is poor design regardless of the use-case, if
you ask me.  It certainly doesn't motivate the extra gpio<->IRQ code.

> > This also gets rid of polling functionality, as this should be done
> > elsewhere if absolutely needed.
>
> As mentioned in previous patch discussions, the polling functionality is
> quite useful during new system integration, so we need to retain that.
> If you have a proposal for where else it could be done, we'd certainly
> entertain a patch that implements that.

Do you actually have systems that have these hooked up to GPIOs without
IRQ support?

Regardless, if this is the case, implementing a GPIO polling IRQ chip
should be possible, if extremely ugly.

Linus may have some comments in this area, though.  Linus?

>
>                                         Thanks,
>                                                 Chris
>
> >
> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> >   drivers/input/rmi4/rmi_driver.c | 143 +++++-----------------------------------
> >   drivers/input/rmi4/rmi_driver.h |   7 --
> >   drivers/input/rmi4/rmi_i2c.c    |  24 +------
> >   include/linux/rmi.h             |  31 +--------
> >   4 files changed, 20 insertions(+), 185 deletions(-)
> >
> > diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> > index 5fb582c..780742f 100644
> > --- a/drivers/input/rmi4/rmi_driver.c
> > +++ b/drivers/input/rmi4/rmi_driver.c
> > @@ -20,7 +20,6 @@
> >   #include <linux/delay.h>
> >   #include <linux/device.h>
> >   #include <linux/fs.h>
> > -#include <linux/gpio.h>
> >   #include <linux/kconfig.h>
> >   #include <linux/list.h>
> >   #include <linux/module.h>
> > @@ -50,74 +49,17 @@ static irqreturn_t rmi_irq_thread(int irq, void *p)
> >       struct rmi_transport_dev *xport = p;
> >       struct rmi_device *rmi_dev = xport->rmi_dev;
> >       struct rmi_driver *driver = rmi_dev->driver;
> > -     struct rmi_device_platform_data *pdata = xport->dev->platform_data;
> >       struct rmi_driver_data *data;
> >
> >       data = dev_get_drvdata(&rmi_dev->dev);
> > -
> > -     if (IRQ_DEBUG(data))
> > -             dev_dbg(xport->dev, "ATTN gpio, value: %d.\n",
> > -                             gpio_get_value(pdata->attn_gpio));
> > -
> > -     if (gpio_get_value(pdata->attn_gpio) == pdata->attn_polarity) {
> > -             data->attn_count++;
> > -             if (driver && driver->irq_handler && rmi_dev)
> > -                     driver->irq_handler(rmi_dev, irq);
> > -     }
> > +     if (driver && driver->irq_handler && rmi_dev)
> > +             driver->irq_handler(rmi_dev, irq);
> >
> >       return IRQ_HANDLED;
> >   }
> >
> >   static int process_interrupt_requests(struct rmi_device *rmi_dev);
> >
> > -static void rmi_poll_work(struct work_struct *work)
> > -{
> > -     struct rmi_driver_data *data =
> > -                     container_of(work, struct rmi_driver_data, poll_work);
> > -     struct rmi_device *rmi_dev = data->rmi_dev;
> > -
> > -     process_interrupt_requests(rmi_dev);
> > -}
> > -
> > -/*
> > - * This is the timer function for polling - it simply has to schedule work
> > - * and restart the timer.
> > - */
> > -static enum hrtimer_restart rmi_poll_timer(struct hrtimer *timer)
> > -{
> > -     struct rmi_driver_data *data =
> > -                     container_of(timer, struct rmi_driver_data, poll_timer);
> > -
> > -     if (!data->enabled)
> > -             return HRTIMER_NORESTART;
> > -     if (!work_pending(&data->poll_work))
> > -             schedule_work(&data->poll_work);
> > -     hrtimer_start(&data->poll_timer, data->poll_interval, HRTIMER_MODE_REL);
> > -     return HRTIMER_NORESTART;
> > -}
> > -
> > -static int enable_polling(struct rmi_device *rmi_dev)
> > -{
> > -     struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> > -
> > -     dev_dbg(&rmi_dev->dev, "Polling enabled.\n");
> > -     INIT_WORK(&data->poll_work, rmi_poll_work);
> > -     hrtimer_init(&data->poll_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> > -     data->poll_timer.function = rmi_poll_timer;
> > -     hrtimer_start(&data->poll_timer, data->poll_interval, HRTIMER_MODE_REL);
> > -
> > -     return 0;
> > -}
> > -
> > -static void disable_polling(struct rmi_device *rmi_dev)
> > -{
> > -     struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> > -
> > -     dev_dbg(&rmi_dev->dev, "Polling disabled.\n");
> > -     hrtimer_cancel(&data->poll_timer);
> > -     cancel_work_sync(&data->poll_work);
> > -}
> > -
> >   static void disable_sensor(struct rmi_device *rmi_dev)
> >   {
> >       struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> > @@ -125,9 +67,6 @@ static void disable_sensor(struct rmi_device *rmi_dev)
> >       if (!data->enabled)
> >               return;
> >
> > -     if (!data->irq)
> > -             disable_polling(rmi_dev);
> > -
> >       if (rmi_dev->xport->ops->disable_device)
> >               rmi_dev->xport->ops->disable_device(rmi_dev->xport);
> >
> > @@ -155,20 +94,14 @@ static int enable_sensor(struct rmi_device *rmi_dev)
> >       }
> >
> >       xport = rmi_dev->xport;
> > -     if (data->irq) {
> > -             retval = request_threaded_irq(data->irq,
> > -                             xport->hard_irq ? xport->hard_irq : NULL,
> > -                             xport->irq_thread ?
> > -                                     xport->irq_thread : rmi_irq_thread,
> > -                             data->irq_flags,
> > -                             dev_name(&rmi_dev->dev), xport);
> > -             if (retval)
> > -                     return retval;
> > -     } else {
> > -             retval = enable_polling(rmi_dev);
> > -             if (retval < 0)
> > -                     return retval;
> > -     }
> > +     retval = request_threaded_irq(data->irq,
> > +                     xport->hard_irq ? xport->hard_irq : NULL,
> > +                     xport->irq_thread ?
> > +                             xport->irq_thread : rmi_irq_thread,
> > +                     IRQF_ONESHOT,
> > +                     dev_name(&rmi_dev->dev), xport);
> > +     if (retval)
> > +             return retval;
> >
> >       data->enabled = true;
> >
> > @@ -751,16 +684,9 @@ static SIMPLE_DEV_PM_OPS(rmi_driver_pm, rmi_driver_suspend, rmi_driver_resume);
> >   static int rmi_driver_remove(struct device *dev)
> >   {
> >       struct rmi_device *rmi_dev = to_rmi_device(dev);
> > -     const struct rmi_device_platform_data *pdata =
> > -                                     to_rmi_platform_data(rmi_dev);
> > -     const struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> > -
> >       disable_sensor(rmi_dev);
> >       rmi_free_function_list(rmi_dev);
> >
> > -     if (data->gpio_held)
> > -             gpio_free(pdata->attn_gpio);
> > -
> >       return 0;
> >   }
> >
> > @@ -895,51 +821,12 @@ static int rmi_driver_probe(struct device *dev)
> >               mutex_init(&data->suspend_mutex);
> >       }
> >
> > -     if (gpio_is_valid(pdata->attn_gpio)) {
> > -             static const char GPIO_LABEL[] = "attn";
> > -             unsigned long gpio_flags = GPIOF_DIR_IN;
> > -
> > -             data->irq = gpio_to_irq(pdata->attn_gpio);
> > -             if (pdata->level_triggered) {
> > -                     data->irq_flags = IRQF_ONESHOT |
> > -                             ((pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH)
> > -                             ? IRQF_TRIGGER_HIGH : IRQF_TRIGGER_LOW);
> > -             } else {
> > -                     data->irq_flags =
> > -                             (pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH)
> > -                             ? IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
> > -             }
> > +     data->irq = pdata->irq;
> > +     if (data->irq < 0) {
> > +             dev_err(dev, "Failed to get attn IRQ.\n");
> > +             retval = data->irq;
> > +             goto err_free_data;
> >
> > -             if (IS_ENABLED(CONFIG_RMI4_DEV))
> > -                     gpio_flags |= GPIOF_EXPORT;
> > -
> > -             retval = gpio_request_one(pdata->attn_gpio, gpio_flags,
> > -                                       GPIO_LABEL);
> > -             if (retval) {
> > -                     dev_warn(dev, "WARNING: Failed to request ATTN gpio %d, code=%d.\n",
> > -                              pdata->attn_gpio, retval);
> > -                     retval = 0;
> > -             } else {
> > -                     dev_info(dev, "Obtained ATTN gpio %d.\n",
> > -                                     pdata->attn_gpio);
> > -                     data->gpio_held = true;
> > -                     if (IS_ENABLED(CONFIG_RMI4_DEV)) {
> > -                             retval = gpio_export_link(dev,
> > -                                             GPIO_LABEL, pdata->attn_gpio);
> > -                             if (retval) {
> > -                                     dev_warn(dev,
> > -                                             "WARNING: Failed to symlink ATTN gpio!\n");
> > -                                     retval = 0;
> > -                             } else {
> > -                                     dev_info(dev, "Exported ATTN gpio %d.",
> > -                                             pdata->attn_gpio);
> > -                             }
> > -                     }
> > -             }
> > -     } else {
> > -             data->poll_interval = ktime_set(0,
> > -                     (pdata->poll_interval_ms ? pdata->poll_interval_ms :
> > -                     DEFAULT_POLL_INTERVAL_MS) * 1000 * 1000);
> >       }
> >
> >       if (data->f01_container->dev.driver) {
> > diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
> > index 4f44a54..aef5521 100644
> > --- a/drivers/input/rmi4/rmi_driver.h
> > +++ b/drivers/input/rmi4/rmi_driver.h
> > @@ -39,9 +39,7 @@ struct rmi_driver_data {
> >
> >       u32 attn_count;
> >       u32 irq_debug;  /* Should be bool, but debugfs wants u32 */
> > -     bool gpio_held;
> >       int irq;
> > -     int irq_flags;
> >       int num_of_irq_regs;
> >       int irq_count;
> >       unsigned long *irq_status;
> > @@ -50,11 +48,6 @@ struct rmi_driver_data {
> >       bool irq_stored;
> >       struct mutex irq_mutex;
> >
> > -     /* Following are used when polling. */
> > -     struct hrtimer poll_timer;
> > -     struct work_struct poll_work;
> > -     ktime_t poll_interval;
> > -
> >       struct mutex pdt_mutex;
> >       u8 pdt_props;
> >       u8 bsr;
> > diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
> > index 910f05c..aebf974 100644
> > --- a/drivers/input/rmi4/rmi_i2c.c
> > +++ b/drivers/input/rmi4/rmi_i2c.c
> > @@ -196,8 +196,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
> >               return -EINVAL;
> >       }
> >
> > -     dev_dbg(&client->dev, "Probing %#02x (GPIO %d).\n",
> > -             client->addr, pdata->attn_gpio);
> > +     dev_dbg(&client->dev, "Probing %#02x.\n", client->addr);
> >
> >       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
> >               dev_err(&client->dev,
> > @@ -205,15 +204,6 @@ static int rmi_i2c_probe(struct i2c_client *client,
> >               return -ENODEV;
> >       }
> >
> > -     if (pdata->gpio_config) {
> > -             retval = pdata->gpio_config(pdata->gpio_data, true);
> > -             if (retval < 0) {
> > -                     dev_err(&client->dev, "Failed to configure GPIOs, code: %d.\n",
> > -                             retval);
> > -                     return retval;
> > -             }
> > -     }
> > -
> >       rmi_i2c = devm_kzalloc(&client->dev, sizeof(struct rmi_i2c_xport),
> >                               GFP_KERNEL);
> >       if (!rmi_i2c)
> > @@ -240,7 +230,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
> >       if (retval) {
> >               dev_err(&client->dev, "Failed to register transport driver at 0x%.2X.\n",
> >                       client->addr);
> > -             goto err_gpio;
> > +             goto err;
> >       }
> >
> >       i2c_set_clientdata(client, rmi_i2c);
> > @@ -249,24 +239,16 @@ static int rmi_i2c_probe(struct i2c_client *client,
> >                       client->addr);
> >       return 0;
> >
> > -err_gpio:
> > -     if (pdata->gpio_config)
> > -             pdata->gpio_config(pdata->gpio_data, false);
> > -
> > +err:
> >       return retval;
> >   }
> >
> >   static int rmi_i2c_remove(struct i2c_client *client)
> >   {
> > -     const struct rmi_device_platform_data *pdata =
> > -                             dev_get_platdata(&client->dev);
> >       struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client);
> >
> >       rmi_unregister_transport_device(&rmi_i2c->xport);
> >
> > -     if (pdata->gpio_config)
> > -             pdata->gpio_config(pdata->gpio_data, false);
> > -
> >       return 0;
> >   }
> >
> > diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> > index 65b59b5..326e741 100644
> > --- a/include/linux/rmi.h
> > +++ b/include/linux/rmi.h
> > @@ -23,11 +23,6 @@
> >   #include <linux/wait.h>
> >   #include <linux/debugfs.h>
> >
> > -enum rmi_attn_polarity {
> > -     RMI_ATTN_ACTIVE_LOW = 0,
> > -     RMI_ATTN_ACTIVE_HIGH = 1
> > -};
> > -
> >   /**
> >    * struct rmi_f11_axis_alignment - target axis alignment
> >    * @swap_axes: set to TRUE if desired to swap x- and y-axis
> > @@ -194,25 +189,10 @@ struct rmi_device_platform_data_spi {
> >   /**
> >    * struct rmi_device_platform_data - system specific configuration info.
> >    *
> > + * @irq - attention IRQ
> >    * @firmware_name - if specified will override default firmware name,
> >    * for reflashing.
> >    *
> > - * @attn_gpio - the index of a GPIO that will be used to provide the ATTN
> > - * interrupt from the touch sensor.
> > - * @attn_polarity - indicates whether ATTN is active high or low.
> > - * @level_triggered - by default, the driver uses edge triggered interrupts.
> > - * However, this can cause problems with suspend/resume on some platforms.  In
> > - * that case, set this to 1 to use level triggered interrupts.
> > - * @gpio_config - a routine that will be called when the driver is loaded to
> > - * perform any platform specific GPIO configuration, and when it is unloaded
> > - * for GPIO de-configuration.  This is typically used to configure the ATTN
> > - * GPIO and the I2C or SPI pins, if necessary.
> > - * @gpio_data - platform specific data to be passed to the GPIO configuration
> > - * function.
> > - *
> > - * @poll_interval_ms - the time in milliseconds between reads of the interrupt
> > - * status register.  This is ignored if attn_gpio is non-zero.
> > - *
> >    * @reset_delay_ms - after issuing a reset command to the touch sensor, the
> >    * driver waits a few milliseconds to give the firmware a chance to
> >    * to re-initialize.  You can override the default wait period here.
> > @@ -245,14 +225,7 @@ struct rmi_device_platform_data_spi {
> >    * functions.
> >    */
> >   struct rmi_device_platform_data {
> > -     int attn_gpio;
> > -     enum rmi_attn_polarity attn_polarity;
> > -     bool level_triggered;
> > -     void *gpio_data;
> > -     int (*gpio_config)(void *gpio_data, bool configure);
> > -
> > -     int poll_interval_ms;
> > -
> > +     int irq;
> >       int reset_delay_ms;
> >
> >       struct rmi_device_platform_data_spi spi_data;
> >

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

* Re: [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks
  2014-02-04 23:09             ` [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks Christopher Heiny
@ 2014-02-05  2:32               ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:32 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:09:45AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > These are unnecessary and ugly. Remove them, and all related code.
> 
> Ugly though they might be, on a number of hardware implementations they 
> are quite necessary in order to provide hooks to handle hardware 
> specific suspend/resume activities relating to power management and 
> device configuration.  Your subsequent patch relating to the VIO/VDD 
> regulators might eventually render these obsolete, but in the meantime 
> let's not kill them off while they're still useful.
> 

Could you provide an example use-case where existing kernel frameworks
(e.g. regulators, pm) do not provide the necessary capabilities?

> >
> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> >   drivers/input/rmi4/rmi_driver.c | 57 ++---------------------------------------
> >   drivers/input/rmi4/rmi_driver.h | 10 --------
> >   include/linux/rmi.h             | 20 ---------------
> >   3 files changed, 2 insertions(+), 85 deletions(-)
> >
> > diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> > index 780742f..691b6fb 100644
> > --- a/drivers/input/rmi4/rmi_driver.c
> > +++ b/drivers/input/rmi4/rmi_driver.c
> > @@ -621,60 +621,16 @@ error_exit:
> >   #ifdef CONFIG_PM_SLEEP
> >   static int rmi_driver_suspend(struct device *dev)
> >   {
> > -	struct rmi_driver_data *data;
> > -	int retval = 0;
> >   	struct rmi_device *rmi_dev = to_rmi_device(dev);
> >
> > -	data = dev_get_drvdata(&rmi_dev->dev);
> > -
> > -	mutex_lock(&data->suspend_mutex);
> > -
> > -	if (data->pre_suspend) {
> > -		retval = data->pre_suspend(data->pm_data);
> > -		if (retval)
> > -			goto exit;
> > -	}
> > -
> >   	disable_sensor(rmi_dev);
> > -
> > -	if (data->post_suspend)
> > -		retval = data->post_suspend(data->pm_data);
> > -
> > -exit:
> > -	mutex_unlock(&data->suspend_mutex);
> > -	return retval;
> > +	return 0;
> >   }
> >
> >   static int rmi_driver_resume(struct device *dev)
> >   {
> > -	struct rmi_driver_data *data;
> > -	int retval = 0;
> >   	struct rmi_device *rmi_dev = to_rmi_device(dev);
> > -
> > -	data = dev_get_drvdata(&rmi_dev->dev);
> > -	mutex_lock(&data->suspend_mutex);
> > -
> > -	if (data->pre_resume) {
> > -		retval = data->pre_resume(data->pm_data);
> > -		if (retval)
> > -			goto exit;
> > -	}
> > -
> > -	retval = enable_sensor(rmi_dev);
> > -	if (retval)
> > -		goto exit;
> > -
> > -
> > -	if (data->post_resume) {
> > -		retval = data->post_resume(data->pm_data);
> > -		if (retval)
> > -			goto exit;
> > -	}
> > -
> > -	data->suspended = false;
> > -exit:
> > -	mutex_unlock(&data->suspend_mutex);
> > -	return retval;
> > +	return enable_sensor(rmi_dev);
> >   }
> >
> >   #endif /* CONFIG_PM_SLEEP */
> > @@ -811,15 +767,6 @@ static int rmi_driver_probe(struct device *dev)
> >   		retval = -ENOMEM;
> >   		goto err_free_data;
> >   	}
> > -	if (IS_ENABLED(CONFIG_PM)) {
> > -		data->pm_data = pdata->pm_data;
> > -		data->pre_suspend = pdata->pre_suspend;
> > -		data->post_suspend = pdata->post_suspend;
> > -		data->pre_resume = pdata->pre_resume;
> > -		data->post_resume = pdata->post_resume;
> > -
> > -		mutex_init(&data->suspend_mutex);
> > -	}
> >
> >   	data->irq = pdata->irq;
> >   	if (data->irq < 0) {
> > diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
> > index aef5521..f28166f 100644
> > --- a/drivers/input/rmi4/rmi_driver.h
> > +++ b/drivers/input/rmi4/rmi_driver.h
> > @@ -53,16 +53,6 @@ struct rmi_driver_data {
> >   	u8 bsr;
> >
> >   	bool enabled;
> > -#ifdef CONFIG_PM_SLEEP
> > -	bool suspended;
> > -	struct mutex suspend_mutex;
> > -
> > -	void *pm_data;
> > -	int (*pre_suspend) (const void *pm_data);
> > -	int (*post_suspend) (const void *pm_data);
> > -	int (*pre_resume) (const void *pm_data);
> > -	int (*post_resume) (const void *pm_data);
> > -#endif
> >
> >   #ifdef CONFIG_RMI4_DEBUG
> >   	struct dentry *debugfs_delay;
> > diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> > index 326e741..41c2c04 100644
> > --- a/include/linux/rmi.h
> > +++ b/include/linux/rmi.h
> > @@ -204,8 +204,6 @@ struct rmi_device_platform_data_spi {
> >    * @f11_rezero_wait - if non-zero, this is how may milliseconds the F11 2D
> >    * sensor will wait before being be rezeroed on exit from suspend.  If
> >    * this value is zero, the F11 2D sensor will not be rezeroed on resume.
> > - * @pre_suspend - this will be called before any other suspend operations are
> > - * done.
> >    * @power_management - overrides default touch sensor doze mode settings (see
> >    * above)
> >    * @f19_button_map - provide initial input subsystem key mappings for F19.
> > @@ -213,16 +211,6 @@ struct rmi_device_platform_data_spi {
> >    * @gpioled_map - provides initial settings for GPIOs and LEDs controlled by
> >    * F30.
> >    * @f41_button_map - provide initial input subsystem key mappings for F41.
> > - *
> > - * @post_suspend - this will be called after all suspend operations are
> > - * completed.  This is the ONLY safe place to power off an RMI sensor
> > - * during the suspend process.
> > - * @pre_resume - this is called before any other resume operations.  If you
> > - * powered off the RMI4 sensor in post_suspend(), then you MUST power it back
> > - * here, and you MUST wait an appropriate time for the ASIC to come up
> > - * (100ms to 200ms, depending on the sensor) before returning.
> > - * @pm_data - this will be passed to the various (pre|post)_(suspend/resume)
> > - * functions.
> >    */
> >   struct rmi_device_platform_data {
> >   	int irq;
> > @@ -242,14 +230,6 @@ struct rmi_device_platform_data {
> >   #ifdef CONFIG_RMI4_FWLIB
> >   	char *firmware_name;
> >   #endif
> > -
> > -#ifdef	CONFIG_PM
> > -	void *pm_data;
> > -	int (*pre_suspend) (const void *pm_data);
> > -	int (*post_suspend) (const void *pm_data);
> > -	int (*pre_resume) (const void *pm_data);
> > -	int (*post_resume) (const void *pm_data);
> > -#endif
> >   };
> >
> >   /**
> >

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

* Re: [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code
  2014-02-04 23:09               ` [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code Christopher Heiny
@ 2014-02-05  2:33                 ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:33 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:09:54AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > As most of this code was already removed, the remainder does nothing.
> > Remove it.
> 
> Actually, the code does something.  The functionality that it supports 
> is not currently being submitted as patches in order to keep the working 
> set size down.  We're trying to keep the submitted code consistent with 
> the production, since that makes it easier to develop the patches and 
> keeps the patches similar to the code that is used in production.
> 

This is getting tedious.  The problem I'm trying to solve here is the
fact that the code in it's current form is not in an upstreamable state.
What you keep saying is that some other tree depends on this code, so we
can't change any of it.  Either you need to break that dependency, or
you need to abort trying to upstream this code.

> >
> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> >   drivers/input/rmi4/Kconfig      |   1 -
> >   drivers/input/rmi4/rmi_bus.c    | 103 ----------------------------------------
> >   drivers/input/rmi4/rmi_bus.h    |  12 -----
> >   drivers/input/rmi4/rmi_driver.c |   3 --
> >   drivers/input/rmi4/rmi_driver.h |  12 -----
> >   drivers/input/rmi4/rmi_f11.c    |   2 +-
> >   include/linux/rmi.h             |   7 ++-
> >   7 files changed, 4 insertions(+), 136 deletions(-)
> >
> > diff --git a/drivers/input/rmi4/Kconfig b/drivers/input/rmi4/Kconfig
> > index d0c7b6e..22d5599 100644
> > --- a/drivers/input/rmi4/Kconfig
> > +++ b/drivers/input/rmi4/Kconfig
> > @@ -14,7 +14,6 @@ config RMI4_CORE
> >   config RMI4_DEBUG
> >   	bool "RMI4 Debugging"
> >   	depends on RMI4_CORE
> > -	select DEBUG_FS
> >   	help
> >   	  Say Y here to enable debug feature in the RMI4 driver.
> >
> > diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> > index fd14acb..a51e6b4 100644
> > --- a/drivers/input/rmi4/rmi_bus.c
> > +++ b/drivers/input/rmi4/rmi_bus.c
> > @@ -15,14 +15,9 @@
> >   #include <linux/rmi.h>
> >   #include <linux/slab.h>
> >   #include <linux/types.h>
> > -#include <linux/debugfs.h>
> >   #include "rmi_bus.h"
> >   #include "rmi_driver.h"
> >
> > -#ifdef CONFIG_RMI4_DEBUG
> > -static struct dentry *rmi_debugfs_root;
> > -#endif
> > -
> >   /*
> >    * RMI Physical devices
> >    *
> > @@ -47,34 +42,6 @@ bool rmi_is_physical_device(struct device *dev)
> >   	return dev->type == &rmi_device_type;
> >   }
> >
> > -#ifdef CONFIG_RMI4_DEBUG
> > -
> > -static void rmi_physical_setup_debugfs(struct rmi_device *rmi_dev)
> > -{
> > -	rmi_dev->debugfs_root = debugfs_create_dir(dev_name(&rmi_dev->dev),
> > -						   rmi_debugfs_root);
> > -	if (!rmi_dev->debugfs_root)
> > -		dev_warn(&rmi_dev->dev, "Failed to create debugfs root.\n");
> > -}
> > -
> > -static void rmi_physical_teardown_debugfs(struct rmi_device *rmi_dev)
> > -{
> > -	if (rmi_dev->debugfs_root)
> > -		debugfs_remove_recursive(rmi_dev->debugfs_root);
> > -}
> > -
> > -#else
> > -
> > -static void rmi_physical_setup_debugfs(struct rmi_device *rmi_dev)
> > -{
> > -}
> > -
> > -static void rmi_physical_teardown_debugfs(struct rmi_device *rmi_dev)
> > -{
> > -}
> > -
> > -#endif
> > -
> >   /**
> >    * rmi_register_transport_device - register a transport device connection
> >    * on the RMI bus.  Transport drivers provide communication from the devices
> > @@ -108,8 +75,6 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
> >
> >   	xport->rmi_dev = rmi_dev;
> >
> > -	rmi_physical_setup_debugfs(rmi_dev);
> > -
> >   	error = device_register(&rmi_dev->dev);
> >   	if (error) {
> >   		put_device(&rmi_dev->dev);
> > @@ -132,7 +97,6 @@ void rmi_unregister_transport_device(struct rmi_transport_dev *xport)
> >   {
> >   	struct rmi_device *rmi_dev = xport->rmi_dev;
> >
> > -	rmi_physical_teardown_debugfs(rmi_dev);
> >   	device_unregister(&rmi_dev->dev);
> >   }
> >   EXPORT_SYMBOL(rmi_unregister_transport_device);
> > @@ -156,37 +120,6 @@ bool rmi_is_function_device(struct device *dev)
> >   	return dev->type == &rmi_function_type;
> >   }
> >
> > -#ifdef CONFIG_RMI4_DEBUG
> > -
> > -static void rmi_function_setup_debugfs(struct rmi_function *fn)
> > -{
> > -	char dirname[12];
> > -
> > -	snprintf(dirname, sizeof(dirname), "F%02X", fn->fd.function_number);
> > -	fn->debugfs_root = debugfs_create_dir(dirname,
> > -					      fn->rmi_dev->debugfs_root);
> > -	if (!fn->debugfs_root)
> > -		dev_warn(&fn->dev, "Failed to create debugfs dir.\n");
> > -}
> > -
> > -static void rmi_function_teardown_debugfs(struct rmi_function *fn)
> > -{
> > -	if (fn->debugfs_root)
> > -		debugfs_remove_recursive(fn->debugfs_root);
> > -}
> > -
> > -#else
> > -
> > -static void rmi_function_setup_debugfs(struct rmi_function *fn)
> > -{
> > -}
> > -
> > -static void rmi_function_teardown_debugfs(struct rmi_function *fn)
> > -{
> > -}
> > -
> > -#endif
> > -
> >   static int rmi_function_match(struct device *dev, struct device_driver *drv)
> >   {
> >   	struct rmi_function_handler *handler = to_rmi_function_handler(drv);
> > @@ -234,8 +167,6 @@ int rmi_register_function(struct rmi_function *fn)
> >   	fn->dev.type = &rmi_function_type;
> >   	fn->dev.bus = &rmi_bus_type;
> >
> > -	rmi_function_setup_debugfs(fn);
> > -
> >   	error = device_register(&fn->dev);
> >   	if (error) {
> >   		dev_err(&rmi_dev->dev,
> > @@ -250,13 +181,11 @@ int rmi_register_function(struct rmi_function *fn)
> >   	return 0;
> >
> >   error_exit:
> > -	rmi_function_teardown_debugfs(fn);
> >   	return error;
> >   }
> >
> >   void rmi_unregister_function(struct rmi_function *fn)
> >   {
> > -	rmi_function_teardown_debugfs(fn);
> >   	device_unregister(&fn->dev);
> >   }
> >
> > @@ -325,34 +254,6 @@ struct bus_type rmi_bus_type = {
> >   	.name		= "rmi",
> >   };
> >
> > -#ifdef CONFIG_RMI4_DEBUG
> > -
> > -static void rmi_bus_setup_debugfs(void)
> > -{
> > -	rmi_debugfs_root = debugfs_create_dir(rmi_bus_type.name, NULL);
> > -	if (!rmi_debugfs_root)
> > -		pr_err("%s: Failed to create debugfs root\n",
> > -		       __func__);
> > -}
> > -
> > -static void rmi_bus_teardown_debugfs(void)
> > -{
> > -	if (rmi_debugfs_root)
> > -		debugfs_remove_recursive(rmi_debugfs_root);
> > -}
> > -
> > -#else
> > -
> > -static void rmi_bus_setup_debugfs(void)
> > -{
> > -}
> > -
> > -static void rmi_bus_teardown_debugfs(void)
> > -{
> > -}
> > -
> > -#endif
> > -
> >   static int __init rmi_bus_init(void)
> >   {
> >   	int error;
> > @@ -364,8 +265,6 @@ static int __init rmi_bus_init(void)
> >   		return error;
> >   	}
> >
> > -	rmi_bus_setup_debugfs();
> > -
> >   	error = rmi_register_f01_handler();
> >   	if (error) {
> >   		pr_err("%s: error registering the RMI F01 handler: %d\n",
> > @@ -385,7 +284,6 @@ static int __init rmi_bus_init(void)
> >   err_unregister_f01:
> >   	rmi_unregister_f01_handler();
> >   err_unregister_bus:
> > -	rmi_bus_teardown_debugfs();
> >   	bus_unregister(&rmi_bus_type);
> >   	return error;
> >   }
> > @@ -400,7 +298,6 @@ static void __exit rmi_bus_exit(void)
> >
> >   	rmi_unregister_physical_driver();
> >   	rmi_unregister_f01_handler();
> > -	rmi_bus_teardown_debugfs();
> >   	bus_unregister(&rmi_bus_type);
> >   }
> >   module_exit(rmi_bus_exit);
> > diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
> > index 2bad2ed..62fd544 100644
> > --- a/drivers/input/rmi4/rmi_bus.h
> > +++ b/drivers/input/rmi4/rmi_bus.h
> > @@ -19,7 +19,6 @@
> >   #include <linux/stat.h>
> >   #include <linux/types.h>
> >   #include <linux/wait.h>
> > -#include <linux/debugfs.h>
> >   #include <linux/rmi.h>
> >
> >   struct rmi_device;
> > @@ -39,7 +38,6 @@ struct rmi_device;
> >    * @data: Private data pointer
> >    *
> >    * @node: entry in device's list of functions
> > - * @debugfs_root: used during debugging
> >    */
> >   struct rmi_function {
> >   	struct rmi_function_descriptor fd;
> > @@ -50,10 +48,6 @@ struct rmi_function {
> >   	unsigned long *irq_mask;
> >   	void *data;
> >   	struct list_head node;
> > -
> > -#ifdef CONFIG_RMI4_DEBUG
> > -	struct dentry *debugfs_root;
> > -#endif
> >   };
> >
> >   #define to_rmi_function(d)	container_of(d, struct rmi_function, dev)
> > @@ -208,8 +202,6 @@ struct rmi_transport_ops {
> >    * @number: Unique number for the device on the bus.
> >    * @driver: Pointer to associated driver
> >    * @xport: Pointer to the transport interface
> > - * @debugfs_root: base for this particular sensor device.
> > - *
> >    */
> >   struct rmi_device {
> >   	struct device dev;
> > @@ -217,10 +209,6 @@ struct rmi_device {
> >
> >   	struct rmi_driver *driver;
> >   	struct rmi_transport_dev *xport;
> > -
> > -#ifdef CONFIG_RMI4_DEBUG
> > -	struct dentry *debugfs_root;
> > -#endif
> >   };
> >
> >   #define to_rmi_device(d) container_of(d, struct rmi_device, dev)
> > diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> > index 691b6fb..e44eff7 100644
> > --- a/drivers/input/rmi4/rmi_driver.c
> > +++ b/drivers/input/rmi4/rmi_driver.c
> > @@ -16,7 +16,6 @@
> >
> >   #include <linux/kernel.h>
> >   #include <linux/bitmap.h>
> > -#include <linux/debugfs.h>
> >   #include <linux/delay.h>
> >   #include <linux/device.h>
> >   #include <linux/fs.h>
> > @@ -42,8 +41,6 @@
> >
> >   #define DEFAULT_POLL_INTERVAL_MS	13
> >
> > -#define IRQ_DEBUG(data) (IS_ENABLED(CONFIG_RMI4_DEBUG) && data->irq_debug)
> > -
> >   static irqreturn_t rmi_irq_thread(int irq, void *p)
> >   {
> >   	struct rmi_transport_dev *xport = p;
> > diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
> > index f28166f..eafbdb3 100644
> > --- a/drivers/input/rmi4/rmi_driver.h
> > +++ b/drivers/input/rmi4/rmi_driver.h
> > @@ -38,7 +38,6 @@ struct rmi_driver_data {
> >   	bool f01_bootloader_mode;
> >
> >   	u32 attn_count;
> > -	u32 irq_debug;	/* Should be bool, but debugfs wants u32 */
> >   	int irq;
> >   	int num_of_irq_regs;
> >   	int irq_count;
> > @@ -54,17 +53,6 @@ struct rmi_driver_data {
> >
> >   	bool enabled;
> >
> > -#ifdef CONFIG_RMI4_DEBUG
> > -	struct dentry *debugfs_delay;
> > -	struct dentry *debugfs_xport;
> > -	struct dentry *debugfs_reg_ctl;
> > -	struct dentry *debugfs_reg;
> > -	struct dentry *debugfs_irq;
> > -	struct dentry *debugfs_attn_count;
> > -	u16 reg_debug_addr;
> > -	u8 reg_debug_size;
> > -#endif
> > -
> >   	void *data;
> >   };
> >
> > diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> > index 553afd8..87d85ab 100644
> > --- a/drivers/input/rmi4/rmi_f11.c
> > +++ b/drivers/input/rmi4/rmi_f11.c
> > @@ -515,7 +515,7 @@ struct f11_2d_sensor {
> >   	u8 *data_pkt;
> >   	int pkt_size;
> >   	u8 sensor_index;
> > -	u32 type_a;	/* boolean but debugfs API requires u32 */
> > +	bool type_a;
> >   	enum rmi_f11_sensor_type sensor_type;
> >   	struct input_dev *input;
> >   	struct input_dev *mouse_input;
> > diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> > index 41c2c04..f3775eb 100644
> > --- a/include/linux/rmi.h
> > +++ b/include/linux/rmi.h
> > @@ -21,7 +21,6 @@
> >   #include <linux/stat.h>
> >   #include <linux/types.h>
> >   #include <linux/wait.h>
> > -#include <linux/debugfs.h>
> >
> >   /**
> >    * struct rmi_f11_axis_alignment - target axis alignment
> > @@ -42,9 +41,9 @@
> >    *               automatically enabled for this sensor.
> >    */
> >   struct rmi_f11_2d_axis_alignment {
> > -	u32 swap_axes;	/* boolean, but u32 is needed by debugfs API */
> > -	u32 flip_x;	/* boolean */
> > -	u32 flip_y;	/* boolean */
> > +	bool swap_axes;
> > +	bool flip_x;
> > +	bool flip_y;
> >   	u16 clip_x_low;
> >   	u16 clip_y_low;
> >   	u16 clip_x_high;
> >

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

* Re: [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data
  2014-02-04 23:10                 ` [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data Christopher Heiny
@ 2014-02-05  2:34                   ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:34 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:10:00AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > Update platform data documentation and remove unneeded/unused stuff in
> > platform data.
> >
> > If these items are needed at some later point, they should be added
> > then.  Until that point, we should unclutter the code.
>
> Taking them out to "unclutter the code" and then putting them back
> (which will be required almost immediately) is just busy work.  It would
> probably be better to concentrate on constructive changes.
>

I'm not sure what "almost immediately" is in this case, but I doubt SPI,
F19, F1A, F30 and F41 functionality will be added in a single commit.
Until the point at which these are added, they are unnecessary.
Additionally, the necessity and validity of this information in platform
data should be evaluated along-side the code, when submitted.

> >
> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> >   drivers/input/rmi4/rmi_f11.c |  14 ++--
> >   include/linux/rmi.h          | 157 ++++++++++---------------------------------
> >   2 files changed, 40 insertions(+), 131 deletions(-)
> >
> > diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> > index 87d85ab..9d94b1a 100644
> > --- a/drivers/input/rmi4/rmi_f11.c
> > +++ b/drivers/input/rmi4/rmi_f11.c
> > @@ -1109,7 +1109,7 @@ static void f11_set_abs_params(struct rmi_function *fn)
> >       /* We assume touchscreen unless demonstrably a touchpad or specified
> >        * as a touchpad in the platform data
> >        */
> > -     if (sensor->sensor_type == rmi_f11_sensor_touchpad ||
> > +     if (sensor->sensor_type == RMI_F11_SENSOR_INDIRECT ||
> >                       (sensor->sens_query.has_info2 &&
> >                               !sensor->sens_query.is_clear))
> >               input_flags = INPUT_PROP_POINTER;
> > @@ -1192,7 +1192,7 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> >               return -ENOMEM;
> >
> >       fn->data = f11;
> > -     f11->rezero_wait_ms = pdata->f11_rezero_wait;
> > +     f11->rezero_wait_ms = pdata->f11_sensor_data.rezero_wait;
> >
> >       query_base_addr = fn->fd.query_base_addr;
> >       control_base_addr = fn->fd.control_base_addr;
> > @@ -1225,13 +1225,9 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> >               return rc;
> >       }
> >
> > -     if (pdata->f11_sensor_data) {
> > -             sensor->axis_align =
> > -                     pdata->f11_sensor_data->axis_align;
> > -             sensor->type_a = pdata->f11_sensor_data->type_a;
> > -             sensor->sensor_type =
> > -                             pdata->f11_sensor_data->sensor_type;
> > -     }
> > +     sensor->axis_align = pdata->f11_sensor_data.axis_align;
> > +     sensor->type_a = pdata->f11_sensor_data.type_a;
> > +     sensor->sensor_type = pdata->f11_sensor_data.sensor_type;
> >
> >       rc = rmi_read_block(rmi_dev,
> >               control_base_addr + F11_CTRL_SENSOR_MAX_X_POS_OFFSET,
> > diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> > index f3775eb..60ddd98 100644
> > --- a/include/linux/rmi.h
> > +++ b/include/linux/rmi.h
> > @@ -37,8 +37,8 @@
> >    *               the specified value
> >    * @offset_x - this value will be added to all reported X coordinates
> >    * @offset_y - this value will be added to all reported Y coordinates
> > - * @rel_report_enabled - if set to true, the relative reporting will be
> > - *               automatically enabled for this sensor.
> > + * @delta_x_threshold - delta X movement required before reporting event
> > + * @delta_y_threshold - delta Y movement required before reporting event
> >    */
> >   struct rmi_f11_2d_axis_alignment {
> >       bool swap_axes;
> > @@ -57,34 +57,36 @@ struct rmi_f11_2d_axis_alignment {
> >   /** This is used to override any hints an F11 2D sensor might have provided
> >    * as to what type of sensor it is.
> >    *
> > - * @rmi_f11_sensor_default - do not override, determine from F11_2D_QUERY14 if
> > - * available.
> > - * @rmi_f11_sensor_touchscreen - treat the sensor as a touchscreen (direct
> > - * pointing).
> > - * @rmi_f11_sensor_touchpad - thread the sensor as a touchpad (indirect
> > - * pointing).
> > + * @RMI_F11_SENSOR_DEFAULT - determine from F11_2D_QUERY14 if available.
> > + * @RMI_F11_SENSOR_DIRECT - direct pointing sensor (e.g. touchscreen)
> > + * @RMI_F11_SENSOR_INDIRECT - indirect pointing sensor (e.g touchpad)
> >    */
> >   enum rmi_f11_sensor_type {
> > -     rmi_f11_sensor_default = 0,
> > -     rmi_f11_sensor_touchscreen,
> > -     rmi_f11_sensor_touchpad
> > +     RMI_F11_SENSOR_DEFAULT = 0,
> > +     RMI_F11_SENSOR_DIRECT,
> > +     RMI_F11_SENSOR_INDIRECT
> >   };
> >
> >   /**
> >    * struct rmi_f11_sensor_data - overrides defaults for a single F11 2D sensor.
> > + *
> >    * @axis_align - provides axis alignment overrides (see above).
> >    * @type_a - all modern RMI F11 firmwares implement Multifinger Type B
> > - * protocol.  Set this to true to force MF Type A behavior, in case you find
> > - * an older sensor.
> > + *           protocol.  Set this to true to force MF Type A behavior, in case
> > + *           you find an older sensor.
> >    * @sensor_type - Forces the driver to treat the sensor as an indirect
> > - * pointing device (touchpad) rather than a direct pointing device
> > - * (touchscreen).  This is useful when F11_2D_QUERY14 register is not
> > - * available.
> > + *                pointing device (touchpad) rather than a direct pointing
> > + *                device (touchscreen).  This is useful when F11_2D_QUERY14
> > + *                register is not available.
> > + * @rezero_wait - if non-zero, this is how may milliseconds the sensor will
> > + *                wait before being be re-zeroed on exit from suspend.  If this
> > + *                value is zero, the sensor will not be re-zeroed on resume.
> >    */
> >   struct rmi_f11_sensor_data {
> >       struct rmi_f11_2d_axis_alignment axis_align;
> >       bool type_a;
> >       enum rmi_f11_sensor_type sensor_type;
> > +     u16 rezero_wait;
> >   };
> >
> >   /**
> > @@ -98,20 +100,22 @@ enum rmi_f01_nosleep {
> >   };
> >
> >   /**
> > - * struct rmi_f01_power_management -When non-zero, these values will be written
> > - * to the touch sensor to override the default firmware settigns.  For a
> > - * detailed explanation of what each field does, see the corresponding
> > - * documention in the RMI4 specification.
> > + * struct rmi_f01_power_management - touch sensor power settings
> > + *
> > + * When non-zero, these values will be written to the touch sensor to override
> > + * the default firmware settings.  For a detailed explanation of what each
> > + * field does, see the corresponding documentation in the RMI4 specification.
> >    *
> >    * @nosleep - specifies whether the device is permitted to sleep or doze (that
> > - * is, enter a temporary low power state) when no fingers are touching the
> > - * sensor.
> > + *            is, enter a temporary low power state) when no fingers are
> > + *            touching the sensor.
> >    * @wakeup_threshold - controls the capacitance threshold at which the touch
> > - * sensor will decide to wake up from that low power state.
> > + *                     sensor will decide to wake up from that low power state.
> >    * @doze_holdoff - controls how long the touch sensor waits after the last
> > - * finger lifts before entering the doze state, in units of 100ms.
> > + *                 finger lifts before entering the doze state, in units of
> > + *                 100ms.
> >    * @doze_interval - controls the interval between checks for finger presence
> > - * when the touch sensor is in doze mode, in units of 10ms.
> > + *                  when the touch sensor is in doze mode, in units of 10ms.
> >    */
> >   struct rmi_f01_power_management {
> >       enum rmi_f01_nosleep nosleep;
> > @@ -121,114 +125,23 @@ struct rmi_f01_power_management {
> >   };
> >
> >   /**
> > - * struct rmi_button_map - used to specify the initial input subsystem key
> > - * event codes to be generated by buttons (or button like entities) on the
> > - * touch sensor.
> > - * @nbuttons - length of the button map.
> > - * @map - the key event codes for the corresponding buttons on the touch
> > - * sensor.
> > - */
> > -struct rmi_button_map {
> > -     u8 nbuttons;
> > -     u8 *map;
> > -};
> > -
> > -struct rmi_f30_gpioled_map {
> > -     u8 ngpioleds;
> > -     u8 *map;
> > -};
> > -
> > -/**
> > - * struct rmi_device_platform_data_spi - provides parameters used in SPI
> > - * communications.  All Synaptics SPI products support a standard SPI
> > - * interface; some also support what is called SPI V2 mode, depending on
> > - * firmware and/or ASIC limitations.  In V2 mode, the touch sensor can
> > - * support shorter delays during certain operations, and these are specified
> > - * separately from the standard mode delays.
> > - *
> > - * @block_delay - for standard SPI transactions consisting of both a read and
> > - * write operation, the delay (in microseconds) between the read and write
> > - * operations.
> > - * @split_read_block_delay_us - for V2 SPI transactions consisting of both a
> > - * read and write operation, the delay (in microseconds) between the read and
> > - * write operations.
> > - * @read_delay_us - the delay between each byte of a read operation in normal
> > - * SPI mode.
> > - * @write_delay_us - the delay between each byte of a write operation in normal
> > - * SPI mode.
> > - * @split_read_byte_delay_us - the delay between each byte of a read operation
> > - * in V2 mode.
> > - * @pre_delay_us - the delay before the start of a SPI transaction.  This is
> > - * typically useful in conjunction with custom chip select assertions (see
> > - * below).
> > - * @post_delay_us - the delay after the completion of an SPI transaction.  This
> > - * is typically useful in conjunction with custom chip select assertions (see
> > - * below).
> > - * @cs_assert - For systems where the SPI subsystem does not control the CS/SSB
> > - * line, or where such control is broken, you can provide a custom routine to
> > - * handle a GPIO as CS/SSB.  This routine will be called at the beginning and
> > - * end of each SPI transaction.  The RMI SPI implementation will wait
> > - * pre_delay_us after this routine returns before starting the SPI transfer;
> > - * and post_delay_us after completion of the SPI transfer(s) before calling it
> > - * with assert==FALSE.
> > - */
> > -struct rmi_device_platform_data_spi {
> > -     u32 block_delay_us;
> > -     u32 split_read_block_delay_us;
> > -     u32 read_delay_us;
> > -     u32 write_delay_us;
> > -     u32 split_read_byte_delay_us;
> > -     u32 pre_delay_us;
> > -     u32 post_delay_us;
> > -
> > -     void *cs_assert_data;
> > -     int (*cs_assert) (const void *cs_assert_data, const bool assert);
> > -};
> > -
> > -/**
> >    * struct rmi_device_platform_data - system specific configuration info.
> >    *
> >    * @irq - attention IRQ
> > - * @firmware_name - if specified will override default firmware name,
> > - * for reflashing.
> > - *
> >    * @reset_delay_ms - after issuing a reset command to the touch sensor, the
> > - * driver waits a few milliseconds to give the firmware a chance to
> > - * to re-initialize.  You can override the default wait period here.
> > - *
> > - * @spi_data - override default settings for SPI delays and SSB management (see
> > - * above).
> > - *
> > + *                   driver waits a few milliseconds to give the firmware a
> > + *                   chance to to re-initialize.  You can override the default
> > + *                   wait period here.
> >    * @f11_sensor_data - platform data for the F11 2D sensor.
> > - * @f11_rezero_wait - if non-zero, this is how may milliseconds the F11 2D
> > - * sensor will wait before being be rezeroed on exit from suspend.  If
> > - * this value is zero, the F11 2D sensor will not be rezeroed on resume.
> > - * @power_management - overrides default touch sensor doze mode settings (see
> > - * above)
> > - * @f19_button_map - provide initial input subsystem key mappings for F19.
> > - * @f1a_button_map - provide initial input subsystem key mappings for F1A.
> > - * @gpioled_map - provides initial settings for GPIOs and LEDs controlled by
> > - * F30.
> > - * @f41_button_map - provide initial input subsystem key mappings for F41.
> > + * @power_management - touch sensor power settings (see above)
> >    */
> >   struct rmi_device_platform_data {
> >       int irq;
> > -     int reset_delay_ms;
> > -
> > -     struct rmi_device_platform_data_spi spi_data;
> > +     u32 reset_delay_ms;
> >
> >       /* function handler pdata */
> > -     struct rmi_f11_sensor_data *f11_sensor_data;
> > -     u16 f11_rezero_wait;
> > +     struct rmi_f11_sensor_data f11_sensor_data;
> >       struct rmi_f01_power_management power_management;
> > -     struct rmi_button_map *f19_button_map;
> > -     struct rmi_button_map *f1a_button_map;
> > -     struct rmi_f30_gpioled_map *gpioled_map;
> > -     struct rmi_button_map *f41_button_map;
> > -
> > -#ifdef CONFIG_RMI4_FWLIB
> > -     char *firmware_name;
> > -#endif
> >   };
> >
> >   /**
> >

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

* Re: [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables
  2014-02-04 23:10                   ` [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables Christopher Heiny
@ 2014-02-05  2:35                     ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:35 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:10:05AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > This is neither a library nor documentation, so it doesn't need to
> > contain all of the information available.  Remove most of the unused
> > struct members and defines.  If they are need to implement some
> > functionality at a later point, they can be added back at that point.
>
> Taking things out only to re-add them later is not productive.  Let's
> concentrate on substantive changes to the code, please.
>

Taking things out in order to move the code towards an upstreamable form
is substantive in my books.  Code that is unnecessary for functionality
has no place in a driver.

> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> >   drivers/input/rmi4/rmi_bus.h    |   1 -
> >   drivers/input/rmi4/rmi_driver.c |   3 -
> >   drivers/input/rmi4/rmi_f01.c    |  40 -----
> >   drivers/input/rmi4/rmi_f11.c    | 375 ----------------------------------------
> >   4 files changed, 419 deletions(-)
> >
> > diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
> > index 62fd544..a21e4c4 100644
> > --- a/drivers/input/rmi4/rmi_bus.h
> > +++ b/drivers/input/rmi4/rmi_bus.h
> > @@ -278,7 +278,6 @@ static inline int rmi_write_block(struct rmi_device *d, u16 addr,
> >
> >   int rmi_register_transport_device(struct rmi_transport_dev *xport);
> >   void rmi_unregister_transport_device(struct rmi_transport_dev *xport);
> > -int rmi_for_each_dev(void *data, int (*func)(struct device *dev, void *data));
> >
> >   /**
> >    * module_rmi_driver() - Helper macro for registering a function driver
> > diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> > index e44eff7..9ec7b93 100644
> > --- a/drivers/input/rmi4/rmi_driver.c
> > +++ b/drivers/input/rmi4/rmi_driver.c
> > @@ -32,15 +32,12 @@
> >
> >   #define RMI4_MAX_N_IRQS 256
> >
> > -#define HAS_NONSTANDARD_PDT_MASK 0x40
> >   #define RMI4_MAX_PAGE 0xff
> >   #define RMI4_PAGE_SIZE 0x100
> >
> >   #define RMI_DEVICE_RESET_CMD        0x01
> >   #define DEFAULT_RESET_DELAY_MS      100
> >
> > -#define DEFAULT_POLL_INTERVAL_MS     13
> > -
> >   static irqreturn_t rmi_irq_thread(int irq, void *p)
> >   {
> >       struct rmi_transport_dev *xport = p;
> > diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
> > index 98bc65a9..4cb9fcb 100644
> > --- a/drivers/input/rmi4/rmi_f01.c
> > +++ b/drivers/input/rmi4/rmi_f01.c
> > @@ -15,27 +15,11 @@
> >   #include "rmi_driver.h"
> >
> >   #define RMI_PRODUCT_ID_LENGTH    10
> > -#define RMI_PRODUCT_INFO_LENGTH   2
> > -
> > -#define RMI_DATE_CODE_LENGTH      3
> > -
> > -#define PRODUCT_ID_OFFSET 0x10
> > -#define PRODUCT_INFO_OFFSET 0x1E
> > -
> > -
> > -/* Force a firmware reset of the sensor */
> > -#define RMI_F01_CMD_DEVICE_RESET     1
> >
> >   /* Various F01_RMI_QueryX bits */
> > -
> > -#define RMI_F01_QRY1_CUSTOM_MAP              (1 << 0)
> > -#define RMI_F01_QRY1_NON_COMPLIANT   (1 << 1)
> >   #define RMI_F01_QRY1_HAS_LTS                (1 << 2)
> > -#define RMI_F01_QRY1_HAS_SENSOR_ID   (1 << 3)
> > -#define RMI_F01_QRY1_HAS_CHARGER_INP (1 << 4)
> >   #define RMI_F01_QRY1_HAS_ADJ_DOZE   (1 << 5)
> >   #define RMI_F01_QRY1_HAS_ADJ_DOZE_HOFF      (1 << 6)
> > -#define RMI_F01_QRY1_HAS_PROPS_2     (1 << 7)
> >
> >   #define RMI_F01_QRY5_YEAR_MASK              0x1f
> >   #define RMI_F01_QRY6_MONTH_MASK             0x0f
> > @@ -52,7 +36,6 @@ struct f01_basic_properties {
> >       bool has_adjustable_doze_holdoff;
> >       char dom[11]; /* YYYY/MM/DD + '\0' */
> >       u8 product_id[RMI_PRODUCT_ID_LENGTH + 1];
> > -     u16 productinfo;
> >   };
> >
> >   /* F01 device status bits */
> > @@ -87,19 +70,6 @@ struct f01_basic_properties {
> >   #define RMI_F01_CRTL0_NOSLEEP_BIT   (1 << 2)
> >
> >   /*
> > - * When this bit is set, the touch controller employs a noise-filtering
> > - * algorithm designed for use with a connected battery charger.
> > - */
> > -#define RMI_F01_CRTL0_CHARGER_BIT    (1 << 5)
> > -
> > -/*
> > - * Sets the report rate for the device. The effect of this setting is
> > - * highly product dependent. Check the spec sheet for your particular
> > - * touch sensor.
> > - */
> > -#define RMI_F01_CRTL0_REPORTRATE_BIT (1 << 6)
> > -
> > -/*
> >    * Written by the host as an indicator that the device has been
> >    * successfully configured.
> >    */
> > @@ -127,7 +97,6 @@ struct f01_data {
> >       struct f01_basic_properties properties;
> >
> >       struct f01_device_control device_control;
> > -     struct mutex control_mutex;
> >
> >       u8 device_status;
> >
> > @@ -135,11 +104,9 @@ struct f01_data {
> >       u16 doze_interval_addr;
> >       u16 wakeup_threshold_addr;
> >       u16 doze_holdoff_addr;
> > -     int irq_count;
> >       int num_of_irq_regs;
> >
> >   #ifdef CONFIG_PM_SLEEP
> > -     bool suspended;
> >       bool old_nosleep;
> >   #endif
> >   };
> > @@ -199,10 +166,6 @@ static int rmi_f01_read_properties(struct rmi_device *rmi_dev,
> >               RMI_PRODUCT_ID_LENGTH);
> >       props->product_id[RMI_PRODUCT_ID_LENGTH] = '\0';
> >
> > -     props->productinfo =
> > -                     ((basic_query[2] & RMI_F01_QRY2_PRODINFO_MASK) << 7) |
> > -                     (basic_query[3] & RMI_F01_QRY2_PRODINFO_MASK);
> > -
> >       return 0;
> >   }
> >
> > @@ -216,8 +179,6 @@ static int rmi_f01_initialize(struct rmi_function *fn)
> >       struct f01_data *data = fn->data;
> >       struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
> >
> > -     mutex_init(&data->control_mutex);
> > -
> >       /*
> >        * Set the configured bit and (optionally) other important stuff
> >        * in the device control register.
> > @@ -263,7 +224,6 @@ static int rmi_f01_initialize(struct rmi_function *fn)
> >               return error;
> >       }
> >
> > -     data->irq_count = driver_data->irq_count;
> >       data->num_of_irq_regs = driver_data->num_of_irq_regs;
> >       ctrl_base_addr += sizeof(u8);
> >
> > diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> > index 9d94b1a..b114f25 100644
> > --- a/drivers/input/rmi4/rmi_f11.c
> > +++ b/drivers/input/rmi4/rmi_f11.c
> > @@ -7,8 +7,6 @@
> >    * the Free Software Foundation.
> >    */
> >
> > -#define FUNCTION_DATA f11_data
> > -
> >   #include <linux/kernel.h>
> >   #include <linux/delay.h>
> >   #include <linux/device.h>
> > @@ -19,9 +17,6 @@
> >   #include <linux/slab.h>
> >   #include "rmi_driver.h"
> >
> > -#define F11_MAX_NUM_OF_FINGERS               10
> > -#define F11_MAX_NUM_OF_TOUCH_SHAPES  16
> > -
> >   #define F11_REL_POS_MIN             -128
> >   #define F11_REL_POS_MAX             127
> >
> > @@ -30,14 +25,12 @@
> >   #define F11_CTRL_SENSOR_MAX_X_POS_OFFSET    6
> >   #define F11_CTRL_SENSOR_MAX_Y_POS_OFFSET    8
> >
> > -#define DEFAULT_XY_MAX 9999
> >   #define DEFAULT_MAX_ABS_MT_PRESSURE 255
> >   #define DEFAULT_MAX_ABS_MT_TOUCH 15
> >   #define DEFAULT_MAX_ABS_MT_ORIENTATION 1
> >   #define DEFAULT_MIN_ABS_MT_TRACKING_ID 1
> >   #define DEFAULT_MAX_ABS_MT_TRACKING_ID 10
> >   #define NAME_BUFFER_SIZE 256
> > -#define FUNCTION_NUMBER 0x11
> >
> >   /** A note about RMI4 F11 register structure.
> >    *
> > @@ -81,108 +74,37 @@
> >   #define RMI_F11_HAS_QUERY28             (1 << 7)
> >
> >   /** Defs for Query 1 */
> > -
> >   #define RMI_F11_NR_FINGERS_MASK 0x07
> >   #define RMI_F11_HAS_REL                 (1 << 3)
> >   #define RMI_F11_HAS_ABS                 (1 << 4)
> >   #define RMI_F11_HAS_GESTURES            (1 << 5)
> > -#define RMI_F11_HAS_SENSITIVITY_ADJ     (1 << 6)
> > -#define RMI_F11_CONFIGURABLE            (1 << 7)
> > -
> > -/** Defs for Query 2, 3, and 4. */
> > -#define RMI_F11_NR_ELECTRODES_MASK      0x7F
> >
> >   /** Defs for Query 5 */
> > -
> > -#define RMI_F11_ABS_DATA_SIZE_MASK      0x03
> > -#define RMI_F11_HAS_ANCHORED_FINGER     (1 << 2)
> > -#define RMI_F11_HAS_ADJ_HYST            (1 << 3)
> > -#define RMI_F11_HAS_DRIBBLE             (1 << 4)
> > -#define RMI_F11_HAS_BENDING_CORRECTION  (1 << 5)
> > -#define RMI_F11_HAS_LARGE_OBJECT_SUPPRESSION    (1 << 6)
> >   #define RMI_F11_HAS_JITTER_FILTER       (1 << 7)
> >
> >   /** Defs for Query 7 */
> > -#define RMI_F11_HAS_SINGLE_TAP                  (1 << 0)
> > -#define RMI_F11_HAS_TAP_AND_HOLD                (1 << 1)
> > -#define RMI_F11_HAS_DOUBLE_TAP                  (1 << 2)
> > -#define RMI_F11_HAS_EARLY_TAP                   (1 << 3)
> >   #define RMI_F11_HAS_FLICK                       (1 << 4)
> > -#define RMI_F11_HAS_PRESS                       (1 << 5)
> >   #define RMI_F11_HAS_PINCH                       (1 << 6)
> > -#define RMI_F11_HAS_CHIRAL                      (1 << 7)
> >
> >   /** Defs for Query 8 */
> > -#define RMI_F11_HAS_PALM_DET                    (1 << 0)
> >   #define RMI_F11_HAS_ROTATE                      (1 << 1)
> >   #define RMI_F11_HAS_TOUCH_SHAPES                (1 << 2)
> > -#define RMI_F11_HAS_SCROLL_ZONES                (1 << 3)
> > -#define RMI_F11_HAS_INDIVIDUAL_SCROLL_ZONES     (1 << 4)
> > -#define RMI_F11_HAS_MF_SCROLL                   (1 << 5)
> > -#define RMI_F11_HAS_MF_EDGE_MOTION              (1 << 6)
> > -#define RMI_F11_HAS_MF_SCROLL_INERTIA           (1 << 7)
> >
> >   /** Defs for Query 9. */
> >   #define RMI_F11_HAS_PEN                         (1 << 0)
> > -#define RMI_F11_HAS_PROXIMITY                   (1 << 1)
> > -#define RMI_F11_HAS_PALM_DET_SENSITIVITY        (1 << 2)
> > -#define RMI_F11_HAS_SUPPRESS_ON_PALM_DETECT     (1 << 3)
> > -#define RMI_F11_HAS_TWO_PEN_THRESHOLDS          (1 << 4)
> > -#define RMI_F11_HAS_CONTACT_GEOMETRY            (1 << 5)
> > -#define RMI_F11_HAS_PEN_HOVER_DISCRIMINATION    (1 << 6)
> > -#define RMI_F11_HAS_PEN_FILTERS                 (1 << 7)
> >
> >   /** Defs for Query 10. */
> >   #define RMI_F11_NR_TOUCH_SHAPES_MASK            0x1F
> >
> > -/** Defs for Query 11 */
> > -
> > -#define RMI_F11_HAS_Z_TUNING                    (1 << 0)
> > -#define RMI_F11_HAS_ALGORITHM_SELECTION         (1 << 1)
> > -#define RMI_F11_HAS_W_TUNING                    (1 << 2)
> > -#define RMI_F11_HAS_PITCH_INFO                  (1 << 3)
> > -#define RMI_F11_HAS_FINGER_SIZE                 (1 << 4)
> > -#define RMI_F11_HAS_SEGMENTATION_AGGRESSIVENESS (1 << 5)
> > -#define RMI_F11_HAS_XY_CLIP                     (1 << 6)
> > -#define RMI_F11_HAS_DRUMMING_FILTER             (1 << 7)
> > -
> >   /** Defs for Query 12. */
> > -
> > -#define RMI_F11_HAS_GAPLESS_FINGER              (1 << 0)
> > -#define RMI_F11_HAS_GAPLESS_FINGER_TUNING       (1 << 1)
> > -#define RMI_F11_HAS_8BIT_W                      (1 << 2)
> > -#define RMI_F11_HAS_ADJUSTABLE_MAPPING          (1 << 3)
> >   #define RMI_F11_HAS_INFO2                       (1 << 4)
> > -#define RMI_F11_HAS_PHYSICAL_PROPS              (1 << 5)
> > -#define RMI_F11_HAS_FINGER_LIMIT                (1 << 6)
> > -#define RMI_F11_HAS_LINEAR_COEFF                (1 << 7)
> > -
> > -/** Defs for Query 13. */
> > -
> > -#define RMI_F11_JITTER_WINDOW_MASK              0x1F
> > -#define RMI_F11_JITTER_FILTER_MASK              0x60
> > -#define RMI_F11_JITTER_FILTER_SHIFT             5
> >
> >   /** Defs for Query 14. */
> > -#define RMI_F11_LIGHT_CONTROL_MASK              0x03
> >   #define RMI_F11_IS_CLEAR                        (1 << 2)
> > -#define RMI_F11_CLICKPAD_PROPS_MASK             0x18
> > -#define RMI_F11_CLICKPAD_PROPS_SHIFT            3
> > -#define RMI_F11_MOUSE_BUTTONS_MASK              0x60
> > -#define RMI_F11_MOUSE_BUTTONS_SHIFT             5
> > -#define RMI_F11_HAS_ADVANCED_GESTURES           (1 << 7)
> >
> >   #define RMI_F11_QUERY_SIZE                      4
> >   #define RMI_F11_QUERY_GESTURE_SIZE              2
> >
> > -#define F11_LIGHT_CTL_NONE 0x00
> > -#define F11_LUXPAD      0x01
> > -#define F11_DUAL_MODE      0x02
> > -
> > -#define F11_NOT_CLICKPAD     0x00
> > -#define F11_HINGED_CLICKPAD  0x01
> > -#define F11_UNIFORM_CLICKPAD 0x02
> > -
> >   /**
> >    * Query registers 1 through 4 are always present.
> >    *
> > @@ -191,55 +113,18 @@
> >    * @has_rel - the sensor supports relative motion reporting.
> >    * @has_abs - the sensor supports absolute poition reporting.
> >    * @has_gestures - the sensor supports gesture reporting.
> > - * @has_sensitivity_adjust - the sensor supports a global sensitivity
> > - * adjustment.
> > - * @configurable - the sensor supports various configuration options.
> > - * @num_of_x_electrodes -  the maximum number of electrodes the 2-D sensor
> > - * supports on the X axis.
> > - * @num_of_y_electrodes -  the maximum number of electrodes the 2-D sensor
> > - * supports on the Y axis.
> > - * @max_electrodes - the total number of X and Y electrodes that may be
> > - * configured.
> >    *
> >    * Query 5 is present if the has_abs bit is set.
> >    *
> > - * @abs_data_size - describes the format of data reported by the absolute
> > - * data source.  Only one format (the kind used here) is supported at this
> > - * time.
> > - * @has_anchored_finger - then the sensor supports the high-precision second
> > - * finger tracking provided by the manual tracking and motion sensitivity
> > - * options.
> > - * @has_adjust_hyst - the difference between the finger release threshold and
> > - * the touch threshold.
> > - * @has_dribble - the sensor supports the generation of dribble interrupts,
> > - * which may be enabled or disabled with the dribble control bit.
> > - * @has_bending_correction - Bending related data registers 28 and 36, and
> > - * control register 52..57 are present.
> > - * @has_large_object_suppression - control register 58 and data register 28
> > - * exist.
> >    * @has_jitter_filter - query 13 and control 73..76 exist.
> >    *
> >    * Gesture information queries 7 and 8 are present if has_gestures bit is set.
> >    *
> > - * @has_single_tap - a basic single-tap gesture is supported.
> > - * @has_tap_n_hold - tap-and-hold gesture is supported.
> > - * @has_double_tap - double-tap gesture is supported.
> > - * @has_early_tap - early tap is supported and reported as soon as the finger
> > - * lifts for any tap event that could be interpreted as either a single tap
> > - * or as the first tap of a double-tap or tap-and-hold gesture.
> >    * @has_flick - flick detection is supported.
> > - * @has_press - press gesture reporting is supported.
> >    * @has_pinch - pinch gesture detection is supported.
> > - * @has_palm_det - the 2-D sensor notifies the host whenever a large conductive
> > - * object such as a palm or a cheek touches the 2-D sensor.
> >    * @has_rotate - rotation gesture detection is supported.
> >    * @has_touch_shapes - TouchShapes are supported.  A TouchShape is a fixed
> >    * rectangular area on the sensor that behaves like a capacitive button.
> > - * @has_scroll_zones - scrolling areas near the sensor edges are supported.
> > - * @has_individual_scroll_zones - if 1, then 4 scroll zones are supported;
> > - * if 0, then only two are supported.
> > - * @has_mf_scroll - the multifinger_scrolling bit will be set when
> > - * more than one finger is involved in a scrolling action.
> >    *
> >    * Convenience for checking bytes in the gesture info registers.  This is done
> >    * often enough that we put it here to declutter the conditionals
> > @@ -251,68 +136,21 @@
> >    *
> >    * @has_pen - detection of a stylus is supported and registers F11_2D_Ctrl20
> >    * and F11_2D_Ctrl21 exist.
> > - * @has_proximity - detection of fingers near the sensor is supported and
> > - * registers F11_2D_Ctrl22 through F11_2D_Ctrl26 exist.
> > - * @has_palm_det_sensitivity -  the sensor supports the palm detect sensitivity
> > - * feature and register F11_2D_Ctrl27 exists.
> > - * @has_two_pen_thresholds - is has_pen is also set, then F11_2D_Ctrl35 exists.
> > - * @has_contact_geometry - the sensor supports the use of contact geometry to
> > - * map absolute X and Y target positions and registers F11_2D_Data18
> > - * through F11_2D_Data27 exist.
> >    *
> >    * Touch shape info (query 10) is present if has_touch_shapes is set.
> >    *
> >    * @nr_touch_shapes - the total number of touch shapes supported.
> >    *
> >    * Query 11 is present if the has_query11 bit is set in query 0.
> > - *
> > - * @has_z_tuning - if set, the sensor supports Z tuning and registers
> > - * F11_2D_Ctrl29 through F11_2D_Ctrl33 exist.
> > - * @has_algorithm_selection - controls choice of noise suppression algorithm
> > - * @has_w_tuning - the sensor supports Wx and Wy scaling and registers
> > - * F11_2D_Ctrl36 through F11_2D_Ctrl39 exist.
> > - * @has_pitch_info - the X and Y pitches of the sensor electrodes can be
> > - * configured and registers F11_2D_Ctrl40 and F11_2D_Ctrl41 exist.
> > - * @has_finger_size -  the default finger width settings for the
> > - * sensor can be configured and registers F11_2D_Ctrl42 through F11_2D_Ctrl44
> > - * exist.
> > - * @has_segmentation_aggressiveness - the sensor???s ability to distinguish
> > - * multiple objects close together can be configured and register F11_2D_Ctrl45
> > - * exists.
> > - * @has_XY_clip -  the inactive outside borders of the sensor can be
> > - * configured and registers F11_2D_Ctrl46 through F11_2D_Ctrl49 exist.
> > - * @has_drumming_filter - the sensor can be configured to distinguish
> > - * between a fast flick and a quick drumming movement and registers
> > - * F11_2D_Ctrl50 and F11_2D_Ctrl51 exist.
> > - *
> >    * Query 12 is present if hasQuery12 bit is set.
> >    *
> > - * @has_gapless_finger - control registers relating to gapless finger are
> > - * present.
> > - * @has_gapless_finger_tuning - additional control and data registers relating
> > - * to gapless finger are present.
> > - * @has_8bit_w - larger W value reporting is supported.
> > - * @has_adjustable_mapping - TBD
> >    * @has_info2 - the general info query14 is present
> > - * @has_physical_props - additional queries describing the physical properties
> > - * of the sensor are present.
> > - * @has_finger_limit - indicates that F11 Ctrl 80 exists.
> > - * @has_linear_coeff - indicates that F11 Ctrl 81 exists.
> >    *
> >    * Query 13 is present if Query 5's has_jitter_filter bit is set.
> > - * @jitter_window_size - used by Design Studio 4.
> > - * @jitter_filter_type - used by Design Studio 4.
> > - *
> >    * Query 14 is present if query 12's has_general_info2 flag is set.
> >    *
> > - * @light_control - Indicates what light/led control features are present, if
> > - * any.
> >    * @is_clear - if set, this is a clear sensor (indicating direct pointing
> >    * application), otherwise it's opaque (indicating indirect pointing).
> > - * @clickpad_props - specifies if this is a clickpad, and if so what sort of
> > - * mechanism it uses
> > - * @mouse_buttons - specifies the number of mouse buttons present (if any).
> > - * @has_advanced_gestures - advanced driver gestures are supported.
> >    */
> >   struct f11_2d_sensor_queries {
> >       /* query1 */
> > @@ -320,112 +158,34 @@ struct f11_2d_sensor_queries {
> >       bool has_rel;
> >       bool has_abs;
> >       bool has_gestures;
> > -     bool has_sensitivity_adjust;
> > -     bool configurable;
> > -
> > -     /* query2 */
> > -     u8 nr_x_electrodes;
> >
> > -     /* query3 */
> > -     u8 nr_y_electrodes;
> > -
> > -     /* query4 */
> > -     u8 max_electrodes;
> > -
> > -     /* query5 */
> > -     u8 abs_data_size;
> > -     bool has_anchored_finger;
> > -     bool has_adj_hyst;
> > -     bool has_dribble;
> > -     bool has_bending_correction;
> > -     bool has_large_object_suppression;
> >       bool has_jitter_filter;
> >
> >       u8 f11_2d_query6;
> >
> >       /* query 7 */
> > -     bool has_single_tap;
> > -     bool has_tap_n_hold;
> > -     bool has_double_tap;
> > -     bool has_early_tap;
> >       bool has_flick;
> > -     bool has_press;
> >       bool has_pinch;
> > -     bool has_chiral;
> > -
> >       bool query7_nonzero;
> >
> >       /* query 8 */
> > -     bool has_palm_det;
> >       bool has_rotate;
> >       bool has_touch_shapes;
> > -     bool has_scroll_zones;
> > -     bool has_individual_scroll_zones;
> > -     bool has_mf_scroll;
> > -     bool has_mf_edge_motion;
> > -     bool has_mf_scroll_inertia;
> > -
> >       bool query8_nonzero;
> >
> >       /* Query 9 */
> >       bool has_pen;
> > -     bool has_proximity;
> > -     bool has_palm_det_sensitivity;
> > -     bool has_suppress_on_palm_detect;
> > -     bool has_two_pen_thresholds;
> > -     bool has_contact_geometry;
> > -     bool has_pen_hover_discrimination;
> > -     bool has_pen_filters;
> >
> >       /* Query 10 */
> >       u8 nr_touch_shapes;
> >
> > -     /* Query 11. */
> > -     bool has_z_tuning;
> > -     bool has_algorithm_selection;
> > -     bool has_w_tuning;
> > -     bool has_pitch_info;
> > -     bool has_finger_size;
> > -     bool has_segmentation_aggressiveness;
> > -     bool has_XY_clip;
> > -     bool has_drumming_filter;
> > -
> >       /* Query 12 */
> > -     bool has_gapless_finger;
> > -     bool has_gapless_finger_tuning;
> > -     bool has_8bit_w;
> > -     bool has_adjustable_mapping;
> >       bool has_info2;
> > -     bool has_physical_props;
> > -     bool has_finger_limit;
> > -     bool has_linear_coeff_2;
> > -
> > -     /* Query 13 */
> > -     u8 jitter_window_size;
> > -     u8 jitter_filter_type;
> >
> >       /* Query 14 */
> > -     u8 light_control;
> >       bool is_clear;
> > -     u8 clickpad_props;
> > -     u8 mouse_buttons;
> > -     bool has_advanced_gestures;
> >   };
> >
> > -/* Defs for Ctrl0. */
> > -#define RMI_F11_REPORT_MODE_MASK        0x07
> > -#define RMI_F11_ABS_POS_FILT            (1 << 3)
> > -#define RMI_F11_REL_POS_FILT            (1 << 4)
> > -#define RMI_F11_REL_BALLISTICS          (1 << 5)
> > -#define RMI_F11_DRIBBLE                 (1 << 6)
> > -#define RMI_F11_REPORT_BEYOND_CLIP      (1 << 7)
> > -
> > -/* Defs for Ctrl1. */
> > -#define RMI_F11_PALM_DETECT_THRESH_MASK 0x0F
> > -#define RMI_F11_MOTION_SENSITIVITY_MASK 0x30
> > -#define RMI_F11_MANUAL_TRACKING         (1 << 6)
> > -#define RMI_F11_MANUAL_TRACKED_FINGER   (1 << 7)
> > -
> >   #define RMI_F11_DELTA_X_THRESHOLD       2
> >   #define RMI_F11_DELTA_Y_THRESHOLD       3
> >
> > @@ -439,24 +199,6 @@ struct f11_2d_ctrl {
> >   #define RMI_F11_ABS_BYTES 5
> >   #define RMI_F11_REL_BYTES 2
> >
> > -/* Defs for Data 8 */
> > -
> > -#define RMI_F11_SINGLE_TAP              (1 << 0)
> > -#define RMI_F11_TAP_AND_HOLD            (1 << 1)
> > -#define RMI_F11_DOUBLE_TAP              (1 << 2)
> > -#define RMI_F11_EARLY_TAP               (1 << 3)
> > -#define RMI_F11_FLICK                   (1 << 4)
> > -#define RMI_F11_PRESS                   (1 << 5)
> > -#define RMI_F11_PINCH                   (1 << 6)
> > -
> > -/* Defs for Data 9 */
> > -
> > -#define RMI_F11_PALM_DETECT                     (1 << 0)
> > -#define RMI_F11_ROTATE                          (1 << 1)
> > -#define RMI_F11_SHAPE                           (1 << 2)
> > -#define RMI_F11_SCROLLZONE                      (1 << 3)
> > -#define RMI_F11_GESTURE_FINGER_COUNT_MASK       0x70
> > -
> >   /** Handy pointers into our data buffer.
> >    *
> >    * @f_state - start of finger state registers.
> > @@ -467,8 +209,6 @@ struct f11_2d_ctrl {
> >    * @pinch   - pinch motion register (if present).
> >    * @flick   - flick distance X & Y, flick time (if present).
> >    * @rotate  - rotate motion and finger separation.
> > - * @multi_scroll - chiral deltas for X and Y (if present).
> > - * @scroll_zones - scroll deltas for 4 regions (if present).
> >    */
> >   struct f11_2d_data {
> >       u8      *f_state;
> > @@ -480,8 +220,6 @@ struct f11_2d_data {
> >       u8      *flick;
> >       u8      *rotate;
> >       u8      *shapes;
> > -     s8      *multi_scroll;
> > -     s8      *scroll_zones;
> >   };
> >
> >   /**
> > @@ -495,7 +233,6 @@ struct f11_2d_data {
> >    * @nbr_fingers - How many fingers can this sensor report?
> >    * @data_pkt - buffer for data reported by this sensor.
> >    * @pkt_size - number of bytes in that buffer.
> > - * @sensor_index - identifies this particular 2D touch sensor
> >    * @type_a - some early RMI4 2D sensors do not reliably track the finger
> >    * position when two fingers are on the device.  When this is true, we
> >    * assume we have one of those sensors and report events appropriately.
> > @@ -514,7 +251,6 @@ struct f11_2d_sensor {
> >       u8 nbr_fingers;
> >       u8 *data_pkt;
> >       int pkt_size;
> > -     u8 sensor_index;
> >       bool type_a;
> >       enum rmi_f11_sensor_type sensor_type;
> >       struct input_dev *input;
> > @@ -529,7 +265,6 @@ struct f11_2d_sensor {
> >    *
> >    * @dev_query - F11 device specific query registers.
> >    * @dev_controls - F11 device specific control registers.
> > - * @dev_controls_mutex - lock for the control registers.
> >    * @rezero_wait_ms - if nonzero, upon resume we will wait this many
> >    * milliseconds before rezeroing the sensor(s).  This is useful in systems with
> >    * poor electrical behavior on resume, where the initial calibration of the
> > @@ -543,7 +278,6 @@ struct f11_data {
> >       bool has_query27;
> >       bool has_query28;
> >       struct f11_2d_ctrl dev_controls;
> > -     struct mutex dev_controls_mutex;
> >       u16 rezero_wait_ms;
> >       struct f11_2d_sensor sensor;
> >   };
> > @@ -871,16 +605,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
> >       sensor_query->has_rel = !!(query_buf[0] & RMI_F11_HAS_REL);
> >       sensor_query->has_abs = !!(query_buf[0] & RMI_F11_HAS_ABS);
> >       sensor_query->has_gestures = !!(query_buf[0] & RMI_F11_HAS_GESTURES);
> > -     sensor_query->has_sensitivity_adjust =
> > -             !!(query_buf[0] && RMI_F11_HAS_SENSITIVITY_ADJ);
> > -     sensor_query->configurable = !!(query_buf[0] & RMI_F11_CONFIGURABLE);
> > -
> > -     sensor_query->nr_x_electrodes =
> > -                             query_buf[1] & RMI_F11_NR_ELECTRODES_MASK;
> > -     sensor_query->nr_y_electrodes =
> > -                             query_buf[2] & RMI_F11_NR_ELECTRODES_MASK;
> > -     sensor_query->max_electrodes =
> > -                             query_buf[3] & RMI_F11_NR_ELECTRODES_MASK;
> >
> >       query_size = RMI_F11_QUERY_SIZE;
> >
> > @@ -889,18 +613,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
> >               if (rc < 0)
> >                       return rc;
> >
> > -             sensor_query->abs_data_size =
> > -                     query_buf[0] & RMI_F11_ABS_DATA_SIZE_MASK;
> > -             sensor_query->has_anchored_finger =
> > -                     !!(query_buf[0] & RMI_F11_HAS_ANCHORED_FINGER);
> > -             sensor_query->has_adj_hyst =
> > -                     !!(query_buf[0] & RMI_F11_HAS_ADJ_HYST);
> > -             sensor_query->has_dribble =
> > -                     !!(query_buf[0] & RMI_F11_HAS_DRIBBLE);
> > -             sensor_query->has_bending_correction =
> > -                     !!(query_buf[0] & RMI_F11_HAS_BENDING_CORRECTION);
> > -             sensor_query->has_large_object_suppression =
> > -             !!(query_buf[0] && RMI_F11_HAS_LARGE_OBJECT_SUPPRESSION);
> >               sensor_query->has_jitter_filter =
> >                       !!(query_buf[0] & RMI_F11_HAS_JITTER_FILTER);
> >               query_size++;
> > @@ -920,40 +632,16 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
> >               if (rc < 0)
> >                       return rc;
> >
> > -             sensor_query->has_single_tap =
> > -                     !!(query_buf[0] & RMI_F11_HAS_SINGLE_TAP);
> > -             sensor_query->has_tap_n_hold =
> > -                     !!(query_buf[0] & RMI_F11_HAS_TAP_AND_HOLD);
> > -             sensor_query->has_double_tap =
> > -                     !!(query_buf[0] & RMI_F11_HAS_DOUBLE_TAP);
> > -             sensor_query->has_early_tap =
> > -                     !!(query_buf[0] & RMI_F11_HAS_EARLY_TAP);
> >               sensor_query->has_flick =
> >                       !!(query_buf[0] & RMI_F11_HAS_FLICK);
> > -             sensor_query->has_press =
> > -                     !!(query_buf[0] & RMI_F11_HAS_PRESS);
> >               sensor_query->has_pinch =
> >                       !!(query_buf[0] & RMI_F11_HAS_PINCH);
> > -             sensor_query->has_chiral =
> > -                     !!(query_buf[0] & RMI_F11_HAS_CHIRAL);
> >
> >               /* query 8 */
> > -             sensor_query->has_palm_det =
> > -                     !!(query_buf[1] & RMI_F11_HAS_PALM_DET);
> >               sensor_query->has_rotate =
> >                       !!(query_buf[1] & RMI_F11_HAS_ROTATE);
> >               sensor_query->has_touch_shapes =
> >                       !!(query_buf[1] & RMI_F11_HAS_TOUCH_SHAPES);
> > -             sensor_query->has_scroll_zones =
> > -                     !!(query_buf[1] & RMI_F11_HAS_SCROLL_ZONES);
> > -             sensor_query->has_individual_scroll_zones =
> > -                     !!(query_buf[1] & RMI_F11_HAS_INDIVIDUAL_SCROLL_ZONES);
> > -             sensor_query->has_mf_scroll =
> > -                     !!(query_buf[1] & RMI_F11_HAS_MF_SCROLL);
> > -             sensor_query->has_mf_edge_motion =
> > -                     !!(query_buf[1] & RMI_F11_HAS_MF_EDGE_MOTION);
> > -             sensor_query->has_mf_scroll_inertia =
> > -                     !!(query_buf[1] & RMI_F11_HAS_MF_SCROLL_INERTIA);
> >
> >               sensor_query->query7_nonzero = !!(query_buf[0]);
> >               sensor_query->query8_nonzero = !!(query_buf[1]);
> > @@ -968,20 +656,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
> >
> >               sensor_query->has_pen =
> >                       !!(query_buf[0] & RMI_F11_HAS_PEN);
> > -             sensor_query->has_proximity =
> > -                     !!(query_buf[0] & RMI_F11_HAS_PROXIMITY);
> > -             sensor_query->has_palm_det_sensitivity =
> > -                     !!(query_buf[0] & RMI_F11_HAS_PALM_DET_SENSITIVITY);
> > -             sensor_query->has_suppress_on_palm_detect =
> > -                     !!(query_buf[0] & RMI_F11_HAS_SUPPRESS_ON_PALM_DETECT);
> > -             sensor_query->has_two_pen_thresholds =
> > -                     !!(query_buf[0] & RMI_F11_HAS_TWO_PEN_THRESHOLDS);
> > -             sensor_query->has_contact_geometry =
> > -                     !!(query_buf[0] & RMI_F11_HAS_CONTACT_GEOMETRY);
> > -             sensor_query->has_pen_hover_discrimination =
> > -                     !!(query_buf[0] & RMI_F11_HAS_PEN_HOVER_DISCRIMINATION);
> > -             sensor_query->has_pen_filters =
> > -                     !!(query_buf[0] & RMI_F11_HAS_PEN_FILTERS);
> >
> >               query_size++;
> >       }
> > @@ -1002,24 +676,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
> >               if (rc < 0)
> >                       return rc;
> >
> > -             sensor_query->has_z_tuning =
> > -                     !!(query_buf[0] & RMI_F11_HAS_Z_TUNING);
> > -             sensor_query->has_algorithm_selection =
> > -                     !!(query_buf[0] & RMI_F11_HAS_ALGORITHM_SELECTION);
> > -             sensor_query->has_w_tuning =
> > -                     !!(query_buf[0] & RMI_F11_HAS_W_TUNING);
> > -             sensor_query->has_pitch_info =
> > -                     !!(query_buf[0] & RMI_F11_HAS_PITCH_INFO);
> > -             sensor_query->has_finger_size =
> > -                     !!(query_buf[0] & RMI_F11_HAS_FINGER_SIZE);
> > -             sensor_query->has_segmentation_aggressiveness =
> > -                     !!(query_buf[0] &
> > -                             RMI_F11_HAS_SEGMENTATION_AGGRESSIVENESS);
> > -             sensor_query->has_XY_clip =
> > -                     !!(query_buf[0] & RMI_F11_HAS_XY_CLIP);
> > -             sensor_query->has_drumming_filter =
> > -                     !!(query_buf[0] & RMI_F11_HAS_DRUMMING_FILTER);
> > -
> >               query_size++;
> >       }
> >
> > @@ -1028,22 +684,8 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
> >               if (rc < 0)
> >                       return rc;
> >
> > -             sensor_query->has_gapless_finger =
> > -                     !!(query_buf[0] & RMI_F11_HAS_GAPLESS_FINGER);
> > -             sensor_query->has_gapless_finger_tuning =
> > -                     !!(query_buf[0] & RMI_F11_HAS_GAPLESS_FINGER_TUNING);
> > -             sensor_query->has_8bit_w =
> > -                     !!(query_buf[0] & RMI_F11_HAS_8BIT_W);
> > -             sensor_query->has_adjustable_mapping =
> > -                     !!(query_buf[0] & RMI_F11_HAS_ADJUSTABLE_MAPPING);
> >               sensor_query->has_info2 =
> >                       !!(query_buf[0] & RMI_F11_HAS_INFO2);
> > -             sensor_query->has_physical_props =
> > -                     !!(query_buf[0] & RMI_F11_HAS_PHYSICAL_PROPS);
> > -             sensor_query->has_finger_limit =
> > -                     !!(query_buf[0] & RMI_F11_HAS_FINGER_LIMIT);
> > -             sensor_query->has_linear_coeff_2 =
> > -                     !!(query_buf[0] & RMI_F11_HAS_LINEAR_COEFF);
> >
> >               query_size++;
> >       }
> > @@ -1053,12 +695,6 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
> >               if (rc < 0)
> >                       return rc;
> >
> > -             sensor_query->jitter_window_size = query_buf[0] &
> > -                     RMI_F11_JITTER_WINDOW_MASK;
> > -             sensor_query->jitter_filter_type = (query_buf[0] &
> > -                     RMI_F11_JITTER_FILTER_MASK) >>
> > -                     RMI_F11_JITTER_FILTER_SHIFT;
> > -
> >               query_size++;
> >       }
> >
> > @@ -1067,18 +703,8 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
> >               if (rc < 0)
> >                       return rc;
> >
> > -             sensor_query->light_control =
> > -                     query_buf[0] & RMI_F11_LIGHT_CONTROL_MASK;
> >               sensor_query->is_clear =
> >                       !!(query_buf[0] & RMI_F11_IS_CLEAR);
> > -             sensor_query->clickpad_props =
> > -                     (query_buf[0] & RMI_F11_CLICKPAD_PROPS_MASK) >>
> > -                     RMI_F11_CLICKPAD_PROPS_SHIFT;
> > -             sensor_query->mouse_buttons =
> > -                     (query_buf[0] & RMI_F11_MOUSE_BUTTONS_MASK) >>
> > -                     RMI_F11_MOUSE_BUTTONS_SHIFT;
> > -             sensor_query->has_advanced_gestures =
> > -                     !!(query_buf[0] & RMI_F11_HAS_ADVANCED_GESTURES);
> >
> >               query_size++;
> >       }
> > @@ -1276,7 +902,6 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> >                               rc);
> >       }
> >
> > -     mutex_init(&f11->dev_controls_mutex);
> >       return 0;
> >   }
> >
> >

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

* Re: [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support
  2014-02-04 23:10                     ` [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support Christopher Heiny
@ 2014-02-05  2:37                       ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:37 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:10:16AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
>
> This is pretty interesting, and looks potentially useful.  I'm not very
> familiar with OF/DT structures, though.  What happens if there are two
> different RMI4 devices in the system, each of which has its own platform
> settings?
>

OF support will be required for most newer platforms as well as for
multi-platform support.

In order to support multiple devices, you just need a DT node for each
device.  The following is an example of two devices on the same I2C bus,
with the devices called "sensor_A" and "sensor_B" at the addresses 0x2c
and 0x2e respectively.

i2c@0 {
        ... /* I2C adapter settings */

        sensor_A@2c {
                compatible = "syn,rmi_i2c";
                reg = <0x2c>;
                interrupts = <61 IRQ_TYPE_EDGE_FALLING>;
                ... /* sensor A settings */
        };


        sensor_B@2e {
                compatible = "syn,rmi_i2c";
                reg = <0x2e>;
                interrupts = <62 IRQ_TYPE_EDGE_RISING>;
                ... /* sensor B settings */
        }
};

> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> >   Documentation/devicetree/bindings/input/rmi4.txt   | 107 +++++++++++++++++
> >   .../devicetree/bindings/vendor-prefixes.txt        |   1 +
> >   drivers/input/rmi4/rmi_bus.c                       |  12 +-
> >   drivers/input/rmi4/rmi_bus.h                       |   3 +-
> >   drivers/input/rmi4/rmi_driver.c                    |  44 +++++--
> >   drivers/input/rmi4/rmi_f01.c                       | 107 +++++++++++++++--
> >   drivers/input/rmi4/rmi_f11.c                       | 133 ++++++++++++++++++++-
> >   drivers/input/rmi4/rmi_i2c.c                       |  19 +--
> >   8 files changed, 388 insertions(+), 38 deletions(-)
> >   create mode 100644 Documentation/devicetree/bindings/input/rmi4.txt
> >
> > diff --git a/Documentation/devicetree/bindings/input/rmi4.txt b/Documentation/devicetree/bindings/input/rmi4.txt
> > new file mode 100644
> > index 0000000..fff9db7
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/rmi4.txt
> > @@ -0,0 +1,107 @@
> > +Synaptics RMI4-based input device binding
> > +
> > +PROPERTIES
> > +
> > +compatible:
> > +     Usage: required
> > +     Type: string, must be "syn,rmi_i2c"
> > +
> > +interrupts:
> > +     Usage: required
> > +     Type: <prop-encoded-array>
> > +     Desc: See devicetree/bindings/interrupt-controller/interrupts.txt;
> > +             Trigger sense required in mask
> > +
> > +syn,reset-delay:
> > +     Usage: optional (default: 100)
> > +     Type: u32, milliseconds
> > +     Desc: Delay after issuing a reset
> > +
> > +syn,power-no-sleep:
> > +     Usage: optional, mutually exclusive with syn,power-sleep
> > +             (default: chip-specific)
> > +     Type: boolean
> > +     Desc: Disable sleep mode
> > +
> > +syn,power-sleep:
> > +     Usage: optional, mutually exclusive with syn,power-no-sleep
> > +             (default: chip-specific)
> > +     Type: boolean
> > +     Desc: Enable sleep mode
> > +
> > +syn,power-wakeup-thresh:
> > +     Usage: optional (default: chip-specific)
> > +     Type: u32, chip-specific unit [0-255]
> > +     Desc: Capacitance threshold at which device should wake
> > +
> > +syn,power-doze-holdoff:
> > +     Usage: optional (default: chip-specific)
> > +     Type: u32, milliseconds [0-25500]
> > +     Desc: Idle delay before entering sleep mode
> > +
> > +syn,power-doze-interval:
> > +     Usage: optional (default: chip-specific)
> > +     Type: u32, milliseconds [0-2550]
> > +     Desc: Interval between checks for idle
> > +
> > +syn,2d-rezero-wait:
> > +     Usage: optional (default: no re-zeroing)
> > +     Type: u32, milliseconds [0-65535]
> > +     Desc: Delay after resume to re-zero sensor
> > +
> > +syn,2d-axis-swap:
> > +     Usage: optional (default: false)
> > +     Type: boolean
> > +     Desc: Swap X and Y axis
> > +
> > +syn,2d-flip-x:
> > +     Usage: optional (default: false)
> > +     Type: boolean
> > +     Desc: Invert X axis
> > +
> > +syn,2d-flip-y:
> > +     Usage: optional (default: false)
> > +     Type: boolean
> > +     Desc: Invert Y axis
> > +
> > +syn,2d-clip-range:
> > +     Usage: optional (default: clip disabled)
> > +     Type: u32 array (<top left bottom right>) [0-65535]
> > +     Usage: Clip values outside this range
> > +
> > +syn,2d-offset:
> > +     Usage: optional (default: offset disabled)
> > +     Type: u32 array (<X-offset Y-offset>) [0-65535]
> > +     Usage: Add offset values to reported events
> > +
> > +syn,2d-delta-thresh:
> > +     Usage: optional (default: chip-specific)
> > +     Type: u32 array (<X-delta Y-delta>) [0-255]
> > +     Usage: Minimum delta before event is reported
> > +
> > +syn,2d-sensor-type:
> > +     Usage: optional (default: chip-specific)
> > +     Type: string, "indirect" or "direct"
> > +     Usage: Set screen type for event reporting
> > +
> > +syn,2d-type-a:
> > +     Usage: optional (default: false)
> > +     Type: boolean
> > +     Usage: Sensor supports only Multifinger Type A protocol
> > +
> > +EXAMPLE
> > +
> > +i2c@0 {
> > +     compatible = "...";
> > +     #address-cells = <1>;
> > +     #size-cells = <0>;
> > +
> > +     synaptics_rmi4@2c {
> > +             compatible = "syn,rmi_i2c";
> > +             reg = <0x2c>;
> > +
> > +             interrupts = <61 IRQ_TYPE_EDGE_FALLING>;
> > +
> > +             syn,2d-clip-range = <0 0 1919 1079>;
> > +     };
> > +};
> > diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
> > index edbb8d8..3388986 100644
> > --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> > +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> > @@ -72,6 +72,7 @@ snps        Synopsys, Inc.
> >   st  STMicroelectronics
> >   ste ST-Ericsson
> >   stericsson  ST-Ericsson
> > +syn  Synaptics, Inc.
> >   ti  Texas Instruments
> >   toshiba     Toshiba Corporation
> >   toumaz      Toumaz
> > diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> > index a51e6b4..57de579 100644
> > --- a/drivers/input/rmi4/rmi_bus.c
> > +++ b/drivers/input/rmi4/rmi_bus.c
> > @@ -52,14 +52,11 @@ bool rmi_is_physical_device(struct device *dev)
> >   int rmi_register_transport_device(struct rmi_transport_dev *xport)
> >   {
> >       static atomic_t transport_device_count = ATOMIC_INIT(0);
> > -     struct rmi_device_platform_data *pdata = xport->dev->platform_data;
> >       struct rmi_device *rmi_dev;
> >       int error;
> >
> > -     if (!pdata) {
> > -             dev_err(xport->dev, "no platform data!\n");
> > -             return -EINVAL;
> > -     }
> > +     if (unlikely(!rmi_bus_type.p))
> > +             return -EPROBE_DEFER;
> >
> >       rmi_dev = kzalloc(sizeof(struct rmi_device), GFP_KERNEL);
> >       if (!rmi_dev)
> > @@ -70,8 +67,10 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
> >
> >       dev_set_name(&rmi_dev->dev, "sensor%02d", rmi_dev->number);
> >
> > +     rmi_dev->dev.parent = xport->dev;
> >       rmi_dev->dev.bus = &rmi_bus_type;
> >       rmi_dev->dev.type = &rmi_device_type;
> > +     rmi_dev->dev.of_node = xport->dev->of_node;
> >
> >       xport->rmi_dev = rmi_dev;
> >
> > @@ -206,6 +205,9 @@ int __rmi_register_function_handler(struct rmi_function_handler *handler,
> >       struct device_driver *driver = &handler->driver;
> >       int error;
> >
> > +     if (WARN_ON(unlikely(!rmi_bus_type.p)))
> > +             return -EAGAIN;
> > +
> >       driver->bus = &rmi_bus_type;
> >       driver->owner = owner;
> >       driver->mod_name = mod_name;
> > diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
> > index a21e4c4..51f9372 100644
> > --- a/drivers/input/rmi4/rmi_bus.h
> > +++ b/drivers/input/rmi4/rmi_bus.h
> > @@ -212,7 +212,8 @@ struct rmi_device {
> >   };
> >
> >   #define to_rmi_device(d) container_of(d, struct rmi_device, dev)
> > -#define to_rmi_platform_data(d) ((d)->xport->dev->platform_data)
> > +#define to_rmi_xport_device(d) ((d)->xport->dev)
> > +#define to_rmi_platform_data(d) (dev_get_platdata(to_rmi_xport_device(d)))
> >
> >   bool rmi_is_physical_device(struct device *dev);
> >
> > diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> > index 9ec7b93..92415ce 100644
> > --- a/drivers/input/rmi4/rmi_driver.c
> > +++ b/drivers/input/rmi4/rmi_driver.c
> > @@ -26,6 +26,8 @@
> >   #include <linux/rmi.h>
> >   #include <linux/slab.h>
> >   #include <linux/uaccess.h>
> > +#include <linux/of_irq.h>
> > +#include <linux/of.h>
> >   #include <uapi/linux/input.h>
> >   #include "rmi_bus.h"
> >   #include "rmi_driver.h"
> > @@ -498,7 +500,7 @@ static int create_function(struct rmi_device *rmi_dev,
> >    * We have to do this before actually building the PDT because the reflash
> >    * updates (if any) might cause various registers to move around.
> >    */
> > -static int rmi_initial_reset(struct rmi_device *rmi_dev)
> > +static int rmi_initial_reset(struct rmi_device *rmi_dev, u32 reset_delay)
> >   {
> >       struct pdt_entry pdt_entry;
> >       int page;
> > @@ -507,8 +509,6 @@ static int rmi_initial_reset(struct rmi_device *rmi_dev)
> >       bool has_f01 = false;
> >       int i;
> >       int retval;
> > -     const struct rmi_device_platform_data *pdata =
> > -                     to_rmi_platform_data(rmi_dev);
> >
> >       dev_dbg(dev, "Initial reset.\n");
> >
> > @@ -538,7 +538,7 @@ static int rmi_initial_reset(struct rmi_device *rmi_dev)
> >                                               retval);
> >                                       return retval;
> >                               }
> > -                             mdelay(pdata->reset_delay_ms);
> > +                             mdelay(reset_delay);
> >                               done = true;
> >                               has_f01 = true;
> >                               break;
> > @@ -648,6 +648,8 @@ static int rmi_driver_probe(struct device *dev)
> >       struct rmi_device_platform_data *pdata;
> >       int retval = 0;
> >       struct rmi_device *rmi_dev;
> > +     unsigned int irq;
> > +     u32 reset_delay;
> >
> >       dev_dbg(dev, "%s: Starting probe.\n", __func__);
> >
> > @@ -661,6 +663,28 @@ static int rmi_driver_probe(struct device *dev)
> >       rmi_dev->driver = rmi_driver;
> >
> >       pdata = to_rmi_platform_data(rmi_dev);
> > +     if (pdata == NULL) {
> > +#ifdef CONFIG_OF
> > +             const char *p;
> > +
> > +             p = "syn,reset-delay";
> > +             retval = of_property_read_u32(dev->of_node, p, &reset_delay);
> > +             if (retval && retval != -EINVAL) {
> > +                     dev_err(dev, "Invalid '%s' property\n", p);
> > +                     return -EINVAL;
> > +             }
> > +             if (retval == -EINVAL)
> > +                     reset_delay = 0;
> > +
> > +             irq = irq_of_parse_and_map(dev->of_node, 0);
> > +#else
> > +             dev_err(dev, "No pdata\n");
> > +             return -EINVAL;
> > +#endif
> > +     } else {
> > +             reset_delay = pdata->reset_delay_ms;
> > +             irq = pdata->irq;
> > +     }
> >
> >       data = devm_kzalloc(dev, sizeof(struct rmi_driver_data), GFP_KERNEL);
> >       if (!data) {
> > @@ -688,9 +712,9 @@ static int rmi_driver_probe(struct device *dev)
> >        * and leave the customer's device unusable.  So we warn them, and
> >        * continue processing.
> >        */
> > -     if (!pdata->reset_delay_ms)
> > -             pdata->reset_delay_ms = DEFAULT_RESET_DELAY_MS;
> > -     retval = rmi_initial_reset(rmi_dev);
> > +     if (!reset_delay)
> > +             reset_delay = DEFAULT_RESET_DELAY_MS;
> > +     retval = rmi_initial_reset(rmi_dev, reset_delay);
> >       if (retval)
> >               dev_warn(dev, "RMI initial reset failed! Continuing in spite of this.\n");
> >
> > @@ -762,10 +786,10 @@ static int rmi_driver_probe(struct device *dev)
> >               goto err_free_data;
> >       }
> >
> > -     data->irq = pdata->irq;
> > -     if (data->irq < 0) {
> > +     data->irq = irq;
> > +     if (data->irq < 0 || data->irq == NO_IRQ) {
> >               dev_err(dev, "Failed to get attn IRQ.\n");
> > -             retval = data->irq;
> > +             retval = -EINVAL;
> >               goto err_free_data;
> >
> >       }
> > diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
> > index 4cb9fcb..22b57f2 100644
> > --- a/drivers/input/rmi4/rmi_f01.c
> > +++ b/drivers/input/rmi4/rmi_f01.c
> > @@ -12,6 +12,7 @@
> >   #include <linux/rmi.h>
> >   #include <linux/slab.h>
> >   #include <linux/uaccess.h>
> > +#include <linux/of.h>
> >   #include "rmi_driver.h"
> >
> >   #define RMI_PRODUCT_ID_LENGTH    10
> > @@ -169,15 +170,104 @@ static int rmi_f01_read_properties(struct rmi_device *rmi_dev,
> >       return 0;
> >   }
> >
> > +#ifdef CONFIG_OF
> > +static int rmi_f01_of_parse(struct device *dev,
> > +             struct rmi_f01_power_management *cdata)
> > +{
> > +     bool sleep, nosleep;
> > +     const char *p;
> > +     u32 val;
> > +     int rc;
> > +
> > +     if (dev->of_node == NULL)
> > +             return -EINVAL;
> > +
> > +     memset(cdata, 0, sizeof(*cdata));
> > +
> > +     sleep = of_property_read_bool(dev->of_node, "syn,power-sleep");
> > +     nosleep = of_property_read_bool(dev->of_node, "syn,power-nosleep");
> > +     if (sleep && nosleep) {
> > +             dev_err(dev, "'syn,power-sleep' and 'syn,power-nosleep' are mutually exclusive\n");
> > +             return -EINVAL;
> > +     }
> > +     if (sleep)
> > +             cdata->nosleep = RMI_F01_NOSLEEP_OFF;
> > +     else if (nosleep)
> > +             cdata->nosleep = RMI_F01_NOSLEEP_ON;
> > +
> > +     p = "syn,power-wakeup-thresh";
> > +     rc = of_property_read_u32(dev->of_node, p, &val);
> > +     if (rc && rc != -EINVAL) {
> > +             dev_err(dev, "Invalid '%s' property\n", p);
> > +             return rc;
> > +     }
> > +     if (rc != -EINVAL) {
> > +             if (val & ~0xff) {
> > +                     dev_err(dev, "'%s' out of range [0-255]\n", p);
> > +                     return -EINVAL;
> > +             }
> > +             cdata->wakeup_threshold = val;
> > +     }
> > +
> > +     p = "syn,power-doze-holdoff";
> > +     rc = of_property_read_u32(dev->of_node, p, &val);
> > +     if (rc && rc != -EINVAL) {
> > +             dev_err(dev, "Invalid '%s' property\n", p);
> > +             return rc;
> > +     }
> > +     if (rc != -EINVAL) {
> > +             if (val > 25500) {
> > +                     dev_err(dev, "'%s' out of range [0-25500]ms\n", p);
> > +                     return -EINVAL;
> > +             }
> > +             cdata->doze_holdoff = (val + 50) / 100;
> > +     }
> > +
> > +     p = "syn,power-doze-interval";
> > +     rc = of_property_read_u32(dev->of_node, p, &val);
> > +     if (rc && rc != -EINVAL) {
> > +             dev_err(dev, "Invalid '%s' property\n", p);
> > +             return rc;
> > +     }
> > +     if (rc != -EINVAL) {
> > +             if (val > 2550) {
> > +                     dev_err(dev, "'%s' out of range [0-2550]ms\n", p);
> > +                     return -EINVAL;
> > +             }
> > +             cdata->doze_interval = (val + 5) / 10;
> > +     }
> > +
> > +     return 0;
> > +}
> > +#else
> > +static int rmi_f01_of_parse(struct device *dev,
> > +             struct rmi_f01_power_management *cdata)
> > +{
> > +     return -EINVAL;
> > +}
> > +#endif
> > +
> >   static int rmi_f01_initialize(struct rmi_function *fn)
> >   {
> >       u8 temp;
> >       int error;
> >       u16 ctrl_base_addr;
> > +     struct rmi_f01_power_management cdata;
> >       struct rmi_device *rmi_dev = fn->rmi_dev;
> > +     struct device *dev = to_rmi_xport_device(rmi_dev);
> >       struct rmi_driver_data *driver_data = dev_get_drvdata(&rmi_dev->dev);
> >       struct f01_data *data = fn->data;
> > -     struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
> > +     struct rmi_device_platform_data *pdata = dev_get_platdata(dev);
> > +
> > +     if (pdata != NULL) {
> > +             cdata = pdata->power_management;
> > +     } else {
> > +             error = rmi_f01_of_parse(dev, &cdata);
> > +             if (error) {
> > +                     dev_err(dev, "Unable to parse DT data\n");
> > +                     return error;
> > +             }
> > +     }
> >
> >       /*
> >        * Set the configured bit and (optionally) other important stuff
> > @@ -191,7 +281,7 @@ static int rmi_f01_initialize(struct rmi_function *fn)
> >               dev_err(&fn->dev, "Failed to read F01 control.\n");
> >               return error;
> >       }
> > -     switch (pdata->power_management.nosleep) {
> > +     switch (cdata.nosleep) {
> >       case RMI_F01_NOSLEEP_DEFAULT:
> >               break;
> >       case RMI_F01_NOSLEEP_OFF:
> > @@ -262,9 +352,9 @@ static int rmi_f01_initialize(struct rmi_function *fn)
> >               data->doze_interval_addr = ctrl_base_addr;
> >               ctrl_base_addr++;
> >
> > -             if (pdata->power_management.doze_interval) {
> > +             if (cdata.doze_interval) {
> >                       data->device_control.doze_interval =
> > -                             pdata->power_management.doze_interval;
> > +                             cdata.doze_interval;
> >                       error = rmi_write(rmi_dev, data->doze_interval_addr,
> >                                       data->device_control.doze_interval);
> >                       if (error < 0) {
> > @@ -283,9 +373,9 @@ static int rmi_f01_initialize(struct rmi_function *fn)
> >               data->wakeup_threshold_addr = ctrl_base_addr;
> >               ctrl_base_addr++;
> >
> > -             if (pdata->power_management.wakeup_threshold) {
> > +             if (cdata.wakeup_threshold) {
> >                       data->device_control.wakeup_threshold =
> > -                             pdata->power_management.wakeup_threshold;
> > +                             cdata.wakeup_threshold;
> >                       error = rmi_write(rmi_dev, data->wakeup_threshold_addr,
> >                                       data->device_control.wakeup_threshold);
> >                       if (error < 0) {
> > @@ -306,9 +396,8 @@ static int rmi_f01_initialize(struct rmi_function *fn)
> >               data->doze_holdoff_addr = ctrl_base_addr;
> >               ctrl_base_addr++;
> >
> > -             if (pdata->power_management.doze_holdoff) {
> > -                     data->device_control.doze_holdoff =
> > -                             pdata->power_management.doze_holdoff;
> > +             if (cdata.doze_holdoff) {
> > +                     data->device_control.doze_holdoff = cdata.doze_holdoff;
> >                       error = rmi_write(rmi_dev, data->doze_holdoff_addr,
> >                                       data->device_control.doze_holdoff);
> >                       if (error < 0) {
> > diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> > index b114f25..837b6e7 100644
> > --- a/drivers/input/rmi4/rmi_f11.c
> > +++ b/drivers/input/rmi4/rmi_f11.c
> > @@ -13,6 +13,7 @@
> >   #include <linux/input.h>
> >   #include <linux/input/mt.h>
> >   #include <linux/kconfig.h>
> > +#include <linux/of.h>
> >   #include <linux/rmi.h>
> >   #include <linux/slab.h>
> >   #include "rmi_driver.h"
> > @@ -794,9 +795,120 @@ static void f11_set_abs_params(struct rmi_function *fn)
> >                                    0, MT_TOOL_FINGER, 0, 0);
> >   }
> >
> > +#ifdef CONFIG_OF
> > +static int rmi_f11_of_parse(struct device *dev,
> > +             struct rmi_f11_sensor_data *cdata)
> > +{
> > +     const char *type;
> > +     const char *p;
> > +     u32 a[4];
> > +     int rc;
> > +
> > +     if (dev->of_node == NULL)
> > +             return -EINVAL;
> > +
> > +     memset(cdata, 0, sizeof(*cdata));
> > +
> > +     p = "syn,2d-rezero-wait";
> > +     rc = of_property_read_u32(dev->of_node, p, &a[0]);
> > +     if (rc && rc != -EINVAL) {
> > +             dev_err(dev, "Invalid '%s' property\n", p);
> > +             return rc;
> > +     }
> > +     if (rc != -EINVAL) {
> > +             if (a[0] & ~0xffff) {
> > +                     dev_err(dev, "'%s' value out of range [0-65535]\n", p);
> > +                     return -EINVAL;
> > +             }
> > +             cdata->rezero_wait = a[0];
> > +     }
> > +
> > +     cdata->type_a = of_property_read_bool(dev->of_node, "syn,2d-type-a");
> > +     cdata->axis_align.swap_axes = of_property_read_bool(dev->of_node,
> > +                     "syn,2d-axis-swap");
> > +     cdata->axis_align.flip_x = of_property_read_bool(dev->of_node,
> > +                     "syn,2d-flip-x");
> > +     cdata->axis_align.flip_y = of_property_read_bool(dev->of_node,
> > +                     "syn,2d-flip-y");
> > +
> > +     p = "syn-2d-clip-range";
> > +     rc = of_property_read_u32_array(dev->of_node, p, a, 4);
> > +     if (rc && rc != -EINVAL) {
> > +             dev_err(dev, "Invalid '%s' property\n", p);
> > +             return rc;
> > +     }
> > +     if (rc != -EINVAL) {
> > +             if ((a[0] | a[1] | a[2] | a[3]) & ~0xffff) {
> > +                     dev_err(dev, "'%s' values out of range [0-65535]\n", p);
> > +                     return -EINVAL;
> > +             }
> > +             cdata->axis_align.clip_x_low = a[0];
> > +             cdata->axis_align.clip_y_low = a[1];
> > +             cdata->axis_align.clip_x_high = a[2];
> > +             cdata->axis_align.clip_y_high = a[3];
> > +     }
> > +
> > +     p = "syn-2d-offset";
> > +     rc = of_property_read_u32_array(dev->of_node, p, a, 2);
> > +     if (rc && rc != -EINVAL) {
> > +             dev_err(dev, "Invalid '%s' property\n", p);
> > +             return rc;
> > +     }
> > +     if (rc != -EINVAL) {
> > +             if ((a[0] | a[1]) & ~0xffff) {
> > +                     dev_err(dev, "'%s' values out of range [0-65535]\n", p);
> > +                     return -EINVAL;
> > +             }
> > +             cdata->axis_align.offset_x = a[0];
> > +             cdata->axis_align.offset_y = a[1];
> > +     }
> > +
> > +     p = "syn,2d-delta-thresh";
> > +     rc = of_property_read_u32_array(dev->of_node, p, a, 2);
> > +     if (rc && rc != -EINVAL) {
> > +             dev_err(dev, "Invalid '%s' property\n", p);
> > +             return rc;
> > +     }
> > +     if (rc != -EINVAL) {
> > +             if ((a[0] | a[1]) & ~0xff) {
> > +                     dev_err(dev, "'%s' values out of range [0-255]\n", p);
> > +                     return -EINVAL;
> > +             }
> > +             cdata->axis_align.delta_x_threshold = a[0];
> > +             cdata->axis_align.delta_y_threshold = a[1];
> > +     }
> > +
> > +     p = "syn,2d-sensor-type";
> > +     rc = of_property_read_string(dev->of_node, p, &type);
> > +     if (rc && rc != -EINVAL) {
> > +             dev_err(dev, "Invalid '%s' property\n", p);
> > +             return rc;
> > +     }
> > +     if (rc != -EINVAL) {
> > +             if (!strcmp(type, "direct")) {
> > +                     cdata->sensor_type = RMI_F11_SENSOR_DIRECT;
> > +             } else if (!strcmp(type, "indirect")) {
> > +                     cdata->sensor_type = RMI_F11_SENSOR_INDIRECT;
> > +             } else {
> > +                     dev_err(dev, "'%s' must be one of: \"indirect\", \"direct\"\n", p);
> > +                     return -EINVAL;
> > +             }
> > +     }
> > +
> > +     return 0;
> > +}
> > +#else
> > +static int rmi_f11_of_parse(struct device *dev,
> > +             struct rmi_f11_sensor_data *cdata)
> > +{
> > +     return -EINVAL;
> > +}
> > +#endif
> > +
> >   static int rmi_f11_initialize(struct rmi_function *fn)
> >   {
> >       struct rmi_device *rmi_dev = fn->rmi_dev;
> > +     struct device *dev = to_rmi_xport_device(rmi_dev);
> >       struct f11_data *f11;
> >       struct f11_2d_ctrl *ctrl;
> >       u8 query_offset;
> > @@ -804,12 +916,23 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> >       u16 control_base_addr;
> >       u16 max_x_pos, max_y_pos, temp;
> >       int rc;
> > -     struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
> > +     struct rmi_device_platform_data *pdata = dev_get_platdata(dev);
> > +     struct rmi_f11_sensor_data cdata;
> >       struct f11_2d_sensor *sensor;
> >       u8 buf;
> >
> >       dev_dbg(&fn->dev, "Initializing F11 values.\n");
> >
> > +     if (pdata != NULL) {
> > +             cdata = pdata->f11_sensor_data;
> > +     } else {
> > +             rc = rmi_f11_of_parse(dev, &cdata);
> > +             if (rc) {
> > +                     dev_err(dev, "Unable to parse DT data\n");
> > +                     return rc;
> > +             }
> > +     }
> > +
> >       /*
> >       ** init instance data, fill in values and create any sysfs files
> >       */
> > @@ -818,7 +941,7 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> >               return -ENOMEM;
> >
> >       fn->data = f11;
> > -     f11->rezero_wait_ms = pdata->f11_sensor_data.rezero_wait;
> > +     f11->rezero_wait_ms = cdata.rezero_wait;
> >
> >       query_base_addr = fn->fd.query_base_addr;
> >       control_base_addr = fn->fd.control_base_addr;
> > @@ -851,9 +974,9 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> >               return rc;
> >       }
> >
> > -     sensor->axis_align = pdata->f11_sensor_data.axis_align;
> > -     sensor->type_a = pdata->f11_sensor_data.type_a;
> > -     sensor->sensor_type = pdata->f11_sensor_data.sensor_type;
> > +     sensor->axis_align = cdata.axis_align;
> > +     sensor->type_a = cdata.type_a;
> > +     sensor->sensor_type = cdata.sensor_type;
> >
> >       rc = rmi_read_block(rmi_dev,
> >               control_base_addr + F11_CTRL_SENSOR_MAX_X_POS_OFFSET,
> > diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
> > index aebf974..377d4cc 100644
> > --- a/drivers/input/rmi4/rmi_i2c.c
> > +++ b/drivers/input/rmi4/rmi_i2c.c
> > @@ -186,16 +186,9 @@ static const struct rmi_transport_ops rmi_i2c_ops = {
> >   static int rmi_i2c_probe(struct i2c_client *client,
> >                        const struct i2c_device_id *id)
> >   {
> > -     const struct rmi_device_platform_data *pdata =
> > -                             dev_get_platdata(&client->dev);
> >       struct rmi_i2c_xport *rmi_i2c;
> >       int retval;
> >
> > -     if (!pdata) {
> > -             dev_err(&client->dev, "no platform data\n");
> > -             return -EINVAL;
> > -     }
> > -
> >       dev_dbg(&client->dev, "Probing %#02x.\n", client->addr);
> >
> >       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
> > @@ -258,10 +251,20 @@ static const struct i2c_device_id rmi_id[] = {
> >   };
> >   MODULE_DEVICE_TABLE(i2c, rmi_id);
> >
> > +#ifdef CONFIG_OF
> > +static struct of_device_id rmi_match_table[] = {
> > +     { .compatible = "syn,rmi_i2c", },
> > +     { },
> > +};
> > +#else
> > +#define rmi_match_table NULL
> > +#endif
> > +
> >   static struct i2c_driver rmi_i2c_driver = {
> >       .driver = {
> >               .owner  = THIS_MODULE,
> > -             .name   = "rmi_i2c"
> > +             .name   = "rmi_i2c",
> > +             .of_match_table = rmi_match_table,
> >       },
> >       .id_table       = rmi_id,
> >       .probe          = rmi_i2c_probe,
> >

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

* Re: [PATCH 11/15] Input: synaptics-rmi4 - add regulator support
  2014-02-04 23:10                       ` [PATCH 11/15] Input: synaptics-rmi4 - add regulator support Christopher Heiny
@ 2014-02-05  2:38                         ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:38 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:10:32AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > Add support for VDD and VIO power supplies.  Since we may need a delay
> > after turning on the chip, adjust code to manage that.  This removes the
> > scanning for active interrupts on resume, as we should get an interrupt
> > when the chip is ready.
> 
> This looks potentially useful.  But what happens in devices where you 
> want to power the touch sensor on at initial boot, but need to leave it 
> power on during suspend/resume states?  Also, how does this work when 
> there are multiple RMI4 sensors in the system?

This can be handled in a few different ways depending on the system:
	- You can specify nothing for the regulator, and you'll get a
	  dummy/NULL one, which will make enable/disable no-ops.
	- You can turn on the regulator in platform setup, and
	  enable/disable will just refcount the regulator.
	- You can use an "always-on" regulator, for which enable/disable
	  will be no-ops.

In the case that there are multiple sensors on the system, you can
specify the regulators 'vdd' and/or 'vio' in each sensor's DT node and
everything will just work.  You can even have them on the same
regulator(s), if you want.

If you don't have DT support, or are using a legacy platform, the
regulators are associated with the device name as well as the names
'vdd' and 'vio'.

> 
> See also comments below.
> 
> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> >   Documentation/devicetree/bindings/input/rmi4.txt | 10 +++++
> >   drivers/input/rmi4/rmi_driver.c                  | 53 +++++++++++++++++++++++-
> >   drivers/input/rmi4/rmi_driver.h                  |  4 ++
> >   3 files changed, 66 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/input/rmi4.txt b/Documentation/devicetree/bindings/input/rmi4.txt
> > index fff9db7..d41beac 100644
> > --- a/Documentation/devicetree/bindings/input/rmi4.txt
> > +++ b/Documentation/devicetree/bindings/input/rmi4.txt
> > @@ -12,6 +12,16 @@ interrupts:
> >   	Desc: See devicetree/bindings/interrupt-controller/interrupts.txt;
> >   		Trigger sense required in mask
> >
> > +vdd-supply:
> > +	Usage: optional (default: no regulator)
> > +	Type: <prop-encoded-array>
> > +	Desc: VDD power supply; See devicetree/bindings/regulator/regulator.txt
> > +
> > +vio-supply:
> > +	Usage: optional (default: no regulator)
> > +	Type: <prop-encoded-array>
> > +	Desc: VIO power supply; See devicetree/bindings/regulator/regulator.txt
> > +
> >   syn,reset-delay:
> >   	Usage: optional (default: 100)
> >   	Type: u32, milliseconds
> > diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> > index 92415ce..52345ae 100644
> > --- a/drivers/input/rmi4/rmi_driver.c
> > +++ b/drivers/input/rmi4/rmi_driver.c
> > @@ -28,6 +28,7 @@
> >   #include <linux/uaccess.h>
> >   #include <linux/of_irq.h>
> >   #include <linux/of.h>
> > +#include <linux/regulator/consumer.h>
> >   #include <uapi/linux/input.h>
> >   #include "rmi_bus.h"
> >   #include "rmi_driver.h"
> > @@ -101,7 +102,7 @@ static int enable_sensor(struct rmi_device *rmi_dev)
> >
> >   	data->enabled = true;
> >
> > -	return process_interrupt_requests(rmi_dev);
> > +	return 0;
> 
> enable_sensor() and disable_sensor() may be called in a variety of 
> contexts, and there may be pending interrupts at the time 
> enable_sensor() is called.
> 
> >   }

Yep, this should be handled by the irq subsystem by calling your
interrupt handler if I'm not mistaken.  Otherwise, request_irq() needs to
be moved to probe, and enable/disable_sensor() should call
enable/disable_irq() instead of request/free_irq().

> >
> >   static void rmi_free_function_list(struct rmi_device *rmi_dev)
> > @@ -616,14 +617,29 @@ error_exit:
> >   static int rmi_driver_suspend(struct device *dev)
> >   {
> >   	struct rmi_device *rmi_dev = to_rmi_device(dev);
> > +	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> >
> >   	disable_sensor(rmi_dev);
> > +
> > +	regulator_disable(data->vio);
> > +	regulator_disable(data->vdd);
> > +
> >   	return 0;
> >   }
> >
> >   static int rmi_driver_resume(struct device *dev)
> >   {
> >   	struct rmi_device *rmi_dev = to_rmi_device(dev);
> > +	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> > +	int retval;
> > +
> > +	retval = regulator_enable(data->vdd);
> > +	if (retval)
> > +		return retval;
> > +	retval = regulator_enable(data->vio);
> > +	if (retval)
> > +		return retval;
> 
> If you've toggled power to the sensor, you may need to do a reset wait 
> here, just like you did on initialization.
> 

This is why I removed process_interrupt_requests() from enable_sensor(),
as in the case that we turned on the sensor, it should raise ATTN when
it is booted, so we don't need to wait for it here.  If we haven't
turned the sensor on, then it should raise ATTN when it has some data
for us.

> > +
> >   	return enable_sensor(rmi_dev);
> >   }
> >
> > @@ -634,7 +650,12 @@ static SIMPLE_DEV_PM_OPS(rmi_driver_pm, rmi_driver_suspend, rmi_driver_resume);
> >   static int rmi_driver_remove(struct device *dev)
> >   {
> >   	struct rmi_device *rmi_dev = to_rmi_device(dev);
> > +	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
> > +
> >   	disable_sensor(rmi_dev);
> > +
> > +	regulator_disable(data->vio);
> > +	regulator_disable(data->vdd);
> >   	rmi_free_function_list(rmi_dev);
> >
> >   	return 0;
> > @@ -649,6 +670,7 @@ static int rmi_driver_probe(struct device *dev)
> >   	int retval = 0;
> >   	struct rmi_device *rmi_dev;
> >   	unsigned int irq;
> > +	bool delay_start = false;
> >   	u32 reset_delay;
> >
> >   	dev_dbg(dev, "%s: Starting probe.\n", __func__);
> > @@ -696,6 +718,33 @@ static int rmi_driver_probe(struct device *dev)
> >   	dev_set_drvdata(&rmi_dev->dev, data);
> >   	mutex_init(&data->pdt_mutex);
> >
> > +	data->vdd = devm_regulator_get_optional(dev, "vdd");
> > +	if (IS_ERR(data->vdd)) {
> > +		dev_err(dev, "Failed to get regulator 'vdd'\n");
> > +		return PTR_ERR(data->vdd);
> > +	}
> > +	data->vio = devm_regulator_get_optional(dev, "vio");
> > +	if (IS_ERR(data->vio)) {
> > +		dev_err(dev, "Failed to get regulator 'vio'\n");
> > +		return PTR_ERR(data->vio);
> > +	}
> > +
> > +	if (data->vdd && !regulator_is_enabled(data->vdd))
> > +		delay_start = true;
> > +	if (data->vio && !regulator_is_enabled(data->vio))
> > +		delay_start = true;
> > +
> > +	retval = regulator_enable(data->vdd);
> > +	if (retval) {
> > +		dev_err(dev, "Failed to enable regulator\n");
> > +		return retval;
> > +	}
> > +	retval = regulator_enable(data->vio);
> > +	if (retval) {
> > +		dev_err(dev, "Failed to enable regulator\n");
> > +		return retval;
> > +	}
> > +
> >   	/*
> >   	 * Right before a warm boot, the sensor might be in some unusual state,
> >   	 * such as F54 diagnostics, or F34 bootloader mode.  In order to clear
> > @@ -714,6 +763,8 @@ static int rmi_driver_probe(struct device *dev)
> >   	 */
> >   	if (!reset_delay)
> >   		reset_delay = DEFAULT_RESET_DELAY_MS;
> > +	if (delay_start)
> > +		mdelay(reset_delay);
> >   	retval = rmi_initial_reset(rmi_dev, reset_delay);
> >   	if (retval)
> >   		dev_warn(dev, "RMI initial reset failed! Continuing in spite of this.\n");
> > diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
> > index eafbdb3..d553722 100644
> > --- a/drivers/input/rmi4/rmi_driver.h
> > +++ b/drivers/input/rmi4/rmi_driver.h
> > @@ -29,9 +29,13 @@
> >
> >   #define RMI_PDT_PROPS_HAS_BSR 0x02
> >
> > +struct regulator;
> > +
> >   struct rmi_driver_data {
> >   	struct list_head function_list;
> >
> > +	struct regulator *vdd;
> > +	struct regulator *vio;
> >   	struct rmi_device *rmi_dev;
> >
> >   	struct rmi_function *f01_container;
> >

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

* Re: [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan
  2014-02-04 23:10                           ` [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan Christopher Heiny
@ 2014-02-05  2:39                             ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:39 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:10:41AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> 
> Although necessary, this is redundant to changes already submitted.
> 

Indeed. Sorry.

> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> >   drivers/input/rmi4/rmi_driver.c | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> > index 52345ae..9d8d6ec 100644
> > --- a/drivers/input/rmi4/rmi_driver.c
> > +++ b/drivers/input/rmi4/rmi_driver.c
> > @@ -488,6 +488,8 @@ static int create_function(struct rmi_device *rmi_dev,
> >   		return error;
> >
> >   	list_add_tail(&fn->node, &data->function_list);
> > +	if (pdt->function_number == 0x01)
> > +		data->f01_container = fn;
> >
> >   	return 0;
> >   }
> >

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

* Re: [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status
  2014-02-04 23:10                             ` [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status Christopher Heiny
@ 2014-02-05  2:40                               ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-05  2:40 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Wed, Feb 05, 2014 at 12:10:49AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> >   drivers/input/rmi4/rmi_f01.c | 16 +++++++++-------
> >   1 file changed, 9 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
> > index 22b57f2..06fc5bc 100644
> > --- a/drivers/input/rmi4/rmi_f01.c
> > +++ b/drivers/input/rmi4/rmi_f01.c
> > @@ -318,13 +318,15 @@ static int rmi_f01_initialize(struct rmi_function *fn)
> >   	ctrl_base_addr += sizeof(u8);
> >
> >   	data->interrupt_enable_addr = ctrl_base_addr;
> > -	error = rmi_read_block(rmi_dev, ctrl_base_addr,
> > -				data->device_control.interrupt_enable,
> > -				sizeof(u8) * (data->num_of_irq_regs));
> > -	if (error < 0) {
> > -		dev_err(&fn->dev,
> > -			"Failed to read F01 control interrupt enable register.\n");
> > -		goto error_exit;
> > +	if (data->num_of_irq_regs > 0) {
> > +		error = rmi_read_block(rmi_dev, ctrl_base_addr,
> > +					data->device_control.interrupt_enable,
> > +					sizeof(u8) * (data->num_of_irq_regs));
> > +		if (error < 0) {
> > +			dev_err(&fn->dev,
> > +				"Failed to read F01 control interrupt enable register.\n");
> > +			goto error_exit;
> > +		}
> 
> If we don't know the number of IRQ registers at this point, we're 
> basically screwed, as most of the control register positions will be 
> known correctly.  The previously submitted IRQ counting patch ensures 
> that number of IRQ registers is know by this point - if they aren't, 
> then we should probably fail entirely rather than just muddling along.
> 

Sounds good.  I just needed this to prevent random failure cases during
testing.  If your patch solves this problem, then it's probably a much
better way to address this.

> >   	}
> >
> >   	ctrl_base_addr += data->num_of_irq_regs;
> >

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

* Re: [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
  2014-02-04 23:08   ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Christopher Heiny
  2014-02-05  2:26     ` Courtney Cavin
@ 2014-02-06  1:09     ` Dmitry Torokhov
  2014-02-06  1:36       ` Christopher Heiny
  1 sibling, 1 reply; 59+ messages in thread
From: Dmitry Torokhov @ 2014-02-06  1:09 UTC (permalink / raw)
  To: Christopher Heiny; +Cc: Courtney Cavin, linux-input

On Tue, Feb 04, 2014 at 03:08:12PM -0800, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> >Cc: Christopher Heiny <cheiny@synaptics.com>
> >Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> >Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> >---
> >  drivers/input/rmi4/rmi_bus.c    |  4 ++--
> >  drivers/input/rmi4/rmi_bus.h    |  2 +-
> >  drivers/input/rmi4/rmi_driver.c | 17 ++++++++++++-----
> >  drivers/input/rmi4/rmi_f11.c    |  4 +++-
> >  4 files changed, 18 insertions(+), 9 deletions(-)
> >
> >diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> >index 96a76e7..8a939f3 100644
> >--- a/drivers/input/rmi4/rmi_bus.c
> >+++ b/drivers/input/rmi4/rmi_bus.c
> >@@ -37,7 +37,7 @@ static void rmi_release_device(struct device *dev)
> >  	kfree(rmi_dev);
> >  }
> >
> >-struct device_type rmi_device_type = {
> >+static struct device_type rmi_device_type = {
> >  	.name		= "rmi_sensor",
> >  	.release	= rmi_release_device,
> >  };
> 
> This struct is used by diagnostic modules to identify sensor
> devices, so it cannot be static.

Then we need to declare it somewhere or provide an accessor function.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 15/15] Input: synaptics-rmi4 - correct RMI4 spec url
  2014-02-04 23:10                               ` Christopher Heiny
@ 2014-02-06  1:14                                 ` Dmitry Torokhov
  0 siblings, 0 replies; 59+ messages in thread
From: Dmitry Torokhov @ 2014-02-06  1:14 UTC (permalink / raw)
  To: Christopher Heiny; +Cc: Courtney Cavin, linux-input

On Tue, Feb 04, 2014 at 03:10:54PM -0800, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> >Cc: Christopher Heiny <cheiny@synaptics.com>
> >Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> >Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> 
> Acked-by: Christopher Heiny <cheiny@synaptics.com>

Applied, thank you.

> 
> >---
> >  drivers/input/rmi4/rmi_driver.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> >index 9d8d6ec..9d845a4 100644
> >--- a/drivers/input/rmi4/rmi_driver.c
> >+++ b/drivers/input/rmi4/rmi_driver.c
> >@@ -7,7 +7,7 @@
> >   * The RMI4 specification can be found here (URL split for line length):
> >   *
> >   * http://www.synaptics.com/sites/default/files/
> >- *      511-000136-01-Rev-E-RMI4%20Intrfacing%20Guide.pdf
> >+ *      511-000136-01-Rev-E-RMI4-Interfacing-Guide.pdf
> >   *
> >   * 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
> >
> 
> 
> -- 
> 
> Christopher Heiny
> Senior Staff Firmware Engineer
> Synaptics Incorporated

-- 
Dmitry

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

* Re: [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
  2014-02-06  1:09     ` Dmitry Torokhov
@ 2014-02-06  1:36       ` Christopher Heiny
  2014-02-13  6:36         ` Dmitry Torokhov
  0 siblings, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-06  1:36 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Courtney Cavin, linux-input

On 02/05/2014 05:09 PM, Dmitry Torokhov wrote:
> On Tue, Feb 04, 2014 at 03:08:12PM -0800, Christopher Heiny wrote:
>> >On 01/23/2014 04:00 PM, Courtney Cavin wrote:
>>> > >Cc: Christopher Heiny<cheiny@synaptics.com>
>>> > >Cc: Dmitry Torokhov<dmitry.torokhov@gmail.com>
>>> > >Signed-off-by: Courtney Cavin<courtney.cavin@sonymobile.com>
>>> > >---
>>> > >  drivers/input/rmi4/rmi_bus.c    |  4 ++--
>>> > >  drivers/input/rmi4/rmi_bus.h    |  2 +-
>>> > >  drivers/input/rmi4/rmi_driver.c | 17 ++++++++++++-----
>>> > >  drivers/input/rmi4/rmi_f11.c    |  4 +++-
>>> > >  4 files changed, 18 insertions(+), 9 deletions(-)
>>> > >
>>> > >diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
>>> > >index 96a76e7..8a939f3 100644
>>> > >--- a/drivers/input/rmi4/rmi_bus.c
>>> > >+++ b/drivers/input/rmi4/rmi_bus.c
>>> > >@@ -37,7 +37,7 @@ static void rmi_release_device(struct device *dev)
>>> > >  	kfree(rmi_dev);
>>> > >  }
>>> > >
>>> > >-struct device_type rmi_device_type = {
>>> > >+static struct device_type rmi_device_type = {
>>> > >  	.name		= "rmi_sensor",
>>> > >  	.release	= rmi_release_device,
>>> > >  };
>> >
>> >This struct is used by diagnostic modules to identify sensor
>> >devices, so it cannot be static.
 >
> Then we need to declare it somewhere or provide an accessor function.

Currently it's in a header not included in the patches.  We'll move it 
to rmi_bus.h.

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

* Re: [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling
  2014-02-05  2:31             ` Courtney Cavin
@ 2014-02-06  9:28               ` Linus Walleij
  2014-02-06 20:05                 ` Christopher Heiny
  2014-02-06 20:05               ` Christopher Heiny
  1 sibling, 1 reply; 59+ messages in thread
From: Linus Walleij @ 2014-02-06  9:28 UTC (permalink / raw)
  To: Courtney Cavin
  Cc: Christopher Heiny, linux-input, dmitry.torokhov, Linus WALLEIJ

On Wed, Feb 5, 2014 at 3:31 AM, Courtney Cavin
<courtney.cavin@sonymobile.com> wrote:
> On Wed, Feb 05, 2014 at 12:08:35AM +0100, Christopher Heiny wrote:
>> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
>> > Since all the configuration needed for an irq can be provided in other
>> > ways, remove all gpio->irq functionality. This cleans up the code quite
>> > a bit.
>>
>> In certain diagnostic modes, we need to be able to release the IRQ so
>> the GPIO can be monitored from userspace.  This patch removes that
>> capability.
>
> Polling a GPIO from userspace is poor design regardless of the use-case, if
> you ask me.  It certainly doesn't motivate the extra gpio<->IRQ code.

I think Courtney is right here, if you want this kind of stuff for debugging
it should be debug-add-on-patches, not part of the normal execution
path for the driver.

>> As mentioned in previous patch discussions, the polling functionality is
>> quite useful during new system integration, so we need to retain that.
>> If you have a proposal for where else it could be done, we'd certainly
>> entertain a patch that implements that.
>
> Do you actually have systems that have these hooked up to GPIOs without
> IRQ support?
>
> Regardless, if this is the case, implementing a GPIO polling IRQ chip
> should be possible, if extremely ugly.

OMG that would be quite horrible.

> Linus may have some comments in this area, though.  Linus?

A driver may rely on polling but a driver may not rely on polling
done from userspace.

Yours,
Linus Walleij

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

* Re: [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling
  2014-02-05  2:31             ` Courtney Cavin
  2014-02-06  9:28               ` Linus Walleij
@ 2014-02-06 20:05               ` Christopher Heiny
  2014-02-07  1:47                 ` Courtney Cavin
  1 sibling, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-06 20:05 UTC (permalink / raw)
  To: Courtney Cavin; +Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On 02/04/2014 06:31 PM, Courtney Cavin wrote:
> On Wed, Feb 05, 2014 at 12:08:35AM +0100, Christopher Heiny wrote:
>> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
>>> Since all the configuration needed for an irq can be provided in other
>>> ways, remove all gpio->irq functionality. This cleans up the code quite
>>> a bit.
>>
>> In certain diagnostic modes, we need to be able to release the IRQ so
>> the GPIO can be monitored from userspace.  This patch removes that
>> capability.
>>
>
> Polling a GPIO from userspace is poor design regardless of the use-case, if
> you ask me.  It certainly doesn't motivate the extra gpio<->IRQ code.

Fortunately, neither the in-driver polling implementation nor the user 
space diagnostic applications are implemented that way.

>>> This also gets rid of polling functionality, as this should be done
>>> elsewhere if absolutely needed.
>>
>> As mentioned in previous patch discussions, the polling functionality is
>> quite useful during new system integration, so we need to retain that.
>> If you have a proposal for where else it could be done, we'd certainly
>> entertain a patch that implements that.
>
> Do you actually have systems that have these hooked up to GPIOs without
> IRQ support?

The right question would be "What are some situations where this polling 
functionality would be needed?"

As I mentioned, this is usually needed during new system integration - 
that is, when trying to bring up the driver on a new or substantially 
modified platform.  You might not know where the ATTN GPIO is not known 
(either by omission or an error in the specifications) at the time it is 
initially brought up, or you might have a prototype board has a layout 
error that leaves the ATTN GPIO unconnected.  You'd be surprised at how 
often these situations occur (twice so far this week, f'rinstance). 
Rather than just telling the engineers "Hey, go play MineSweeper for a 
few days (or weeks) while someone tracks down the specs (or spins the 
PCB)", having in-driver polling support lets you bring up the sensor 
right away.

> Regardless, if this is the case, implementing a GPIO polling IRQ chip
> should be possible, if extremely ugly.
>
> Linus may have some comments in this area, though.  Linus?
>
>>
>>                                          Thanks,
>>                                                  Chris
>>
>>>
>>> Cc: Christopher Heiny <cheiny@synaptics.com>
>>> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>>> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
>>> ---
>>>    drivers/input/rmi4/rmi_driver.c | 143 +++++-----------------------------------
>>>    drivers/input/rmi4/rmi_driver.h |   7 --
>>>    drivers/input/rmi4/rmi_i2c.c    |  24 +------
>>>    include/linux/rmi.h             |  31 +--------
>>>    4 files changed, 20 insertions(+), 185 deletions(-)
>>>
>>> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
>>> index 5fb582c..780742f 100644
>>> --- a/drivers/input/rmi4/rmi_driver.c
>>> +++ b/drivers/input/rmi4/rmi_driver.c
>>> @@ -20,7 +20,6 @@
>>>    #include <linux/delay.h>
>>>    #include <linux/device.h>
>>>    #include <linux/fs.h>
>>> -#include <linux/gpio.h>
>>>    #include <linux/kconfig.h>
>>>    #include <linux/list.h>
>>>    #include <linux/module.h>
>>> @@ -50,74 +49,17 @@ static irqreturn_t rmi_irq_thread(int irq, void *p)
>>>        struct rmi_transport_dev *xport = p;
>>>        struct rmi_device *rmi_dev = xport->rmi_dev;
>>>        struct rmi_driver *driver = rmi_dev->driver;
>>> -     struct rmi_device_platform_data *pdata = xport->dev->platform_data;
>>>        struct rmi_driver_data *data;
>>>
>>>        data = dev_get_drvdata(&rmi_dev->dev);
>>> -
>>> -     if (IRQ_DEBUG(data))
>>> -             dev_dbg(xport->dev, "ATTN gpio, value: %d.\n",
>>> -                             gpio_get_value(pdata->attn_gpio));
>>> -
>>> -     if (gpio_get_value(pdata->attn_gpio) == pdata->attn_polarity) {
>>> -             data->attn_count++;
>>> -             if (driver && driver->irq_handler && rmi_dev)
>>> -                     driver->irq_handler(rmi_dev, irq);
>>> -     }
>>> +     if (driver && driver->irq_handler && rmi_dev)
>>> +             driver->irq_handler(rmi_dev, irq);
>>>
>>>        return IRQ_HANDLED;
>>>    }
>>>
>>>    static int process_interrupt_requests(struct rmi_device *rmi_dev);
>>>
>>> -static void rmi_poll_work(struct work_struct *work)
>>> -{
>>> -     struct rmi_driver_data *data =
>>> -                     container_of(work, struct rmi_driver_data, poll_work);
>>> -     struct rmi_device *rmi_dev = data->rmi_dev;
>>> -
>>> -     process_interrupt_requests(rmi_dev);
>>> -}
>>> -
>>> -/*
>>> - * This is the timer function for polling - it simply has to schedule work
>>> - * and restart the timer.
>>> - */
>>> -static enum hrtimer_restart rmi_poll_timer(struct hrtimer *timer)
>>> -{
>>> -     struct rmi_driver_data *data =
>>> -                     container_of(timer, struct rmi_driver_data, poll_timer);
>>> -
>>> -     if (!data->enabled)
>>> -             return HRTIMER_NORESTART;
>>> -     if (!work_pending(&data->poll_work))
>>> -             schedule_work(&data->poll_work);
>>> -     hrtimer_start(&data->poll_timer, data->poll_interval, HRTIMER_MODE_REL);
>>> -     return HRTIMER_NORESTART;
>>> -}
>>> -
>>> -static int enable_polling(struct rmi_device *rmi_dev)
>>> -{
>>> -     struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
>>> -
>>> -     dev_dbg(&rmi_dev->dev, "Polling enabled.\n");
>>> -     INIT_WORK(&data->poll_work, rmi_poll_work);
>>> -     hrtimer_init(&data->poll_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
>>> -     data->poll_timer.function = rmi_poll_timer;
>>> -     hrtimer_start(&data->poll_timer, data->poll_interval, HRTIMER_MODE_REL);
>>> -
>>> -     return 0;
>>> -}
>>> -
>>> -static void disable_polling(struct rmi_device *rmi_dev)
>>> -{
>>> -     struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
>>> -
>>> -     dev_dbg(&rmi_dev->dev, "Polling disabled.\n");
>>> -     hrtimer_cancel(&data->poll_timer);
>>> -     cancel_work_sync(&data->poll_work);
>>> -}
>>> -
>>>    static void disable_sensor(struct rmi_device *rmi_dev)
>>>    {
>>>        struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
>>> @@ -125,9 +67,6 @@ static void disable_sensor(struct rmi_device *rmi_dev)
>>>        if (!data->enabled)
>>>                return;
>>>
>>> -     if (!data->irq)
>>> -             disable_polling(rmi_dev);
>>> -
>>>        if (rmi_dev->xport->ops->disable_device)
>>>                rmi_dev->xport->ops->disable_device(rmi_dev->xport);
>>>
>>> @@ -155,20 +94,14 @@ static int enable_sensor(struct rmi_device *rmi_dev)
>>>        }
>>>
>>>        xport = rmi_dev->xport;
>>> -     if (data->irq) {
>>> -             retval = request_threaded_irq(data->irq,
>>> -                             xport->hard_irq ? xport->hard_irq : NULL,
>>> -                             xport->irq_thread ?
>>> -                                     xport->irq_thread : rmi_irq_thread,
>>> -                             data->irq_flags,
>>> -                             dev_name(&rmi_dev->dev), xport);
>>> -             if (retval)
>>> -                     return retval;
>>> -     } else {
>>> -             retval = enable_polling(rmi_dev);
>>> -             if (retval < 0)
>>> -                     return retval;
>>> -     }
>>> +     retval = request_threaded_irq(data->irq,
>>> +                     xport->hard_irq ? xport->hard_irq : NULL,
>>> +                     xport->irq_thread ?
>>> +                             xport->irq_thread : rmi_irq_thread,
>>> +                     IRQF_ONESHOT,
>>> +                     dev_name(&rmi_dev->dev), xport);
>>> +     if (retval)
>>> +             return retval;
>>>
>>>        data->enabled = true;
>>>
>>> @@ -751,16 +684,9 @@ static SIMPLE_DEV_PM_OPS(rmi_driver_pm, rmi_driver_suspend, rmi_driver_resume);
>>>    static int rmi_driver_remove(struct device *dev)
>>>    {
>>>        struct rmi_device *rmi_dev = to_rmi_device(dev);
>>> -     const struct rmi_device_platform_data *pdata =
>>> -                                     to_rmi_platform_data(rmi_dev);
>>> -     const struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
>>> -
>>>        disable_sensor(rmi_dev);
>>>        rmi_free_function_list(rmi_dev);
>>>
>>> -     if (data->gpio_held)
>>> -             gpio_free(pdata->attn_gpio);
>>> -
>>>        return 0;
>>>    }
>>>
>>> @@ -895,51 +821,12 @@ static int rmi_driver_probe(struct device *dev)
>>>                mutex_init(&data->suspend_mutex);
>>>        }
>>>
>>> -     if (gpio_is_valid(pdata->attn_gpio)) {
>>> -             static const char GPIO_LABEL[] = "attn";
>>> -             unsigned long gpio_flags = GPIOF_DIR_IN;
>>> -
>>> -             data->irq = gpio_to_irq(pdata->attn_gpio);
>>> -             if (pdata->level_triggered) {
>>> -                     data->irq_flags = IRQF_ONESHOT |
>>> -                             ((pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH)
>>> -                             ? IRQF_TRIGGER_HIGH : IRQF_TRIGGER_LOW);
>>> -             } else {
>>> -                     data->irq_flags =
>>> -                             (pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH)
>>> -                             ? IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
>>> -             }
>>> +     data->irq = pdata->irq;
>>> +     if (data->irq < 0) {
>>> +             dev_err(dev, "Failed to get attn IRQ.\n");
>>> +             retval = data->irq;
>>> +             goto err_free_data;
>>>
>>> -             if (IS_ENABLED(CONFIG_RMI4_DEV))
>>> -                     gpio_flags |= GPIOF_EXPORT;
>>> -
>>> -             retval = gpio_request_one(pdata->attn_gpio, gpio_flags,
>>> -                                       GPIO_LABEL);
>>> -             if (retval) {
>>> -                     dev_warn(dev, "WARNING: Failed to request ATTN gpio %d, code=%d.\n",
>>> -                              pdata->attn_gpio, retval);
>>> -                     retval = 0;
>>> -             } else {
>>> -                     dev_info(dev, "Obtained ATTN gpio %d.\n",
>>> -                                     pdata->attn_gpio);
>>> -                     data->gpio_held = true;
>>> -                     if (IS_ENABLED(CONFIG_RMI4_DEV)) {
>>> -                             retval = gpio_export_link(dev,
>>> -                                             GPIO_LABEL, pdata->attn_gpio);
>>> -                             if (retval) {
>>> -                                     dev_warn(dev,
>>> -                                             "WARNING: Failed to symlink ATTN gpio!\n");
>>> -                                     retval = 0;
>>> -                             } else {
>>> -                                     dev_info(dev, "Exported ATTN gpio %d.",
>>> -                                             pdata->attn_gpio);
>>> -                             }
>>> -                     }
>>> -             }
>>> -     } else {
>>> -             data->poll_interval = ktime_set(0,
>>> -                     (pdata->poll_interval_ms ? pdata->poll_interval_ms :
>>> -                     DEFAULT_POLL_INTERVAL_MS) * 1000 * 1000);
>>>        }
>>>
>>>        if (data->f01_container->dev.driver) {
>>> diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
>>> index 4f44a54..aef5521 100644
>>> --- a/drivers/input/rmi4/rmi_driver.h
>>> +++ b/drivers/input/rmi4/rmi_driver.h
>>> @@ -39,9 +39,7 @@ struct rmi_driver_data {
>>>
>>>        u32 attn_count;
>>>        u32 irq_debug;  /* Should be bool, but debugfs wants u32 */
>>> -     bool gpio_held;
>>>        int irq;
>>> -     int irq_flags;
>>>        int num_of_irq_regs;
>>>        int irq_count;
>>>        unsigned long *irq_status;
>>> @@ -50,11 +48,6 @@ struct rmi_driver_data {
>>>        bool irq_stored;
>>>        struct mutex irq_mutex;
>>>
>>> -     /* Following are used when polling. */
>>> -     struct hrtimer poll_timer;
>>> -     struct work_struct poll_work;
>>> -     ktime_t poll_interval;
>>> -
>>>        struct mutex pdt_mutex;
>>>        u8 pdt_props;
>>>        u8 bsr;
>>> diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
>>> index 910f05c..aebf974 100644
>>> --- a/drivers/input/rmi4/rmi_i2c.c
>>> +++ b/drivers/input/rmi4/rmi_i2c.c
>>> @@ -196,8 +196,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
>>>                return -EINVAL;
>>>        }
>>>
>>> -     dev_dbg(&client->dev, "Probing %#02x (GPIO %d).\n",
>>> -             client->addr, pdata->attn_gpio);
>>> +     dev_dbg(&client->dev, "Probing %#02x.\n", client->addr);
>>>
>>>        if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
>>>                dev_err(&client->dev,
>>> @@ -205,15 +204,6 @@ static int rmi_i2c_probe(struct i2c_client *client,
>>>                return -ENODEV;
>>>        }
>>>
>>> -     if (pdata->gpio_config) {
>>> -             retval = pdata->gpio_config(pdata->gpio_data, true);
>>> -             if (retval < 0) {
>>> -                     dev_err(&client->dev, "Failed to configure GPIOs, code: %d.\n",
>>> -                             retval);
>>> -                     return retval;
>>> -             }
>>> -     }
>>> -
>>>        rmi_i2c = devm_kzalloc(&client->dev, sizeof(struct rmi_i2c_xport),
>>>                                GFP_KERNEL);
>>>        if (!rmi_i2c)
>>> @@ -240,7 +230,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
>>>        if (retval) {
>>>                dev_err(&client->dev, "Failed to register transport driver at 0x%.2X.\n",
>>>                        client->addr);
>>> -             goto err_gpio;
>>> +             goto err;
>>>        }
>>>
>>>        i2c_set_clientdata(client, rmi_i2c);
>>> @@ -249,24 +239,16 @@ static int rmi_i2c_probe(struct i2c_client *client,
>>>                        client->addr);
>>>        return 0;
>>>
>>> -err_gpio:
>>> -     if (pdata->gpio_config)
>>> -             pdata->gpio_config(pdata->gpio_data, false);
>>> -
>>> +err:
>>>        return retval;
>>>    }
>>>
>>>    static int rmi_i2c_remove(struct i2c_client *client)
>>>    {
>>> -     const struct rmi_device_platform_data *pdata =
>>> -                             dev_get_platdata(&client->dev);
>>>        struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client);
>>>
>>>        rmi_unregister_transport_device(&rmi_i2c->xport);
>>>
>>> -     if (pdata->gpio_config)
>>> -             pdata->gpio_config(pdata->gpio_data, false);
>>> -
>>>        return 0;
>>>    }
>>>
>>> diff --git a/include/linux/rmi.h b/include/linux/rmi.h
>>> index 65b59b5..326e741 100644
>>> --- a/include/linux/rmi.h
>>> +++ b/include/linux/rmi.h
>>> @@ -23,11 +23,6 @@
>>>    #include <linux/wait.h>
>>>    #include <linux/debugfs.h>
>>>
>>> -enum rmi_attn_polarity {
>>> -     RMI_ATTN_ACTIVE_LOW = 0,
>>> -     RMI_ATTN_ACTIVE_HIGH = 1
>>> -};
>>> -
>>>    /**
>>>     * struct rmi_f11_axis_alignment - target axis alignment
>>>     * @swap_axes: set to TRUE if desired to swap x- and y-axis
>>> @@ -194,25 +189,10 @@ struct rmi_device_platform_data_spi {
>>>    /**
>>>     * struct rmi_device_platform_data - system specific configuration info.
>>>     *
>>> + * @irq - attention IRQ
>>>     * @firmware_name - if specified will override default firmware name,
>>>     * for reflashing.
>>>     *
>>> - * @attn_gpio - the index of a GPIO that will be used to provide the ATTN
>>> - * interrupt from the touch sensor.
>>> - * @attn_polarity - indicates whether ATTN is active high or low.
>>> - * @level_triggered - by default, the driver uses edge triggered interrupts.
>>> - * However, this can cause problems with suspend/resume on some platforms.  In
>>> - * that case, set this to 1 to use level triggered interrupts.
>>> - * @gpio_config - a routine that will be called when the driver is loaded to
>>> - * perform any platform specific GPIO configuration, and when it is unloaded
>>> - * for GPIO de-configuration.  This is typically used to configure the ATTN
>>> - * GPIO and the I2C or SPI pins, if necessary.
>>> - * @gpio_data - platform specific data to be passed to the GPIO configuration
>>> - * function.
>>> - *
>>> - * @poll_interval_ms - the time in milliseconds between reads of the interrupt
>>> - * status register.  This is ignored if attn_gpio is non-zero.
>>> - *
>>>     * @reset_delay_ms - after issuing a reset command to the touch sensor, the
>>>     * driver waits a few milliseconds to give the firmware a chance to
>>>     * to re-initialize.  You can override the default wait period here.
>>> @@ -245,14 +225,7 @@ struct rmi_device_platform_data_spi {
>>>     * functions.
>>>     */
>>>    struct rmi_device_platform_data {
>>> -     int attn_gpio;
>>> -     enum rmi_attn_polarity attn_polarity;
>>> -     bool level_triggered;
>>> -     void *gpio_data;
>>> -     int (*gpio_config)(void *gpio_data, bool configure);
>>> -
>>> -     int poll_interval_ms;
>>> -
>>> +     int irq;
>>>        int reset_delay_ms;
>>>
>>>        struct rmi_device_platform_data_spi spi_data;
>>>

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

* Re: [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling
  2014-02-06  9:28               ` Linus Walleij
@ 2014-02-06 20:05                 ` Christopher Heiny
  2014-02-07  1:45                   ` Courtney Cavin
  0 siblings, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-06 20:05 UTC (permalink / raw)
  To: Linus Walleij, Courtney Cavin; +Cc: linux-input, dmitry.torokhov, Linus WALLEIJ

On 02/06/2014 01:28 AM, Linus Walleij wrote:
> On Wed, Feb 5, 2014 at 3:31 AM, Courtney Cavin
> <courtney.cavin@sonymobile.com>  wrote:
>> >On Wed, Feb 05, 2014 at 12:08:35AM +0100, Christopher Heiny wrote:
>>> >>On 01/23/2014 04:00 PM, Courtney Cavin wrote:
>>>> >> >Since all the configuration needed for an irq can be provided in other
>>>> >> >ways, remove all gpio->irq functionality. This cleans up the code quite
>>>> >> >a bit.
>>> >>
>>> >>In certain diagnostic modes, we need to be able to release the IRQ so
>>> >>the GPIO can be monitored from userspace.  This patch removes that
>>> >>capability.
>> >
>> >Polling a GPIO from userspace is poor design regardless of the use-case, if
>> >you ask me.  It certainly doesn't motivate the extra gpio<->IRQ code.
 >
> I think Courtney is right here, if you want this kind of stuff for debugging
> it should be debug-add-on-patches, not part of the normal execution
> path for the driver.

I'm OK with replacing the current polling implementation with an 
add-on-patch, as long as the support for the debug-add-on-patches 
doesn't get torn out of the driver because "hey, I don't see what this 
is used for in the core driver code, so it must be unnecessary".


>>> >>As mentioned in previous patch discussions, the polling functionality is
>>> >>quite useful during new system integration, so we need to retain that.
>>> >>If you have a proposal for where else it could be done, we'd certainly
>>> >>entertain a patch that implements that.
>> >
>> >Do you actually have systems that have these hooked up to GPIOs without
>> >IRQ support?
>> >
>> >Regardless, if this is the case, implementing a GPIO polling IRQ chip
>> >should be possible, if extremely ugly.
> OMG that would be quite horrible.
>
>> >Linus may have some comments in this area, though.  Linus?
 >
> A driver may rely on polling but a driver may not rely on polling
> done from userspace.

Fortunately, the driver doesn't rely on polling from user space.

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

* Re: [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling
  2014-02-06 20:05                 ` Christopher Heiny
@ 2014-02-07  1:45                   ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-07  1:45 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: Linus Walleij, linux-input, dmitry.torokhov, Linus WALLEIJ

On Thu, Feb 06, 2014 at 09:05:09PM +0100, Christopher Heiny wrote:
> On 02/06/2014 01:28 AM, Linus Walleij wrote:
> > On Wed, Feb 5, 2014 at 3:31 AM, Courtney Cavin
> > <courtney.cavin@sonymobile.com>  wrote:
> >> >On Wed, Feb 05, 2014 at 12:08:35AM +0100, Christopher Heiny wrote:
> >>> >>On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> >>>> >> >Since all the configuration needed for an irq can be provided in other
> >>>> >> >ways, remove all gpio->irq functionality. This cleans up the code quite
> >>>> >> >a bit.
> >>> >>
> >>> >>In certain diagnostic modes, we need to be able to release the IRQ so
> >>> >>the GPIO can be monitored from userspace.  This patch removes that
> >>> >>capability.
> >> >
> >> >Polling a GPIO from userspace is poor design regardless of the use-case, if
> >> >you ask me.  It certainly doesn't motivate the extra gpio<->IRQ code.
>  >
> > I think Courtney is right here, if you want this kind of stuff for debugging
> > it should be debug-add-on-patches, not part of the normal execution
> > path for the driver.
> 
> I'm OK with replacing the current polling implementation with an 
> add-on-patch, as long as the support for the debug-add-on-patches 
> doesn't get torn out of the driver because "hey, I don't see what this 
> is used for in the core driver code, so it must be unnecessary".

An add-on patch shouldn't force dependencies on the code which it
patches.  Thus, the code shouldn't need support for debug add-ons.

Besides, try "hey, this isn't used in the core driver code, so it is
unnecessary."  This whole "there's another tree which depends on things
staying the way they are," isn't conducive to actually making changes to
improve the driver.

> >>> >>As mentioned in previous patch discussions, the polling functionality is
> >>> >>quite useful during new system integration, so we need to retain that.
> >>> >>If you have a proposal for where else it could be done, we'd certainly
> >>> >>entertain a patch that implements that.
> >> >
> >> >Do you actually have systems that have these hooked up to GPIOs without
> >> >IRQ support?
> >> >
> >> >Regardless, if this is the case, implementing a GPIO polling IRQ chip
> >> >should be possible, if extremely ugly.
> > OMG that would be quite horrible.
> >
> >> >Linus may have some comments in this area, though.  Linus?
>  >
> > A driver may rely on polling but a driver may not rely on polling
> > done from userspace.
> 
> Fortunately, the driver doesn't rely on polling from user space.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling
  2014-02-06 20:05               ` Christopher Heiny
@ 2014-02-07  1:47                 ` Courtney Cavin
  0 siblings, 0 replies; 59+ messages in thread
From: Courtney Cavin @ 2014-02-07  1:47 UTC (permalink / raw)
  To: Christopher Heiny
  Cc: linux-input, dmitry.torokhov, linus.walleij, linus.walleij

On Thu, Feb 06, 2014 at 09:05:05PM +0100, Christopher Heiny wrote:
> On 02/04/2014 06:31 PM, Courtney Cavin wrote:
> > On Wed, Feb 05, 2014 at 12:08:35AM +0100, Christopher Heiny wrote:
> >> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> >>> Since all the configuration needed for an irq can be provided in other
> >>> ways, remove all gpio->irq functionality. This cleans up the code quite
> >>> a bit.
> >>
> >> In certain diagnostic modes, we need to be able to release the IRQ so
> >> the GPIO can be monitored from userspace.  This patch removes that
> >> capability.
> >>
> >
> > Polling a GPIO from userspace is poor design regardless of the use-case, if
> > you ask me.  It certainly doesn't motivate the extra gpio<->IRQ code.
> 
> Fortunately, neither the in-driver polling implementation nor the user
> space diagnostic applications are implemented that way.

I'm missing something here then.  If the userspace diagnostic
applications do not poll the GPIO, then what exactly is the purpose of
them accessing the GPIO at all?

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

* Re: [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
  2014-02-06  1:36       ` Christopher Heiny
@ 2014-02-13  6:36         ` Dmitry Torokhov
  2014-02-13 18:56           ` Christopher Heiny
  0 siblings, 1 reply; 59+ messages in thread
From: Dmitry Torokhov @ 2014-02-13  6:36 UTC (permalink / raw)
  To: Christopher Heiny; +Cc: Courtney Cavin, linux-input

On Wed, Feb 05, 2014 at 05:36:09PM -0800, Christopher Heiny wrote:
> On 02/05/2014 05:09 PM, Dmitry Torokhov wrote:
> >On Tue, Feb 04, 2014 at 03:08:12PM -0800, Christopher Heiny wrote:
> >>>On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> >>>> >Cc: Christopher Heiny<cheiny@synaptics.com>
> >>>> >Cc: Dmitry Torokhov<dmitry.torokhov@gmail.com>
> >>>> >Signed-off-by: Courtney Cavin<courtney.cavin@sonymobile.com>
> >>>> >---
> >>>> >  drivers/input/rmi4/rmi_bus.c    |  4 ++--
> >>>> >  drivers/input/rmi4/rmi_bus.h    |  2 +-
> >>>> >  drivers/input/rmi4/rmi_driver.c | 17 ++++++++++++-----
> >>>> >  drivers/input/rmi4/rmi_f11.c    |  4 +++-
> >>>> >  4 files changed, 18 insertions(+), 9 deletions(-)
> >>>> >
> >>>> >diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> >>>> >index 96a76e7..8a939f3 100644
> >>>> >--- a/drivers/input/rmi4/rmi_bus.c
> >>>> >+++ b/drivers/input/rmi4/rmi_bus.c
> >>>> >@@ -37,7 +37,7 @@ static void rmi_release_device(struct device *dev)
> >>>> >  	kfree(rmi_dev);
> >>>> >  }
> >>>> >
> >>>> >-struct device_type rmi_device_type = {
> >>>> >+static struct device_type rmi_device_type = {
> >>>> >  	.name		= "rmi_sensor",
> >>>> >  	.release	= rmi_release_device,
> >>>> >  };
> >>>
> >>>This struct is used by diagnostic modules to identify sensor
> >>>devices, so it cannot be static.
> >
> >Then we need to declare it somewhere or provide an accessor function.
> 
> Currently it's in a header not included in the patches.  We'll move
> it to rmi_bus.h.

Hmm, we do have rmi_is_physical_device() to identify whether it is a
sensor or a function, so I believe we should mark all structures static
to avoid anyone poking at them.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
  2014-02-13  6:36         ` Dmitry Torokhov
@ 2014-02-13 18:56           ` Christopher Heiny
  2014-02-13 19:10             ` Dmitry Torokhov
  0 siblings, 1 reply; 59+ messages in thread
From: Christopher Heiny @ 2014-02-13 18:56 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Courtney Cavin, linux-input

On 02/12/2014 10:36 PM, Dmitry Torokhov wrote:
> On Wed, Feb 05, 2014 at 05:36:09PM -0800, Christopher Heiny wrote:
>> >On 02/05/2014 05:09 PM, Dmitry Torokhov wrote:
>>> > >On Tue, Feb 04, 2014 at 03:08:12PM -0800, Christopher Heiny wrote:
>>>>> > >>>On 01/23/2014 04:00 PM, Courtney Cavin wrote:
>>>>>>> > >>>> >Cc: Christopher Heiny<cheiny@synaptics.com>
>>>>>>> > >>>> >Cc: Dmitry Torokhov<dmitry.torokhov@gmail.com>
>>>>>>> > >>>> >Signed-off-by: Courtney Cavin<courtney.cavin@sonymobile.com>
>>>>>>> > >>>> >---
>>>>>>> > >>>> >  drivers/input/rmi4/rmi_bus.c    |  4 ++--
>>>>>>> > >>>> >  drivers/input/rmi4/rmi_bus.h    |  2 +-
>>>>>>> > >>>> >  drivers/input/rmi4/rmi_driver.c | 17 ++++++++++++-----
>>>>>>> > >>>> >  drivers/input/rmi4/rmi_f11.c    |  4 +++-
>>>>>>> > >>>> >  4 files changed, 18 insertions(+), 9 deletions(-)
>>>>>>> > >>>> >
>>>>>>> > >>>> >diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
>>>>>>> > >>>> >index 96a76e7..8a939f3 100644
>>>>>>> > >>>> >--- a/drivers/input/rmi4/rmi_bus.c
>>>>>>> > >>>> >+++ b/drivers/input/rmi4/rmi_bus.c
>>>>>>> > >>>> >@@ -37,7 +37,7 @@ static void rmi_release_device(struct device *dev)
>>>>>>> > >>>> >  	kfree(rmi_dev);
>>>>>>> > >>>> >  }
>>>>>>> > >>>> >
>>>>>>> > >>>> >-struct device_type rmi_device_type = {
>>>>>>> > >>>> >+static struct device_type rmi_device_type = {
>>>>>>> > >>>> >  	.name		= "rmi_sensor",
>>>>>>> > >>>> >  	.release	= rmi_release_device,
>>>>>>> > >>>> >  };
>>>>> > >>>
>>>>> > >>>This struct is used by diagnostic modules to identify sensor
>>>>> > >>>devices, so it cannot be static.
>>> > >
>>> > >Then we need to declare it somewhere or provide an accessor function.
>> >
>> >Currently it's in a header not included in the patches.  We'll move
>> >it to rmi_bus.h.
> Hmm, we do have rmi_is_physical_device() to identify whether it is a
> sensor or a function, so I believe we should mark all structures static
> to avoid anyone poking at them.

I was poking around in the dependent code late last night and came to 
the same conclusion.  I'll send a micropatch later today to get it out 
of the way.


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

* Re: [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
  2014-02-13 18:56           ` Christopher Heiny
@ 2014-02-13 19:10             ` Dmitry Torokhov
  2014-02-13 19:12               ` Dmitry Torokhov
  0 siblings, 1 reply; 59+ messages in thread
From: Dmitry Torokhov @ 2014-02-13 19:10 UTC (permalink / raw)
  To: Christopher Heiny; +Cc: Courtney Cavin, linux-input

On Thursday, February 13, 2014 10:56:25 AM Christopher Heiny wrote:
> On 02/12/2014 10:36 PM, Dmitry Torokhov wrote:
> > On Wed, Feb 05, 2014 at 05:36:09PM -0800, Christopher Heiny wrote:
> >> >On 02/05/2014 05:09 PM, Dmitry Torokhov wrote:
> >>> > >On Tue, Feb 04, 2014 at 03:08:12PM -0800, Christopher Heiny wrote:
> >>>>> > >>>On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> >>>>>>> > >>>> >Cc: Christopher Heiny<cheiny@synaptics.com>
> >>>>>>> > >>>> >Cc: Dmitry Torokhov<dmitry.torokhov@gmail.com>
> >>>>>>> > >>>> >Signed-off-by: Courtney Cavin<courtney.cavin@sonymobile.com>
> >>>>>>> > >>>> >---
> >>>>>>> > >>>> >
> >>>>>>> > >>>> >  drivers/input/rmi4/rmi_bus.c    |  4 ++--
> >>>>>>> > >>>> >  drivers/input/rmi4/rmi_bus.h    |  2 +-
> >>>>>>> > >>>> >  drivers/input/rmi4/rmi_driver.c | 17 ++++++++++++-----
> >>>>>>> > >>>> >  drivers/input/rmi4/rmi_f11.c    |  4 +++-
> >>>>>>> > >>>> >  4 files changed, 18 insertions(+), 9 deletions(-)
> >>>>>>> > >>>> >
> >>>>>>> > >>>> >diff --git a/drivers/input/rmi4/rmi_bus.c
> >>>>>>> > >>>> >b/drivers/input/rmi4/rmi_bus.c
> >>>>>>> > >>>> >index 96a76e7..8a939f3 100644
> >>>>>>> > >>>> >--- a/drivers/input/rmi4/rmi_bus.c
> >>>>>>> > >>>> >+++ b/drivers/input/rmi4/rmi_bus.c
> >>>>>>> > >>>> >@@ -37,7 +37,7 @@ static void rmi_release_device(struct
> >>>>>>> > >>>> >device *dev)
> >>>>>>> > >>>> >
> >>>>>>> > >>>> >  	kfree(rmi_dev);
> >>>>>>> > >>>> >  
> >>>>>>> > >>>> >  }
> >>>>>>> > >>>> >
> >>>>>>> > >>>> >-struct device_type rmi_device_type = {
> >>>>>>> > >>>> >+static struct device_type rmi_device_type = {
> >>>>>>> > >>>> >
> >>>>>>> > >>>> >  	.name		= "rmi_sensor",
> >>>>>>> > >>>> >  	.release	= rmi_release_device,
> >>>>>>> > >>>> >  
> >>>>>>> > >>>> >  };
> >>>>> > >>>
> >>>>> > >>>This struct is used by diagnostic modules to identify sensor
> >>>>> > >>>devices, so it cannot be static.
> >>> > >
> >>> > >Then we need to declare it somewhere or provide an accessor function.
> >> >
> >> >Currently it's in a header not included in the patches.  We'll move
> >> >it to rmi_bus.h.
> > 
> > Hmm, we do have rmi_is_physical_device() to identify whether it is a
> > sensor or a function, so I believe we should mark all structures static
> > to avoid anyone poking at them.
> 
> I was poking around in the dependent code late last night and came to
> the same conclusion.  I'll send a micropatch later today to get it out
> of the way.

No need, I untangled relevant bits from the one Courtney sent.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
  2014-02-13 19:10             ` Dmitry Torokhov
@ 2014-02-13 19:12               ` Dmitry Torokhov
  2014-02-13 19:25                 ` Christopher Heiny
  0 siblings, 1 reply; 59+ messages in thread
From: Dmitry Torokhov @ 2014-02-13 19:12 UTC (permalink / raw)
  To: Christopher Heiny; +Cc: Courtney Cavin, linux-input

On Thu, Feb 13, 2014 at 11:10:29AM -0800, Dmitry Torokhov wrote:
> On Thursday, February 13, 2014 10:56:25 AM Christopher Heiny wrote:
> > On 02/12/2014 10:36 PM, Dmitry Torokhov wrote:
> > > On Wed, Feb 05, 2014 at 05:36:09PM -0800, Christopher Heiny wrote:
> > >> >On 02/05/2014 05:09 PM, Dmitry Torokhov wrote:
> > >>> > >On Tue, Feb 04, 2014 at 03:08:12PM -0800, Christopher Heiny wrote:
> > >>>>> > >>>On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > >>>>>>> > >>>> >Cc: Christopher Heiny<cheiny@synaptics.com>
> > >>>>>>> > >>>> >Cc: Dmitry Torokhov<dmitry.torokhov@gmail.com>
> > >>>>>>> > >>>> >Signed-off-by: Courtney Cavin<courtney.cavin@sonymobile.com>
> > >>>>>>> > >>>> >---
> > >>>>>>> > >>>> >
> > >>>>>>> > >>>> >  drivers/input/rmi4/rmi_bus.c    |  4 ++--
> > >>>>>>> > >>>> >  drivers/input/rmi4/rmi_bus.h    |  2 +-
> > >>>>>>> > >>>> >  drivers/input/rmi4/rmi_driver.c | 17 ++++++++++++-----
> > >>>>>>> > >>>> >  drivers/input/rmi4/rmi_f11.c    |  4 +++-
> > >>>>>>> > >>>> >  4 files changed, 18 insertions(+), 9 deletions(-)
> > >>>>>>> > >>>> >
> > >>>>>>> > >>>> >diff --git a/drivers/input/rmi4/rmi_bus.c
> > >>>>>>> > >>>> >b/drivers/input/rmi4/rmi_bus.c
> > >>>>>>> > >>>> >index 96a76e7..8a939f3 100644
> > >>>>>>> > >>>> >--- a/drivers/input/rmi4/rmi_bus.c
> > >>>>>>> > >>>> >+++ b/drivers/input/rmi4/rmi_bus.c
> > >>>>>>> > >>>> >@@ -37,7 +37,7 @@ static void rmi_release_device(struct
> > >>>>>>> > >>>> >device *dev)
> > >>>>>>> > >>>> >
> > >>>>>>> > >>>> >  	kfree(rmi_dev);
> > >>>>>>> > >>>> >  
> > >>>>>>> > >>>> >  }
> > >>>>>>> > >>>> >
> > >>>>>>> > >>>> >-struct device_type rmi_device_type = {
> > >>>>>>> > >>>> >+static struct device_type rmi_device_type = {
> > >>>>>>> > >>>> >
> > >>>>>>> > >>>> >  	.name		= "rmi_sensor",
> > >>>>>>> > >>>> >  	.release	= rmi_release_device,
> > >>>>>>> > >>>> >  
> > >>>>>>> > >>>> >  };
> > >>>>> > >>>
> > >>>>> > >>>This struct is used by diagnostic modules to identify sensor
> > >>>>> > >>>devices, so it cannot be static.
> > >>> > >
> > >>> > >Then we need to declare it somewhere or provide an accessor function.
> > >> >
> > >> >Currently it's in a header not included in the patches.  We'll move
> > >> >it to rmi_bus.h.
> > > 
> > > Hmm, we do have rmi_is_physical_device() to identify whether it is a
> > > sensor or a function, so I believe we should mark all structures static
> > > to avoid anyone poking at them.
> > 
> > I was poking around in the dependent code late last night and came to
> > the same conclusion.  I'll send a micropatch later today to get it out
> > of the way.
> 
> No need, I untangled relevant bits from the one Courtney sent.
> 
> Thanks.

Here it is by the way.

Input: synaptics-rmi4 - make device types module-private

From: Courtney Cavin <courtney.cavin@sonymobile.com>

Nobody outside of RMI bus core should be accessing rmi_device_type,
rmi_function_type or rmi_physical_driver structures so let's limit their
scope.

We provide rmi_is_physical_device() and rmi_is_function_device() to allow
determining whether one is dealing with sensor or function device.

Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/rmi4/rmi_bus.c    |    4 ++--
 drivers/input/rmi4/rmi_driver.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index 7efe7ed..6e0454a 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -38,7 +38,7 @@ static void rmi_release_device(struct device *dev)
 	kfree(rmi_dev);
 }
 
-struct device_type rmi_device_type = {
+static struct device_type rmi_device_type = {
 	.name		= "rmi_sensor",
 	.release	= rmi_release_device,
 };
@@ -154,7 +154,7 @@ static void rmi_release_function(struct device *dev)
 	kfree(fn);
 }
 
-struct device_type rmi_function_type = {
+static struct device_type rmi_function_type = {
 	.name		= "rmi_function",
 	.release	= rmi_release_function,
 };
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 788343a..4406a7f 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -946,7 +946,7 @@ err_free_mem:
 	return retval < 0 ? retval : 0;
 }
 
-struct rmi_driver rmi_physical_driver = {
+static struct rmi_driver rmi_physical_driver = {
 	.driver = {
 		.owner	= THIS_MODULE,
 		.name	= "rmi_physical",

-- 
Dmitry

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

* Re: [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings
  2014-02-13 19:12               ` Dmitry Torokhov
@ 2014-02-13 19:25                 ` Christopher Heiny
  0 siblings, 0 replies; 59+ messages in thread
From: Christopher Heiny @ 2014-02-13 19:25 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Courtney Cavin, linux-input

On 02/13/2014 11:12 AM, Dmitry Torokhov wrote:
> On Thu, Feb 13, 2014 at 11:10:29AM -0800, Dmitry Torokhov wrote:
>> On Thursday, February 13, 2014 10:56:25 AM Christopher Heiny wrote:
>>> On 02/12/2014 10:36 PM, Dmitry Torokhov wrote:
>>>> On Wed, Feb 05, 2014 at 05:36:09PM -0800, Christopher Heiny wrote:
>>>>>> On 02/05/2014 05:09 PM, Dmitry Torokhov wrote:
>>>>>>>> On Tue, Feb 04, 2014 at 03:08:12PM -0800, Christopher Heiny wrote:
>>>>>>>>>>>> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
>>>>>>>>>>>>>>>> Cc: Christopher Heiny<cheiny@synaptics.com>
>>>>>>>>>>>>>>>> Cc: Dmitry Torokhov<dmitry.torokhov@gmail.com>
>>>>>>>>>>>>>>>> Signed-off-by: Courtney Cavin<courtney.cavin@sonymobile.com>
>>>>>>>>>>>>>>>> ---
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>   drivers/input/rmi4/rmi_bus.c    |  4 ++--
>>>>>>>>>>>>>>>>   drivers/input/rmi4/rmi_bus.h    |  2 +-
>>>>>>>>>>>>>>>>   drivers/input/rmi4/rmi_driver.c | 17 ++++++++++++-----
>>>>>>>>>>>>>>>>   drivers/input/rmi4/rmi_f11.c    |  4 +++-
>>>>>>>>>>>>>>>>   4 files changed, 18 insertions(+), 9 deletions(-)
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> diff --git a/drivers/input/rmi4/rmi_bus.c
>>>>>>>>>>>>>>>> b/drivers/input/rmi4/rmi_bus.c
>>>>>>>>>>>>>>>> index 96a76e7..8a939f3 100644
>>>>>>>>>>>>>>>> --- a/drivers/input/rmi4/rmi_bus.c
>>>>>>>>>>>>>>>> +++ b/drivers/input/rmi4/rmi_bus.c
>>>>>>>>>>>>>>>> @@ -37,7 +37,7 @@ static void rmi_release_device(struct
>>>>>>>>>>>>>>>> device *dev)
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>   	kfree(rmi_dev);
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>   }
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> -struct device_type rmi_device_type = {
>>>>>>>>>>>>>>>> +static struct device_type rmi_device_type = {
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>   	.name		= "rmi_sensor",
>>>>>>>>>>>>>>>>   	.release	= rmi_release_device,
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>   };
>>>>>>>>>>>>
>>>>>>>>>>>> This struct is used by diagnostic modules to identify sensor
>>>>>>>>>>>> devices, so it cannot be static.
>>>>>>>>
>>>>>>>> Then we need to declare it somewhere or provide an accessor function.
>>>>>>
>>>>>> Currently it's in a header not included in the patches.  We'll move
>>>>>> it to rmi_bus.h.
>>>>
>>>> Hmm, we do have rmi_is_physical_device() to identify whether it is a
>>>> sensor or a function, so I believe we should mark all structures static
>>>> to avoid anyone poking at them.
>>>
>>> I was poking around in the dependent code late last night and came to
>>> the same conclusion.  I'll send a micropatch later today to get it out
>>> of the way.
>>
>> No need, I untangled relevant bits from the one Courtney sent.

Thanks!

>>
>> Thanks.
>
> Here it is by the way.
>
> Input: synaptics-rmi4 - make device types module-private
>
> From: Courtney Cavin <courtney.cavin@sonymobile.com>
>
> Nobody outside of RMI bus core should be accessing rmi_device_type,
> rmi_function_type or rmi_physical_driver structures so let's limit their
> scope.
>
> We provide rmi_is_physical_device() and rmi_is_function_device() to allow
> determining whether one is dealing with sensor or function device.
>
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Christopher Heiny <cheiny@synaptics.com>

> ---
>   drivers/input/rmi4/rmi_bus.c    |    4 ++--
>   drivers/input/rmi4/rmi_driver.c |    2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> index 7efe7ed..6e0454a 100644
> --- a/drivers/input/rmi4/rmi_bus.c
> +++ b/drivers/input/rmi4/rmi_bus.c
> @@ -38,7 +38,7 @@ static void rmi_release_device(struct device *dev)
>   	kfree(rmi_dev);
>   }
>
> -struct device_type rmi_device_type = {
> +static struct device_type rmi_device_type = {
>   	.name		= "rmi_sensor",
>   	.release	= rmi_release_device,
>   };
> @@ -154,7 +154,7 @@ static void rmi_release_function(struct device *dev)
>   	kfree(fn);
>   }
>
> -struct device_type rmi_function_type = {
> +static struct device_type rmi_function_type = {
>   	.name		= "rmi_function",
>   	.release	= rmi_release_function,
>   };
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 788343a..4406a7f 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -946,7 +946,7 @@ err_free_mem:
>   	return retval < 0 ? retval : 0;
>   }
>
> -struct rmi_driver rmi_physical_driver = {
> +static struct rmi_driver rmi_physical_driver = {
>   	.driver = {
>   		.owner	= THIS_MODULE,
>   		.name	= "rmi_physical",
>


-- 

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated

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

end of thread, other threads:[~2014-02-13 19:25 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-24  0:00 [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support Courtney Cavin
2014-01-24  0:00 ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Courtney Cavin
2014-01-24  0:00   ` [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory Courtney Cavin
2014-01-24  0:00     ` [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly Courtney Cavin
2014-01-24  0:00       ` [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data Courtney Cavin
2014-01-24  0:00         ` [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling Courtney Cavin
2014-01-24  0:00           ` [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks Courtney Cavin
2014-01-24  0:00             ` [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code Courtney Cavin
2014-01-24  0:00               ` [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data Courtney Cavin
2014-01-24  0:00                 ` [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables Courtney Cavin
2014-01-24  0:00                   ` [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support Courtney Cavin
2014-01-24  0:00                     ` [PATCH 11/15] Input: synaptics-rmi4 - add regulator support Courtney Cavin
2014-01-24  0:00                       ` [PATCH 12/15] Input: synaptics-rmi4 - don't immediately set page on probe Courtney Cavin
2014-01-24  0:00                         ` [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan Courtney Cavin
2014-01-24  0:00                           ` [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status Courtney Cavin
2014-01-24  0:00                             ` [PATCH 15/15] Input: synaptics-rmi4 - correct RMI4 spec url Courtney Cavin
2014-02-04 23:10                               ` Christopher Heiny
2014-02-06  1:14                                 ` Dmitry Torokhov
2014-02-04 23:10                             ` [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status Christopher Heiny
2014-02-05  2:40                               ` Courtney Cavin
2014-02-04 23:10                           ` [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan Christopher Heiny
2014-02-05  2:39                             ` Courtney Cavin
2014-02-04 23:10                       ` [PATCH 11/15] Input: synaptics-rmi4 - add regulator support Christopher Heiny
2014-02-05  2:38                         ` Courtney Cavin
2014-02-04 23:10                     ` [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support Christopher Heiny
2014-02-05  2:37                       ` Courtney Cavin
2014-02-04 23:10                   ` [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables Christopher Heiny
2014-02-05  2:35                     ` Courtney Cavin
2014-02-04 23:10                 ` [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data Christopher Heiny
2014-02-05  2:34                   ` Courtney Cavin
2014-02-04 23:09               ` [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code Christopher Heiny
2014-02-05  2:33                 ` Courtney Cavin
2014-02-04 23:09             ` [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks Christopher Heiny
2014-02-05  2:32               ` Courtney Cavin
2014-02-04 23:08           ` [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling Christopher Heiny
2014-02-05  2:31             ` Courtney Cavin
2014-02-06  9:28               ` Linus Walleij
2014-02-06 20:05                 ` Christopher Heiny
2014-02-07  1:45                   ` Courtney Cavin
2014-02-06 20:05               ` Christopher Heiny
2014-02-07  1:47                 ` Courtney Cavin
2014-02-04 23:08         ` [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data Christopher Heiny
2014-02-05  2:30           ` Courtney Cavin
2014-02-04 23:08       ` [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly Christopher Heiny
2014-02-05  2:28         ` Courtney Cavin
2014-02-04 23:08     ` [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory Christopher Heiny
2014-02-05  2:27       ` Courtney Cavin
2014-02-04 23:08   ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Christopher Heiny
2014-02-05  2:26     ` Courtney Cavin
2014-02-06  1:09     ` Dmitry Torokhov
2014-02-06  1:36       ` Christopher Heiny
2014-02-13  6:36         ` Dmitry Torokhov
2014-02-13 18:56           ` Christopher Heiny
2014-02-13 19:10             ` Dmitry Torokhov
2014-02-13 19:12               ` Dmitry Torokhov
2014-02-13 19:25                 ` Christopher Heiny
2014-01-24  0:06 ` [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support Courtney Cavin
2014-01-24 23:24 ` Christopher Heiny
2014-01-25  1:08   ` Courtney Cavin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.