KernelNewbies:

Note, This article is originally based on the article, [http://www.linuxdevices.com/articles/AT5340618290.html Writing Portable Device Drivers] published in Linux Journal Embedded by [http://http://wiki.kernelnewbies.org/GregKH Greg Kroah-Hartman], and has been added here by the original author. Please feel free to update it like any other page on this site.

Almost all Linux kernel device drivers work on more than just one type of processor. This only happens because device-driver writers adhere to a few important rules. These rules include using the proper variable types, not relying on specific memory page sizes, being aware of endian issues with external data, setting up proper data alignment and accessing device memory locations through the proper interface. Here is a list of these rules:

If you follow these different rules when creating a new Linux kernel device driver, or when modifying an existing one, the resulting code will run successfully on a wide range of processors. These rules are also good to remember when debugging a driver that only works on one platform (remember those endian issues).

The most important resource to remember is to look at existing kernel drivers that are known to work on different platforms. One of Linux's strengths is the open access of its code, which provides a powerful learning tool for aspiring driver authors.

KernelNewbies: WritingPortableDrivers (last edited 2005-10-07 19:11:12 by c-24-22-115-24)