All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: linux-input@vger.kernel.org, Benson Leung <bleung@chromium.org>
Cc: Nick Dyer <nick@shmanahar.org>, Olof Johansson <olof@lixom.net>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 03/14] Input: atmel_mxt_ts - switch ChromeOS ACPI devices to generic props
Date: Mon, 12 Mar 2018 12:08:56 -0700	[thread overview]
Message-ID: <20180312190907.174301-4-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20180312190907.174301-1-dmitry.torokhov@gmail.com>

Move older ChromeOS devices describing Atmel controllers in ACPI, but not
providing enough details to configure the controllers properly, from
platform data over to generic device properties. This will allow us
remove support for platform data later on, leaving only generic device
properties in place.

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

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 072b78d3c6e00..cf2aac4e79ae8 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -2972,7 +2972,7 @@ mxt_parse_device_properties(struct i2c_client *client)
 
 struct mxt_acpi_platform_data {
 	const char *hid;
-	struct mxt_platform_data pdata;
+	const struct property_entry *props;
 };
 
 static unsigned int samus_touchpad_buttons[] = {
@@ -2982,14 +2982,16 @@ static unsigned int samus_touchpad_buttons[] = {
 	BTN_LEFT
 };
 
+static const struct property_entry samus_touchpad_props[] = {
+	PROPERTY_ENTRY_U32_ARRAY("linux,gpio-keymap", samus_touchpad_buttons),
+	{ }
+};
+
 static struct mxt_acpi_platform_data samus_platform_data[] = {
 	{
 		/* Touchpad */
 		.hid	= "ATML0000",
-		.pdata	= {
-			.t19_num_keys	= ARRAY_SIZE(samus_touchpad_buttons),
-			.t19_keymap	= samus_touchpad_buttons,
-		},
+		.props	= samus_touchpad_props,
 	},
 	{
 		/* Touchscreen */
@@ -3007,14 +3009,16 @@ static unsigned int chromebook_tp_buttons[] = {
 	BTN_LEFT
 };
 
+static const struct property_entry chromebook_tp_props[] = {
+	PROPERTY_ENTRY_U32_ARRAY("linux,gpio-keymap", chromebook_tp_buttons),
+	{ }
+};
+
 static struct mxt_acpi_platform_data chromebook_platform_data[] = {
 	{
 		/* Touchpad */
 		.hid	= "ATML0000",
-		.pdata	= {
-			.t19_num_keys	= ARRAY_SIZE(chromebook_tp_buttons),
-			.t19_keymap	= chromebook_tp_buttons,
-		},
+		.props	= chromebook_tp_props,
 	},
 	{
 		/* Touchscreen */
@@ -3044,7 +3048,7 @@ static const struct dmi_system_id mxt_dmi_table[] = {
 	{ }
 };
 
-static const struct mxt_platform_data *mxt_parse_acpi(struct i2c_client *client)
+static int mxt_acpi_probe(struct i2c_client *client)
 {
 	struct acpi_device *adev;
 	const struct dmi_system_id *system_id;
@@ -3061,33 +3065,46 @@ static const struct mxt_platform_data *mxt_parse_acpi(struct i2c_client *client)
 	 * as a threshold.
 	 */
 	if (client->addr < 0x40)
-		return ERR_PTR(-ENXIO);
+		return -ENXIO;
 
 	adev = ACPI_COMPANION(&client->dev);
 	if (!adev)
-		return ERR_PTR(-ENOENT);
+		return -ENOENT;
 
 	system_id = dmi_first_match(mxt_dmi_table);
 	if (!system_id)
-		return ERR_PTR(-ENOENT);
+		return -ENOENT;
 
 	acpi_pdata = system_id->driver_data;
 	if (!acpi_pdata)
-		return ERR_PTR(-ENOENT);
+		return -ENOENT;
 
 	while (acpi_pdata->hid) {
-		if (!strcmp(acpi_device_hid(adev), acpi_pdata->hid))
-			return &acpi_pdata->pdata;
+		if (!strcmp(acpi_device_hid(adev), acpi_pdata->hid)) {
+			/*
+			 * Remove previously installed properties if we
+			 * are probing this device not for the very first
+			 * time.
+			 */
+			device_remove_properties(&client->dev);
+
+			/*
+			 * Now install the platform-specific properties
+			 * that are missing from ACPI.
+			 */
+			device_add_properties(&client->dev, acpi_pdata->props);
+			break;
+		}
 
 		acpi_pdata++;
 	}
 
-	return ERR_PTR(-ENOENT);
+	return 0;
 }
 #else
-static const struct mxt_platform_data *mxt_parse_acpi(struct i2c_client *client)
+static int mxt_acpi_probe(struct i2c_client *client)
 {
-	return ERR_PTR(-ENOENT);
+	return -ENOENT;
 }
 #endif
 
@@ -3100,10 +3117,6 @@ mxt_get_platform_data(struct i2c_client *client)
 	if (pdata)
 		return pdata;
 
-	pdata = mxt_parse_acpi(client);
-	if (!IS_ERR(pdata) || PTR_ERR(pdata) != -ENOENT)
-		return pdata;
-
 	return mxt_parse_device_properties(client);
 }
 
@@ -3113,6 +3126,10 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	const struct mxt_platform_data *pdata;
 	int error;
 
+	error = mxt_acpi_probe(client);
+	if (error && error != -ENOENT)
+		return error;
+
 	pdata = mxt_get_platform_data(client);
 	if (IS_ERR(pdata))
 		return PTR_ERR(pdata);
-- 
2.16.2.660.g709887971b-goog

  parent reply	other threads:[~2018-03-12 19:09 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12 19:08 [PATCH 00/14] chrome_laptop: stop being a platform driver Dmitry Torokhov
2018-03-12 19:08 ` [PATCH 01/14] Input: atmel_mxt_ts - do not pass suspend mode in platform data Dmitry Torokhov
2018-03-14 20:51   ` Nick Dyer
2018-03-15 23:56     ` Dmitry Torokhov
2018-03-16 20:40       ` Nick Dyer
2018-03-17 17:42         ` Dmitry Torokhov
2018-03-17 20:42           ` Nick Dyer
2018-03-12 19:08 ` [PATCH 02/14] Input: atmel_mxt_ts - switch from OF to generic device properties Dmitry Torokhov
2018-03-14 20:51   ` Nick Dyer
2018-03-12 19:08 ` Dmitry Torokhov [this message]
2018-03-14 20:52   ` [PATCH 03/14] Input: atmel_mxt_ts - switch ChromeOS ACPI devices to generic props Nick Dyer
2018-03-12 19:08 ` [PATCH 04/14] platform/chrome: chromeos_laptop - add SPDX identifier Dmitry Torokhov
2018-03-20  1:53   ` Benson Leung
2018-03-12 19:08 ` [PATCH 05/14] platform/chrome: chromeos_laptop - stop setting suspend mode for Atmel devices Dmitry Torokhov
2018-03-12 19:08 ` [PATCH 06/14] platform/chrome: chromeos_laptop - introduce pr_fmt() Dmitry Torokhov
2018-03-20  2:03   ` Benson Leung
2018-03-12 19:09 ` [PATCH 07/14] platform/chrome: chromeos_laptop - factor out getting IRQ from DMI Dmitry Torokhov
2018-03-20  2:14   ` Benson Leung
2018-03-12 19:09 ` [PATCH 08/14] platform/chrome: chromeos_laptop - rework i2c peripherals initialization Dmitry Torokhov
2018-03-12 19:09 ` [PATCH 09/14] platform/chrome: chromeos_laptop - parse DMI IRQ data once Dmitry Torokhov
2018-03-12 19:09 ` [PATCH 10/14] platform/chrome: chromeos_laptop - use I2C notifier to create devices Dmitry Torokhov
2018-03-12 19:09 ` [PATCH 11/14] platform/chrome: chromeos_laptop - rely on I2C to set up interrupt trigger Dmitry Torokhov
2018-03-12 19:09 ` [PATCH 12/14] platform/chrome: chromeos_laptop - use device properties for Pixel Dmitry Torokhov
2018-03-12 19:09 ` [PATCH 13/14] platform/chrome: chromeos_laptop - discard data for unneeded boards Dmitry Torokhov
2018-03-12 19:09 ` [PATCH 14/14] Input: atmel_mxt_ts - remove platform data support Dmitry Torokhov
2018-03-14 20:59   ` Nick Dyer
2018-03-16  0:06     ` Dmitry Torokhov
2018-03-16 20:41       ` Nick Dyer
2018-03-12 19:17 ` [PATCH 00/14] chrome_laptop: stop being a platform driver Benson Leung

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180312190907.174301-4-dmitry.torokhov@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=bleung@chromium.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nick@shmanahar.org \
    --cc=olof@lixom.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.