proc新接口
注意,在較新版本的內(nèi)核中,procfs
的函數(shù)接口有所變化。
系統(tǒng) | 內(nèi)核版本 |
---|---|
Linux | 5.10.111 |
在驅(qū)動(dòng)中添加以下代碼:
#include < linux/kernel.h >
#include < linux/module.h >
#include < linux/init.h >
#include < linux/proc_fs.h >
#include < linux/seq_file.h >
struct proc_dir_entry *my_proc_entry;
static int proc_clk_show(struct seq_file *m, void *v)
{
seq_printf(m,
"pll0: %lu Mhzn"
"pll1: %lu Mhzn"
"pll2: %lu Mhzn",
100, 200, 300);
return 0;
}
static int clk_info_open(struct inode *inode, struct file *filp)
{
return single_open(filp, proc_clk_show, NULL);
}
static const struct proc_ops clk_stat_proc_fops = {
.proc_open = clk_info_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = seq_release,
};
static int __init my_module_init(void)
{
my_proc_entry = proc_create("clk", 0, NULL, &clk_stat_proc_fops);
return 0;
}
static void __exit my_module_exit(void)
{
proc_remove(my_proc_entry);
}
module_init(my_module_init);
module_exit(my_module_exit);
MODULE_LICENSE("GPL");
新的proc
接口中,將原來(lái)的struct file_operations
換成了struct proc_ops
,其中成員函數(shù)也添加了對(duì)應(yīng)的前綴proc
,但本質(zhì)還是一樣的,只是換了名字,更加規(guī)范了一些。
-
內(nèi)核
+關(guān)注
關(guān)注
3文章
1382瀏覽量
40425 -
接口
+關(guān)注
關(guān)注
33文章
8691瀏覽量
151920 -
驅(qū)動(dòng)
+關(guān)注
關(guān)注
12文章
1851瀏覽量
85643 -
Linux
+關(guān)注
關(guān)注
87文章
11345瀏覽量
210399
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
Linux驅(qū)動(dòng)中創(chuàng)建procfs接口的方法
![<b class='flag-5'>Linux</b><b class='flag-5'>驅(qū)動(dòng)</b>中創(chuàng)建procfs<b class='flag-5'>接口</b>的方法](https://file1.elecfans.com/web2/M00/88/EB/wKgaomR3CW6ABERUAAAMSvL9fV8917.jpg)
Linux平臺(tái)/proc虛擬文件系統(tǒng)詳解
![<b class='flag-5'>Linux</b>平臺(tái)/<b class='flag-5'>proc</b>虛擬文件系統(tǒng)詳解](https://file1.elecfans.com/web2/M00/89/53/wKgaomSBQL2ASwvCAACYBEsbUVM468.jpg)
Linux proc文件系統(tǒng)詳解
USB接口驅(qū)動(dòng)的移植介紹
Linux內(nèi)核空間設(shè)備驅(qū)動(dòng)程序的開(kāi)發(fā)
需要了解的Linux中 /proc/[pid] 目錄的各文件
Linux驅(qū)動(dòng)開(kāi)發(fā)-proc接口介紹
AIO 3399ProC工具Linux Upgrade Tool 1.34
![AIO 3399<b class='flag-5'>ProC</b>工具<b class='flag-5'>Linux</b> Upgrade Tool 1.34](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
AIO 3399ProC工具Linux Upgrade Tool v1.24
![AIO 3399<b class='flag-5'>ProC</b>工具<b class='flag-5'>Linux</b> Upgrade Tool v1.24](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
AIO 3399ProC解合包工具(Linux)
![AIO 3399<b class='flag-5'>ProC</b>解合包工具(<b class='flag-5'>Linux</b>)](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
AIO 3399ProC Linux SDK源碼包(僅支持RK3399Pro)
![AIO 3399<b class='flag-5'>ProC</b> <b class='flag-5'>Linux</b> SDK源碼包(僅支持RK3399Pro)](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
如何通過(guò)proc接口發(fā)起系統(tǒng)請(qǐng)求
Linux驅(qū)動(dòng)中procfs接口的創(chuàng)建
![<b class='flag-5'>Linux</b><b class='flag-5'>驅(qū)動(dòng)</b>中procfs<b class='flag-5'>接口</b>的創(chuàng)建](https://file1.elecfans.com/web2/M00/88/EB/wKgaomR3CW6ABERUAAAMSvL9fV8917.jpg)
Linux中的proc介紹
![<b class='flag-5'>Linux</b>中的<b class='flag-5'>proc</b><b class='flag-5'>介紹</b>](https://file1.elecfans.com/web2/M00/02/94/wKgZoma8g7OARd4_AAW33AFOb04808.png)
評(píng)論