Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Aug 1997 17:44:48 -0700 (PDT)
From:      Pat Bozeman <peb@george.lbl.gov>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   lkm.h MOD_DEV & DISPATCH
Message-ID:  <Pine.SOL.3.95.970825173548.22258E-100000@george.lbl.gov>
In-Reply-To: <199708252325.AAA14034@awfulhak.org>

next in thread | previous in thread | raw e-mail | index | archive | help

Why does MOD_DEV concatinate the name of the device with _module when
none of the other module types do?  This leads to a conflict with DISPATCH
which does not expect the name to be concatinated to _module.

Here is the relevant code.  The static struct lkm_* is the part I am
talking about, notice the differnce in the naming of the lkm_* structure.

#define MOD_DEV(name,devtype,devslot,devp)      \
        MOD_DECL(name);                         \
        static struct lkm_dev name ## _module = { \   
                LM_DEV,                         \
                LKM_VERSION,                    \
                #name ## "_mod",                \
                devslot,                        \
                devtype,                        \
                (void *)devp                    \
        }

#define MOD_EXEC(name,execslot,execsw)          \
        MOD_DECL(name);                         \
        static struct lkm_exec _module = {      \
                LM_EXEC,                        \
                LKM_VERSION,                    \
                #name ## "_mod",                \
                execslot,                       \
                execsw                          \
        } 

MOD_DEV and DISPATCH do not get along because dispatch just uses 
_module on fisrt line of the 'case LKM_E_LOAD' block.  

#define DISPATCH(lkmtp,cmd,ver,load,unload,stat)                        \
        if (ver != LKM_VERSION)                                         \
                return EINVAL;  /* version mismatch */                  \
        switch (cmd) {                                                  \
        int     error;                                                  \
        case LKM_E_LOAD:                                                \
                lkmtp->private.lkm_any = (struct lkm_any *)&_module;    \
                if (lkmexists(lkmtp)) /* !!! */                         \
                        return EEXIST;                                  \
                if ((error = load(lkmtp, cmd)))                         \
                        return error;                                   \
                break;                

(rest of macro cut)

Is there a reason that this is like this?


--
Patrick Bozeman
PBozeman@lbl.gov




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SOL.3.95.970825173548.22258E-100000>