2 .\" Copyright (c) 2003, 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 DDI_DEV_IS_NEEDED 9F "Dec 7, 2003"
8 ddi_dev_is_needed \- inform the system that a device's component is required
13 #include <sys/sunddi.h>
17 \fBint\fR \fBddi_dev_is_needed\fR(\fBdev_info_t *\fR\fIdip\fR, \fBint\fR \fIcomponent\fR, \fBint\fR \fIlevel\fR);
23 Solaris DDI specific (Solaris DDI)
31 Pointer to the device's \fBdev_info\fR structure.
40 Component of the driver which is needed.
49 Power level at which the component is needed.
55 The \fBddi_dev_is_needed()\fR function is obsolete and will be removed in a
56 future release. It is recommended that device drivers use
57 \fBpm_raise_power\fR(9F) and \fBpm_lower_power\fR(9F).
60 The \fBddi_dev_is_needed()\fR function informs the system that a device
61 component is needed at the specified power level. The \fIlevel\fR argument must
65 This function sets a \fIcomponent\fR to the required level and sets all devices
66 which depend on this to their normal power levels.
69 The state of the device should be examined before each physical access. The
70 \fBddi_dev_is_needed()\fR function should be called to set a \fIcomponent\fR to
71 the required power level if the operation to be performed requires the
72 component to be at a power level other than its current level.
75 The \fBddi_dev_is_needed()\fR function might cause re-entry of the driver.
76 Deadlock may result if driver locks are held across the call to
77 \fBddi_dev_is_needed()\fR.
81 The \fBddi_dev_is_needed()\fR function returns:
85 \fB\fBDDI_SUCCESS\fR\fR
88 Power successfully set to the requested level.
94 \fB\fBDDI_FAILURE\fR\fR
102 \fBExample 1 \fRdisk driver code
105 A hypothetical disk driver might include this code:
111 xxdisk_spun_down(struct xxstate *xsp)
113 return (xsp->power_level[DISK_COMPONENT] < POWER_SPUN_UP);
116 xxdisk_strategy(struct buf *bp)
121 mutex_enter(&xxstate_lock);
123 * Since we have to drop the mutex, we have to do this in a loop
124 * in case we get preempted and the device gets taken away from
127 while (device_spun_down(sp)) {
128 mutex_exit(&xxstate_lock);
129 if (ddi_dev_is_needed(xsp->mydip,
130 XXDISK_COMPONENT, XXPOWER_SPUN_UP) != DDI_SUCCESS) {
135 mutex_enter(&xxstate_lock);
138 mutex_exit(&xxstate_lock);
149 This function can be called from user or kernel context.
153 See \fBattributes\fR(5) for descriptions of the following attributes:
161 ATTRIBUTE TYPE ATTRIBUTE VALUE
163 Interface Stability Obsolete
169 \fBpm\fR(7D), \fBpm-components\fR(9P), \fBattach\fR(9E), \fBdetach\fR(9E),
170 \fBpower\fR(9E), \fBpm_busy_component\fR(9F), \fBpm_idle_component\fR(9F)
173 \fIWriting Device Drivers\fR