19e86db79SHyon Kim /*
29e86db79SHyon Kim * CDDL HEADER START
39e86db79SHyon Kim *
49e86db79SHyon Kim * The contents of this file are subject to the terms of the
59e86db79SHyon Kim * Common Development and Distribution License (the "License").
69e86db79SHyon Kim * You may not use this file except in compliance with the License.
79e86db79SHyon Kim *
89e86db79SHyon Kim * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99e86db79SHyon Kim * or http://www.opensolaris.org/os/licensing.
109e86db79SHyon Kim * See the License for the specific language governing permissions
119e86db79SHyon Kim * and limitations under the License.
129e86db79SHyon Kim *
139e86db79SHyon Kim * When distributing Covered Code, include this CDDL HEADER in each
149e86db79SHyon Kim * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159e86db79SHyon Kim * If applicable, add the following below this CDDL HEADER, with the
169e86db79SHyon Kim * fields enclosed by brackets "[]" replaced with your own identifying
179e86db79SHyon Kim * information: Portions Copyright [yyyy] [name of copyright owner]
189e86db79SHyon Kim *
199e86db79SHyon Kim * CDDL HEADER END
209e86db79SHyon Kim */
219e86db79SHyon Kim
229e86db79SHyon Kim /*
239e86db79SHyon Kim * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
249e86db79SHyon Kim * Use is subject to license terms.
259e86db79SHyon Kim */
26*00f453f4SRob Johnston /*
27*00f453f4SRob Johnston * Copyright 2019 Joyent, Inc.
28*00f453f4SRob Johnston */
299e86db79SHyon Kim
309e86db79SHyon Kim #include "sun_sas.h"
319e86db79SHyon Kim
329e86db79SHyon Kim /*
339e86db79SHyon Kim * Returns the text string which describes this adapter and which is used to
349e86db79SHyon Kim * open the adapter with the library.
359e86db79SHyon Kim *
369e86db79SHyon Kim * Arguments:
37*00f453f4SRob Johnston * index the index to which adapter to retrieve the name
389e86db79SHyon Kim * name buffer to which the adapter name will be placed
399e86db79SHyon Kim */
40*00f453f4SRob Johnston HBA_STATUS
Sun_sasGetAdapterName(HBA_UINT32 index,char * name)41*00f453f4SRob Johnston Sun_sasGetAdapterName(HBA_UINT32 index, char *name)
42*00f453f4SRob Johnston {
439e86db79SHyon Kim const char ROUTINE[] = "Sun_sasGetAdapterName";
449e86db79SHyon Kim struct sun_sas_hba *hba_ptr;
459e86db79SHyon Kim
469e86db79SHyon Kim if (name == NULL) {
47*00f453f4SRob Johnston log(LOG_DEBUG, ROUTINE, "NULL adapter name");
48*00f453f4SRob Johnston return (HBA_STATUS_ERROR_ARG);
499e86db79SHyon Kim }
509e86db79SHyon Kim lock(&all_hbas_lock);
519e86db79SHyon Kim for (hba_ptr = global_hba_head; hba_ptr != NULL;
52*00f453f4SRob Johnston hba_ptr = hba_ptr->next) {
53*00f453f4SRob Johnston if (hba_ptr->index == index) {
54*00f453f4SRob Johnston if (hba_ptr->handle_name[0] == '\0') {
55*00f453f4SRob Johnston hba_ptr = NULL;
56*00f453f4SRob Johnston break;
57*00f453f4SRob Johnston }
58*00f453f4SRob Johnston /*
59*00f453f4SRob Johnston * Flaw in the spec! How do we know the size of name?
60*00f453f4SRob Johnston */
61*00f453f4SRob Johnston (void) strlcpy(name, hba_ptr->handle_name,
62*00f453f4SRob Johnston strlen(hba_ptr->handle_name)+1);
639e86db79SHyon Kim break;
64*00f453f4SRob Johnston }
659e86db79SHyon Kim }
669e86db79SHyon Kim unlock(&all_hbas_lock);
679e86db79SHyon Kim if (hba_ptr == NULL) {
68*00f453f4SRob Johnston log(LOG_DEBUG, ROUTINE,
69*00f453f4SRob Johnston "Unable to find adapter index %d.", index);
70*00f453f4SRob Johnston return (HBA_STATUS_ERROR_ILLEGAL_INDEX);
719e86db79SHyon Kim }
729e86db79SHyon Kim
739e86db79SHyon Kim return (HBA_STATUS_OK);
749e86db79SHyon Kim }
75