2014-04-12 39 views
1

我試圖修改我的android手機的linux內核中的一個模塊。內核相當新。我在這裏閱讀了關於__setup()宏:http://www.e-reading.ws/chapter.php/101551/103/Hallinan_-_Embedded_Linux_Primer__A_Practical,_Real-World_Approach.html__setup宏不工作

這是我到目前爲止的代碼:

/* Read cmdline */ 
static int __init read_cmdline(char *dt2w) 
{ 
if (strcmp(dt2w, "1") == 0) { 
    pr_info(LOGTAG" Enabled. | dt2w='%s'\n", dt2w); 
    dt2w_switch = 1; 
} else if (strcmp(dt2w, "0") == 0) { 
    pr_info(LOGTAG" Disabled. | dt2w='%s'\n", dt2w); 
    dt2w_switch = 0; 
} else { 
    pr_info(LOGTAG" No valid input found. Going with default: | dt2w='%u'\n", dt2w_switch); 
} 

return 1; 
} 
__setup("dt2w=", read_cmdline); 

但是當我執行dt2w=<some int>我沒有看到任何dmesg日誌輸出。 我敢肯定,該模塊正在編譯和加載,因爲它工作正常。

回答

1

內核命令行參數在加載內核時(即加載模塊之前)處理。

要處理模塊中的參數,請使用模塊參數。 (通過使用類似mymodule.dt2w=xxx的東西,仍然可以在內核命令行上給出模塊參數。)