Linux内核模块和驱动的编写(2)

2008-02-23 07:14:50来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

degine MODBERSIONS

#include" Linux.modversions.h"

#endif

#difine devicename mydevice

/* the init funcion*/

int init_module()

{

int tag=module_register_chrdev(0,mydevice,&Fops);

if (tag<0)

{

printk("the device init is erro!\n");

return 1;

}

return 0;

}

/*the funcion which the device will be used */

int device_open ()

{

…….

}

int device_read ()

{

…….

}

int device_write ()

{

…….

}

int device_ioctl ()

{

…….

}

……

/* the deltter function of this module*/

int cleanup_module()

{

int re=module_unregister_chrdev(tag,mydevice);

if( re<0)

{

printk("erro unregister the module !!\n");

return 1;

}

return 0;

}

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Linux上安装GCC编译器过程

下一篇:Linux中文件查找方法大全