te
Copyright (c) 2006 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]
DDI_GET_INSTANCE 9F "Jan 16, 2006"
NAME
ddi_get_instance - get device instance number
SYNOPSIS
#include <sys/ddi.h>
#include <sys/sunddi.h>



int ddi_get_instance(dev_info_t *dip);
INTERFACE LEVEL
illumos DDI specific (illumos DDI).
PARAMETERS
dip

Pointer to dev_info structure.

DESCRIPTION
The ddi_get_instance() function returns the instance number of the device corresponding to dip.

The system assigns an instance number to every device. Instance numbers for devices attached to the same driver are unique. This provides a way for the system and the driver to uniquely identify one or more devices of the same type. The instance number is derived by the system from different properties for different device types in an implementation specific manner.

Once an instance number has been assigned to a device, it will remain the same even across reconfigurations and reboots. Therefore, instance numbers seen by a driver may not appear to be in consecutive order. For example, if device foo0 has been assigned an instance number of 0 and device foo1 has been assigned an instance number of 1, if foo0 is removed, foo1 will continue to be associated with instance number 1 (even though foo1 is now the only device of its type on the system).

RETURN VALUES
The ddi_get_instance() function returns the instance number of the device corresponding to dip.
CONTEXT
The ddi_get_instance() function can be called from user, interrupt, or kernel context.
SEE ALSO
path_to_inst (5)

Writing Device Drivers