4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
32 * the handle is removed from the open_handles list
35 Sun_sasCloseAdapter(HBA_HANDLE handle
)
37 const char ROUTINE
[] = "Sun_sasCloseAdapter";
38 struct open_handle
*open_handle_ptr
, *open_handle_prev_ptr
;
41 if (global_hba_head
== NULL
) {
42 log(LOG_DEBUG
, ROUTINE
,
43 "Attempted to close an invalid handle %08lx. "
44 "There are no hba handles loaded in the VSL.",
49 /* Removing handle from open_handles; */
50 lock(&open_handles_lock
);
51 if (global_hba_head
->open_handles
== NULL
) {
52 /* check to see if there are any open global_hba_head */
53 log(LOG_DEBUG
, ROUTINE
,
54 "Attempted to close an invalid handle %08lx. "
55 "There are no open handles in the VSL.",
57 } else if (global_hba_head
->open_handles
->next
== NULL
) {
58 /* there is only one handle open */
59 if (global_hba_head
->open_handles
->handle
== handle
) {
60 free(global_hba_head
->open_handles
);
61 global_hba_head
->open_handles
= NULL
;
63 log(LOG_DEBUG
, ROUTINE
,
64 "Attempted to close an invalid handle %08lx. "
65 "Unable to find handle to close.", handle
);
67 } else { /* there is more than one handle open */
68 open_handle_ptr
= global_hba_head
->open_handles
;
69 if (open_handle_ptr
->handle
== handle
) {
70 global_hba_head
->open_handles
= open_handle_ptr
->next
;
71 free(open_handle_ptr
);
73 for (open_handle_ptr
= open_handle_ptr
->next
,
74 open_handle_prev_ptr
=
75 global_hba_head
->open_handles
;
76 open_handle_ptr
!= NULL
;
77 open_handle_ptr
= open_handle_ptr
->next
) {
78 if (open_handle_ptr
->handle
== handle
) {
79 open_handle_prev_ptr
->next
=
80 open_handle_ptr
->next
;
81 free(open_handle_ptr
);
85 open_handle_prev_ptr
=
86 open_handle_prev_ptr
->next
;
90 log(LOG_DEBUG
, ROUTINE
,
91 "Attempted to close an invalid handle "
92 "%08lx. Unable to find handle to close.",
98 unlock(&open_handles_lock
);