/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Adam Hamsik.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code Must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.42 2021/08/21 22:23:33 andvar Exp $");
/*
* Try to autoload target module if it was not found in current
* target list.
*/
dm_target_t *
dm_target_autoload(const char *dm_target_name)
{
char name[30];
unsigned int gen;
dm_target_t *dmt;
if (strncmp(dm_target_name, dm_target->name, slen) == 0)
return dm_target;
}
return NULL;
}
/*
* Insert new target struct into the TAIL.
* dm_target
* contains name, version, function pointer to specific target functions.
*/
int
dm_target_insert(dm_target_t *dm_target)
{
dm_target_t *dmt;
/* Sanity check for any missing function */
if (dm_target->init == NULL) {
printf("%s missing init\n", dm_target->name);
return EINVAL;
}
if (dm_target->strategy == NULL) {
printf("%s missing strategy\n", dm_target->name);
return EINVAL;
}
if (dm_target->destroy == NULL) {
printf("%s missing destroy\n", dm_target->name);
return EINVAL;
}
#if 0
if (dm_target->upcall == NULL) {
printf("%s missing upcall\n", dm_target->name);
return EINVAL;
}
#endif
/*
* Destroy all targets and remove them from queue.
* This routine is called from dm_detach, before module
* is unloaded.
*/
int
dm_target_destroy(void)
{
dm_target_t *dm_target;