On Tue, 11 Jan 2000, Tigran Aivazian wrote:
> Hi guys,
>
> Here is the idea:
>
> Instead of current way of switching request_module() depending on
> CONFIG_KMOD inside <linux/kmod.h> and having each driver contain a block
> of code like this (see e.g. fs/block_device.c:get_blkfops())
>
>
> #ifdef CONFIG_KMOD
> if (!blkdevs[major].bdops) {
> char name[20];
> sprintf(name, "block-major-%d", major);
> request_module(name);
> }
> #endif
>
> have a request_module() function with printf()-like syntax inside
> kmod.c:
>
> int request_module(const char *fmt, ...)
> {
> #ifdef CONFIG_KMOD
> va_list args;
> ....
> #else
> return -1;
> #endif
> }
>
> so, the drivers just call request_module("block-major-%d", major);
First of all, #ifdef... is bogus - check kmod.h and you'll see what
happens if CONFIG_KMOD is undefined. So removing it is OK right now.
Another thing being that yes, it would be nice to have printf-like _real_
request_module(). The only thing to watch for is literal module name
passing - if you know that name will never contain % you are fine,
otherwise you'll need to go for "%s",name.
> Disadvantage:
>
> 0. an extra function call even if CONFIG_KMOD is not defined. This is not
> serious as request_module() is never called on a hot path (usually opening
> a device etc.)
See above. Don't bother with always making it a function - just keep
kmod.h as-is and it will take care of the thing.
-
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/
This archive was generated by hypermail 2b29 : Sat Jan 15 2000 - 21:00:18 EST