1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
* Copyright (C) 2012 Invensense, Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/err.h>
#include <linux/delay.h>
#include <linux/sysfs.h>
#include <linux/jiffies.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/kfifo.h>
#include <linux/poll.h>
#include <linux/miscdevice.h>
#include <linux/spinlock.h>
#include "iio.h"
#include "sysfs.h"
#include "trigger.h"
#include "inv_mpu_iio.h"
/*
* inv_mpu_data_rdy_trigger_set_state() set data ready interrupt state
*/
static int inv_mpu_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool state)
{
return 0;
}
static const struct iio_trigger_ops inv_mpu_trigger_ops = {
.owner = THIS_MODULE,
.set_trigger_state = &inv_mpu_data_rdy_trigger_set_state,
};
int inv_mpu_probe_trigger(struct iio_dev *indio_dev)
{
int ret;
struct inv_mpu_state *st = iio_priv(indio_dev);
#ifdef CONFIG_INV_KERNEL_3_10
st->trig = iio_trigger_alloc("%s-dev%d",
#else
st->trig = iio_allocate_trigger("%s-dev%d",
#endif
indio_dev->name,
indio_dev->id);
if (st->trig == NULL)
return -ENOMEM;
st->trig->dev.parent = &st->client->dev;
#ifndef CONFIG_INV_KERNEL_3_10
st->trig->private_data = indio_dev;
#endif
st->trig->ops = &inv_mpu_trigger_ops;
ret = iio_trigger_register(st->trig);
if (ret) {
#ifdef CONFIG_INV_KERNEL_3_10
iio_trigger_free(st->trig);
#else
iio_free_trigger(st->trig);
#endif
return -EPERM;
}
indio_dev->trig = st->trig;
return 0;
}
void inv_mpu_remove_trigger(struct iio_dev *indio_dev)
{
struct inv_mpu_state *st = iio_priv(indio_dev);
iio_trigger_unregister(st->trig);
#ifdef CONFIG_INV_KERNEL_3_10
iio_trigger_free(st->trig);
#else
iio_free_trigger(st->trig);
#endif
}
|