]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
Move definition of container_of() to common.h
authorHaavard Skinnemoen <haavard.skinnemoen@atmel.com>
Fri, 16 May 2008 09:10:30 +0000 (11:10 +0200)
committerWolfgang Denk <wd@denx.de>
Tue, 3 Jun 2008 18:27:23 +0000 (20:27 +0200)
AVR32 and AT91SAM9 both have their own identical definitions of
container_of() taken from the Linux kernel. Move it to common.h so
that all architectures can use it.

container_of() is already used by some drivers, and will be used
extensively by the new and improved SPI API.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
include/asm-arm/arch-at91sam9/hardware.h
include/asm-avr32/u-boot.h
include/common.h

index e7c572d8ba5cf40faa163698ccd5cb74cc23b683..f31241901a3224c88dd24a57efa2c2a9809b86b2 100644 (file)
 #error "Unsupported AT91 processor"
 #endif
 
-/*
- * container_of - cast a member of a structure out to the containing structure
- *
- * @ptr:       the pointer to the member.
- * @type:      the type of the container struct this is embedded in.
- * @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)); })
-
 #endif
index 71dfcaf284076e99cf18592fb27d2bdf89399745..85ef008b7272b3d756ddbba0e64d8649327b6da7 100644 (file)
@@ -42,15 +42,4 @@ typedef struct bd_info {
 #define bi_memstart bi_dram[0].start
 #define bi_memsize bi_dram[0].size
 
-/**
- *  container_of - cast a member of a structure out to the containing structure
- *
- *    @ptr:        the pointer to the member.
- *    @type:       the type of the container struct this is embedded in.
- *    @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) );})
-
 #endif /* __ASM_U_BOOT_H__ */
index d0f57040ee435c627457711d264fa34682a0816e..26e1b469a12e048da358580131c52e7d110ad83f 100644 (file)
@@ -176,6 +176,17 @@ typedef void (interrupt_handler_t)(void *);
                (__x > __y) ? __x : __y; })
 
 
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr:       the pointer to the member.
+ * @type:      the type of the container struct this is embedded in.
+ * @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) );})
+
 /*
  * Function Prototypes
  */