%Data Types %Thadeu Cascardo # Macros * include/linux/kernel.h * ARRAY\\_SIZE * FIELD\\_SIZEOF * ALIGN * PTR\\_ALIGN * IS\\_ALIGNED # More macros * container\\_of * offsetof # krefs Reference: * Documentation/kref.txt # API * struct kref * kref\\_init - struct kref pointer * kref\\_get - struct kref pointer * kref\\_put - struct kref pointer and release function # Usage * Embed struct kref into your own structure * Do not forget to call kref\\_init when initializing your structure * Pass a release function as parameter to kref\\_put, where you release your structure * Follow the rules for calling kref\\_get and kref\\_put # Rules * Must increment count if passing a non-temporary copy * May increment count without a lock if already has a valid pointer * Must decrement when done with the pointer * If code never tries to get a ref without a valid pointer, may be done without a lock * Must serialize getting a ref without a valid pointer with putting a ref # Endianness # Lists # Bitmaps # Trees and hashes # Other data types