Linux Kernel Driver porting-general Linux technology-Linux programming and kernel information. The following is a detailed description. With the release of Linux2.6, the driver of each device needs to be rewritten to varying degrees due to the modifications made to the 2.6 kernel. To facilitate Linux fans, I will share this article. This article lists the vast majority of changes in the 2.6 kernel compared with previous versions. Unfortunately, due to limited time and energy, the usage of each function is not listed in detail.
Special statement: the content of this document from the http://lwn.net, the network also has a more detailed description of each function for your reference. If you need the word version of this document, please mail to the weiriver@sohu.com.
1. Use a new portal
Must contain
Module_init (your_init_func );
Module_exit (your_exit_func );
Old Version: int init_module (void );
Void cleanup_module (voi );
2.4 can be used in both cases. For example, you do not need to display any header files for the entry function.
2. GPL
MODULE_LICENSE ("Dual BSD/GPL ");
Old Version: MODULE_LICENSE ("GPL ");
3. Module Parameters
Must explicitly include
Module_param (name, type, perm );
Module_param_named (name, value, type, perm );
Parameter Definition
Module_param_string (name, string, len, perm );
Module_param_array (name, type, num, perm );
Old Version: MODULE_PARM (variable, type );
MODULE_PARM_DESC (variable, type );
4. Module alias
MODULE_ALIAS ("alias-name ");
This is newly added. In the old version, you need to configure in/etc/modules. conf, which can be implemented in the code now.
5. Module count
Int try_module_get (& module );
Module_put ();
Earlier versions: MOD_INC_USE_COUNT and MOD_DEC_USE_COUNT
6. Export symbols
Only the displayed exported symbols can be used by other modules. By default, no symbols are exported, and EXPORT_NO_SYMBOLS is not required.
Boss: All symbols are exported by default, unless EXPORT_NO_SYMBOLS is used
7. kernel version check
When you need to include multiple files, you do not need to define _ NO_VERSION __
Old Version: when multiple files are included, _ NO_VERSION __must be defined in other files except the main file to prevent duplicate versions.
8. device number
Kdev_t is abolished and unavailable. The new dev_t is extended to 32-bit, 12-bit master device number, and 20-bit device number.
Unsigned int iminor (struct inode * inode );
Unsigned int imajor (struct inode * inode );
Old Version: eight-digit master device number, eight-digit master device number
Int MAJOR (kdev_t dev );
Int MINOR (kdev_t dev );
9. Memory Allocation header file change
All memory allocation functions are included in the header file, but the original memory does not exist.
Old Version: the memory allocation function is included in the header file.
10. initial trial of struct
Gcc starts to use the initialization form of the ansi c struct:
Static struct some_structure = {
. Field1 = value,
. Field2 = value,
...
};
Old Version: non-standard preliminary trial form
Static struct some_structure = {
Field1: value,
Field2: value,
...
};
11. User Mode helper
Int call_usermodehelper (char * path, char ** argv, char ** envp,
Int wait );
Add wait Parameters
12. request_module ()
Request_module ("foo-device-% d", number );
Old Version:
Char module_name [32];
Printf (module_name, "foo-device-% d", number );
Request_module (module_name );
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service