* [PATCH 2/2] input: tsc2007: Don't require an interrupt to load
[not found] <1959876509.19488.1427814135809.JavaMail.zimbra@xes-inc.com>
@ 2015-03-31 15:06 ` Aaron Sierra
2015-03-31 21:35 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: Aaron Sierra @ 2015-03-31 15:06 UTC (permalink / raw)
To: Kwangwoo Lee, Dmitry Torokhov, Thierry Reding, Philip Rakity; +Cc: linux-input
When an IRQ isn't available, poll the device based on poll_period.
Signed-off-by: Aaron Sierra <asierra@xes-inc.com>
---
drivers/input/touchscreen/tsc2007.c | 43 +++++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 7 deletions(-)
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 4e97afb..e49a88f 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -71,6 +71,7 @@ struct tsc2007 {
char phys[32];
struct i2c_client *client;
+ struct delayed_work work;
u16 model;
u16 x_plate_ohms;
@@ -82,6 +83,7 @@ struct tsc2007 {
unsigned gpio;
int irq;
+ bool using_irq;
wait_queue_head_t wait;
bool stopped;
@@ -242,13 +244,27 @@ static irqreturn_t tsc2007_hard_irq(int irq, void *handle)
return IRQ_HANDLED;
}
+static void tsc2007_work(struct work_struct *work)
+{
+ struct tsc2007 *ts =
+ container_of(to_delayed_work(work), struct tsc2007, work);
+
+ tsc2007_soft_irq(ts->irq, ts);
+
+ /* reschedule the task */
+ schedule_delayed_work(&ts->work, ts->poll_period);
+}
+
static void tsc2007_stop(struct tsc2007 *ts)
{
ts->stopped = true;
mb();
wake_up(&ts->wait);
- disable_irq(ts->irq);
+ if (ts->using_irq)
+ disable_irq(ts->irq);
+ else
+ cancel_delayed_work_sync(&ts->work);
}
static int tsc2007_open(struct input_dev *input_dev)
@@ -259,7 +275,10 @@ static int tsc2007_open(struct input_dev *input_dev)
ts->stopped = false;
mb();
- enable_irq(ts->irq);
+ if (ts->using_irq)
+ enable_irq(ts->irq);
+ else
+ schedule_delayed_work(&ts->work, ts->poll_period);
/* Prepare for touch readings - power down ADC and enable PENIRQ */
err = tsc2007_xfer(ts, PWRDOWN);
@@ -405,6 +424,7 @@ static int tsc2007_probe(struct i2c_client *client,
ts->client = client;
ts->irq = client->irq;
+ ts->using_irq = false;
ts->input = input_dev;
init_waitqueue_head(&ts->wait);
@@ -445,14 +465,23 @@ static int tsc2007_probe(struct i2c_client *client,
pdata->init_platform_hw();
}
- err = devm_request_threaded_irq(&client->dev, ts->irq,
+ if (ts->irq >= 0) {
+ err = devm_request_threaded_irq(&client->dev, ts->irq,
tsc2007_hard_irq, 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 (err) {
+ dev_warn(&client->dev, "Failed to request irq %d: %d\n",
+ ts->irq, err);
+ } else {
+ ts->using_irq = true;
+ }
+ }
+
+ if (!ts->using_irq) {
+ dev_info(&client->dev,
+ "No IRQ, polling every %ld ms\n", ts->poll_period);
+ INIT_DELAYED_WORK(&ts->work, tsc2007_work);
}
tsc2007_stop(ts);
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] input: tsc2007: Don't require an interrupt to load
2015-03-31 15:06 ` [PATCH 2/2] input: tsc2007: Don't require an interrupt to load Aaron Sierra
@ 2015-03-31 21:35 ` Dmitry Torokhov
2015-03-31 21:55 ` Aaron Sierra
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2015-03-31 21:35 UTC (permalink / raw)
To: Aaron Sierra; +Cc: Kwangwoo Lee, Thierry Reding, Philip Rakity, linux-input
Hi Aaron,
On Tue, Mar 31, 2015 at 10:06:05AM -0500, Aaron Sierra wrote:
> When an IRQ isn't available, poll the device based on poll_period.
What is the point in using such mode? Why would not IRQ be available?
If this is for device bringup I'd say just carry this locally.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] input: tsc2007: Don't require an interrupt to load
2015-03-31 21:35 ` Dmitry Torokhov
@ 2015-03-31 21:55 ` Aaron Sierra
0 siblings, 0 replies; 3+ messages in thread
From: Aaron Sierra @ 2015-03-31 21:55 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Kwangwoo Lee, Thierry Reding, Philip Rakity, linux-input
----- Original Message -----
> From: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>
> Sent: Tuesday, March 31, 2015 4:35:18 PM
>
> Hi Aaron,
>
> On Tue, Mar 31, 2015 at 10:06:05AM -0500, Aaron Sierra wrote:
> > When an IRQ isn't available, poll the device based on poll_period.
>
> What is the point in using such mode? Why would not IRQ be available?
> If this is for device bringup I'd say just carry this locally.
Dmitry,
I am using this touchscreen in a system where the PENIRQ# output is
tied to a GPIO. I was originally taking advantage of the poll_delay
value from the platform_data structure, but that has since been
removed.
I am fine maintaining this locally. Thanks.
-Aaron S.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-31 21:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1959876509.19488.1427814135809.JavaMail.zimbra@xes-inc.com>
2015-03-31 15:06 ` [PATCH 2/2] input: tsc2007: Don't require an interrupt to load Aaron Sierra
2015-03-31 21:35 ` Dmitry Torokhov
2015-03-31 21:55 ` Aaron Sierra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).