Instead of using platform data to specify GPIO that is used as interrupt
source, rely on the platform and I2C core to set it up properly.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/cy8ctmg110_ts.c | 32 +----------------------
include/linux/input/cy8ctmg110_pdata.h | 1 -
2 files changed, 1 insertion(+), 32 deletions(-)
@@ -191,7 +190,6 @@ static int cy8ctmg110_probe(struct i2c_client *client,ts->client=client;ts->input=input_dev;ts->reset_pin=pdata->reset_pin;-ts->irq_pin=pdata->irq_pin;snprintf(ts->phys,sizeof(ts->phys),"%s/input0",dev_name(&client->dev));
@@ -222,38 +220,13 @@ static int cy8ctmg110_probe(struct i2c_client *client,cy8ctmg110_power(ts,true);cy8ctmg110_set_sleepmode(ts,false);-err=gpio_request(ts->irq_pin,"touch_irq_key");-if(err<0){-dev_err(&client->dev,-"Failed to request GPIO %d, error %d\n",-ts->irq_pin,err);-gotoerr_shutoff_device;-}--err=gpio_direction_input(ts->irq_pin);-if(err<0){-dev_err(&client->dev,-"Failed to configure input direction for GPIO %d, error %d\n",-ts->irq_pin,err);-gotoerr_free_irq_gpio;-}--client->irq=gpio_to_irq(ts->irq_pin);-if(client->irq<0){-err=client->irq;-dev_err(&client->dev,-"Unable to get irq number for GPIO %d, error %d\n",-ts->irq_pin,err);-gotoerr_free_irq_gpio;-}-err=request_threaded_irq(client->irq,NULL,cy8ctmg110_irq_thread,IRQF_TRIGGER_RISING|IRQF_ONESHOT,"touch_reset_key",ts);if(err<0){dev_err(&client->dev,"irq %d busy? error %d\n",client->irq,err);-gotoerr_free_irq_gpio;+gotoerr_shutoff_device;}err=input_register_device(input_dev);
@@ -266,8 +239,6 @@ static int cy8ctmg110_probe(struct i2c_client *client,err_free_irq:free_irq(client->irq,ts);-err_free_irq_gpio:-gpio_free(ts->irq_pin);err_shutoff_device:cy8ctmg110_set_sleepmode(ts,true);cy8ctmg110_power(ts,false);
@@ -318,7 +289,6 @@ static int cy8ctmg110_remove(struct i2c_client *client)free_irq(client->irq,ts);input_unregister_device(ts->input);-gpio_free(ts->irq_pin);if(ts->reset_pin)gpio_free(ts->reset_pin);kfree(ts);
@@ -5,7 +5,6 @@structcy8ctmg110_pdata{intreset_pin;/* Reset pin is wired to this GPIO (optional) */-intirq_pin;/* IRQ pin is wired to this GPIO */};#endif
Let platform specify whether the controller should be a wakeup source
by registering as I2C_CLIENT_WAKE.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/cy8ctmg110_ts.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
I2C core already configures interrupt as wakeup source when device is
registered using I2C_CLIENT_WAKE flag, so let's rely on it instead of
configuring it ourselves.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/cy8ctmg110_ts.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
Switch to using be16_to_cpup() instead of shifting and combining data by
hand.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/cy8ctmg110_ts.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
@@ -111,7 +112,6 @@ static int cy8ctmg110_touch_pos(struct cy8ctmg110 *tsc){structinput_dev*input=tsc->input;unsignedcharreg_p[CY8CTMG110_REG_MAX];-intx,y;memset(reg_p,0,CY8CTMG110_REG_MAX);
@@ -119,16 +119,15 @@ static int cy8ctmg110_touch_pos(struct cy8ctmg110 *tsc)if(cy8ctmg110_read_regs(tsc,reg_p,9,CY8CTMG110_TOUCH_X1)!=0)return-EIO;-y=reg_p[2]<<8|reg_p[3];-x=reg_p[0]<<8|reg_p[1];-/* Number of touch */if(reg_p[8]==0){input_report_key(input,BTN_TOUCH,0);}else{input_report_key(input,BTN_TOUCH,1);-input_report_abs(input,ABS_X,x);-input_report_abs(input,ABS_Y,y);+input_report_abs(input,ABS_X,+be16_to_cpup((__be16*)(reg_p+0)));+input_report_abs(input,ABS_Y,+be16_to_cpup((__be16*)(reg_p+2)));}input_sync(input);
Instead of legacy gpio API let's use newer gpiod API. This also allows us
to get rid of platform data.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/cy8ctmg110_ts.c | 41 +++++++++--------------
1 file changed, 15 insertions(+), 26 deletions(-)
@@ -172,17 +170,10 @@ static void cy8ctmg110_shut_off(void *_ts)staticintcy8ctmg110_probe(structi2c_client*client,conststructi2c_device_id*id){-conststructcy8ctmg110_pdata*pdata=dev_get_platdata(&client->dev);structcy8ctmg110*ts;structinput_dev*input_dev;interr;-/* No pdata no way forward */-if(pdata==NULL){-dev_err(&client->dev,"no pdata\n");-return-ENODEV;-}-if(!i2c_check_functionality(client->adapter,I2C_FUNC_SMBUS_READ_WORD_DATA))return-EIO;
@@ -197,7 +188,6 @@ static int cy8ctmg110_probe(struct i2c_client *client,ts->client=client;ts->input=input_dev;-ts->reset_pin=pdata->reset_pin;snprintf(ts->phys,sizeof(ts->phys),"%s/input0",dev_name(&client->dev));
@@ -212,14 +202,13 @@ static int cy8ctmg110_probe(struct i2c_client *client,input_set_abs_params(input_dev,ABS_Y,CY8CTMG110_Y_MIN,CY8CTMG110_Y_MAX,4,0);-if(ts->reset_pin){-err=devm_gpio_request(&client->dev,ts->reset_pin,NULL);-if(err){-dev_err(&client->dev,-"Unable to request GPIO pin %d.\n",-ts->reset_pin);-returnerr;-}+ts->reset_gpio=devm_gpiod_get_optional(&client->dev,NULL,+GPIOD_OUT_HIGH);+if(IS_ERR(ts->reset_gpio)){+err=PTR_ERR(ts->reset_gpio);+dev_err(&client->dev,+"Unable to request reset GPIO: %d\n",err);+returnerr;}cy8ctmg110_power(ts,true);
Hi Dmitry,
I see you noticed that there is no upstream board defining
any cy8ctmg110_pdata, so I don't see any problem with
fixing this. Outoftree users can adopt.
On Thu, Jun 3, 2021 at 6:37 AM Dmitry Torokhov
[off-list ref] wrote:
Instead of using platform data to specify GPIO that is used as interrupt
source, rely on the platform and I2C core to set it up properly.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Linus Walleij <redacted>
- client->irq = gpio_to_irq(ts->irq_pin);
This looks like a violation of the struct anyway....
Yours,
Linus Walleij
On Thu, Jun 3, 2021 at 6:37 AM Dmitry Torokhov
[off-list ref] wrote:
Rely on the platform to set up interrupt polarity/type properly instead
of hard-coding falling edge.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
On Thu, Jun 3, 2021 at 6:37 AM Dmitry Torokhov
[off-list ref] wrote:
Let platform specify whether the controller should be a wakeup source
by registering as I2C_CLIENT_WAKE.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
On Thu, Jun 3, 2021 at 6:37 AM Dmitry Torokhov
[off-list ref] wrote:
I2C core already configures interrupt as wakeup source when device is
registered using I2C_CLIENT_WAKE flag, so let's rely on it instead of
configuring it ourselves.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Linus Walleij <redacted>
I wonder how many bugs of this deep semantic type we have in the kernel :/
Yours,
Linus Walleij
On Thu, Jun 3, 2021 at 6:37 AM Dmitry Torokhov
[off-list ref] wrote:
Instead of legacy gpio API let's use newer gpiod API. This also allows us
to get rid of platform data.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
On Fri, Jun 04, 2021 at 09:38:04AM +0200, Linus Walleij wrote:
On Thu, Jun 3, 2021 at 6:37 AM Dmitry Torokhov
[off-list ref] wrote:
quoted
Instead of legacy gpio API let's use newer gpiod API. This also allows us
to get rid of platform data.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
On Fri, Jun 04, 2021 at 09:32:53AM +0200, Linus Walleij wrote:
On Thu, Jun 3, 2021 at 6:37 AM Dmitry Torokhov
[off-list ref] wrote:
quoted
I2C core already configures interrupt as wakeup source when device is
registered using I2C_CLIENT_WAKE flag, so let's rely on it instead of
configuring it ourselves.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Linus Walleij <redacted>
I wonder how many bugs of this deep semantic type we have in the kernel :/
I do not think this is necessarily a bug, it just shows age of the
driver that was written before I2C core was doing this set up for us.
Thanks.
--
Dmitry