From 4417deb76fffa9b30746000983e148643ba3d17c Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Mon, 5 Jan 2015 11:09:11 -0800 Subject: Move container_of() macro to stddef.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's not a SPI related macro, hence move it to stddef.h where other similar macros live. Change-Id: I1008894af7a272f1bc36d3ae6cee3881132b6ba9 Signed-off-by: Stefan Reinauer Reviewed-on: http://review.coreboot.org/8109 Tested-by: build bot (Jenkins) Reviewed-by: Kyösti Mälkki --- src/include/spi_flash.h | 11 ----------- src/include/stddef.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/include') diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h index d697d8f8ae..8b8b0c54fe 100644 --- a/src/include/spi_flash.h +++ b/src/include/spi_flash.h @@ -28,17 +28,6 @@ #include #include -/** - * container_of - cast a member of a structure out to the containing structure - * @param ptr: the pointer to the member. - * @param type: the type of the container struct this is embedded in. - * @param member: the name of the member within the struct. - * - */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - struct spi_flash { struct spi_slave *spi; diff --git a/src/include/stddef.h b/src/include/stddef.h index 137de04405..3a030e14a1 100644 --- a/src/include/stddef.h +++ b/src/include/stddef.h @@ -32,6 +32,17 @@ typedef unsigned int wint_t; offsetof(struct structure, member) == offset, \ "`struct " #structure "` offset for `" #member "` is not " #offset ) +/** + * container_of - cast a member of a structure out to the containing structure + * @param ptr: the pointer to the member. + * @param type: the type of the container struct this is embedded in. + * @param member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + #ifdef __PRE_RAM__ #define ROMSTAGE_CONST const #else -- cgit v1.2.3