linux26内核,Linux26內核驱动与24的区别.doc

Linux26內核驱动与24的区别

Linux2.6内核驱动与2.4的区别

随着Linux2.6的发布,由于2.6内核做了新的改动,各个设备的驱动程序在不同程度上要进行改写。为了方便各位Linux爱好者我把自己整理的这分文档share出来。该文当列举了2.6内核同以前版本的绝大多数变化,可惜的是由于时间和精力有限没有详细列出各个函数的用法。

1、 使用新的入口必须包含 module_init(your_init_func);module_exit(your_exit_func);老版本:int init_module(void);void cleanup_module(voi);2.4中两种都可以用,对如后面的入口函数不必要显示包含任何头文件。

2、 GPLMODULE_LICENSE("Dual BSD/GPL");老版本:MODULE_LICENSE("GPL");

3、 模块参数必须显式包含module_param(name, type, perm);module_param_named(name, value, type, perm);参数定义module_param_string(name, string, len, perm);module_param_array(name, type, num, perm);老版本:MODULE_PARM(variable,type);MODULE_PARM_DESC(variable,type);

4、 模块别名MODULE_ALIAS("alias-name");这是新增的,在老版本中需在/etc/modules.conf配置,现在在代码中就可以实现。

5、 模块计数int try_module_get(&module);module_put();老版本:MOD_INC_USE_COUNT 和 MOD_DEC_USE_COUNT

HYPERLINK "/~sean/parser.cgi?modules" /~sean/parser.cgi?modules

In 2.4 modules, the MOD_INC_USE_COUNT macro is used to prevent unloading of the module while there is an open file. The 2.6 kernel, however, knows not to unload a module that owns a character device that's currently open.However, this requires that the module be explicit in specifying ownership of character devices, using the THIS_MODULE macro.

You also have to take out all calls to MOD_INC_USE_COUNT and MOD_DEC_USE_COUNT.?????????? static struct file_operations fops ={???????? .owner = THIS_MODULE,???????? .read = device_read,???????? .write = device_write,???????? .open = device_open,???????? .release = device_release}

The 2.6 kernel considers modules that use the deprecated facility to be unsafe, and does not permit their unloading, even with rmmod -f.

2.6,2.5的kbuild不需要到处加上MOD_INC_USE_COUNT来消除模块卸载竞争(module unload race)

6、 符号导出只有显示的导出符号才能被其他模块使用,默认不导出所有的符号,不必使用EXPORT_NO_SYMBOLS老板本:默认导出所有的符号,除非使用EXPORT_NO_SYMBOLS

7、 内核版本检查需要在多个文件中包含时,不必定义__NO_VERSION__老版本:在多个文件中包含时,除在主文件外的其他文件中必须定义__NO_VERSION__,防止版本重复定义。

8、 设备号kdev_t被废除不可用,新的d

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值