Re: [PATCH v2 2/3] Input: goodix - use string-based chip ID
flat view
From: Bastien Nocera <hadess@hadess.net>
Date: 2020-02-27 17:50:34
Also in:
linux-devicetree, lkml
On Fri, 2020-02-28 at 00:08 +0800, Icenowy Zheng wrote:
quoted hunk ↗ jump to hunk
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.cb/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 structfirmware *); }; +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.