Patchwork [U-Boot,1/2] common: introduce a genutils.h file

login
register
mail settings
Submitter Heiko Schocher
Date Dec. 13, 2010, 9:26 a.m.
Message ID <1292232393-26481-1-git-send-email-hs@denx.de>
Download mbox | patch
Permalink /patch/75309/
State Changes Requested
Delegated to: Wolfgang Denk
Headers show

Comments

Heiko Schocher - Dec. 13, 2010, 9:26 a.m.
as discussed in thread
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/76654

and as a result of this discussion Michael Zaidman
proposed to create a genutils.h, see:

http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/78692

So, introduce this genutils.h, as BUILD_BUG_ON is also
needed in sensor support.

Signed-off-by: Heiko Schocher <hs@denx.de>
cc: Michael Zaidman <michael.zaidman@gmail.com>
---
maybe I should include genutils.h in common.h ?

 include/genutils.h  |   30 ++++++++++++++++++++++++++++++
 include/ubi_uboot.h |    4 +---
 2 files changed, 31 insertions(+), 3 deletions(-)
 create mode 100644 include/genutils.h
Wolfgang Denk - Jan. 9, 2011, 4:46 p.m.
Dear Heiko Schocher,

In message <1292232393-26481-1-git-send-email-hs@denx.de> you wrote:
> as discussed in thread
> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/76654
> 
> and as a result of this discussion Michael Zaidman
> proposed to create a genutils.h, see:
> 
> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/78692
> 
> So, introduce this genutils.h, as BUILD_BUG_ON is also
> needed in sensor support.
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>
> cc: Michael Zaidman <michael.zaidman@gmail.com>
> ---
> maybe I should include genutils.h in common.h ?
> 
>  include/genutils.h  |   30 ++++++++++++++++++++++++++++++

I do not like the idea of adding yet another nonstandard header file
with just a few definitions in it.

Linux defines this is include/linux/kernel.h, i. e. in a pretty
central place, and we should porobably do the same.

How about adding it to include/common.h instead?

Best regards,

Wolfgang Denk
Heiko Schocher - Jan. 10, 2011, 7:09 a.m.
Hello Wolfgang,

Wolfgang Denk wrote:
> In message <1292232393-26481-1-git-send-email-hs@denx.de> you wrote:
>> as discussed in thread
>> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/76654
>>
>> and as a result of this discussion Michael Zaidman
>> proposed to create a genutils.h, see:
>>
>> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/78692
>>
>> So, introduce this genutils.h, as BUILD_BUG_ON is also
>> needed in sensor support.
>>
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>> cc: Michael Zaidman <michael.zaidman@gmail.com>
>> ---
>> maybe I should include genutils.h in common.h ?
>>
>>  include/genutils.h  |   30 ++++++++++++++++++++++++++++++
> 
> I do not like the idea of adding yet another nonstandard header file
> with just a few definitions in it.
> 
> Linux defines this is include/linux/kernel.h, i. e. in a pretty
> central place, and we should porobably do the same.
> 
> How about adding it to include/common.h instead?

Hmm..  I thought exactly this should not go in common.h as a
result from this thread:

http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/78692

bye,
Heiko
Wolfgang Denk - Jan. 10, 2011, 10:19 a.m.
Dear Heiko Schocher,

In message <4D2AB091.9030405@denx.de> you wrote:
> 
> > Linux defines this is include/linux/kernel.h, i. e. in a pretty
> > central place, and we should porobably do the same.
> > 
> > How about adding it to include/common.h instead?
> 
> Hmm..  I thought exactly this should not go in common.h as a
> result from this thread:
> 
> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/78692

Well, OK.

Then please let's find a better name than "genutils".  Eventually we
should create u-boot.h (which then probably would / should  include
asm/u-boot.h).

Best regards,

Wolfgang Denk

Patch

diff --git a/include/genutils.h b/include/genutils.h
new file mode 100644
index 0000000..102f048
--- /dev/null
+++ b/include/genutils.h
@@ -0,0 +1,30 @@ 
+/*
+ * (C) Copyright 2010
+ * Heiko Schocher, DENX Software Engineering, hs@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __GENUTILS_H_
+#define __GENUTILS_H_	1
+
+/* Force a compilation error if condition is true */
+#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
+
+#endif	/* __GENUTILS_H_ */
diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
index d2c90a6..ad15c8e 100644
--- a/include/ubi_uboot.h
+++ b/include/ubi_uboot.h
@@ -16,6 +16,7 @@ 
 
 #include <common.h>
 #include <compiler.h>
+#include <genutils.h>
 #include <malloc.h>
 #include <div64.h>
 #include <linux/crc32.h>
@@ -191,9 +192,6 @@  static inline long IS_ERR(const void *ptr)
 	return IS_ERR_VALUE((unsigned long)ptr);
 }
 
-/* Force a compilation error if condition is true */
-#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
-
 /* module */
 #define THIS_MODULE		0
 #define try_module_get(...)	1