summaryrefslogtreecommitdiff
path: root/usr/src/lib/sun_sas/common/Sun_sasFreeLibrary.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/sun_sas/common/Sun_sasFreeLibrary.c')
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasFreeLibrary.c84
1 files changed, 44 insertions, 40 deletions
diff --git a/usr/src/lib/sun_sas/common/Sun_sasFreeLibrary.c b/usr/src/lib/sun_sas/common/Sun_sasFreeLibrary.c
index caffe52de1..b30e975fe1 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasFreeLibrary.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasFreeLibrary.c
@@ -23,7 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
@@ -31,8 +33,10 @@
* Frees the HBA Library. Must be called after all HBA library functions
* to free all resources
*/
-HBA_STATUS Sun_sasFreeLibrary() {
- HBA_STATUS status;
+HBA_STATUS
+Sun_sasFreeLibrary(void)
+{
+ HBA_STATUS status;
lock(&all_hbas_lock);
@@ -58,7 +62,9 @@ HBA_STATUS Sun_sasFreeLibrary() {
/*
* Internal routine to free up hba_ptr's (and all sub-structures)
*/
-HBA_STATUS FreeHBA(struct sun_sas_hba *hba) {
+HBA_STATUS
+FreeHBA(struct sun_sas_hba *hba)
+{
struct sun_sas_hba *hba_ptr = NULL;
struct sun_sas_hba *last_hba_ptr = NULL;
struct sun_sas_port *hba_port = NULL;
@@ -74,57 +80,55 @@ HBA_STATUS FreeHBA(struct sun_sas_hba *hba) {
last_hba_ptr = NULL;
/* walk through global_hba_head list freeing each handle */
- for (hba_ptr = hba;
- hba_ptr != NULL;
- hba_ptr = hba_ptr->next) {
+ for (hba_ptr = hba; hba_ptr != NULL; hba_ptr = hba_ptr->next) {
/* Free the nested structures (port and attached port) */
hba_port = hba_ptr->first_port;
while (hba_port != NULL) {
- /* Free discovered port structure list. */
- tgt_port = hba_port->first_attached_port;
- while (tgt_port != NULL) {
- /* Free target mapping data list first. */
- scsi_info = tgt_port->scsiInfo;
- while (scsi_info != NULL) {
- last_scsi_info = scsi_info;
- scsi_info = scsi_info->next;
- free(last_scsi_info);
- }
- last_tgt_port = tgt_port;
- tgt_port = tgt_port->next;
- free(last_tgt_port->port_attributes.\
+ /* Free discovered port structure list. */
+ tgt_port = hba_port->first_attached_port;
+ while (tgt_port != NULL) {
+ /* Free target mapping data list first. */
+ scsi_info = tgt_port->scsiInfo;
+ while (scsi_info != NULL) {
+ last_scsi_info = scsi_info;
+ scsi_info = scsi_info->next;
+ free(last_scsi_info);
+ }
+ last_tgt_port = tgt_port;
+ tgt_port = tgt_port->next;
+ free(last_tgt_port->port_attributes.\
+ PortSpecificAttribute.SASPort);
+ free(last_tgt_port);
+ }
+
+ phy_ptr = hba_port->first_phy;
+ while (phy_ptr != NULL) {
+ last_phy = phy_ptr;
+ phy_ptr = phy_ptr->next;
+ free(last_phy);
+ }
+
+ last_hba_port = hba_port;
+ hba_port = hba_port->next;
+ free(last_hba_port->port_attributes.\
PortSpecificAttribute.SASPort);
- free(last_tgt_port);
- }
-
- phy_ptr = hba_port->first_phy;
- while (phy_ptr != NULL) {
- last_phy = phy_ptr;
- phy_ptr = phy_ptr->next;
- free(last_phy);
- }
-
- last_hba_port = hba_port;
- hba_port = hba_port->next;
- free(last_hba_port->port_attributes.\
- PortSpecificAttribute.SASPort);
- free(last_hba_port);
+ free(last_hba_port);
}
open_handle = hba_ptr->open_handles;
while (open_handle != NULL) {
- last_open_handle = open_handle;
- open_handle = open_handle->next;
- free(last_open_handle);
+ last_open_handle = open_handle;
+ open_handle = open_handle->next;
+ free(last_open_handle);
}
/* Free up the top level HBA structure from the last spin */
if (last_hba_ptr != NULL) {
- free(last_hba_ptr);
+ free(last_hba_ptr);
}
last_hba_ptr = hba_ptr;
}
if (last_hba_ptr != NULL) {
- free(last_hba_ptr);
+ free(last_hba_ptr);
}
return (HBA_STATUS_OK);