linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Martin Kepplinger <martink@posteo.de>
Cc: devicetree@vger.kernel.org, linux-input@vger.kernel.org,
	robh+dt@kernel.org, mark.rutland@arm.com,
	chinyeow.sim.xt@renesas.com, linux-kernel@vger.kernel.org,
	Martin Kepplinger <martin.kepplinger@ginzinger.com>
Subject: Re: [PATCH v2 2/2] Input: st1232 - add support for st1633
Date: Fri, 25 Jan 2019 16:55:36 -0800	[thread overview]
Message-ID: <20190126005536.GA212026@dtor-ws> (raw)
In-Reply-To: <20190124102125.25458-2-martink@posteo.de>

Hi Martin,

On Thu, Jan 24, 2019 at 11:21:25AM +0100, Martin Kepplinger wrote:
> From: Martin Kepplinger <martin.kepplinger@ginzinger.com>
> 
> Add support for the Sitronix ST1633 touchscreen controller to the st1232
> driver. A protocol spec can be found here:
> www.ampdisplay.com/documents/pdf/AM-320480B6TZQW-TC0H.pdf
> 
> Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.com>
> ---
> 
> while this works, I'm not totally convinced by how the i2c path of probe
> looks. what do you say?

Not quite what I had in mind. See below...

>  static int st1232_ts_probe(struct i2c_client *client,
>  			   const struct i2c_device_id *id)
>  {
>  	struct st1232_ts_data *ts;
> +	struct st1232_ts_finger *finger;
>  	struct input_dev *input_dev;
>  	int error;
> +	const struct st_chip_info *match = NULL;
> +
> +	if (dev_fwnode(&client->dev))
> +		match = device_get_match_data(&client->dev);
> +	else if (id && id->driver_data == st1232)
> +		match = &st1232_chip_info;
> +	else if (id && id->driver_data == st1633)
> +		match = &st1633_chip_info;
> +	if (!match) {
> +		dev_err(&client->dev, "unknown device model\n");
> +		return -ENODEV;
> +	}

If you do:

static const struct i2c_device_id st1232_ts_id[] = {
	{ ST1232_TS_NAME, (unsigned long)&st1232_chip_info },
	{ ST1633_TS_NAME, (unsigned long)&st1633_chip_info },
	{ }
};


Then you can do:

	match = device_get_match_data(&client->dev);
	if (!match && id)
		match = (const void *)id->driver_data;
	if (!match) {
		dev_err(&client->dev, "unknown device model\n");
		return -ENODEV;
	}

Thanks.

-- 
Dmitry

      reply	other threads:[~2019-01-26  0:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-24 10:21 [PATCH v2 1/2] dt-bindings: input: sitronix-st1232: add compatible string for ST1633 Martin Kepplinger
2019-01-24 10:21 ` [PATCH v2 2/2] Input: st1232 - add support for st1633 Martin Kepplinger
2019-01-26  0:55   ` Dmitry Torokhov [this message]

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=20190126005536.GA212026@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=chinyeow.sim.xt@renesas.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=martin.kepplinger@ginzinger.com \
    --cc=martink@posteo.de \
    --cc=robh+dt@kernel.org \
    /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).