用于SPI设备的Sysfs

时间:2010-06-09 07:09:37

标签: linux

如何使用sysfs检测我的硬件模块(例如MSR)是否执行事件或中断?

2 个答案:

答案 0 :(得分:1)

你的问题有点模糊 对于中断,您可以查看cat /proc/interrupts的输出,并查看驱动程序的中断计数是否在增加。

sysfs用于显示设备或驱动程序的属性。如果要跟踪驱动程序代码的执行,请查看源代码。可能有调试printk,只有在使用某些命令行参数加载驱动程序时才会启用。例如:

rmmod mymodule
modprobe mymodule debug=1

调试消息通常出现在控制台上,您也可以使用dmesg命令查看它们

答案 1 :(得分:0)

如果您的意思是如何导出硬件模块(例如MSR)是否执行事件或中断的信息,可以回答:

您可以使用sysfs api创建设备属性,如:

static numbers;  
/* suppose numbers may be increased in your event function */
static DEVICE_ATTR(event_numbers, 0400, event_numbers_show, NULL);

并定义event_numbers_show属性:

static ssize_t event_numbers_show(struct device *dev,
        struct device_attribute *attr, char *buf)
    .....
    sprintf(buf, "%d\n", numbers);
    .....
}

然后在驱动程序初始化期间执行sysfs条目create func:

sysfs_create_file(&dev->kobj, &dev_attr_event_numbers_show->attr);

如果以上所有内容都成功,那么您将在/ sys / bus / platform / devices / {YOUR_DEVICE_NAME}目录中找到event_numbers文件,只有cat event_numbers,它将显示相应的'numbers'变量值。