tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: MODULE_CLASS_DRIVER and locators stuff



On Sat, 03 May 2008 22:30:38 +0900 (JST)
Masao Uebayashi <uebayasi%gmail.com@localhost> wrote:

> I think you can call the module_driver_load equivalent function from
> mi_modcmd() passing those (*_cd, *_cai, *_cf) arguments.

Based on this suggestion I modified the code. Now the module's code
passes them to module_driver_load/unload:
                                        
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/device.h>

extern const struct cfiattrdata audiobuscf_iattrdata;

static int locs[] = { -1, -1 };
static const struct cfiattrdata * const attrs[] = {
        &audiobuscf_iattrdata, NULL
};

DRIVER_MODULE(MODULE_CLASS_DRIVER, auich, pci, locs, attrs, NULL);

static int
auich_modcmd(modcmd_t cmd, void *arg)
{
        int error = 0;

        switch (cmd) {
        case MODULE_CMD_INIT:
                error = module_driver_load(auich_cfdrivers,
                    auich_cfattachinit, auich_cfdata);
                break;
        case MODULE_CMD_FINI:
                error = module_driver_unload(auich_cfdrivers,
                    auich_cfattachinit, auich_cfdata);
                break;
        default:
                return ENOTTY;
        }

        return error;
}

http://www.netbsd.org/~xtraeme/kmodule_drivers2.diff

-- 
Juan Romero Pardines - xtraeme at gmail|netbsd dot org
        The NetBSD Project

Make your own NetBSD/x86 Live CD:
http://www.netbsd.org/~xtraeme/mklivecd/


Home | Main Index | Thread Index | Old Index