<pre name="code" class="objc">#include <linux/module.h>
#include <linux/slab.h>
#include <linux/kobject.h>
#include <linux/platform_device.h>
struct att_dev
{
struct platform_device *pdev;
struct kobject *kobj;
};
static struct att_dev *dev = NULL;
static ssize_t att_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
printk("echo debug buf\n");
return count;
}
static ssize_t att_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
printk("cat debug buf\n");
return 0;
}
static DEVICE_ATTR(test,0666,att_show,att_store);//使用DEVICE_ATTR,可以在sys fs中添加“文件”,通过修改该文件内容,可以实现在运行过程中动态控制device的目的
static __devinit int att_probe(struct platform_device *pdev)
{
int ret;
/* 增加节点/sys/devic
驱动学习--SYS属性节点创建
最新推荐文章于 2023-10-18 15:48:09 发布
这篇博客介绍了如何在Linux驱动程序中创建SYS属性节点,通过insmod命令加载模块后,可以在/sys/devices/platform目录下观察到新增的att_test节点。
摘要由CSDN通过智能技术生成