dm_table.c revision 1.1.2.7 1 1.1.2.7 haad /* $NetBSD: dm_table.c,v 1.1.2.7 2008/08/19 13:30:36 haad Exp $ */
2 1.1.2.7 haad
3 1.1.2.1 haad /*
4 1.1.2.1 haad * Copyright (c) 1996, 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
5 1.1.2.1 haad * All rights reserved.
6 1.1.2.1 haad *
7 1.1.2.1 haad * This code is derived from software contributed to The NetBSD Foundation
8 1.1.2.1 haad * by Adam Hamsik.
9 1.1.2.1 haad *
10 1.1.2.1 haad * Redistribution and use in source and binary forms, with or without
11 1.1.2.1 haad * modification, are permitted provided that the following conditions
12 1.1.2.1 haad * are met:
13 1.1.2.1 haad * 1. Redistributions of source code must retain the above copyright
14 1.1.2.1 haad * notice, this list of conditions and the following disclaimer.
15 1.1.2.1 haad * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.2.1 haad * notice, this list of conditions and the following disclaimer in the
17 1.1.2.1 haad * documentation and/or other materials provided with the distribution.
18 1.1.2.1 haad *
19 1.1.2.1 haad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1.2.1 haad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1.2.1 haad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1.2.1 haad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1.2.1 haad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1.2.1 haad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1.2.1 haad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1.2.1 haad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1.2.1 haad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1.2.1 haad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1.2.1 haad * POSSIBILITY OF SUCH DAMAGE.
30 1.1.2.1 haad */
31 1.1.2.1 haad
32 1.1.2.1 haad #include <sys/types.h>
33 1.1.2.1 haad #include <sys/param.h>
34 1.1.2.1 haad
35 1.1.2.1 haad #include <sys/errno.h>
36 1.1.2.1 haad #include <sys/kmem.h>
37 1.1.2.1 haad
38 1.1.2.1 haad #include "dm.h"
39 1.1.2.1 haad
40 1.1.2.5 haad /*
41 1.1.2.5 haad * Destroy all table data. This function should be called with held
42 1.1.2.5 haad * dev_mtx.
43 1.1.2.5 haad */
44 1.1.2.5 haad
45 1.1.2.1 haad int
46 1.1.2.1 haad dm_table_destroy(struct dm_table *head)
47 1.1.2.1 haad {
48 1.1.2.1 haad struct dm_table_entry *table_en;
49 1.1.2.1 haad
50 1.1.2.6 haad while (!SLIST_EMPTY(head)) { /* List Deletion. */
51 1.1.2.1 haad
52 1.1.2.6 haad table_en = SLIST_FIRST(head);
53 1.1.2.1 haad
54 1.1.2.6 haad /*
55 1.1.2.6 haad * Remove target specific config data. After successfull
56 1.1.2.6 haad * call table_en->target_config must be set to NULL.
57 1.1.2.6 haad */
58 1.1.2.6 haad table_en->target->destroy(table_en);
59 1.1.2.1 haad
60 1.1.2.1 haad
61 1.1.2.6 haad SLIST_REMOVE_HEAD(head, next);
62 1.1.2.6 haad
63 1.1.2.2 haad kmem_free(table_en, sizeof(*table_en));
64 1.1.2.1 haad }
65 1.1.2.1 haad
66 1.1.2.1 haad return 0;
67 1.1.2.1 haad }
68