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
iio
common
hid-sensors
hid-sensor-trigger.c
Go to the documentation of this file.
1
/*
2
* HID Sensors Driver
3
* Copyright (c) 2012, Intel Corporation.
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License along with
15
* this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17
*
18
*/
19
#include <linux/device.h>
20
#include <
linux/platform_device.h
>
21
#include <linux/module.h>
22
#include <
linux/interrupt.h
>
23
#include <
linux/irq.h
>
24
#include <linux/slab.h>
25
#include <
linux/hid-sensor-hub.h
>
26
#include <
linux/iio/iio.h
>
27
#include <
linux/iio/trigger.h
>
28
#include <
linux/iio/sysfs.h
>
29
#include "
hid-sensor-attributes.h
"
30
#include "
hid-sensor-trigger.h
"
31
32
static
int
hid_sensor_data_rdy_trigger_set_state(
struct
iio_trigger
*trig,
33
bool
state
)
34
{
35
struct
hid_sensor_iio_common
*
st
= trig->
private_data
;
36
int
state_val;
37
38
state_val = state ? 1 : 0;
39
#if (defined CONFIG_HID_SENSOR_ENUM_BASE_QUIRKS) || \
40
(defined CONFIG_HID_SENSOR_ENUM_BASE_QUIRKS_MODULE)
41
++state_val;
42
#endif
43
st->
data_ready
=
state
;
44
sensor_hub_set_feature
(st->
hsdev
, st->
power_state
.report_id,
45
st->
power_state
.index,
46
(
s32
)state_val);
47
48
sensor_hub_set_feature
(st->
hsdev
, st->
report_state
.report_id,
49
st->
report_state
.index,
50
(
s32
)state_val);
51
52
return
0;
53
}
54
55
void
hid_sensor_remove_trigger
(
struct
iio_dev
*indio_dev)
56
{
57
iio_trigger_unregister
(indio_dev->
trig
);
58
iio_trigger_free
(indio_dev->
trig
);
59
indio_dev->
trig
=
NULL
;
60
}
61
EXPORT_SYMBOL
(
hid_sensor_remove_trigger
);
62
63
static
const
struct
iio_trigger_ops
hid_sensor_trigger_ops = {
64
.owner =
THIS_MODULE
,
65
.set_trigger_state = &hid_sensor_data_rdy_trigger_set_state,
66
};
67
68
int
hid_sensor_setup_trigger
(
struct
iio_dev
*indio_dev,
const
char
*
name
,
69
struct
hid_sensor_iio_common
*attrb)
70
{
71
int
ret
;
72
struct
iio_trigger
*trig;
73
74
trig =
iio_trigger_alloc
(
"%s-dev%d"
, name, indio_dev->
id
);
75
if
(trig ==
NULL
) {
76
dev_err
(&indio_dev->
dev
,
"Trigger Allocate Failed\n"
);
77
ret = -
ENOMEM
;
78
goto
error_ret;
79
}
80
81
trig->
dev
.parent = indio_dev->
dev
.parent;
82
trig->
private_data
= attrb;
83
trig->
ops
= &hid_sensor_trigger_ops;
84
ret =
iio_trigger_register
(trig);
85
86
if
(ret) {
87
dev_err
(&indio_dev->
dev
,
"Trigger Register Failed\n"
);
88
goto
error_free_trig;
89
}
90
indio_dev->
trig
= trig;
91
92
return
ret
;
93
94
error_free_trig:
95
iio_trigger_free
(trig);
96
error_ret:
97
return
ret
;
98
}
99
EXPORT_SYMBOL
(
hid_sensor_setup_trigger
);
100
101
MODULE_AUTHOR
(
"Srinivas Pandruvada <
[email protected]
>"
);
102
MODULE_DESCRIPTION
(
"HID Sensor trigger processing"
);
103
MODULE_LICENSE
(
"GPL"
);
Generated on Thu Jan 10 2013 13:36:35 for Linux Kernel by
1.8.2