2 .\" Copyright (c) 2000 Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH PROP_OP 9E "Jul 8, 1996"
8 prop_op \- report driver property information
12 #include <sys/types.h>
14 #include <sys/sunddi.h>
18 \fBint prefix\fR\fBprop_op\fR(\fBdev_t\fR \fIdev\fR, \fBdev_info_t *\fR\fIdip\fR,
19 \fBddi_prop_op_t\fR \fIprop_op\fR, \fBint\fR \fIflags\fR, \fBchar *\fR\fIname\fR, \fBcaddr_t\fR \fIvaluep\fR,
20 \fBint *\fR\fIlengthp\fR);
26 Solaris DDI specific (Solaris DDI). This entry point is required, but it can be
27 \fBddi_prop_op\fR(9F).
35 Device number associated with this device.
44 A pointer to the device information structure for this device.
53 Property operator. Valid operators are:
60 Get property length only. (\fIvaluep\fR unaffected).
66 \fB\fBPROP_LEN_AND_VAL_BUF\fR\fR
69 Get length and value into caller's buffer. (\fIvaluep\fR used as input).
75 \fB\fBPROP_LEN_AND_VAL_ALLOC\fR\fR
78 Get length and value into allocated buffer. (\fIvaluep\fR returned as pointer
79 to pointer to allocated buffer).
90 The only possible flag value is:
94 \fB\fBDDI_PROP_DONTPASS\fR\fR
97 Do not pass request to parent if property not found.
108 Pointer to name of property to be interrogated.
117 If \fIprop_op\fR is \fBPROP_LEN_AND_VAL_BUF\fR, this should be a pointer to
118 the user's buffer. If \fIprop_op\fR is \fBPROP_LEN_AND_VAL_ALLOC\fR, this
119 should be the \fIaddress\fR of a pointer.
128 On exit, *\fIlengthp\fR will contain the property length. If \fIprop_op\fR is
129 \fBPROP_LEN_AND_VAL_BUF\fR then \fIlengthp\fR should point to an \fBint\fR that
130 contains the length of caller's buffer, before calling \fBprop_op()\fR.
136 \fBprop_op()\fR is an entry point which reports the values of certain
137 properties of the driver or device to the system. Each driver must have a
138 \fIprefix\fR \fBprop_op\fR entry point, but most drivers that do not need to
139 create or manage their own properties can use \fBddi_prop_op()\fR for this
140 entry point. Then the driver can use \fBddi_prop_update\fR(9F) to create
141 properties for its device.
145 \fBprop_op()\fR should return:
149 \fB\fBDDI_PROP_SUCCESS\fR \fR
152 Property found and returned.
158 \fB\fBDDI_PROP_NOT_FOUND\fR \fR
167 \fB\fBDDI_PROP_UNDEFINED\fR \fR
170 Prop explicitly undefined.
176 \fB\fBDDI_PROP_NO_MEMORY\fR \fR
179 Property found, but unable to allocate memory. \fIlengthp\fR has the correct
186 \fB\fBDDI_PROP_BUF_TOO_SMALL\fR \fR
189 Property found, but the supplied buffer is too small. \fIlengthp\fR has the
190 correct property length.
195 \fBExample 1 \fRUsing \fBprop_op()\fR to Report Property Information
198 In the following example, \fBprop_op()\fR intercepts requests for the
199 \fItemperature\fR property. The driver tracks changes to \fItemperature\fR
200 using a variable in the state structure in order to avoid frequent calls to
201 \fBddi_prop_update\fR(9F). The \fItemperature\fR property is only updated when
202 a request is made for this property. It then uses the system routine
203 \fBddi_prop_op\fR(9F) to process the property request. If the property request
204 is not specific to a device, the driver does not intercept the request. This is
205 indicated when the value of the \fIdev\fR parameter is equal to
211 int temperature; /* current device temperature */
216 xxprop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
217 int flags, char *name, caddr_t valuep, int *lengthp)
221 if (dev == DDI_DEV_T_ANY)
223 instance = getminor(dev);
224 xsp = ddi_get_soft_state(statep, instance);
226 return (DDI_PROP_NOT_FOUND);
227 if (strcmp(name, "temperature") == 0) {
228 ddi_prop_update_int(dev, dip,\e
229 "temperature", temperature);
233 return (ddi_prop_op(dev, dip, prop_op, flags,\e
234 name, valuep, lengthp));
242 \fBIntro\fR(9E), \fBddi_prop_op\fR(9F), \fBddi_prop_update\fR(9F)
245 \fIWriting Device Drivers\fR