1*10652SHyon.Kim@Sun.COM /*
2*10652SHyon.Kim@Sun.COM * CDDL HEADER START
3*10652SHyon.Kim@Sun.COM *
4*10652SHyon.Kim@Sun.COM * The contents of this file are subject to the terms of the
5*10652SHyon.Kim@Sun.COM * Common Development and Distribution License (the "License").
6*10652SHyon.Kim@Sun.COM * You may not use this file except in compliance with the License.
7*10652SHyon.Kim@Sun.COM *
8*10652SHyon.Kim@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*10652SHyon.Kim@Sun.COM * or http://www.opensolaris.org/os/licensing.
10*10652SHyon.Kim@Sun.COM * See the License for the specific language governing permissions
11*10652SHyon.Kim@Sun.COM * and limitations under the License.
12*10652SHyon.Kim@Sun.COM *
13*10652SHyon.Kim@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*10652SHyon.Kim@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*10652SHyon.Kim@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
16*10652SHyon.Kim@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
17*10652SHyon.Kim@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
18*10652SHyon.Kim@Sun.COM *
19*10652SHyon.Kim@Sun.COM * CDDL HEADER END
20*10652SHyon.Kim@Sun.COM */
21*10652SHyon.Kim@Sun.COM
22*10652SHyon.Kim@Sun.COM /*
23*10652SHyon.Kim@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24*10652SHyon.Kim@Sun.COM * Use is subject to license terms.
25*10652SHyon.Kim@Sun.COM */
26*10652SHyon.Kim@Sun.COM
27*10652SHyon.Kim@Sun.COM #include <sun_sas.h>
28*10652SHyon.Kim@Sun.COM
29*10652SHyon.Kim@Sun.COM /*
30*10652SHyon.Kim@Sun.COM * Opens a named adapter.
31*10652SHyon.Kim@Sun.COM * By opening an adapter, an upper level application is ensuring that all access
32*10652SHyon.Kim@Sun.COM * to an HBA_HANDLE between and open and a close is to the same adapter.
33*10652SHyon.Kim@Sun.COM *
34*10652SHyon.Kim@Sun.COM * Sun_sasOpenAdapter just creates a new handle and returns the handle.
35*10652SHyon.Kim@Sun.COM * It does not do a driver open
36*10652SHyon.Kim@Sun.COM */
Sun_sasOpenAdapter(char * name)37*10652SHyon.Kim@Sun.COM HBA_HANDLE Sun_sasOpenAdapter(char *name) {
38*10652SHyon.Kim@Sun.COM const char ROUTINE[] = "Sun_sasOpenAdapter";
39*10652SHyon.Kim@Sun.COM struct sun_sas_hba *hba_ptr;
40*10652SHyon.Kim@Sun.COM
41*10652SHyon.Kim@Sun.COM if (name == NULL) {
42*10652SHyon.Kim@Sun.COM log(LOG_DEBUG, ROUTINE, "NULL adapter name.");
43*10652SHyon.Kim@Sun.COM return (HANDLE_ERROR);
44*10652SHyon.Kim@Sun.COM }
45*10652SHyon.Kim@Sun.COM lock(&all_hbas_lock);
46*10652SHyon.Kim@Sun.COM for (hba_ptr = global_hba_head; hba_ptr != NULL;
47*10652SHyon.Kim@Sun.COM hba_ptr = hba_ptr->next) {
48*10652SHyon.Kim@Sun.COM if (strcmp(hba_ptr->handle_name, name) == 0) {
49*10652SHyon.Kim@Sun.COM break;
50*10652SHyon.Kim@Sun.COM }
51*10652SHyon.Kim@Sun.COM }
52*10652SHyon.Kim@Sun.COM unlock(&all_hbas_lock);
53*10652SHyon.Kim@Sun.COM if (hba_ptr == NULL) {
54*10652SHyon.Kim@Sun.COM log(LOG_DEBUG, ROUTINE, "Invalid adapter name \"%s\"", name);
55*10652SHyon.Kim@Sun.COM return (HANDLE_ERROR);
56*10652SHyon.Kim@Sun.COM }
57*10652SHyon.Kim@Sun.COM
58*10652SHyon.Kim@Sun.COM return (CreateHandle(hba_ptr->index));
59*10652SHyon.Kim@Sun.COM }
60