define lkm_nofunc, to be used instead of nosys (blech!) for unused load,

unload, and stat functions.  arguably could (should?) use NULL instead,
but this is a bit more descriptive.  also, unconditionally call the
load/unload/stat functions, as now they're known to work (because, at
worst, they're lkm_nofunc).
This commit is contained in:
cgd 1994-12-24 13:25:48 +00:00
parent 0332985c6c
commit da93322976
2 changed files with 23 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_lkm.c,v 1.21 1994/10/30 21:47:41 cgd Exp $ */
/* $NetBSD: kern_lkm.c,v 1.22 1994/12/24 13:25:48 cgd Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
@ -463,6 +463,19 @@ lkmenodev(dev, oflags, devtype, p)
return (enodev());
}
/*
* A placeholder function for load/unload/stat calls; simply returns zero.
* Used where people don't wnat tp specify a special function.
*/
int
lkm_nofunc(lkmtp, cmd)
struct lkm_table *lkmtp;
int cmd;
{
return (0);
}
int
lkmexists(lkmtp)
struct lkm_table *lkmtp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lkm.h,v 1.9 1994/10/07 14:20:11 mycroft Exp $ */
/* $NetBSD: lkm.h,v 1.10 1994/12/24 13:26:06 cgd Exp $ */
/*
* Header file used by loadable kernel modules and loadable kernel module
@ -241,16 +241,17 @@ struct lkm_table {
};
extern int nosys();
extern int lkm_nofunc __P((struct lkm_table *lkmtp, int cmd));
/*
* DISPATCH -- body function for use in module entry point function;
* generally, the function body will consist entirely of a single
* DISPATCH line.
*
* If load/unload/stat are not "nosys", then they are called on each
* corresponding entry instance. "cmd" is passed to each function so
* that a single function can be used if desired.
* If load/unload/stat are called on each corresponding entry instance.
* If no function is desired for load/stat/unload, lkm_nofunc() should
* be specified. "cmd" is passed to each function so that a single
* function can be used if desired.
*/
#define DISPATCH(lkmtp,cmd,ver,load,unload,stat) \
if (ver != LKM_VERSION) \
@ -259,15 +260,15 @@ extern int nosys();
int error; \
case LKM_E_LOAD: \
lkmtp->private.lkm_any = (struct lkm_any *)&_module; \
if (load != nosys && (error = load(lkmtp, cmd))) \
if (error = load(lkmtp, cmd)) \
return error; \
break; \
case LKM_E_UNLOAD: \
if (unload != nosys && (error = unload(lkmtp, cmd))) \
if (error = unload(lkmtp, cmd)) \
return error; \
break; \
case LKM_E_STAT: \
if (stat != nosys && (error = stat(lkmtp, cmd))) \
if (error = stat(lkmtp, cmd)) \
return error; \
break; \
} \