diff mbox series

[v1,1/1] input: touchcreen: tsc2007: make interrupt optional

Message ID 20240210175530.137361-2-clamor95@gmail.com (mailing list archive)
State New
Headers show
Series input: touchcreen: tsc2007: make interrupt optional | expand

Commit Message

Svyatoslav Ryhel Feb. 10, 2024, 5:55 p.m. UTC
In case tsc2007 is used as an ADC sensor there will be no interrupt
provided at all, so set up an interrupt only if one is present and
remove associated warning.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/input/touchscreen/tsc2007_core.c | 30 +++++++++++++-----------
 1 file changed, 16 insertions(+), 14 deletions(-)

Comments

Dmitry Torokhov Feb. 15, 2024, 5:55 p.m. UTC | #1
Hi Svyatoslav,

On Sat, Feb 10, 2024 at 07:55:30PM +0200, Svyatoslav Ryhel wrote:
> In case tsc2007 is used as an ADC sensor there will be no interrupt
> provided at all, so set up an interrupt only if one is present and
> remove associated warning.

If we want to do this, we should better handle the input device portion
of the driver. We have 2 options:

- switch the input device into polling mode when interrupt is absent
- do not create input device

Those do not need to be mutually exclusive (i.e. we could use absence of
both device tree interrupt property as well as lack of poll-interval
property to suppress creation of the input device and only leave iio.

Thanks.
Svyatoslav Ryhel Feb. 15, 2024, 6:09 p.m. UTC | #2
чт, 15 лют. 2024 р. о 19:55 Dmitry Torokhov <dmitry.torokhov@gmail.com> пише:
>
> Hi Svyatoslav,
>
> On Sat, Feb 10, 2024 at 07:55:30PM +0200, Svyatoslav Ryhel wrote:
> > In case tsc2007 is used as an ADC sensor there will be no interrupt
> > provided at all, so set up an interrupt only if one is present and
> > remove associated warning.
>
> If we want to do this, we should better handle the input device portion
> of the driver. We have 2 options:
>
> - switch the input device into polling mode when interrupt is absent
> - do not create input device
>
> Those do not need to be mutually exclusive (i.e. we could use absence of
> both device tree interrupt property as well as lack of poll-interval
> property to suppress creation of the input device and only leave iio.
>
> Thanks.
>

I do not care about input part and suppressing it is perfectly fine for me.
Which implementation would be accepted?
I suppose I may isolate input device creation into separate function and
add check for interrupt or poll-interval. If both are not present then input
device creation will be skipped. Will this be sufficient?

> --
> Dmitry
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
index b3655250d4a7..f6bb12ebf97f 100644
--- a/drivers/input/touchscreen/tsc2007_core.c
+++ b/drivers/input/touchscreen/tsc2007_core.c
@@ -178,7 +178,8 @@  static void tsc2007_stop(struct tsc2007 *ts)
 	mb();
 	wake_up(&ts->wait);
 
-	disable_irq(ts->irq);
+	if (ts->irq)
+		disable_irq(ts->irq);
 }
 
 static int tsc2007_open(struct input_dev *input_dev)
@@ -189,7 +190,8 @@  static int tsc2007_open(struct input_dev *input_dev)
 	ts->stopped = false;
 	mb();
 
-	enable_irq(ts->irq);
+	if (ts->irq)
+		enable_irq(ts->irq);
 
 	/* Prepare for touch readings - power down ADC and enable PENIRQ */
 	err = tsc2007_xfer(ts, PWRDOWN);
@@ -253,8 +255,6 @@  static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)
 
 	if (ts->gpiod)
 		ts->get_pendown_state = tsc2007_get_pendown_state_gpio;
-	else
-		dev_warn(dev, "Pen down GPIO is not specified in properties\n");
 
 	return 0;
 }
@@ -362,17 +362,19 @@  static int tsc2007_probe(struct i2c_client *client)
 			pdata->init_platform_hw();
 	}
 
-	err = devm_request_threaded_irq(&client->dev, ts->irq,
-					NULL, tsc2007_soft_irq,
-					IRQF_ONESHOT,
-					client->dev.driver->name, ts);
-	if (err) {
-		dev_err(&client->dev, "Failed to request irq %d: %d\n",
-			ts->irq, err);
-		return err;
-	}
+	if (ts->irq) {
+		err = devm_request_threaded_irq(&client->dev, ts->irq,
+						NULL, tsc2007_soft_irq,
+						IRQF_ONESHOT,
+						client->dev.driver->name, ts);
+		if (err) {
+			dev_err(&client->dev, "Failed to request irq %d: %d\n",
+				ts->irq, err);
+			return err;
+		}
 
-	tsc2007_stop(ts);
+		tsc2007_stop(ts);
+	}
 
 	/* power down the chip (TSC2007_SETUP does not ACK on I2C) */
 	err = tsc2007_xfer(ts, PWRDOWN);