mutex.9: Misc updates and minor improvements.
[dragonfly.git] / share / man / man9 / sensor_attach.9
1 .\" $OpenBSD: sensor_attach.9,v 1.4 2007/03/22 16:55:31 deraadt Exp $
2 .\" $DragonFly: src/share/man/man9/sensor_attach.9,v 1.4 2008/07/09 17:50:44 thomas Exp $
3 .\"
4 .\" Copyright (c) 2006 Michael Knudsen <mk@openbsd.org>
5 .\" Copyright (c) 2006 Constantine A. Murenin <cnst+openbsd@bugmail.mojo.ru>
6 .\" All rights reserved.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\"
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\" 2. The name of the author may not be used to endorse or promote products
15 .\"    derived from this software without specific prior written permission.
16 .\"
17 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 .\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19 .\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20 .\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 .\" EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 .\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 .\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 .\"
28 .Dd August 19, 2007
29 .Dt SENSOR_ATTACH 9
30 .Os
31 .Sh NAME
32 .Nm sensor_attach ,
33 .Nm sensor_detach ,
34 .Nm sensordev_install ,
35 .Nm sensordev_deinstall ,
36 .Nm sensor_task_register ,
37 .Nm sensor_task_unregister
38 .Nd sensors framework
39 .Sh SYNOPSIS
40 .In sys/time.h
41 .In sys/sensors.h
42 .Ft void
43 .Fn "sensordev_install" "struct ksensordev *sensdev"
44 .Ft void
45 .Fn "sensordev_deinstall" "struct ksensordev *sensdev"
46 .Ft void
47 .Fn "sensor_attach" "struct ksensordev *sensdev" "struct ksensor *sens"
48 .Ft void
49 .Fn "sensor_detach" "struct ksensordev *sensdev" "struct ksensor *sens"
50 .Ft int
51 .Fn "sensor_task_register" "void *arg" "void (*func)(void *)" "int period"
52 .Ft void
53 .Fn "sensor_task_unregister" "void *arg"
54 .Sh DESCRIPTION
55 The
56 sensors
57 framework API provides a mechanism for manipulation of hardware sensors
58 that are available under the
59 .Va hw.sensors
60 .Xr sysctl 8
61 tree.
62 .Pp
63 The
64 .Fn sensor_attach
65 function adds the sensor specified by the
66 .Fa sens
67 argument to the sensor device specified by the
68 .Fa sensdev
69 argument.
70 The
71 .Fn sensor_detach
72 function can be used to remove sensors previously added by
73 .Fn sensor_attach .
74 .Pp
75 The
76 .Fn sensordev_install
77 function registers the sensor device specified by the
78 .Fa sensdev
79 argument so that all sensors that are attached to the device become
80 accessible via the sysctl interface.
81 The
82 .Fn sensordev_deinstall
83 function can be used to remove sensor devices previously registered by
84 .Fn sensordev_install .
85 .Pp
86 Drivers are responsible for retrieving, interpreting and normalising
87 sensor values and updating the sensor struct periodically.
88 If the driver needs process context, for example to sleep, it can
89 register a task with the sensor framework.
90 .Pp
91 The
92 .Fn sensor_task_register
93 function is used to register a periodic task to update sensors.
94 The
95 .Fa func
96 argument is a pointer to the function to run with an interval of
97 .Fa period
98 seconds.
99 The
100 .Fa arg
101 parameter is the argument given to the
102 .Fa func
103 function.
104 The
105 .Fn sensor_task_unregister
106 function removes all tasks previously registered with
107 .Fn sensor_task_register
108 with an argument of
109 .Fa arg .
110 .Sh COMPATIBILITY
111 .Ss sensor_task
112 The
113 .Fn sensor_task_register
114 and
115 .Fn sensor_task_unregister
116 functions that are included in
117 .Ox 4.2
118 and later
119 are not compatible with
120 .Dx .
121 .Dx
122 includes an implementation that is similar and compatible
123 with an earlier version of
124 these
125 .Fn sensor_task
126 functions that was available from
127 .Ox 3.9
128 until
129 .Ox 4.1 .
130 .Pp
131 Drivers that only call
132 .Fn sensor_task_register
133 and do not check its return value are not affected by this
134 .Fn sensor_task
135 compatibility notice.
136 .Sh SEE ALSO
137 .Xr systat 1 ,
138 .Xr sysctl 3 ,
139 .Xr sensorsd 8 ,
140 .Xr sysctl 8
141 .Sh HISTORY
142 The sensor framework was written by
143 .An Alexander Yurchenko Aq grange@openbsd.org
144 and first appeared in
145 .Ox 3.4 .
146 .An David Gwynne Aq dlg@openbsd.org
147 later extended it for
148 .Ox 3.8 .
149 .An Constantine A. Murenin Aq cnst+openbsd@bugmail.mojo.ru
150 extended it even further by introducing the concept of sensor devices in
151 .Ox 4.1 .
152 .Pp
153 The framework was ported to
154 .Fx
155 by
156 .An Constantine A. Murenin
157 as a Google Summer of Code 2007 project.