Book Note: Linux Device Driver Dos and Don'ts
Book Note: Linux Device Driver Dos and Don'ts
http://janitor.kernelnewbies.org/docs/driver-howto.html
what a hardened (robust) device
driver should mean and how it should be implemented and measured.
1.3 Robust device drivers
-Follows the Linux CodingStyle.
-Efficient in managing faults and handling, reporting and recovering from errors.
(Also not panic() happy.)
-Complies with latest Linux kernel APIs and interfaces.
(Uses the new device driver model, kobjects and sysfs.)
-Properly manages resources (memory, semaphores, interrupts, etc.).
-Uses kernel-provided "C" I/O functions instead of assembly code.
2.0 Where do I start?
3.0 OK, I'm ready...
3.1 Efficient error handling, reporting and recovery:
1)<printk()>
you should always check printk() calls to include appropriate KERN_* constant.
2)<goto>
3) <Enumerated return codes> <return EWHATEVER should be return -EWHATEVER>
4) <No need to panic()>
Rather, the device driver should try to recover, re-initialize, or finally simply
return an appropriate error code, release allocated resources, log a message and
exit gracefully.
3.2.1 Module interface changes
<Initialization and cleanup>
<Module Reference Count macros>
You no longer need to adjust your own module reference count
-Reference counting from other modules:
;A Golden Rule: if you are calling through a function pointer into a (different) module,
you must hold a reference to that module.
Otherwise you risk sleeping in the module while it is unloaded.
You can get a reference to a module by using:
try_module_get(owner);
and you don't have to check if OWNER != NULL, this is done by try_module_g
相关文档:
Fedora 8.0(linux)用RPM安装gcc
前一阵装了一个Fedora 8.0,居然将gcc选项没选,现在想在Linux环境下调试c程序,只有再安装gcc编译器。在Fedora 8.0安装的源文件中,找到Package文件夹,里面安装gcc编译器的文件,Fedora 8.0的gcc 是version 4.12 (20070925)。
安装顺序:
(1)rpm -ivh kernheaders-2.6 ......
发布文件到linux的apache服务器:
1. 添加映射到httpd文件
(1)打开httpd.conf文件
vi /etc/httpd/conf/httpd.conf
(2)添加以下内容到httpd.conf文件
Alias /shop/ "/usr/local/tomcat-6.0.16/webapps/ShoppingSearch/images/"
<Directory "/usr/local/tomcat-6.0.16/webapps/ShoppingSea ......
vmlinux 编译出来的最原始的内核文件,未压缩。
zImage 是vmlinux经过gzip压缩后的文件。
bzImage bz表示“big zImage”,不是用bzip2压缩的。两者的不同之处在于,zImage解压缩内核到低端内存(第一个640K),bzImage解压缩内核到高端内存(1M以上)。如果内核比较小,那么采用zImage或bzI ......
所有的内核代码,基本都包含了linux\compile.h这个文件,所以它是基础,打算先分析这个文件里的代码看看,有空再分析分析其它的代码。
首先印入眼帘的是对__ASSEMBLY__这个宏的判断,这个变量实际是在编译汇编代码的时候,由编译器使用-D这样的参数加进去 的,AFLAGS这个变量也定义了这个变量,gcc会把这个宏定义为1。用在 ......
管理员想要提高Linux管理效率是要遵循一些管理技巧的,这里简单介绍有关Linux管理效率的三个技巧:卸载无响应的 DVD 驱动器、恢复出现问题的屏幕、屏幕协作。相信他们会对管理员效率有提高。
技巧 1:卸载无响应的 DVD 驱动器
网络新手的经历:按下服务器(运行基于 Redmond 的操作系统)DVD 驱动器上的 Eject 按钮时, ......