From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Svyatoslav Ryhel <clamor95@gmail.com>,
"H . Nikolaus Schaller" <hns@goldelico.com>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
Andreas Kemnade <andreas@kemnade.info>,
Johannes Kirchmair <johannes.kirchmair@skidata.com>,
Yuki Horii <yuuki198708@gmail.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
linux-input@vger.kernel.org, linux-sh@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 4/5] Input: tsc2007 - do not register input device without IRQ
Date: Wed, 11 Nov 2026 22:50:36 -0800 [thread overview]
Message-ID: <20261112065037.1800467-5-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20261112065037.1800467-1-dmitry.torokhov@gmail.com>
The driver has no polled input mode and only reports touchscreen input
events from its threaded interrupt handler. When no interrupt is wired,
the device is used solely as an IIO ADC, so registering an input device
serves no purpose and creates a non-functional input node.
Only allocate, configure, and register the input device when an
interrupt is present. This also allows removing the unnecessary
ts->irq checks in the open and stop callbacks.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/tsc2007_core.c | 95 +++++++++++++-----------
1 file changed, 51 insertions(+), 44 deletions(-)
diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
index 8197ad91ed8b..1fb2c26189ba 100644
--- a/drivers/input/touchscreen/tsc2007_core.c
+++ b/drivers/input/touchscreen/tsc2007_core.c
@@ -172,8 +172,7 @@ static void tsc2007_stop(struct tsc2007 *ts)
ts->stopped = true;
wake_up(&ts->wait);
- if (ts->irq)
- disable_irq(ts->irq);
+ disable_irq(ts->irq);
}
static int tsc2007_open(struct input_dev *input_dev)
@@ -182,9 +181,7 @@ static int tsc2007_open(struct input_dev *input_dev)
int err;
ts->stopped = false;
-
- if (ts->irq)
- enable_irq(ts->irq);
+ enable_irq(ts->irq);
/* Prepare for touch readings - power down ADC and enable PENIRQ */
err = tsc2007_xfer(ts, PWRDOWN);
@@ -243,37 +240,19 @@ static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)
return 0;
}
-static int tsc2007_probe(struct i2c_client *client)
+static int tsc2007_input_configure(struct tsc2007 *ts)
{
- struct tsc2007 *ts;
+ struct device *dev = &ts->client->dev;
struct input_dev *input_dev;
int err;
- if (!i2c_check_functionality(client->adapter,
- I2C_FUNC_SMBUS_READ_WORD_DATA))
- return -EIO;
-
- ts = devm_kzalloc_obj(&client->dev, struct tsc2007);
- if (!ts)
- return -ENOMEM;
-
- err = tsc2007_probe_properties(&client->dev, ts);
- if (err)
- return err;
-
- input_dev = devm_input_allocate_device(&client->dev);
+ input_dev = devm_input_allocate_device(dev);
if (!input_dev)
return -ENOMEM;
- ts->client = client;
- ts->irq = client->irq;
ts->input = input_dev;
- init_waitqueue_head(&ts->wait);
- mutex_init(&ts->mlock);
-
- snprintf(ts->phys, sizeof(ts->phys),
- "%s/input0", dev_name(&client->dev));
+ snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev));
input_dev->name = "TSC2007 Touchscreen";
input_dev->phys = ts->phys;
@@ -291,20 +270,49 @@ static int tsc2007_probe(struct i2c_client *client)
input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT,
ts->fuzzz, 0);
- 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;
- }
+ err = devm_request_threaded_irq(dev, ts->irq,
+ NULL, tsc2007_soft_irq,
+ IRQF_ONESHOT,
+ dev->driver->name, ts);
+ if (err) {
+ dev_err(dev, "Failed to request irq %d: %d\n", ts->irq, err);
+ return err;
+ }
- tsc2007_stop(ts);
+ tsc2007_stop(ts);
+
+ err = input_register_device(input_dev);
+ if (err) {
+ dev_err(dev, "Failed to register input device: %d\n", err);
+ return err;
}
+ return 0;
+}
+
+static int tsc2007_probe(struct i2c_client *client)
+{
+ struct tsc2007 *ts;
+ int err;
+
+ if (!i2c_check_functionality(client->adapter,
+ I2C_FUNC_SMBUS_READ_WORD_DATA))
+ return -EIO;
+
+ ts = devm_kzalloc_obj(&client->dev, struct tsc2007);
+ if (!ts)
+ return -ENOMEM;
+
+ ts->client = client;
+ ts->irq = client->irq;
+
+ init_waitqueue_head(&ts->wait);
+ mutex_init(&ts->mlock);
+
+ err = tsc2007_probe_properties(&client->dev, ts);
+ if (err)
+ return err;
+
/* power down the chip (TSC2007_SETUP does not ACK on I2C) */
err = tsc2007_xfer(ts, PWRDOWN);
if (err < 0) {
@@ -313,14 +321,13 @@ static int tsc2007_probe(struct i2c_client *client)
return err; /* chip does not respond */
}
- err = input_register_device(input_dev);
- if (err) {
- dev_err(&client->dev,
- "Failed to register input device: %d\n", err);
- return err;
+ if (ts->irq) {
+ err = tsc2007_input_configure(ts);
+ if (err)
+ return err;
}
- err = tsc2007_iio_configure(ts);
+ err = tsc2007_iio_configure(ts);
if (err) {
dev_err(&client->dev,
"Failed to register with IIO: %d\n", err);
--
2.56.0.567.gdb80ae8cd5-goog
next prev parent reply other threads:[~2026-11-12 6:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 6:50 [PATCH 0/5] Input: tsc2007 - drop platform data support and cleanups Dmitry Torokhov
2026-11-12 6:50 ` [PATCH 1/5] Input: tsc2007 - drop platform data support Dmitry Torokhov
2026-11-12 6:50 ` [PATCH 2/5] Input: tsc2007 - remove unneeded memory barriers Dmitry Torokhov
2026-11-12 6:50 ` [PATCH 3/5] Input: tsc2007 - fix minor coding style issues Dmitry Torokhov
2026-11-12 6:50 ` Dmitry Torokhov [this message]
2026-11-12 6:50 ` [PATCH 5/5] Input: tsc2007 - use IRQF_NO_AUTOEN when requesting interrupt Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261112065037.1800467-5-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=andreas@kemnade.info \
--cc=andy.shevchenko@gmail.com \
--cc=clamor95@gmail.com \
--cc=dalias@libc.org \
--cc=geert+renesas@glider.be \
--cc=glaubitz@physik.fu-berlin.de \
--cc=hns@goldelico.com \
--cc=johannes.kirchmair@skidata.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=ysato@users.sourceforge.jp \
--cc=yuuki198708@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®