summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/iio_simple_dummy_events.c
diff options
context:
space:
mode:
authorDaniel Baluta <daniel.baluta@intel.com>2014-11-10 14:45:29 +0200
committerJonathan Cameron <jic23@kernel.org>2014-11-22 11:05:44 +0000
commit356ae946f9945997213b19279bc2e84bb61cc26a (patch)
treebb833bd9115524bc59d4a69424cd4ae8913d5c8f /drivers/staging/iio/iio_simple_dummy_events.c
parentd7d787d29148cde12958c2e3765ad3a55dc55eaf (diff)
iio: dummy: Add virtual registers for dummy device
We need a way to store events generated by iio_dummy_evgen module, in order to correctly process IRQs in iio_simple_dummy_events. For the moment, we add two registers: * id_reg - ID register, stores the source of the event * id_data - DATA register, stores the type of the event e.g echo 4 > /sys/bus/iio/devices/iio_evgen/poke2 id_reg 0x02, id_data 0x04 This means, event of type 4 was generated by fake device 2. We currently use a hardcoded mapping of virtual events to IIO events. Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/staging/iio/iio_simple_dummy_events.c')
-rw-r--r--drivers/staging/iio/iio_simple_dummy_events.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/staging/iio/iio_simple_dummy_events.c b/drivers/staging/iio/iio_simple_dummy_events.c
index 64b45b077549..719dfa5ae7df 100644
--- a/drivers/staging/iio/iio_simple_dummy_events.c
+++ b/drivers/staging/iio/iio_simple_dummy_events.c
@@ -148,12 +148,23 @@ int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,
static irqreturn_t iio_simple_dummy_event_handler(int irq, void *private)
{
struct iio_dev *indio_dev = private;
+ struct iio_dummy_state *st = iio_priv(indio_dev);
+
+ dev_dbg(&indio_dev->dev, "id %x event %x\n",
+ st->regs->reg_id, st->regs->reg_data);
+
+ switch (st->regs->reg_data) {
+ case 0:
+ iio_push_event(indio_dev,
+ IIO_EVENT_CODE(IIO_VOLTAGE, 0, 0,
+ IIO_EV_DIR_RISING,
+ IIO_EV_TYPE_THRESH, 0, 0, 0),
+ iio_get_time_ns());
+ break;
+ default:
+ break;
+ }
- iio_push_event(indio_dev,
- IIO_EVENT_CODE(IIO_VOLTAGE, 0, 0,
- IIO_EV_DIR_RISING,
- IIO_EV_TYPE_THRESH, 0, 0, 0),
- iio_get_time_ns());
return IRQ_HANDLED;
}
@@ -179,6 +190,8 @@ int iio_simple_dummy_events_register(struct iio_dev *indio_dev)
ret = st->event_irq;
goto error_ret;
}
+ st->regs = iio_dummy_evgen_get_regs(st->event_irq);
+
ret = request_threaded_irq(st->event_irq,
NULL,
&iio_simple_dummy_event_handler,