自动创建和删除设备节点

/* 驱动入口函数 */
static int __init xxx_init(void)
{
 /* 创建类 */
 class = class_create(THIS_MODULE, "xxx");
 /* 创建设备 */
 device = device_create(class, NULL, devid, NULL, "xxx");
 return 0;
 }

 /* 驱动出口函数 */
 static void __exit led_exit(void)
 {
 /* 删除设备 */
 device_destroy(newchrled.class, newchrled.devid);
 /* 删除类 */
 class_destroy(newchrled.class);
 }
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章