Copyright (c) 1995, Sun Microsystems, Inc.
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.
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.
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]
#include <sys/ddi.h> #include <sys/sunddi.h> int ddi_prop_exists(dev_t match_dev, dev_info_t *dip, uint_t flags, char *name);
Device number associated with property or DDI_DEV_T_ANY.
Pointer to the device info node of device whose property list should be searched.
Possible flag values are some combination of: DDI_PROP_DONTPASS
Do not pass request to parent device information node if the property is not found.
Do not look at PROM properties (ignored on platforms that do not support PROM properties).
String containing the name of the property.
Properties are searched for based on the dip, name, and match_dev. The property search order is as follows:
1. Search software properties created by the driver.
2. Search the software properties created by the system (or nexus nodes in the device info tree).
3. Search the driver global properties list.
4. If DDI_PROP_NOTPROM is not set, search the PROM properties (if they exist).
5. If DDI_PROP_DONTPASS is not set, pass this request to the parent device information node.
6. Return 0 if not found and 1 if found.
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_exists() will match the request regardless of the match_dev the property was created with. That is the first property whose name matches name will be returned. 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 following example demonstrates the use of ddi_prop_exists().
/* * Enable "whizzy" mode if the "whizzy-mode" property exists */ if (ddi_prop_exists(xx_dev, xx_dip, DDI_PROP_NOTPROM, "whizzy-mode") == 1) { xx_enable_whizzy_mode(xx_dip); } else { xx_disable_whizzy_mode(xx_dip); }
Writing Device Drivers