Re: Calling module functions from the kernel proper

David Woodhouse (dwmw2@infradead.org)
Tue, 08 Aug 2000 14:55:24 +0100


baettig@scs.ch said:
> > What is the best way to go about calling a kernel module's function(s)
> > from within the kernel itself?

> Sorry, I did not get it.

> What should happen if the kernel wants to call a function of your
> module and the module is not loaded yet???

int do_myroutine()
{
int (*myroutine_ptr)(void) = NULL;
int ret;

myroutine_ptr = get_module_symbol("", "myroutine");

if (!myroutine_ptr) {
request_module("mymodule");
myroutine_ptr = get_module_symbol("", "myroutine");
}

if (!myroutine_ptr)
return -EINVAL;

ret = (*myroutine_ptr)();

put_module_symbol(myroutine_ptr);

return ret;
}

--
dwmw2

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/