1*9e86db79SHyon Kim /* 2*9e86db79SHyon Kim * CDDL HEADER START 3*9e86db79SHyon Kim * 4*9e86db79SHyon Kim * The contents of this file are subject to the terms of the 5*9e86db79SHyon Kim * Common Development and Distribution License (the "License"). 6*9e86db79SHyon Kim * You may not use this file except in compliance with the License. 7*9e86db79SHyon Kim * 8*9e86db79SHyon Kim * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*9e86db79SHyon Kim * or http://www.opensolaris.org/os/licensing. 10*9e86db79SHyon Kim * See the License for the specific language governing permissions 11*9e86db79SHyon Kim * and limitations under the License. 12*9e86db79SHyon Kim * 13*9e86db79SHyon Kim * When distributing Covered Code, include this CDDL HEADER in each 14*9e86db79SHyon Kim * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*9e86db79SHyon Kim * If applicable, add the following below this CDDL HEADER, with the 16*9e86db79SHyon Kim * fields enclosed by brackets "[]" replaced with your own identifying 17*9e86db79SHyon Kim * information: Portions Copyright [yyyy] [name of copyright owner] 18*9e86db79SHyon Kim * 19*9e86db79SHyon Kim * CDDL HEADER END 20*9e86db79SHyon Kim */ 21*9e86db79SHyon Kim 22*9e86db79SHyon Kim /* 23*9e86db79SHyon Kim * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24*9e86db79SHyon Kim * Use is subject to license terms. 25*9e86db79SHyon Kim */ 26*9e86db79SHyon Kim 27*9e86db79SHyon Kim #include "sun_sas.h" 28*9e86db79SHyon Kim 29*9e86db79SHyon Kim /* 30*9e86db79SHyon Kim * Returns the text string which describes this adapter and which is used to 31*9e86db79SHyon Kim * open the adapter with the library. 32*9e86db79SHyon Kim * 33*9e86db79SHyon Kim * Arguments: 34*9e86db79SHyon Kim * index the index to which adapter to retrive the name 35*9e86db79SHyon Kim * name buffer to which the adapter name will be placed 36*9e86db79SHyon Kim */ 37*9e86db79SHyon Kim HBA_STATUS Sun_sasGetAdapterName(HBA_UINT32 index, char *name) { 38*9e86db79SHyon Kim const char ROUTINE[] = "Sun_sasGetAdapterName"; 39*9e86db79SHyon Kim struct sun_sas_hba *hba_ptr; 40*9e86db79SHyon Kim 41*9e86db79SHyon Kim if (name == NULL) { 42*9e86db79SHyon Kim log(LOG_DEBUG, ROUTINE, "NULL adapter name"); 43*9e86db79SHyon Kim return (HBA_STATUS_ERROR_ARG); 44*9e86db79SHyon Kim } 45*9e86db79SHyon Kim lock(&all_hbas_lock); 46*9e86db79SHyon Kim for (hba_ptr = global_hba_head; hba_ptr != NULL; 47*9e86db79SHyon Kim hba_ptr = hba_ptr->next) { 48*9e86db79SHyon Kim if (hba_ptr->index == index) { 49*9e86db79SHyon Kim if (hba_ptr->handle_name == NULL) { 50*9e86db79SHyon Kim hba_ptr = NULL; 51*9e86db79SHyon Kim break; 52*9e86db79SHyon Kim } 53*9e86db79SHyon Kim /* Flaw in the spec! How do we know the size of name? */ 54*9e86db79SHyon Kim (void) strlcpy(name, hba_ptr->handle_name, 55*9e86db79SHyon Kim strlen(hba_ptr->handle_name)+1); 56*9e86db79SHyon Kim break; 57*9e86db79SHyon Kim } 58*9e86db79SHyon Kim } 59*9e86db79SHyon Kim unlock(&all_hbas_lock); 60*9e86db79SHyon Kim if (hba_ptr == NULL) { 61*9e86db79SHyon Kim log(LOG_DEBUG, ROUTINE, 62*9e86db79SHyon Kim "Unable to find adapter index %d.", index); 63*9e86db79SHyon Kim return (HBA_STATUS_ERROR_ILLEGAL_INDEX); 64*9e86db79SHyon Kim } 65*9e86db79SHyon Kim 66*9e86db79SHyon Kim return (HBA_STATUS_OK); 67*9e86db79SHyon Kim } 68