查看设备树platform总线上的所有节点

来源:互联网 发布:unity2d编程 编辑:程序博客网 时间:2024/05/29 18:36
#include <linux/init.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/version.h>#include <linux/of.h>#include <linux/platform_device.h>#include <asm/io.h>MODULE_LICENSE("Dual BSD/GPL");MODULE_DESCRIPTION("a simple driver example!");int showdevice(struct device *devp, void *data){struct platform_device *pdev;pdev = container_of(devp, struct platform_device, dev);printk("%s: %d\n", pdev->name, pdev->num_resources);return 0;}static int mymodule_init(void){#if 0struct device_node *node = of_allnodes;while(node){printk("%s\n", node->name);node = node->allnext;}#endif//int bus_for_each_dev(struct bus_type *bus, struct device *start,//     void *data, int (*fn)(struct device *, void *))bus_for_each_dev(&platform_bus_type, NULL, NULL, showdevice);printk("module install\n");return 0;}static void mymodule_exit(void){printk("module release\n");}module_init(mymodule_init);module_exit(mymodule_exit);

0 0
原创粉丝点击