logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

DEV_MODULE — device driver module declaration macro

Authors

       This manual page was written by Alexander Langer <alex@FreeBSD.org>.

Debian                                          January 19, 2012                                   DEV_MODULE(9)

Description

       The  DEV_MODULE() macro declares a device driver kernel module.  It fills in a moduledata_t structure and
       then calls DECLARE_MODULE() with the correct args, where name is the name of the module and evh (with its
       argument arg) is the event handler for the module (refer to DECLARE_MODULE(9) for more information).  The
       event handler is supposed to create the device with make_dev() on load and  to  destroy  it  when  it  is
       unloaded using destroy_dev().

Examples

       #include <sys/module.h>
       #include <sys/conf.h>

       static struct cdevsw foo_devsw = { ... };

       static struct cdev *sdev;

       static int
       foo_load(module_t mod, int cmd, void *arg)
       {
           int err = 0;

           switch (cmd) {
           case MOD_LOAD:
               sdev = make_dev(&foo_devsw, 0, UID_ROOT, GID_WHEEL, 0600, "foo");
               break;          /* Success*/

           case MOD_UNLOAD:
           case MOD_SHUTDOWN:
               destroy_dev(sdev);
               break;          /* Success*/

           default:
               err = EINVAL;
               break;
           }

           return(err);
       }

       DEV_MODULE(foo, foo_load, NULL);

Name

       DEV_MODULE — device driver module declaration macro

See Also

DECLARE_MODULE(9), destroy_dev(9), make_dev(9), module(9)

Synopsis

#include<sys/param.h>#include<sys/kernel.h>#include<sys/module.h>#include<sys/conf.h>DEV_MODULE(name, modeventhand_tevh, void*arg);

See Also