Re: [PATCH v2 2/3] Input: goodix - use string-based chip ID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
> ---
> 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.




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux