2 * Copyright (C) 2010 Timo Kokkonen <kaapeli@itanic.dy.fi>
4 * Some of the code is taken from other GPLv2 sources, such as the
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #define MAX(a, b) ((a) > (b) ? (a) : (b))
27 #define MIN(a, b) ((a) < (b) ? (a) : (b))
30 * container_of - cast a member of a structure out to the containing structure
31 * @ptr: the pointer to the member.
32 * @type: the type of the container struct this is embedded in.
33 * @member: the name of the member within the struct.
36 #define container_of(ptr, type, member) ({ \
37 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
38 (type *)( (char *)__mptr - offsetof(type,member) );})