From: Hans de Goede <hidden> Date: 2021-12-12 12:42:48
Hi Dmitry,
Here is a series with some fixes and improvements for the Goodix
touchscreen driver based on your review of my recent patch to
add pen support (which has already been merged).
This is based on goodix.c with all goodix patches from both
input/for-next and input/for-linux applied so that it is tested
against what goodix.c will look like in 5.17-rc1 when both branches
are merged. I don't expect this to cause any problems applying,
but let me know if you want me to rebase on just input/for-next.
Regards,
Hans
Hans de Goede (5):
Input: Add input_copy_abs() function
Input: goodix - Use input_copy_abs() helper
Input: goodix - Improve gpiod_get() error logging
Input: goodix - 2 small fixes for pen support
Input: goodix - Fix race on driver unbind
drivers/input/input.c | 34 ++++++++++++++++
drivers/input/touchscreen/goodix.c | 65 +++++++++++++++---------------
drivers/input/touchscreen/goodix.h | 1 +
include/linux/input.h | 2 +
4 files changed, 69 insertions(+), 33 deletions(-)
--
2.33.1
From: Hans de Goede <hidden> Date: 2021-12-12 12:42:49
Add a new helper function to copy absinfo from one input_dev to
another input_dev.
This is useful to e.g. setup a pen/stylus input-device for combined
touchscreen/pen hardware where the pen uses the same coordinates as
the touchscreen.
Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Hans de Goede <redacted>
---
drivers/input/input.c | 34 ++++++++++++++++++++++++++++++++++
include/linux/input.h | 2 ++
2 files changed, 36 insertions(+)
From: Hans de Goede <hidden> Date: 2021-12-12 12:42:54
goodix_get_gpio_config() errors are fatal (abort probe()) so log them
at KERN_ERR level rather then as debug messages.
Signed-off-by: Hans de Goede <redacted>
---
Changes in v2:
- Just do s/dev_dbg/dev_err/, rather then switching to dev_err_probe()
---
drivers/input/touchscreen/goodix.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -967,7 +967,7 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)if(IS_ERR(gpiod)){error=PTR_ERR(gpiod);if(error!=-EPROBE_DEFER)-dev_dbg(dev,"Failed to get %s GPIO: %d\n",+dev_err(dev,"Failed to get %s GPIO: %d\n",GOODIX_GPIO_INT_NAME,error);returnerror;}
@@ -984,7 +984,7 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)if(IS_ERR(gpiod)){error=PTR_ERR(gpiod);if(error!=-EPROBE_DEFER)-dev_dbg(dev,"Failed to get %s GPIO: %d\n",+dev_err(dev,"Failed to get %s GPIO: %d\n",GOODIX_GPIO_RST_NAME,error);returnerror;}
From: Hans de Goede <hidden> Date: 2021-12-12 12:42:54
Use the new input_copy_abs() helper and move the 2 input_abs_set_res()
calls up to be directly after the 2 input_copy_abs() calls, so that
the calls initializing the X and Y axis are all together.
Signed-off-by: Hans de Goede <redacted>
---
drivers/input/touchscreen/goodix.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)
From: Hans de Goede <hidden> Date: 2021-12-12 12:42:55
2 small fixes for pen support
1. Set the id.vendor field for the pen input_dev
2. Fix a typo in a comment
Signed-off-by: Hans de Goede <redacted>
---
drivers/input/touchscreen/goodix.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
From: Hans de Goede <hidden> Date: 2021-12-12 12:42:56
Because there is no way to detect if the touchscreen has pen support,
the driver is allocating and registering the input_pen input_dev on
receiving the first pen event.
But this means that the input_dev gets allocated after the request_irq()
call which means that the devm framework will free it before disabling
the irq, leaving a window where the irq handler may run and reference the
free-ed input_dev.
To fix this move the allocation of the input_pen input_dev to before
the request_irq() call, while still only registering it on the first pen
event so that the driver does not advertise pen capability on touchscreens
without it (most goodix touchscreens do not have pen support).
Signed-off-by: Hans de Goede <redacted>
---
drivers/input/touchscreen/goodix.c | 32 ++++++++++++++++++------------
drivers/input/touchscreen/goodix.h | 1 +
2 files changed, 20 insertions(+), 13 deletions(-)
Hi Hans,
On Sun, Dec 12, 2021 at 01:42:42PM +0100, Hans de Goede wrote:
quoted hunk
Because there is no way to detect if the touchscreen has pen support,
the driver is allocating and registering the input_pen input_dev on
receiving the first pen event.
But this means that the input_dev gets allocated after the request_irq()
call which means that the devm framework will free it before disabling
the irq, leaving a window where the irq handler may run and reference the
free-ed input_dev.
To fix this move the allocation of the input_pen input_dev to before
the request_irq() call, while still only registering it on the first pen
event so that the driver does not advertise pen capability on touchscreens
without it (most goodix touchscreens do not have pen support).
Signed-off-by: Hans de Goede <redacted>
---
drivers/input/touchscreen/goodix.c | 32 ++++++++++++++++++------------
drivers/input/touchscreen/goodix.h | 1 +
2 files changed, 20 insertions(+), 13 deletions(-)
I do not think you want to try and re-register input device if first
registration failed. You probably also don't want to waste time and
return early from here in case of failures.
Thanks.
--
Dmitry
On Sun, Dec 12, 2021 at 01:42:40PM +0100, Hans de Goede wrote:
goodix_get_gpio_config() errors are fatal (abort probe()) so log them
at KERN_ERR level rather then as debug messages.
Signed-off-by: Hans de Goede <redacted>
Hi Hans,
On Sun, Dec 12, 2021 at 01:42:38PM +0100, Hans de Goede wrote:
quoted hunk
Add a new helper function to copy absinfo from one input_dev to
another input_dev.
This is useful to e.g. setup a pen/stylus input-device for combined
touchscreen/pen hardware where the pen uses the same coordinates as
the touchscreen.
Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Hans de Goede <redacted>
---
drivers/input/input.c | 34 ++++++++++++++++++++++++++++++++++
include/linux/input.h | 2 ++
2 files changed, 36 insertions(+)
From: Hans de Goede <hidden> Date: 2022-01-31 13:21:10
Hi Dmitry,
Thank you for your review of this patch series; and sorry for
being so slow in getting back to you on this.
On 12/13/21 05:58, Dmitry Torokhov wrote:
Hi Hans,
On Sun, Dec 12, 2021 at 01:42:38PM +0100, Hans de Goede wrote:
quoted
Add a new helper function to copy absinfo from one input_dev to
another input_dev.
This is useful to e.g. setup a pen/stylus input-device for combined
touchscreen/pen hardware where the pen uses the same coordinates as
the touchscreen.
Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Hans de Goede <redacted>
---
drivers/input/input.c | 34 ++++++++++++++++++++++++++++++++++
include/linux/input.h | 2 ++
2 files changed, 36 insertions(+)
From: Hans de Goede <hidden> Date: 2022-01-31 14:31:47
Hi,
On 12/13/21 05:56, Dmitry Torokhov wrote:
Hi Hans,
On Sun, Dec 12, 2021 at 01:42:42PM +0100, Hans de Goede wrote:
quoted
Because there is no way to detect if the touchscreen has pen support,
the driver is allocating and registering the input_pen input_dev on
receiving the first pen event.
But this means that the input_dev gets allocated after the request_irq()
call which means that the devm framework will free it before disabling
the irq, leaving a window where the irq handler may run and reference the
free-ed input_dev.
To fix this move the allocation of the input_pen input_dev to before
the request_irq() call, while still only registering it on the first pen
event so that the driver does not advertise pen capability on touchscreens
without it (most goodix touchscreens do not have pen support).
Signed-off-by: Hans de Goede <redacted>
---
drivers/input/touchscreen/goodix.c | 32 ++++++++++++++++++------------
drivers/input/touchscreen/goodix.h | 1 +
2 files changed, 20 insertions(+), 13 deletions(-)
I do not think you want to try and re-register input device if first
registration failed. You probably also don't want to waste time and
return early from here in case of failures.
Ack, I've fixed both for v2 of this patch-series.
Regards,
Hans