/* In 2.2.3 /usr/include/linux/version.h includes a * macro for this, but 2.0.35 doesn't - so I add it * here if necessary. */ #ifndef KERNEL_VERSION #define KERNEL_VERSION(a,b,c) ((a)*65536+(b)*256+(c)) #endif
/* Emmanuel Papirakis: * * Prameter names are now (2.2) handled in a macro. * The kernel doesn't resolve the symbol names * like it seems to have once did. * * To pass parameters to a module, you have to use a macro * defined in include/linux/modules.h (line 176). * The macro takes two parameters. The parameter's name and * it's type. The type is a letter in double quotes. * For example, "i" should be an integer and "s" should * be a string. */
/* Initialize the module - show the parameters */ int init_module() { if (str1 == NULL || str2 == NULL) { printk("Next time, do insmod param str1=<something>"); printk("str2=<something>/n"); } else printk("Strings:%s and %s/n", str1, str2);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) printk("If you try to insmod this module twice,"); printk("(without rmmod'ing/n"); printk("it first), you might get the wrong"); printk("error message:/n"); printk("'symbol for parameters str1 not found'./n"); #endif