Commit 7cd7a82d authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: ad7879 - use threaded IRQ

Tested-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 08fa16b6
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/gpio.h> #include <linux/gpio.h>
...@@ -131,13 +130,12 @@ typedef struct i2c_client bus_device; ...@@ -131,13 +130,12 @@ typedef struct i2c_client bus_device;
struct ad7879 { struct ad7879 {
bus_device *bus; bus_device *bus;
struct input_dev *input; struct input_dev *input;
struct work_struct work;
struct timer_list timer; struct timer_list timer;
#ifdef CONFIG_GPIOLIB #ifdef CONFIG_GPIOLIB
struct gpio_chip gc; struct gpio_chip gc;
#endif #endif
struct mutex mutex; struct mutex mutex;
unsigned disabled:1; /* P: mutex */ bool disabled; /* P: mutex */
#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE) #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
struct spi_message msg; struct spi_message msg;
...@@ -196,16 +194,6 @@ static void ad7879_report(struct ad7879 *ts) ...@@ -196,16 +194,6 @@ static void ad7879_report(struct ad7879 *ts)
} }
} }
static void ad7879_work(struct work_struct *work)
{
struct ad7879 *ts = container_of(work, struct ad7879, work);
/* use keventd context to read the result registers */
ad7879_collect(ts);
ad7879_report(ts);
mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
}
static void ad7879_ts_event_release(struct ad7879 *ts) static void ad7879_ts_event_release(struct ad7879 *ts)
{ {
struct input_dev *input_dev = ts->input; struct input_dev *input_dev = ts->input;
...@@ -225,13 +213,10 @@ static irqreturn_t ad7879_irq(int irq, void *handle) ...@@ -225,13 +213,10 @@ static irqreturn_t ad7879_irq(int irq, void *handle)
{ {
struct ad7879 *ts = handle; struct ad7879 *ts = handle;
/* The repeated conversion sequencer controlled by TMR kicked off too fast. ad7879_collect(ts);
* We ignore the last and process the sample sequence currently in the queue. ad7879_report(ts);
* It can't be older than 9.4ms
*/
if (!work_pending(&ts->work)) mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
schedule_work(&ts->work);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -249,11 +234,9 @@ static void ad7879_disable(struct ad7879 *ts) ...@@ -249,11 +234,9 @@ static void ad7879_disable(struct ad7879 *ts)
if (!ts->disabled) { if (!ts->disabled) {
ts->disabled = 1; ts->disabled = true;
disable_irq(ts->bus->irq); disable_irq(ts->bus->irq);
cancel_work_sync(&ts->work);
if (del_timer_sync(&ts->timer)) if (del_timer_sync(&ts->timer))
ad7879_ts_event_release(ts); ad7879_ts_event_release(ts);
...@@ -270,7 +253,7 @@ static void ad7879_enable(struct ad7879 *ts) ...@@ -270,7 +253,7 @@ static void ad7879_enable(struct ad7879 *ts)
if (ts->disabled) { if (ts->disabled) {
ad7879_setup(ts); ad7879_setup(ts);
ts->disabled = 0; ts->disabled = false;
enable_irq(ts->bus->irq); enable_irq(ts->bus->irq);
} }
...@@ -458,7 +441,6 @@ static int __devinit ad7879_construct(bus_device *bus, struct ad7879 *ts) ...@@ -458,7 +441,6 @@ static int __devinit ad7879_construct(bus_device *bus, struct ad7879 *ts)
ts->input = input_dev; ts->input = input_dev;
setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts); setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts);
INIT_WORK(&ts->work, ad7879_work);
mutex_init(&ts->mutex); mutex_init(&ts->mutex);
ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; ts->x_plate_ohms = pdata->x_plate_ohms ? : 400;
...@@ -526,9 +508,9 @@ static int __devinit ad7879_construct(bus_device *bus, struct ad7879 *ts) ...@@ -526,9 +508,9 @@ static int __devinit ad7879_construct(bus_device *bus, struct ad7879 *ts)
ad7879_setup(ts); ad7879_setup(ts);
err = request_irq(bus->irq, ad7879_irq, err = request_threaded_irq(bus->irq, NULL, ad7879_irq,
IRQF_TRIGGER_FALLING, bus->dev.driver->name, ts); IRQF_TRIGGER_FALLING,
bus->dev.driver->name, ts);
if (err) { if (err) {
dev_err(&bus->dev, "irq %d busy?\n", bus->irq); dev_err(&bus->dev, "irq %d busy?\n", bus->irq);
goto err_free_mem; goto err_free_mem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment