linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	"Franklin S Cooper Jr" <fcooper@ti.com>,
	"Maxime Ripard" <maxime.ripard@free-electrons.com>,
	"Lothar Waßmann" <LW@KARO-electronics.de>
Subject: [PATCH 4/6] Input: edt-ft5x06 - use generic properties API
Date: Sat, 12 Sep 2015 10:45:49 -0700	[thread overview]
Message-ID: <cad5ddbdef527ffaadaf25e9d54c7828a14beb4e.1442079408.git.dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <5044530af510d6686e78f8dfa912d89ef824f899.1442079408.git.dmitry.torokhov@gmail.com>
In-Reply-To: <5044530af510d6686e78f8dfa912d89ef824f899.1442079408.git.dmitry.torokhov@gmail.com>

Instead of only parsing device tree properties let's switch to using
generic properties API so that the driver can also work on other platforms.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/edt-ft5x06.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 134c66c..ef8a7cd 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -808,20 +808,24 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client,
 	return 0;
 }
 
-#define EDT_GET_PROP(name, reg) {				\
-	u32 val;						\
-	if (of_property_read_u32(np, #name, &val) == 0)		\
-		edt_ft5x06_register_write(tsdata, reg, val);	\
-}
-
-static void edt_ft5x06_ts_get_defaults(struct device_node *np,
+static void edt_ft5x06_ts_get_defaults(struct device *dev,
 				       struct edt_ft5x06_ts_data *tsdata)
 {
 	struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
+	u32 val;
+	int error;
+
+	error = device_property_read_u32(dev, "threshold", &val);
+	if (!error)
+		reg_addr->reg_threshold = val;
+
+	error = device_property_read_u32(dev, "gain", &val);
+	if (!error)
+		reg_addr->reg_gain = val;
 
-	EDT_GET_PROP(threshold, reg_addr->reg_threshold);
-	EDT_GET_PROP(gain, reg_addr->reg_gain);
-	EDT_GET_PROP(offset, reg_addr->reg_offset);
+	error = device_property_read_u32(dev, "offset", &val);
+	if (!error)
+		reg_addr->reg_offset = val;
 }
 
 static void
@@ -928,7 +932,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 	}
 
 	edt_ft5x06_ts_set_regs(tsdata);
-	edt_ft5x06_ts_get_defaults(client->dev.of_node, tsdata);
+	edt_ft5x06_ts_get_defaults(&client->dev, tsdata);
 	edt_ft5x06_ts_get_parameters(tsdata);
 
 	dev_dbg(&client->dev,
-- 
2.6.0.rc0.131.gf624c3d

  parent reply	other threads:[~2015-09-12 17:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-12 17:45 [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
2015-09-12 17:45 ` [PATCH 2/6] Input: edt-ft5x06 - drop parsing of irq gpio Dmitry Torokhov
2015-09-12 17:45 ` [PATCH 3/6] Input: edt-ft5x06 - remove support for platform data Dmitry Torokhov
2015-09-12 17:45 ` Dmitry Torokhov [this message]
2015-09-12 17:45 ` [PATCH 5/6] Input: edt-ft5x06 - do not hardcode interrupt trigger type Dmitry Torokhov
2015-09-12 17:45 ` [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts Dmitry Torokhov
2015-09-14 21:24   ` Felipe Balbi
     [not found]     ` <20150914212426.GA9968-HgARHv6XitJaoMGHk7MhZQC/G2K4zDHf@public.gmane.org>
2015-09-15 15:40       ` Tony Lindgren
     [not found]   ` <2adcbfd1d5b237598d37edcbeec4a8dbd443f36f.1442079408.git.dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-23 12:16     ` Shawn Guo
2015-09-21 22:55 ` [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
2015-09-22 22:00   ` Franklin S Cooper Jr.

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=cad5ddbdef527ffaadaf25e9d54c7828a14beb4e.1442079408.git.dmitry.torokhov@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=LW@KARO-electronics.de \
    --cc=fcooper@ti.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).