Input: tsc2007 - enable GPIO chips that can sleep
Subsystems (2)
PATCH 1/1 Input: tsc2007 - enable GPIO chips that can sleep
From: Benjamin Bara <[email protected]>
This enables the usage of "can_sleep" GPIO chips as "pin up" GPIO. This might be the case if the GPIO chip is an expander behind i2c.
--- drivers/input/touchscreen/tsc2007.h | 1 + drivers/input/touchscreen/tsc2007_core.c | 38 ++++++++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-)
drivers/input/touchscreen/tsc2007.h +1 -0
@@ -78,6 +78,7 @@ struct tsc2007 {bool stopped;int (*get_pendown_state)(struct device *); +int (*get_pendown_state_cansleep)(struct device *);void (*clear_penirq)(void );struct mutex mlock;
drivers/input/touchscreen/tsc2007_core.c +33 -5
@@ -20,6 +20,7 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/gpio/consumer.h> +#include <linux/gpio/driver.h> #include <linux/input.h> #include <linux/interrupt.h> #include <linux/i2c.h>
@@ -108,6 +109,14 @@ bool tsc2007_is_pen_down(struct tsc2007 *ts)return ts->get_pendown_state (&ts->client->dev); } +bool tsc2007_is_pen_down_cansleep (struct tsc2007 *ts) +{ +if (!ts->get_pendown_state_cansleep) +return true; + +return ts->get_pendown_state_cansleep (&ts->client->dev); +} +static irqreturn_t tsc2007_soft_irq (int irq,void *handle) {struct tsc2007 *ts = handle;
@@ -115,7 +124,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)struct ts_event tc;u32 rt; -while (!ts->stopped &&tsc2007_is_pen_down (ts)) { +while (!ts->stopped &&tsc2007_is_pen_down_cansleep (ts)) {/* pen is down, continue with the measurement */
@@ -125,7 +134,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle) rt =tsc2007_calculate_resistance (ts, &tc); -if (!rt && !ts->get_pendown_state) { +if (!rt && !ts->get_pendown_state_cansleep) {/* * If pressure reported is 0 and we don't have * callback to check pendown state, we have to
@@ -229,6 +238,14 @@ static int tsc2007_get_pendown_state_gpio(struct device *dev)return gpiod_get_value (ts->gpiod); } +static int tsc2007_get_pendown_state_gpio_cansleep (struct device *dev) +{ +struct i2c_client *client =to_i2c_client (dev); +struct tsc2007 *ts =i2c_get_clientdata (client); + +return gpiod_get_value_cansleep (ts->gpiod); +} +static int tsc2007_probe_properties (struct device *dev,struct tsc2007 *ts) {u32 val32;
@@ -264,10 +281,21 @@ static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)if (IS_ERR (ts->gpiod))return PTR_ERR (ts->gpiod); -if (ts->gpiod) - ts->get_pendown_state = tsc2007_get_pendown_state_gpio; -else +if (ts->gpiod) { +/* to support detection during the hard IRQ, the GPIO chip is required to not sleep. +* this might be the case if the GPIO is e.g. behind an i2c-based GPIO expander. +* it is fine to sleep later in the soft IRQ, as it is threaded. +*/ + ts->get_pendown_state_cansleep = tsc2007_get_pendown_state_gpio_cansleep; +if (gpiod_to_chip (ts->gpiod) && !gpiod_to_chip (ts->gpiod)->can_sleep) { + ts->get_pendown_state = tsc2007_get_pendown_state_gpio; + }else { +dev_dbg (dev,"Pen down GPIO chip can sleep\n" ); + } + + }else {dev_warn (dev,"Pen down GPIO is not specified in properties\n" ); + }return 0 ; }
Signature · 1 line
2.34.1
Le 13/07/2022 à 10:42, Benjamin Bara a écrit :
Quoted 4 lines
From: Benjamin Bara <[email protected]>
This enables the usage of "
can_sleep" GPIO chips as "pin up" GPIO. This might be the case if the GPIO chip is an expander behind i2c.
Hi,
should you care and/or should there be a v2, some nitpick below.
CJ
Quoted 81 lines
Signed-off-by Benjamin Bara <[email protected]>Signed-off-by Richard Leitner <[email protected]>--- drivers/input/touchscreen/tsc2007.h | 1 + drivers/input/touchscreen/tsc2007_core.c | 38 ++++++++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-)drivers/input/touchscreen/tsc2007.h +1
-0@@ -78,6 +78,7 @@ struct tsc2007 {bool stopped;int (*get_pendown_state)(struct device *); +int (*get_pendown_state_cansleep)(struct device *);void (*clear_penirq)(void );struct mutex mlock;drivers/input/touchscreen/tsc2007_core.c +19
-2@@ -20,6 +20,7 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/gpio/consumer.h> +#include <linux/gpio/driver.h> #include <linux/input.h> #include <linux/interrupt.h> #include <linux/i2c.h> @@ -108,6 +109,14 @@ bool tsc2007_is_pen_down(struct tsc2007 *ts)return ts->get_pendown_state (&ts->client->dev); } +bool tsc2007_is_pen_down_cansleep (struct tsc2007 *ts) +{ +if (!ts->get_pendown_state_cansleep) +return true; + +return ts->get_pendown_state_cansleep (&ts->client->dev); +} +static irqreturn_t tsc2007_soft_irq (int irq,void *handle) {struct tsc2007 *ts = handle;@@ -115,7 +124,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)struct ts_event tc;u32 rt; -while (!ts->stopped &&tsc2007_is_pen_down (ts)) { +while (!ts->stopped &&tsc2007_is_pen_down_cansleep (ts)) {/* pen is down, continue with the measurement */ @@ -125,7 +134,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle) rt =tsc2007_calculate_resistance (ts, &tc); -if (!rt && !ts->get_pendown_state) { +if (!rt && !ts->get_pendown_state_cansleep) {/* * If pressure reported is 0 and we don't have * callback to check pendown state, we have to @@ -229,6 +238,14 @@ static int tsc2007_get_pendown_state_gpio(struct device *dev)return gpiod_get_value (ts->gpiod); } +static int tsc2007_get_pendown_state_gpio_cansleep (struct device *dev) +{ +struct i2c_client *client =to_i2c_client (dev); +struct tsc2007 *ts =i2c_get_clientdata (client); + +return gpiod_get_value_cansleep (ts->gpiod); +} +static int tsc2007_probe_properties (struct device *dev,struct tsc2007 *ts) {u32 val32;
drivers/input/touchscreen/tsc2007_core.c static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts) · line 285
Quoted 8 lines
drivers/input/touchscreen/tsc2007_core.c +2
-3@@ -264,10 +281,21 @@ static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)if (IS_ERR (ts->gpiod))return PTR_ERR (ts->gpiod); -if (ts->gpiod) - ts->get_pendown_state = tsc2007_get_pendown_state_gpio; -else +if (ts->gpiod) { +/* to support detection during the hard IRQ, the GPIO chip is required to not sleep.
There should be /* alone on the first line of the comment.
drivers/input/touchscreen/tsc2007_core.c static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts) · line 294
Quoted 9 lines
drivers/input/touchscreen/tsc2007_core.c +9
-0+* this might be the case if the GPIO is e.g. behind an i2c-based GPIO expander. +* it is fine to sleep later in the soft IRQ, as it is threaded. +*/ + ts->get_pendown_state_cansleep = tsc2007_get_pendown_state_gpio_cansleep; +if (gpiod_to_chip (ts->gpiod) && !gpiod_to_chip (ts->gpiod)->can_sleep) { + ts->get_pendown_state = tsc2007_get_pendown_state_gpio; + }else { +dev_dbg (dev,"Pen down GPIO chip can sleep\n" ); + }
Un-needed extra { } around each branch of this "if".
Just my 2c,
CJ
Quoted 7 lines
drivers/input/touchscreen/tsc2007_core.c +3
-0+ + }else {dev_warn (dev,"Pen down GPIO is not specified in properties\n" ); + }return 0 ; }
Am Mi., 13. Juli 2022 um 10:56 Uhr schrieb Christophe JAILLET <[email protected]>:
Quoted 1 line
should you care and/or should there be a v2, some nitpick below.
I will soon provide a v2 with the mentioned fixes.
Thanks & br,
bb
PATCH v2 1/1 Input: tsc2007 - enable GPIO chips that can sleep
From: Benjamin Bara <[email protected]>
This enables the usage of "can_sleep" GPIO chips as "pin up" GPIO. This might be the case if the GPIO chip is an expander behind i2c.
--- drivers/input/touchscreen/tsc2007.h | 1 + drivers/input/touchscreen/tsc2007_core.c | 34 ++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-)
drivers/input/touchscreen/tsc2007.h +1 -0
@@ -78,6 +78,7 @@ struct tsc2007 {bool stopped;int (*get_pendown_state)(struct device *); +int (*get_pendown_state_cansleep)(struct device *dev);void (*clear_penirq)(void );struct mutex mlock;
drivers/input/touchscreen/tsc2007_core.c +29 -5
@@ -20,6 +20,7 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/gpio/consumer.h> +#include <linux/gpio/driver.h> #include <linux/input.h> #include <linux/interrupt.h> #include <linux/i2c.h>
@@ -108,6 +109,14 @@ bool tsc2007_is_pen_down(struct tsc2007 *ts)return ts->get_pendown_state (&ts->client->dev); } +static bool tsc2007_is_pen_down_cansleep (struct tsc2007 *ts) +{ +if (!ts->get_pendown_state_cansleep) +return true; + +return ts->get_pendown_state_cansleep (&ts->client->dev); +} +static irqreturn_t tsc2007_soft_irq (int irq,void *handle) {struct tsc2007 *ts = handle;
@@ -115,7 +124,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)struct ts_event tc;u32 rt; -while (!ts->stopped &&tsc2007_is_pen_down (ts)) { +while (!ts->stopped &&tsc2007_is_pen_down_cansleep (ts)) {/* pen is down, continue with the measurement */
@@ -125,7 +134,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle) rt =tsc2007_calculate_resistance (ts, &tc); -if (!rt && !ts->get_pendown_state) { +if (!rt && !ts->get_pendown_state_cansleep) {/* * If pressure reported is 0 and we don't have * callback to check pendown state, we have to
@@ -229,6 +238,14 @@ static int tsc2007_get_pendown_state_gpio(struct device *dev)return gpiod_get_value (ts->gpiod); } +static int tsc2007_get_pendown_state_gpio_cansleep (struct device *dev) +{ +struct i2c_client *client =to_i2c_client (dev); +struct tsc2007 *ts =i2c_get_clientdata (client); + +return gpiod_get_value_cansleep (ts->gpiod); +} +static int tsc2007_probe_properties (struct device *dev,struct tsc2007 *ts) {u32 val32;
@@ -264,10 +281,17 @@ static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)if (IS_ERR (ts->gpiod))return PTR_ERR (ts->gpiod); -if (ts->gpiod) - ts->get_pendown_state = tsc2007_get_pendown_state_gpio; -else +if (ts->gpiod) { + ts->get_pendown_state_cansleep = tsc2007_get_pendown_state_gpio_cansleep; + +/* pendown pin is read during hard irq -> gpio chip is not allowed to sleep */ +if (gpiod_to_chip (ts->gpiod) && !gpiod_to_chip (ts->gpiod)->can_sleep) + ts->get_pendown_state = tsc2007_get_pendown_state_gpio; +else +dev_dbg (dev,"Pen down GPIO chip can sleep\n" ); + }else {dev_warn (dev,"Pen down GPIO is not specified in properties\n" ); + }return 0 ; }
Signature · 1 line
2.34.1
Le 13/07/2022 à 10:42, Benjamin Bara a écrit :
Quoted 4 lines
From: Benjamin Bara <[email protected]>
This enables the usage of "
can_sleep" GPIO chips as "pin up" GPIO. This might be the case if the GPIO chip is an expander behind i2c.
Hi,
should you care and/or should there be a v2, some nitpick below.
CJ
Quoted 81 lines
Signed-off-by Benjamin Bara <[email protected]>Signed-off-by Richard Leitner <[email protected]>--- drivers/input/touchscreen/tsc2007.h | 1 + drivers/input/touchscreen/tsc2007_core.c | 38 ++++++++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-)drivers/input/touchscreen/tsc2007.h +1
-0@@ -78,6 +78,7 @@ struct tsc2007 {bool stopped;int (*get_pendown_state)(struct device *); +int (*get_pendown_state_cansleep)(struct device *);void (*clear_penirq)(void );struct mutex mlock;drivers/input/touchscreen/tsc2007_core.c +19
-2@@ -20,6 +20,7 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/gpio/consumer.h> +#include <linux/gpio/driver.h> #include <linux/input.h> #include <linux/interrupt.h> #include <linux/i2c.h> @@ -108,6 +109,14 @@ bool tsc2007_is_pen_down(struct tsc2007 *ts)return ts->get_pendown_state (&ts->client->dev); } +bool tsc2007_is_pen_down_cansleep (struct tsc2007 *ts) +{ +if (!ts->get_pendown_state_cansleep) +return true; + +return ts->get_pendown_state_cansleep (&ts->client->dev); +} +static irqreturn_t tsc2007_soft_irq (int irq,void *handle) {struct tsc2007 *ts = handle;@@ -115,7 +124,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)struct ts_event tc;u32 rt; -while (!ts->stopped &&tsc2007_is_pen_down (ts)) { +while (!ts->stopped &&tsc2007_is_pen_down_cansleep (ts)) {/* pen is down, continue with the measurement */ @@ -125,7 +134,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle) rt =tsc2007_calculate_resistance (ts, &tc); -if (!rt && !ts->get_pendown_state) { +if (!rt && !ts->get_pendown_state_cansleep) {/* * If pressure reported is 0 and we don't have * callback to check pendown state, we have to @@ -229,6 +238,14 @@ static int tsc2007_get_pendown_state_gpio(struct device *dev)return gpiod_get_value (ts->gpiod); } +static int tsc2007_get_pendown_state_gpio_cansleep (struct device *dev) +{ +struct i2c_client *client =to_i2c_client (dev); +struct tsc2007 *ts =i2c_get_clientdata (client); + +return gpiod_get_value_cansleep (ts->gpiod); +} +static int tsc2007_probe_properties (struct device *dev,struct tsc2007 *ts) {u32 val32;
drivers/input/touchscreen/tsc2007_core.c static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts) · line 285
Quoted 8 lines
drivers/input/touchscreen/tsc2007_core.c +2
-3@@ -264,10 +281,21 @@ static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)if (IS_ERR (ts->gpiod))return PTR_ERR (ts->gpiod); -if (ts->gpiod) - ts->get_pendown_state = tsc2007_get_pendown_state_gpio; -else +if (ts->gpiod) { +/* to support detection during the hard IRQ, the GPIO chip is required to not sleep.
There should be /* alone on the first line of the comment.
drivers/input/touchscreen/tsc2007_core.c static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts) · line 294
Quoted 9 lines
drivers/input/touchscreen/tsc2007_core.c +9
-0+* this might be the case if the GPIO is e.g. behind an i2c-based GPIO expander. +* it is fine to sleep later in the soft IRQ, as it is threaded. +*/ + ts->get_pendown_state_cansleep = tsc2007_get_pendown_state_gpio_cansleep; +if (gpiod_to_chip (ts->gpiod) && !gpiod_to_chip (ts->gpiod)->can_sleep) { + ts->get_pendown_state = tsc2007_get_pendown_state_gpio; + }else { +dev_dbg (dev,"Pen down GPIO chip can sleep\n" ); + }
Un-needed extra { } around each branch of this "if".
Just my 2c,
CJ
Quoted 7 lines
drivers/input/touchscreen/tsc2007_core.c +3
-0+ + }else {dev_warn (dev,"Pen down GPIO is not specified in properties\n" ); + }return 0 ; }
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Benjamin,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on dtor-input/next]
[also build test WARNING on hid/for-next linus/master v5.19-rc6 next-20220714] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Benjamin-Bara/Input-tsc2007-enable-GPIO-chips-that-can-sleep/20220713-164521 base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next config: riscv-randconfig-r003-20220714 (https://download.01.org/0day-ci/archive/20220715/[email protected]/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 5e61b9c556267086ef9b743a0b57df302eef831b)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/13455f523263c4e90b5cc8c587ef2be97008ff5f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Benjamin-Bara/Input-tsc2007-enable-GPIO-chips-that-can-sleep/20220713-164521
git checkout 13455f523263c4e90b5cc8c587ef2be97008ff5f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/gpu/drm/amd/display/amdgpu_dm/ drivers/input/touchscreen/
If you fix the issue, kindly add following tag where applicable
All warnings (new ones prefixed by >>):
>> drivers/input/touchscreen/tsc2007_core.c:112:6: warning: no previous prototype for function 'tsc2007_is_pen_down_cansleep' [-Wmissing-prototypes]
bool tsc2007_is_pen_down_cansleep(struct tsc2007 *ts)
^ drivers/input/touchscreen/tsc2007_core.c:112:1: note: declare 'static' if the function is not intended to be used outside of this translation unit bool tsc2007_is_pen_down_cansleep(struct tsc2007 *ts)
^
static
1 warning generated.
vim +/tsc2007_is_pen_down_cansleep +112 drivers/input/touchscreen/tsc2007_core.c
111
> 112 bool tsc2007_is_pen_down_cansleep(struct tsc2007 *ts)
113 {
114 if (!ts->get_pendown_state_cansleep)
115 return true;
116
117 return ts->get_pendown_state_cansleep(&ts->client->dev);
118 }
119
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Benjamin,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on dtor-input/next]
[also build test WARNING on linus/master v5.19-rc6 next-20220714] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Benjamin-Bara/Input-tsc2007-enable-GPIO-chips-that-can-sleep/20220713-164521 base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20220715/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-3) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/13455f523263c4e90b5cc8c587ef2be97008ff5f git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Benjamin-Bara/Input-tsc2007-enable-GPIO-chips-that-can-sleep/20220713-164521 git checkout 13455f523263c4e90b5cc8c587ef2be97008ff5f # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/input/touchscreen/ sound/soc/codecs/
If you fix the issue, kindly add following tag where applicable
All warnings (new ones prefixed by >>):
>> drivers/input/touchscreen/tsc2007_core.c:112:6: warning: no previous prototype for 'tsc2007_is_pen_down_cansleep' [-Wmissing-prototypes]
112 | bool tsc2007_is_pen_down_cansleep(struct tsc2007 *ts)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~vim +/tsc2007_is_pen_down_cansleep +112 drivers/input/touchscreen/tsc2007_core.c
111
> 112 bool tsc2007_is_pen_down_cansleep(struct tsc2007 *ts)
113 {
114 if (!ts->get_pendown_state_cansleep)
115 return true;
116
117 return ts->get_pendown_state_cansleep(&ts->client->dev);
118 }
119
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Benjamin,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on dtor-input/next]
[also build test WARNING on linus/master v5.19-rc6 next-20220714] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Benjamin-Bara/Input-tsc2007-enable-GPIO-chips-that-can-sleep/20220713-164521 base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next config: i386-randconfig-s003 (https://download.01.org/0day-ci/archive/20220715/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-3) 11.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.4-39-gce1a6720-dirty # https://github.com/intel-lab-lkp/linux/commit/13455f523263c4e90b5cc8c587ef2be97008ff5f git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Benjamin-Bara/Input-tsc2007-enable-GPIO-chips-that-can-sleep/20220713-164521 git checkout 13455f523263c4e90b5cc8c587ef2be97008ff5f # save the config file mkdir build_dir && cp config build_dir/.config make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/input/touchscreen/
If you fix the issue, kindly add following tag where applicable
sparse warnings: (new ones prefixed by >>)
>> drivers/input/touchscreen/tsc2007_core.c:112:6: sparse: sparse: symbol 'tsc2007_is_pen_down_cansleep' was not declared. Should it be static?
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp