lkml.org 
[lkml]   [2020]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 2/3] Input: goodix - use string-based chip ID
From
Date
On Fri, 2020-02-28 at 00:08 +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>
> ---
> Changes in v2:
> - Used a table to save ID and chip data info.
> - Use strscpy().
>
> drivers/input/touchscreen/goodix.c | 61 +++++++++++++++++-----------
> --
> 1 file changed, 35 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/input/touchscreen/goodix.c
> b/drivers/input/touchscreen/goodix.c
> index 0403102e807e..dde85b894ca4 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -37,6 +37,11 @@ struct goodix_chip_data {
> int (*check_config)(struct goodix_ts_data *, const struct
> firmware *);
> };
>
> +struct goodix_chip_id {
> + const char *id;
> + const struct goodix_chip_data *data;
> +};
> +
> struct goodix_ts_data {
> struct i2c_client *client;
> struct input_dev *input_dev;
> @@ -48,7 +53,7 @@ struct goodix_ts_data {
> struct regulator *vddio;
> struct gpio_desc *gpiod_int;
> struct gpio_desc *gpiod_rst;
> - u16 id;
> + char id[5];

Could you please change this "5" into a constant (#define) to make sure
that...
<snip>
> + strscpy(ts->id, id_str, 5);

...we copy the same length here. Otherwise you can be certain it's
going to cause problems in the future.

\
 
 \ /
  Last update: 2020-02-27 18:52    [W:0.050 / U:1.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site