| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: dm_target.c,v 1.15 2010/12/23 14:58:13 mlelstv Exp $ */ | | 1 | /* $NetBSD: dm_target.c,v 1.16 2011/08/27 17:06:08 ahoka Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Adam Hamsik. | | 8 | * by Adam Hamsik. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code Must retain the above copyright | | 13 | * 1. Redistributions of source code Must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -140,26 +140,36 @@ dm_target_lookup_name(const char *dm_tar | | | @@ -140,26 +140,36 @@ dm_target_lookup_name(const char *dm_tar |
140 | | | 140 | |
141 | return NULL; | | 141 | return NULL; |
142 | } | | 142 | } |
143 | /* | | 143 | /* |
144 | * Insert new target struct into the TAIL. | | 144 | * Insert new target struct into the TAIL. |
145 | * dm_target | | 145 | * dm_target |
146 | * contains name, version, function pointer to specifif target functions. | | 146 | * contains name, version, function pointer to specifif target functions. |
147 | */ | | 147 | */ |
148 | int | | 148 | int |
149 | dm_target_insert(dm_target_t * dm_target) | | 149 | dm_target_insert(dm_target_t * dm_target) |
150 | { | | 150 | { |
151 | dm_target_t *dmt; | | 151 | dm_target_t *dmt; |
152 | | | 152 | |
| | | 153 | /* Sanity check for any missing function */ |
| | | 154 | KASSERT(dmt->init != NULL); |
| | | 155 | KASSERT(dmt->status != NULL); |
| | | 156 | KASSERT(dmt->strategy != NULL); |
| | | 157 | KASSERT(dmt->deps != NULL); |
| | | 158 | KASSERT(dmt->destroy != NULL); |
| | | 159 | KASSERT(dmt->upcall != NULL); |
| | | 160 | KASSERT(dmt->sync != NULL); |
| | | 161 | KASSERT(dmt->secsize != NULL); |
| | | 162 | |
153 | mutex_enter(&dm_target_mutex); | | 163 | mutex_enter(&dm_target_mutex); |
154 | | | 164 | |
155 | dmt = dm_target_lookup_name(dm_target->name); | | 165 | dmt = dm_target_lookup_name(dm_target->name); |
156 | if (dmt != NULL) { | | 166 | if (dmt != NULL) { |
157 | mutex_exit(&dm_target_mutex); | | 167 | mutex_exit(&dm_target_mutex); |
158 | return EEXIST; | | 168 | return EEXIST; |
159 | } | | 169 | } |
160 | TAILQ_INSERT_TAIL(&dm_target_list, dm_target, dm_target_next); | | 170 | TAILQ_INSERT_TAIL(&dm_target_list, dm_target, dm_target_next); |
161 | | | 171 | |
162 | mutex_exit(&dm_target_mutex); | | 172 | mutex_exit(&dm_target_mutex); |
163 | | | 173 | |
164 | return 0; | | 174 | return 0; |
165 | } | | 175 | } |