mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-13 22:25:03 +00:00
59c85e82c2
As the majority of triggers don't actually have any other control_attrs lets use the fact that struct device has a groups element when we do need to have these attributes registered. A vargs function is used to cut down on lots of building strings in every single driver just in order to pass them into the allocate. Also iio_allocate_trigger_named -> iio_allocate_trigger as there is no unamed version any more, so that is now just confusing. Blackfin tested and fixed by Michael Hennerich. V2: Elements from Michael Hennerich's patches for the ade7758 Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
75 lines
1.7 KiB
C
75 lines
1.7 KiB
C
#include <linux/interrupt.h>
|
|
#include <linux/irq.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/device.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/sysfs.h>
|
|
#include <linux/list.h>
|
|
#include <linux/spi/spi.h>
|
|
|
|
#include "../iio.h"
|
|
#include "../sysfs.h"
|
|
#include "../trigger.h"
|
|
#include "adis16204.h"
|
|
|
|
/**
|
|
* adis16204_data_rdy_trigger_set_state() set datardy interrupt state
|
|
**/
|
|
static int adis16204_data_rdy_trigger_set_state(struct iio_trigger *trig,
|
|
bool state)
|
|
{
|
|
struct adis16204_state *st = trig->private_data;
|
|
struct iio_dev *indio_dev = st->indio_dev;
|
|
|
|
dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
|
|
return adis16204_set_irq(st->indio_dev, state);
|
|
}
|
|
|
|
int adis16204_probe_trigger(struct iio_dev *indio_dev)
|
|
{
|
|
int ret;
|
|
struct adis16204_state *st = indio_dev->dev_data;
|
|
|
|
st->trig = iio_allocate_trigger("adis16204-dev%d", indio_dev->id);
|
|
if (st->trig == NULL) {
|
|
ret = -ENOMEM;
|
|
goto error_ret;
|
|
}
|
|
|
|
ret = request_irq(st->us->irq,
|
|
&iio_trigger_generic_data_rdy_poll,
|
|
IRQF_TRIGGER_RISING,
|
|
"adis16204",
|
|
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 = &adis16204_data_rdy_trigger_set_state;
|
|
ret = iio_trigger_register(st->trig);
|
|
|
|
/* select default trigger */
|
|
indio_dev->trig = st->trig;
|
|
if (ret)
|
|
goto error_free_irq;
|
|
|
|
return 0;
|
|
|
|
error_free_irq:
|
|
free_irq(st->us->irq, st->trig);
|
|
error_free_trig:
|
|
iio_free_trigger(st->trig);
|
|
error_ret:
|
|
return ret;
|
|
}
|
|
|
|
void adis16204_remove_trigger(struct iio_dev *indio_dev)
|
|
{
|
|
struct adis16204_state *state = indio_dev->dev_data;
|
|
|
|
iio_trigger_unregister(state->trig);
|
|
free_irq(state->us->irq, state->trig);
|
|
iio_free_trigger(state->trig);
|
|
}
|