PROP_OP(9E) | Driver Entry Points | PROP_OP(9E) |
prop_op - report driver property information
#include <sys/types.h> #include <sys/ddi.h> #include <sys/sunddi.h> int prefixprop_op(dev_t dev, dev_info_t *dip,
ddi_prop_op_t prop_op, int flags, char *name, caddr_t valuep,
int *lengthp);
illumos DDI specific (illumos DDI). This entry point is required, but it can be ddi_prop_op(9F).
dev
dip
prop_op
PROP_LEN
PROP_LEN_AND_VAL_BUF
PROP_LEN_AND_VAL_ALLOC
flags
DDI_PROP_DONTPASS
name
valuep
lengthp
prop_op() is an entry point which reports the values of certain properties of the driver or device to the system. Each driver must have a prefix prop_op entry point, but most drivers that do not need to create or manage their own properties can use ddi_prop_op() for this entry point. Then the driver can use ddi_prop_update(9F) to create properties for its device.
prop_op() should return:
DDI_PROP_SUCCESS
DDI_PROP_NOT_FOUND
DDI_PROP_UNDEFINED
DDI_PROP_NO_MEMORY
DDI_PROP_BUF_TOO_SMALL
Example 1 Using prop_op() to Report Property Information
In the following example, prop_op() intercepts requests for the temperature property. The driver tracks changes to temperature using a variable in the state structure in order to avoid frequent calls to ddi_prop_update(9F). The temperature property is only updated when a request is made for this property. It then uses the system routine ddi_prop_op(9F) to process the property request. If the property request is not specific to a device, the driver does not intercept the request. This is indicated when the value of the dev parameter is equal to DDI_DEV_T_ANY.
int temperature; /* current device temperature */
.
.
. static int xxprop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
int flags, char *name, caddr_t valuep, int *lengthp) { int instance; struct xxstate *xsp;
if (dev == DDI_DEV_T_ANY) goto skip;
instance = getminor(dev);
xsp = ddi_get_soft_state(statep, instance);
if (xsp == NULL) return (DDI_PROP_NOT_FOUND);
if (strcmp(name, "temperature") == 0) { ddi_prop_update_int(dev, dip,\
"temperature", temperature);
} /* other cases... */
skip:
return (ddi_prop_op(dev, dip, prop_op, flags,\
name, valuep, lengthp)); }
Intro(9E), ddi_prop_op(9F), ddi_prop_update(9F)
Writing Device Drivers
July 8, 1996 | OmniOS |