__iomem cookie

__iomem is a kernel cookie used by Sparse, a semantic checker used by the kernel to find possible coding faults. To take advantage of the features offered by Sparse, it should be enabled at kernel compile time; if not, __iomem cookie will be ignored anyway.

The C=1 in the command line will enable Sparse for you, but Sparse should be installed first on your system:

sudo apt-get install sparse  

For example, when building a module, use:

make -C $KPATH M=$PWD C=1 modules

Alternatively, if the makefile is well-written, just type:

make C=1  

The following shows how __iomem is defined in the kernel:

#define __iomem    __attribute__((noderef, address_space(2))) 

It protects us from faulty drivers performing I/O memory access. Adding the ...

Get Linux Device Drivers Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.