Managing and Developing Dynamically Loadable Kernel Modules

Managing and Developing Dynamically Loadable Kernel Modules
Developing Dynamically Loadable Kernel Modules
Chapter 12 545
Example 12-7 WSIO Interface Driver Loading and Initialization Coding
static wsio_drv_info_t
module_name
_wsio_info = { ... };
static int (*
module_name
_saved_attach)();
int
module_name
_load(void *arg)
{
/* Use the drv_info passed to us instead of the static
* version */
wsio_info.drv_info = (drv_info_t *) arg;
/* Register the driver with WSIO */
if (!wsio_install_driver(&wsio_info))
return ENXIO; /* install failed! */
/* Add the attach function to the DLKM attach list. */
mod_wsio_attach_list_add(MOD_WSIO_CORE,
&
module_name
_core_attach);
/* Register the device probe. */
wsio_register_dev_probe(IF_CLASS, probe_func,
"
probe_name
");
/* The following step is only required for dynamically
* loaded modules: attach the probe function to the
* drv_info structure */
wsio_activate_probe("
probe_name
", wsio_info.drv_info);
return 0;
}
int
module_name
_install(void)
{
/* Add the attach function to the list. */
extern init (*core_attach)();
module_name
_saved_attach=
core_attach;
core_attach=
module_name
_attach_linked;
/* Register the device probe. */
wsio_register_dev_probe(IF_CLASS, probe_func,
"
probe_name
");
/* Register the driver with WSIO */