[LinuxBIOS] r413 - in LinuxBIOSv3: arch/x86 include mainboard/artecgroup/dbe61 southbridge/amd/cs5536 superio/winbond/w83627hf

svn at openbios.org svn at openbios.org
Fri Jun 29 16:36:03 CEST 2007


Author: uwe
Date: 2007-06-29 16:36:03 +0200 (Fri, 29 Jun 2007)
New Revision: 413

Modified:
   LinuxBIOSv3/arch/x86/linuxbios_table.c
   LinuxBIOSv3/include/lib.h
   LinuxBIOSv3/mainboard/artecgroup/dbe61/initram.c
   LinuxBIOSv3/southbridge/amd/cs5536/cs5536.c
   LinuxBIOSv3/superio/winbond/w83627hf/superio.c
Log:
Add an ARRAY_SIZE() macro which returns the size of an array, regardless
of the data types of the individual array elements.

The macro is defined in lib.h, so code which uses it must include lib.h.

Signed-off-by: Uwe Hermann <uwe at hermann-uwe.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>



Modified: LinuxBIOSv3/arch/x86/linuxbios_table.c
===================================================================
--- LinuxBIOSv3/arch/x86/linuxbios_table.c	2007-06-29 14:20:02 UTC (rev 412)
+++ LinuxBIOSv3/arch/x86/linuxbios_table.c	2007-06-29 14:36:03 UTC (rev 413)
@@ -25,6 +25,7 @@
 #include <device/device.h>
 #include <tables.h>
 #include <mc146818rtc.h>
+#include <lib.h>
 //#include <cpu/cpu.h>
 //#include <pirq_routing.h>
 //#include <smp/mpspec.h>
@@ -159,7 +160,7 @@
 		{ LB_TAG_ASSEMBLER,      (const u8 *)LINUXBIOS_ASSEMBLER      },
 	};
 	unsigned int i;
-	for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
+	for(i = 0; i < ARRAY_SIZE(strings); i++) {
 		struct lb_string *rec;
 		size_t len;
 		rec = (struct lb_string *)lb_new_record(header);

Modified: LinuxBIOSv3/include/lib.h
===================================================================
--- LinuxBIOSv3/include/lib.h	2007-06-29 14:20:02 UTC (rev 412)
+++ LinuxBIOSv3/include/lib.h	2007-06-29 14:36:03 UTC (rev 413)
@@ -21,6 +21,12 @@
 #ifndef LIB_H
 #define LIB_H
 
+/**
+ * Return the size of a given array, no matter of which data type
+ * the individual array elements are.
+ */
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
 int log2(unsigned int n);
 
 void udelay(unsigned int usecs);

Modified: LinuxBIOSv3/mainboard/artecgroup/dbe61/initram.c
===================================================================
--- LinuxBIOSv3/mainboard/artecgroup/dbe61/initram.c	2007-06-29 14:20:02 UTC (rev 412)
+++ LinuxBIOSv3/mainboard/artecgroup/dbe61/initram.c	2007-06-29 14:36:03 UTC (rev 413)
@@ -120,7 +120,7 @@
 static void dbe61_msr_init(void)
 {
 	int i;
-	for(i = 0; i < sizeof(dbe61_msr)/sizeof(dbe61_msr[0]); i++)
+	for (i = 0; i < ARRAY_SIZE(dbe61_msr); i++)
 		wrmsr(dbe61_msr[i].reg, dbe61_msr[i].msr);
 }
 

Modified: LinuxBIOSv3/southbridge/amd/cs5536/cs5536.c
===================================================================
--- LinuxBIOSv3/southbridge/amd/cs5536/cs5536.c	2007-06-29 14:20:02 UTC (rev 412)
+++ LinuxBIOSv3/southbridge/amd/cs5536/cs5536.c	2007-06-29 14:36:03 UTC (rev 413)
@@ -93,8 +93,6 @@
 	{FLASH_TYPE_NONE, 0, 0},	/* CS3, or Flash Device 3 */
 };
 
-#define FlashInitTableLen (sizeof(FlashInitTable)/sizeof(FlashInitTable[0]))
-
 u32 FlashPort[] = {
 	MDD_LBAR_FLSH0,
 	MDD_LBAR_FLSH1,
@@ -149,7 +147,7 @@
 	int numEnabled = 0;
 
 	printk(BIOS_DEBUG, "chipset_flash_setup: Start\n");
-	for (i = 0; i < FlashInitTableLen; i++) {
+	for (i = 0; i < ARRAY_SIZE(FlashInitTable); i++) {
 		if (FlashInitTable[i].fType != FLASH_TYPE_NONE) {
 			printk(BIOS_DEBUG, "Enable CS%d\n", i);
 			/* we need to configure the memory/IO mask */

Modified: LinuxBIOSv3/superio/winbond/w83627hf/superio.c
===================================================================
--- LinuxBIOSv3/superio/winbond/w83627hf/superio.c	2007-06-29 14:20:02 UTC (rev 412)
+++ LinuxBIOSv3/superio/winbond/w83627hf/superio.c	2007-06-29 14:36:03 UTC (rev 413)
@@ -22,6 +22,7 @@
  */
 
 #include <io.h>
+#include <lib.h>
 #include <device/device.h>
 #include <device/pnp.h>
 #include <console.h>
@@ -99,7 +100,7 @@
                                                                             
 	};
 
-	for(i = 0; i<  sizeof(hwm_reg_values)/sizeof(hwm_reg_values[0]); i+=3 ) { 
+	for (i = 0; i < ARRAY_SIZE(hwm_reg_values); i += 3) { 
 		reg = hwm_reg_values[i];	
 	 	value = pnp_read_index(base, reg);		
 		value &= 0xff & hwm_reg_values[i+1];
@@ -207,8 +208,7 @@
 
 static void phase2_setup_scan_bus(struct device *dev)
 {
-	pnp_enable_devices(dev, &ops,
-		sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+	pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
 }
 
 static struct device_operations ops = {





More information about the coreboot mailing list