1, array_size macro, is to find the device structure in the number of devices defined in the Linux/kernel.h #define ARRAY_SIZE (arr) (sizeof (arr)/sizeof (arr) [0]) + __must_be_ The array (arr)/sizeof (arr) [0]) is the number of devices to be found, __must_be_array (arr) is prevented from being used by Wu, for example with pointers instead of arrays.
2, int_work before the kernel in the definition of this function is #define init_work (_work, _func, _data), it can be understood that init_work will be in your definition of _work task Force to add a work task, the task is _ Func _func This task will require some data as a parameter, and this parameter is passed through _data. do{ / (_work)->data = (atomic_long_t) work_data_init (); / Init_list_head (& (_work)->entry); / Prepare_work ((_work), (_func)); / } while (0) #define Init_delayed_work (_work,_func) / do{ / init_work (& (_work)- >work, (_func)); / Init_timer (& (_work)->timer); /
3, container_of () #define CONTAINER_OF (PTR, type, member) ({ const typeof (((type *) 0)->member) *__mptr = (PTR);
(Type *) ((char*) __mptr-offsetof (Type,member));}) (char *) __mptr converted to a byte-type pointer. (char *) __mptr-offsetof (Type,member)) is used to find the struct start address (char * pointer), then (type*) ((char *) __mptr-offsetof (Type,member)) in ( Type *) to convert a byte-type struct start pointer to a type-type struct start pointer. It is obvious that a pointer to an entire struct variable is obtained based on a pointer to a domain member variable in a struct variable.
Summary of related function comments in Linux driver (with new)