if(ret < 0)
{
printk("<1> init module error! \n"
"error code is %d" , ret) ;
return ret ;
}
printk ("%s The major device number is %d.\n",
"Registeration is a success",_MARJO);
printk ("If you want to talk to the device driver,\n");
printk ("you'll have to create a device file. \n");
printk ("We suggest you use:\n");
printk ("mknod %s c %d 0\n", DEV_NAME, _MARJO);
printk ("The device file name is important, because\n");
printk ("the ioctl program assumes that's the\n");
printk ("file you'll use.\n");
return SUCCESS ;
}
void cleanup_module()
{
int ret ;
ret = unregister_chrdev(_MARJO,DEV_NAME) ;
if(ret < 0)
printk(" unregister module error") ;
}
/*************************************************/
/* *.h 文件*/
/*
* This is test of module
* of io control
* duan
* 2002-11-19
*/
/* 初始化模块 - 代替系统调用 */
int init_module()
{
/* 警告 - 现在可能太迟了,但可能对下次... */
printk("I'm dangerous. I hope you did a ");
printk("sync before you insmod'ed me.\n");
printk("My counterpart, cleanup_module(), is even");
printk("more dangerous. If\n");
printk("you value your file system, it will ");
printk("be \"sync; rmmod\" \n");
printk("when you remove this module.\n");
/* 清除 - 从/proc中注销相关的文件 */
void cleanup_module()
{
/* 将系统调用恢复原状 */
if (sys_call_table[__NR_open] != our_sys_open) {
printk("Somebody else also played with the ");
printk("open system call\n");
printk("The system may be left in ");
printk("an unstable state.\n");
}