linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Icenowy Zheng <icenowy@aosc.io>
Cc: Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Bastien Nocera <hadess@hadess.net>,
	Jagan Teki <jagan@amarulasolutions.com>,
	linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] Input: goodix - use string-based chip ID
Date: Fri, 10 Jan 2020 16:26:52 -0800	[thread overview]
Message-ID: <20200111002652.GX8314@dtor-ws> (raw)
In-Reply-To: <20200110162608.1066397-3-icenowy@aosc.io>

On Sat, Jan 11, 2020 at 12:26:07AM +0800, Icenowy Zheng wrote:
> For Goodix GT917S chip, the chip ID string is "917S", which contains not
> only numbers now.
> 
> Use string-based chip ID in the driver to support this chip and further
> chips with alphanumber ID.
> 
> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> ---
>  drivers/input/touchscreen/goodix.c | 39 ++++++++++++++----------------
>  1 file changed, 18 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
> index 0403102e807e..bfd067d7145e 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -48,7 +48,7 @@ struct goodix_ts_data {
>  	struct regulator *vddio;
>  	struct gpio_desc *gpiod_int;
>  	struct gpio_desc *gpiod_rst;
> -	u16 id;
> +	char id[5];
>  	u16 version;
>  	const char *cfg_name;
>  	struct completion firmware_loading_complete;
> @@ -235,28 +235,25 @@ static int goodix_i2c_write_u8(struct i2c_client *client, u16 reg, u8 value)
>  	return goodix_i2c_write(client, reg, &value, sizeof(value));
>  }
>  
> -static const struct goodix_chip_data *goodix_get_chip_data(u16 id)
> +static const struct goodix_chip_data *goodix_get_chip_data(const char *id)
>  {
> -	switch (id) {
> -	case 1151:
> -	case 5663:
> -	case 5688:
> +	if (!strcmp(id, "1151") ||
> +	    !strcmp(id, "5663") ||
> +	    !strcmp(id, "5688"))
>  		return &gt1x_chip_data;
>  
> -	case 911:
> -	case 9271:
> -	case 9110:
> -	case 927:
> -	case 928:
> +	if (!strcmp(id, "911") ||
> +	    !strcmp(id, "9271") ||
> +	    !strcmp(id, "9110") ||
> +	    !strcmp(id, "927") ||
> +	    !strcmp(id, "928"))
>  		return &gt911_chip_data;
>  
> -	case 912:
> -	case 967:
> +	if (!strcmp(id, "912") ||
> +	    !strcmp(id, "967"))
>  		return &gt967_chip_data;
>  
> -	default:
> -		return &gt9x_chip_data;
> -	}
> +	return &gt9x_chip_data;

I wonder if with strings it would not be simpler to have a id -> pointer
mapping table and loop over it.

Thanks.

-- 
Dmitry

  reply	other threads:[~2020-01-11  0:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10 16:26 [PATCH 0/3] Add support for Goodix GT917S touch controller Icenowy Zheng
2020-01-10 16:26 ` [PATCH 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S Icenowy Zheng
2020-01-15 15:25   ` Rob Herring
2020-01-10 16:26 ` [PATCH 2/3] Input: goodix - use string-based chip ID Icenowy Zheng
2020-01-11  0:26   ` Dmitry Torokhov [this message]
2020-01-10 16:26 ` [PATCH 3/3] Input: goodix - Add support for Goodix GT917S Icenowy Zheng

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=20200111002652.GX8314@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hadess@hadess.net \
    --cc=icenowy@aosc.io \
    --cc=jagan@amarulasolutions.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --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).