All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] Input: icn8318 - Move of specific probe code to a helper function
@ 2017-06-17 10:58 Hans de Goede
  2017-06-17 10:58 ` [PATCH 2/4] Input: icn8318 - Add support for icn8505 Hans de Goede
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Hans de Goede @ 2017-06-17 10:58 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Hans de Goede, Jiri Kosina, Benjamin Tissoires, linux-input

This is a preparation patch for adding support for ACPI enumerated
Chipone touchscreens. On ACPI platforms the wake GPIO is unused, move
the code to get the GPIO to a new icn8318_probe_of helper function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/input/touchscreen/chipone_icn8318.c | 50 ++++++++++++++++++++---------
 1 file changed, 35 insertions(+), 15 deletions(-)

diff --git a/drivers/input/touchscreen/chipone_icn8318.c b/drivers/input/touchscreen/chipone_icn8318.c
index 0bf14067c167..ddaae91f02fc 100644
--- a/drivers/input/touchscreen/chipone_icn8318.c
+++ b/drivers/input/touchscreen/chipone_icn8318.c
@@ -137,7 +137,8 @@ static int icn8318_start(struct input_dev *dev)
 	struct icn8318_data *data = input_get_drvdata(dev);
 
 	enable_irq(data->client->irq);
-	gpiod_set_value_cansleep(data->wake_gpio, 1);
+	if (data->wake_gpio)
+		gpiod_set_value_cansleep(data->wake_gpio, 1);
 
 	return 0;
 }
@@ -149,7 +150,8 @@ static void icn8318_stop(struct input_dev *dev)
 	disable_irq(data->client->irq);
 	i2c_smbus_write_byte_data(data->client, ICN8318_REG_POWER,
 				  ICN8318_POWER_HIBERNATE);
-	gpiod_set_value_cansleep(data->wake_gpio, 0);
+	if (data->wake_gpio)
+		gpiod_set_value_cansleep(data->wake_gpio, 0);
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -180,8 +182,29 @@ static int icn8318_resume(struct device *dev)
 
 static SIMPLE_DEV_PM_OPS(icn8318_pm_ops, icn8318_suspend, icn8318_resume);
 
-static int icn8318_probe(struct i2c_client *client,
-			 const struct i2c_device_id *id)
+#ifdef CONFIG_OF
+static int icn8318_probe_of(struct icn8318_data *data, struct device *dev)
+{
+	int error;
+
+	data->wake_gpio = devm_gpiod_get(dev, "wake", GPIOD_OUT_LOW);
+	if (IS_ERR(data->wake_gpio)) {
+		error = PTR_ERR(data->wake_gpio);
+		if (error != -EPROBE_DEFER)
+			dev_err(dev, "Error getting wake gpio: %d\n", error);
+		return error;
+	}
+
+	return 0;
+}
+#else
+static int icn8318_probe_of(struct icn8318_data *data, struct device *dev)
+{
+	return -ENODEV;
+}
+#endif
+
+static int icn8318_probe(struct i2c_client *client)
 {
 	struct device *dev = &client->dev;
 	struct icn8318_data *data;
@@ -197,18 +220,13 @@ static int icn8318_probe(struct i2c_client *client,
 	if (!data)
 		return -ENOMEM;
 
-	data->wake_gpio = devm_gpiod_get(dev, "wake", GPIOD_OUT_LOW);
-	if (IS_ERR(data->wake_gpio)) {
-		error = PTR_ERR(data->wake_gpio);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Error getting wake gpio: %d\n", error);
-		return error;
-	}
-
 	input = devm_input_allocate_device(dev);
 	if (!input)
 		return -ENOMEM;
 
+	data->client = client;
+	data->input = input;
+
 	input->name = client->name;
 	input->id.bustype = BUS_I2C;
 	input->open = icn8318_start;
@@ -218,6 +236,10 @@ static int icn8318_probe(struct i2c_client *client,
 	input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
 	input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
 
+	error = icn8318_probe_of(data, dev);
+	if (error)
+		return error;
+
 	touchscreen_parse_properties(input, true, &data->prop);
 	if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
 	    !input_abs_get_max(input, ABS_MT_POSITION_Y)) {
@@ -230,8 +252,6 @@ static int icn8318_probe(struct i2c_client *client,
 	if (error)
 		return error;
 
-	data->client = client;
-	data->input = input;
 	input_set_drvdata(input, data);
 
 	error = devm_request_threaded_irq(dev, client->irq, NULL, icn8318_irq,
@@ -271,7 +291,7 @@ static struct i2c_driver icn8318_driver = {
 		.pm	= &icn8318_pm_ops,
 		.of_match_table = icn8318_of_match,
 	},
-	.probe = icn8318_probe,
+	.probe_new = icn8318_probe,
 	.id_table = icn8318_i2c_id,
 };
 
-- 
2.13.0


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

end of thread, other threads:[~2017-06-19 14:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-17 10:58 [PATCH 1/4] Input: icn8318 - Move of specific probe code to a helper function Hans de Goede
2017-06-17 10:58 ` [PATCH 2/4] Input: icn8318 - Add support for icn8505 Hans de Goede
2017-06-17 10:58 ` [PATCH 3/4] Input: icn8318 - Add support for ACPI enumeration Hans de Goede
2017-06-17 20:09   ` Hans de Goede
2017-06-18  8:41     ` Hans de Goede
2017-06-19  8:51       ` Benjamin Tissoires
2017-06-19 14:01         ` Hans de Goede
2017-06-19 14:24           ` Benjamin Tissoires
2017-06-17 10:58 ` [PATCH 4/4] Input: icn8318 - Add support for capacative home button Hans de Goede

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.