|DDI_PROP_GET_INT(9F)||Kernel Functions for Drivers||DDI_PROP_GET_INT(9F)|
#include <sys/ddi.h> #include <sys/sunddi.h> int ddi_prop_get_int(dev_t match_dev, dev_info_t *dip, uint_t flags, char *name, int defvalue);
int64_t ddi_prop_get_int64(dev_t match_dev, dev_info_t *dip, uint_t flags, char *name, int64_t defvalue);
Properties are searched for based on the dip, name, match_dev, and the type of the data (integer). The property search order is as follows:
Usually, the match_dev argument should be set to the actual device number that this property is associated with. However, if the match_dev argument is DDI_DEV_T_ANY, then ddi_prop_get_int() and ddi_prop_get_int() will match the request regardless of the match_dev the property was created with. If a property was created with match_dev set to DDI_DEV_T_NONE, then the only way to look up this property is with a match_dev set to DDI_DEV_T_ANY. PROM properties are always created with match_dev set to DDI_DEV_T_NONE.
name must always be set to the name of the property being looked up.
The return value of the routine is the value of the property. If the property is not found, the argument defvalue is returned as the value of the property.
ddi_prop_get_int64() will not search the PROM for 64-bit property values.
The following example demonstrates the use of ddi_prop_get_int().
/* * Get the value of the integer "width" property, using * our own default if no such property exists */ width = ddi_prop_get_int(xx_dev, xx_dip, 0, "width", XX_DEFAULT_WIDTH);
Writing Device Drivers
|August 25, 2001||OmniOS|