diff options
Diffstat (limited to 'drivers/staging/iio/accel/adis16209_trigger.c')
-rw-r--r-- | drivers/staging/iio/accel/adis16209_trigger.c | 77 |
1 files changed, 19 insertions, 58 deletions
diff --git a/drivers/staging/iio/accel/adis16209_trigger.c b/drivers/staging/iio/accel/adis16209_trigger.c index d2980dc..211ee70 100644 --- a/drivers/staging/iio/accel/adis16209_trigger.c +++ b/drivers/staging/iio/accel/adis16209_trigger.c @@ -15,32 +15,12 @@ /** * adis16209_data_rdy_trig_poll() the event handler for the data rdy trig **/ -static int adis16209_data_rdy_trig_poll(struct iio_dev *dev_info, - int index, - s64 timestamp, - int no_test) +static irqreturn_t adis16209_data_rdy_trig_poll(int irq, void *trig) { - struct adis16209_state *st = iio_dev_get_devdata(dev_info); - struct iio_trigger *trig = st->trig; - - iio_trigger_poll(trig, timestamp); - + iio_trigger_poll(trig, iio_get_time_ns()); return IRQ_HANDLED; } -IIO_EVENT_SH(data_rdy_trig, &adis16209_data_rdy_trig_poll); - -static IIO_TRIGGER_NAME_ATTR; - -static struct attribute *adis16209_trigger_attrs[] = { - &dev_attr_name.attr, - NULL, -}; - -static const struct attribute_group adis16209_trigger_attr_group = { - .attrs = adis16209_trigger_attrs, -}; - /** * adis16209_data_rdy_trigger_set_state() set datardy interrupt state **/ @@ -49,31 +29,9 @@ static int adis16209_data_rdy_trigger_set_state(struct iio_trigger *trig, { struct adis16209_state *st = trig->private_data; struct iio_dev *indio_dev = st->indio_dev; - int ret = 0; dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state); - ret = adis16209_set_irq(&st->indio_dev->dev, state); - if (state == false) { - iio_remove_event_from_list(&iio_event_data_rdy_trig, - &indio_dev->interrupts[0] - ->ev_list); - flush_scheduled_work(); - } else { - iio_add_event_to_list(&iio_event_data_rdy_trig, - &indio_dev->interrupts[0]->ev_list); - } - return ret; -} - -/** - * adis16209_trig_try_reen() try renabling irq for data rdy trigger - * @trig: the datardy trigger - **/ -static int adis16209_trig_try_reen(struct iio_trigger *trig) -{ - struct adis16209_state *st = trig->private_data; - enable_irq(st->us->irq); - return 0; + return adis16209_set_irq(st->indio_dev, state); } int adis16209_probe_trigger(struct iio_dev *indio_dev) @@ -81,34 +39,37 @@ int adis16209_probe_trigger(struct iio_dev *indio_dev) int ret; struct adis16209_state *st = indio_dev->dev_data; - st->trig = iio_allocate_trigger(); - st->trig->name = kasprintf(GFP_KERNEL, - "adis16209-dev%d", - indio_dev->id); - if (!st->trig->name) { + st->trig = iio_allocate_trigger("adis16209-dev%d", indio_dev->id); + if (st->trig == NULL) { ret = -ENOMEM; - goto error_free_trig; + goto error_ret; } + + ret = request_irq(st->us->irq, + adis16209_data_rdy_trig_poll, + IRQF_TRIGGER_RISING, + "adis16209", + st->trig); + if (ret) + goto error_free_trig; st->trig->dev.parent = &st->us->dev; st->trig->owner = THIS_MODULE; st->trig->private_data = st; st->trig->set_trigger_state = &adis16209_data_rdy_trigger_set_state; - st->trig->try_reenable = &adis16209_trig_try_reen; - st->trig->control_attrs = &adis16209_trigger_attr_group; ret = iio_trigger_register(st->trig); /* select default trigger */ indio_dev->trig = st->trig; if (ret) - goto error_free_trig_name; + goto error_free_irq; return 0; -error_free_trig_name: - kfree(st->trig->name); +error_free_irq: + free_irq(st->us->irq, st->trig); error_free_trig: iio_free_trigger(st->trig); - +error_ret: return ret; } @@ -117,6 +78,6 @@ void adis16209_remove_trigger(struct iio_dev *indio_dev) struct adis16209_state *state = indio_dev->dev_data; iio_trigger_unregister(state->trig); - kfree(state->trig->name); + free_irq(state->us->irq, state->trig); iio_free_trigger(state->trig); } |