dapl_pz_free.c revision 9517:b4839b0aa7a4
1/* 2 * CDDL HEADER START 3 * 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. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved. 24 */ 25 26/* 27 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 28 * Use is subject to license terms. 29 */ 30 31/* 32 * 33 * MODULE: dapl_pz_create.c 34 * 35 * PURPOSE: Memory management 36 * Description: Interfaces in this file are completely described in 37 * the DAPL 1.1 API, Chapter 6, section 6 38 * 39 * $Id: dapl_pz_free.c,v 1.9 2003/07/30 18:13:40 hobie16 Exp $ 40 */ 41 42#include "dapl.h" 43#include "dapl_pz_util.h" 44#include "dapl_adapter_util.h" 45#include "dapl_ia_util.h" 46 47/* 48 * dapl_pz_free 49 * 50 * DAPL Requirements Version xxx, 6.6.2.1 51 * 52 * Remove an instance of a protection zone 53 * 54 * Input: 55 * pz_handle 56 * 57 * Output: 58 * None. 59 * 60 * Returns: 61 * DAT_SUCCESS 62 * DAT_INVALID_PARAMETER 63 * DAT_INVALID_STATE 64 */ 65DAT_RETURN 66dapl_pz_free( 67 IN DAT_PZ_HANDLE pz_handle) 68{ 69 DAPL_PZ *pz; 70 DAT_RETURN dat_status; 71 72 dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_pz_free(%p)\n", pz_handle); 73 74 dat_status = DAT_SUCCESS; 75 if (DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) { 76 dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 77 DAT_INVALID_HANDLE_PZ); 78 goto bail; 79 } 80 81 pz = (DAPL_PZ *)pz_handle; 82 83 if (0 != pz->pz_ref_count) { 84 dat_status = DAT_ERROR(DAT_INVALID_STATE, 85 DAT_INVALID_STATE_PZ_IN_USE); 86 goto bail; 87 } 88 89 dat_status = dapls_ib_pd_free(pz); 90 91 if (dat_status == DAT_SUCCESS) { 92 dapl_pz_dealloc(pz); 93 } 94 95bail: 96 return (dat_status); 97} 98