Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
drivers
staging
iio
imu
adis16400_trigger.c
Go to the documentation of this file.
1
#include <
linux/interrupt.h
>
2
#include <linux/kernel.h>
3
#include <
linux/spi/spi.h
>
4
#include <linux/export.h>
5
6
#include <
linux/iio/iio.h
>
7
#include <
linux/iio/trigger.h
>
8
#include "
adis16400.h
"
9
13
static
int
adis16400_data_rdy_trigger_set_state(
struct
iio_trigger
*trig,
14
bool
state
)
15
{
16
struct
iio_dev
*indio_dev = trig->
private_data
;
17
18
dev_dbg
(&indio_dev->
dev
,
"%s (%d)\n"
, __func__, state);
19
return
adis16400_set_irq
(indio_dev, state);
20
}
21
22
static
const
struct
iio_trigger_ops
adis16400_trigger_ops = {
23
.owner =
THIS_MODULE
,
24
.set_trigger_state = &adis16400_data_rdy_trigger_set_state,
25
};
26
27
int
adis16400_probe_trigger
(
struct
iio_dev
*indio_dev)
28
{
29
int
ret
;
30
struct
adis16400_state
*
st
= iio_priv(indio_dev);
31
32
st->
trig
=
iio_trigger_alloc
(
"%s-dev%d"
,
33
indio_dev->
name
,
34
indio_dev->
id
);
35
if
(st->
trig
==
NULL
) {
36
ret = -
ENOMEM
;
37
goto
error_ret;
38
}
39
40
ret =
request_irq
(st->
us
->irq,
41
&
iio_trigger_generic_data_rdy_poll
,
42
IRQF_TRIGGER_RISING
,
43
"adis16400"
,
44
st->
trig
);
45
if
(ret)
46
goto
error_free_trig;
47
st->
trig
->dev.parent = &st->
us
->dev;
48
st->
trig
->private_data = indio_dev;
49
st->
trig
->ops = &adis16400_trigger_ops;
50
ret =
iio_trigger_register
(st->
trig
);
51
52
/* select default trigger */
53
indio_dev->
trig
= st->
trig
;
54
if
(ret)
55
goto
error_free_irq;
56
57
return
0;
58
59
error_free_irq:
60
free_irq
(st->
us
->irq, st->
trig
);
61
error_free_trig:
62
iio_trigger_free
(st->
trig
);
63
error_ret:
64
return
ret
;
65
}
66
67
void
adis16400_remove_trigger
(
struct
iio_dev
*indio_dev)
68
{
69
struct
adis16400_state
*
st
= iio_priv(indio_dev);
70
71
iio_trigger_unregister
(st->
trig
);
72
free_irq
(st->
us
->irq, st->
trig
);
73
iio_trigger_free
(st->
trig
);
74
}
Generated on Thu Jan 10 2013 14:28:47 for Linux Kernel by
1.8.2