linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Daniel Mack <zonque@gmail.com>
Cc: linux-input@vger.kernel.org, broonie@kernel.org,
	grant.likely@linaro.org, agust@denx.de, imre.deak@nokia.com,
	chf@fritzc.com
Subject: Re: [PATCH RESEND v2 1/2] Input: touchscreen: ads7846: keep copy of pdata in private struct
Date: Sun, 30 Jun 2013 18:33:24 -0700	[thread overview]
Message-ID: <20130701013324.GA10755@core.coreip.homeip.net> (raw)
In-Reply-To: <1372626555-29479-1-git-send-email-zonque@gmail.com>

Hi Daniel,

On Sun, Jun 30, 2013 at 11:09:14PM +0200, Daniel Mack wrote:
> +
> +	if (!pdata->model)
> +		pdata->model = 7846;
> +
> +	if (!pdata->vref_delay_usecs)
> +		pdata->vref_delay_usecs = 100;
> +
> +	if (!pdata->x_plate_ohms)
> +		pdata->x_plate_ohms = 400;
> +
> +	if (!pdata->pressure_max)
> +		pdata->pressure_max = ~0;

We should not be changing the platform data as the device does not own
it and it may well be declared as a constant structure.

In fact, I have a patch that declares pdata pointer as const.

-- 
Dmitry


Input: ads7846 - make sure we do not change platform data

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Let's declare platform data a const pointer so that we don't accitentally
change it. Also fetch it with dev_get_platdata().

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

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 84ccf14..5ff0419 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -961,9 +961,9 @@ static int ads7846_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume);
 
 static int ads7846_setup_pendown(struct spi_device *spi,
-					   struct ads7846 *ts)
+				 struct ads7846 *ts,
+				 const struct ads7846_platform_data *pdata)
 {
-	struct ads7846_platform_data *pdata = spi->dev.platform_data;
 	int err;
 
 	/*
@@ -1003,7 +1003,7 @@ static int ads7846_setup_pendown(struct spi_device *spi,
  * use formula #2 for pressure, not #3.
  */
 static void ads7846_setup_spi_msg(struct ads7846 *ts,
-				const struct ads7846_platform_data *pdata)
+				  const struct ads7846_platform_data *pdata)
 {
 	struct spi_message *m = &ts->msg[0];
 	struct spi_transfer *x = ts->xfer;
@@ -1203,10 +1203,10 @@ static void ads7846_setup_spi_msg(struct ads7846 *ts,
 
 static int ads7846_probe(struct spi_device *spi)
 {
+	const struct ads7846_platform_data *pdata = dev_get_platdata(&spi->dev);
 	struct ads7846 *ts;
 	struct ads7846_packet *packet;
 	struct input_dev *input_dev;
-	struct ads7846_platform_data *pdata = spi->dev.platform_data;
 	unsigned long irq_flags;
 	int err;
 
@@ -1281,7 +1281,7 @@ static int ads7846_probe(struct spi_device *spi)
 		ts->filter = ads7846_no_filter;
 	}
 
-	err = ads7846_setup_pendown(spi, ts);
+	err = ads7846_setup_pendown(spi, ts, pdata);
 	if (err)
 		goto err_cleanup_filter;
 

  parent reply	other threads:[~2013-07-01  1:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-30 21:09 [PATCH RESEND v2 1/2] Input: touchscreen: ads7846: keep copy of pdata in private struct Daniel Mack
2013-06-30 21:09 ` [PATCH RESEND v2 2/2] Input: touchscreen: ads7846: add device tree bindings Daniel Mack
2013-07-01  1:35   ` Dmitry Torokhov
2013-07-01  3:12     ` Dmitry Torokhov
2013-07-01  6:52     ` Daniel Mack
2013-07-01  1:33 ` Dmitry Torokhov [this message]
2013-07-01  6:48   ` [PATCH RESEND v2 1/2] Input: touchscreen: ads7846: keep copy of pdata in private struct Daniel Mack
2013-07-01  7:09     ` Dmitry Torokhov
2013-07-01  7:14       ` Daniel Mack
2013-07-01  7:21         ` Dmitry Torokhov
  -- strict thread matches above, loose matches on Subject: below --
2013-05-22 17:57 Daniel Mack
2013-06-23 13:01 ` Daniel Mack

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=20130701013324.GA10755@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=agust@denx.de \
    --cc=broonie@kernel.org \
    --cc=chf@fritzc.com \
    --cc=grant.likely@linaro.org \
    --cc=imre.deak@nokia.com \
    --cc=linux-input@vger.kernel.org \
    --cc=zonque@gmail.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).