arm驱动linux内核时钟
register_chrdev_region(devno, 1, "timerlist_dev");
}else{
result = alloc_chrdev_region(&devno, 0, 1, "timerlist_dev");
VirtualDisk_major = MAJOR(devno);
}
if(result < 0 ){
return result;
}
VirtualDiskp = kmalloc(sizeof(struct VirtualDisk), GFP_KERNEL);
if(!VirtualDiskp){
result = -ENOMEM;
goto fail_malloc;
}
memset(VirtualDiskp, 0, sizeof(struct VirtualDisk));
VirtualDisk_setup_cdev(VirtualDiskp, 0);
timerlist_class = class_create(THIS_MODULE, "timerlist_drv");
if (IS_ERR(timerlist_class))
return PTR_ERR(timerlist_class);
timerlist_class_dev = class_device_create(timerlist_class, NULL, MKDEV(VirtualDisk_major, 0), NULL, "timerlist_dev"); /* /dev/xyz */
if (IS_ERR(timerlist_class_dev))
return PTR_ERR(timerlist_class_dev);
return 0;
fail_malloc:
unregister_chrdev_region(devno, 1);
return result;
}
static void timerlist_drv_exit(void)
{
if(VirtualDiskp)del_timer(&VirtualDiskp->mytimer);
cdev_del(&VirtualDiskp->cdev);
kfree(VirtualDiskp);
unregister_chrdev_region(MKDEV(VirtualDisk_major, 0), 1);
class_device_unregister(timerlist_class_dev);
class_destroy(timerlist_class);
}
module_init(timerlist_drv_init);
module_exit(timerlist_drv_exit);
MODULE_LICENSE("GPL");
arm驱动linux内核时 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)