summaryrefslogtreecommitdiffstats
path: root/share/man/man9/sensor_attach.9
blob: dea8d4fa341acf7cb5ef1dd74a1262a9e9e1df3f (plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
.\"	$OpenBSD: sensor_attach.9,v 1.4 2007/03/22 16:55:31 deraadt Exp $
.\"
.\" Copyright (c) 2006 Michael Knudsen <mk@openbsd.org>
.\" Copyright (c) 2006 Constantine A. Murenin <cnst+openbsd@bugmail.mojo.ru>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. The name of the author may not be used to endorse or promote products
.\"    derived from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
.\" EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd August 19, 2007
.Dt SENSOR_ATTACH 9
.Os
.Sh NAME
.Nm sensor_attach ,
.Nm sensor_detach ,
.Nm sensordev_install ,
.Nm sensordev_deinstall ,
.Nm sensor_task_register ,
.Nm sensor_task_unregister
.Nd sensors framework
.Sh SYNOPSIS
.In sys/sensors.h
.Ft void
.Fn "sensordev_install" "struct ksensordev *sensdev"
.Ft void
.Fn "sensordev_deinstall" "struct ksensordev *sensdev"
.Ft void
.Fn "sensor_attach" "struct ksensordev *sensdev" "struct ksensor *sens"
.Ft void
.Fn "sensor_detach" "struct ksensordev *sensdev" "struct ksensor *sens"
.Ft int
.Fn "sensor_task_register" "void *arg" "void (*func)(void *)" "int period"
.Ft void
.Fn "sensor_task_unregister" "void *arg"
.Sh DESCRIPTION
The
sensors
framework API provides a mechanism for manipulation of hardware sensors
that are available under the
.Va hw.sensors
.Xr sysctl 8
tree.
.Pp
The
.Fn sensor_attach
function
adds the sensor specified by the
.Fa sens
argument to the sensor device specified by the
.Fa sensdev
argument.
The
.Fn sensor_detach
function
can be used to remove sensors previously added by
.Fn sensor_attach .
.Pp
The
.Fn sensordev_install
function
registers the sensor device specified by the
.Fa sensdev
argument so that all sensors that are attached to the device become
accessible via the sysctl interface.
The
.Fn sensordev_deinstall
function
can be used to remove sensor devices previously registered by
.Fn sensordev_install .
.Pp
Drivers are responsible for retrieving, interpreting and normalising
sensor values and updating the sensor struct periodically.
If the driver needs process context, for example to sleep, it can
register a task with the sensor framework.
.Pp
The
.Fn sensor_task_register
function
is used to register a periodic task to update sensors.
The
.Fa func
argument is a pointer to the function to run with an interval of
.Fa period
seconds.
The
.Fa arg
parameter is the argument given to the
.Fa func
function.
The
.Fn sensor_task_unregister
function
removes all tasks previously registered with
.Fn sensor_task_register
with an argument of
.Fa arg .
.Sh COMPATIBILITY
.Ss sensor_task
The
.Fn sensor_task_register
and
.Fn sensor_task_unregister
functions that are included in
.Ox 4.2
and later
are not compatible with
.Fx .
.Fx
includes an implementation that is similar and compatible
with an earlier version of
these
.Fn sensor_task
functions that was available from
.Ox 3.9
until
.Ox 4.1 .
.Pp
Drivers that only call
.Fn sensor_task_register
and do not check its return value are not affected by this
.Fn sensor_task
compatibility notice.
.Sh SEE ALSO
.Xr systat 1 ,
.Xr sysctl 3 ,
.Xr sensorsd 8 ,
.Xr sysctl 8
.Sh HISTORY
.An -nosplit
The sensor framework was written by
.An Alexander Yurchenko Aq grange@openbsd.org
and first appeared in
.Ox 3.4 .
.An David Gwynne Aq dlg@openbsd.org
later extended it for
.Ox 3.8 .
.An Constantine A. Murenin Aq cnst+openbsd@bugmail.mojo.ru
extended it even further by introducing the concept of sensor devices in
.Ox 4.1 .
.Pp
The framework was ported to
.Fx
by
.An Constantine A. Murenin Aq cnst@FreeBSD.org
as a Google Summer of Code 2007 project,
and first appeared in
.Fx 8.0 .
OpenPOWER on IntegriCloud