自動創建和刪除設備節點

/* 驅動入口函數 */
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);
 }
 

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