Re: How to compile module params into kernel?

From: Joakim Tjernlund
Date: Thu Nov 09 2006 - 03:32:02 EST


Jan-Benedict Glaw wrote:
> On Wed, 2006-11-08 21:09:04 +0100, Jesper Juhl <jesper.juhl@xxxxxxxxx> wrote:
>
>> On 08/11/06, Joakim Tjernlund <joakim.tjernlund@xxxxxxxxxxxx> wrote:
>>
>>>> -----Original Message-----
>>>> From: Jesper Juhl [mailto:jesper.juhl@xxxxxxxxx]
>>>> On 08/11/06, Joakim Tjernlund <joakim.tjernlund@xxxxxxxxxxxx> wrote:
>>>>
>>>>> Instead of passing a module param on the cmdline I want to compile that
>>>>> into the kernel, but I can't figure out how.
>>>>>
>>>> You could edit the module source and hardcode default values.
>>>>
>>> Yes, but I don't want to do that since it makes maintance
>>> harder.
>>>
>> Well, as far as I know, there's no way to specify default module
>> options at compile time. The defaults are set in the module source and
>> are modifiable at module load time or by setting options on the kernel
>> command line at boot tiem. So, if that's no good for you I don't see
>> any other way except modifying the source to hardcode new defaults.
>>
>
> However, that could probably be hacked in easily. We use a similar
> approach for VAX, since we're not yet regularly booting off a local
> harddisk, but commonly via MOP off the network.
>
> MfG, JBG
>
>
This works for me in should want to known:

#include <linux/moduleparam.h>
int set_module_params(void)
{
extern struct kernel_param __start___param[], __stop___param[];
char module_params[]="rtc-ds1307.force=0,0x68";

parse_args("hard module params", module_params, __start___param,
__stop___param - __start___param, NULL);
return 0;
}
arch_initcall(set_module_params);

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