summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2008-10-01 12:52:52 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2008-10-01 12:52:52 +0000
commit2ee6779a64922af755a35ce70f85f2d67b488557 (patch)
tree4ae6d7310d71fa29baab3e937cfcd9bb408db5a6
parentdc65196f8f18c28085d40ccbeb45bba3bfe28294 (diff)
downloadcoreboot-2ee6779a64922af755a35ce70f85f2d67b488557.tar.xz
The ARRAY_SIZE macro is convenient, yet mostly unused. Switch lots of
code to use it. That makes the code more readable and also less error-prone. Abuild tested. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3624 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r--src/arch/i386/boot/acpi.c2
-rw-r--r--src/arch/i386/boot/coreboot_table.c2
-rw-r--r--src/arch/i386/lib/cpu.c4
-rw-r--r--src/arch/i386/lib/exception.c2
-rw-r--r--src/arch/i386/smp/ioapic.c2
-rw-r--r--src/arch/ppc/boot/coreboot_table.c2
-rw-r--r--src/cpu/amd/model_10xxx/init_cpus.c8
-rw-r--r--src/cpu/amd/sc520/sc520.c2
-rw-r--r--src/cpu/emulation/qemu-x86/northbridge.c2
-rw-r--r--src/drivers/ati/ragexl/xlinit.c4
-rw-r--r--src/mainboard/a-trend/atc-6220/auto.c3
-rw-r--r--src/mainboard/agami/aruma/auto.c3
-rw-r--r--src/mainboard/agami/aruma/get_bus_conf.c3
-rw-r--r--src/mainboard/agami/aruma/resourcemap.c2
-rw-r--r--src/mainboard/amd/dbm690t/get_bus_conf.c3
-rw-r--r--src/mainboard/amd/dbm690t/resourcemap.c2
-rw-r--r--src/mainboard/amd/serengeti_cheetah/get_bus_conf.c3
-rw-r--r--src/mainboard/amd/serengeti_cheetah/resourcemap.c2
-rw-r--r--src/mainboard/amd/serengeti_cheetah_fam10/get_bus_conf.c3
-rw-r--r--src/mainboard/amd/serengeti_cheetah_fam10/resourcemap.c2
-rw-r--r--src/mainboard/arima/hdama/auto.c5
-rw-r--r--src/mainboard/arima/hdama/cache_as_ram_auto.c3
-rw-r--r--src/mainboard/artecgroup/dbe61/cache_as_ram_auto.c3
-rw-r--r--src/mainboard/asus/a8n_e/get_bus_conf.c1
-rw-r--r--src/mainboard/asus/mew-vm/auto.c3
-rw-r--r--src/mainboard/asus/p2b-f/auto.c3
-rw-r--r--src/mainboard/asus/p2b/auto.c3
-rw-r--r--src/mainboard/asus/p3b-f/auto.c3
-rw-r--r--src/mainboard/azza/pt-6ibd/auto.c3
-rw-r--r--src/mainboard/biostar/m6tba/auto.c3
-rw-r--r--src/mainboard/broadcom/blast/get_bus_conf.c3
-rw-r--r--src/mainboard/broadcom/blast/resourcemap.c2
-rw-r--r--src/mainboard/compaq/deskpro_en_sff_p600/auto.c3
-rw-r--r--src/mainboard/dell/s1850/auto.c3
-rw-r--r--src/mainboard/digitallogic/adl855pc/auto.c3
-rw-r--r--src/mainboard/eaglelion/5bcm/auto.c3
-rw-r--r--src/mainboard/gigabyte/ga-6bxc/auto.c3
-rw-r--r--src/mainboard/gigabyte/ga_2761gxdk/get_bus_conf.c3
-rw-r--r--src/mainboard/gigabyte/ga_2761gxdk/resourcemap.c2
-rw-r--r--src/mainboard/gigabyte/m57sli/fanctl.c5
-rw-r--r--src/mainboard/gigabyte/m57sli/get_bus_conf.c3
-rw-r--r--src/mainboard/gigabyte/m57sli/resourcemap.c2
-rw-r--r--src/mainboard/ibm/e325/auto.c3
-rw-r--r--src/mainboard/ibm/e325/cache_as_ram_auto.c3
-rw-r--r--src/mainboard/ibm/e325/resourcemap.c2
-rw-r--r--src/mainboard/ibm/e326/auto.c3
-rw-r--r--src/mainboard/ibm/e326/cache_as_ram_auto.c3
-rw-r--r--src/mainboard/ibm/e326/resourcemap.c2
-rw-r--r--src/mainboard/intel/jarrell/auto.c3
-rw-r--r--src/mainboard/intel/xe7501devkit/auto.c3
-rw-r--r--src/mainboard/iwill/dk8_htx/get_bus_conf.c3
-rw-r--r--src/mainboard/iwill/dk8_htx/resourcemap.c2
-rw-r--r--src/mainboard/iwill/dk8s2/auto.c3
-rw-r--r--src/mainboard/iwill/dk8x/auto.c5
-rw-r--r--src/mainboard/msi/ms6178/auto.c3
-rw-r--r--src/mainboard/msi/ms7135/get_bus_conf.c5
-rw-r--r--src/mainboard/msi/ms7260/get_bus_conf.c3
-rw-r--r--src/mainboard/msi/ms7260/resourcemap.c2
-rw-r--r--src/mainboard/msi/ms9185/get_bus_conf.c3
-rw-r--r--src/mainboard/msi/ms9185/resourcemap.c2
-rw-r--r--src/mainboard/msi/ms9282/get_bus_conf.c3
-rw-r--r--src/mainboard/msi/ms9282/resourcemap.c2
-rw-r--r--src/mainboard/newisys/khepri/auto.c3
-rw-r--r--src/mainboard/newisys/khepri/resourcemap.c2
-rw-r--r--src/mainboard/nvidia/l1_2pvv/get_bus_conf.c3
-rw-r--r--src/mainboard/nvidia/l1_2pvv/resourcemap.c2
-rw-r--r--src/mainboard/sunw/ultra40/auto.c3
-rw-r--r--src/mainboard/sunw/ultra40/get_bus_conf.c3
-rw-r--r--src/mainboard/sunw/ultra40/resourcemap.c2
-rw-r--r--src/mainboard/supermicro/h8dmr/get_bus_conf.c3
-rw-r--r--src/mainboard/supermicro/h8dmr/resourcemap.c2
-rw-r--r--src/mainboard/supermicro/x6dai_g/auto.c3
-rw-r--r--src/mainboard/supermicro/x6dhe_g/auto.c3
-rw-r--r--src/mainboard/supermicro/x6dhe_g2/auto.c3
-rw-r--r--src/mainboard/supermicro/x6dhe_g2/auto.updated.c3
-rw-r--r--src/mainboard/supermicro/x6dhr_ig/auto.c3
-rw-r--r--src/mainboard/supermicro/x6dhr_ig2/auto.c3
-rw-r--r--src/mainboard/tyan/s1846/auto.c3
-rw-r--r--src/mainboard/tyan/s2735/auto.c3
-rw-r--r--src/mainboard/tyan/s2850/auto.c3
-rw-r--r--src/mainboard/tyan/s2850/cache_as_ram_auto.c3
-rw-r--r--src/mainboard/tyan/s2875/auto.c3
-rw-r--r--src/mainboard/tyan/s2875/cache_as_ram_auto.c3
-rw-r--r--src/mainboard/tyan/s2880/cache_as_ram_auto.c3
-rw-r--r--src/mainboard/tyan/s2881/auto.c3
-rw-r--r--src/mainboard/tyan/s2881/get_bus_conf.c3
-rw-r--r--src/mainboard/tyan/s2881/resourcemap.c2
-rw-r--r--src/mainboard/tyan/s2882/auto.c3
-rw-r--r--src/mainboard/tyan/s2882/cache_as_ram_auto.c3
-rw-r--r--src/mainboard/tyan/s2885/auto.c3
-rw-r--r--src/mainboard/tyan/s2885/get_bus_conf.c3
-rw-r--r--src/mainboard/tyan/s2885/resourcemap.c2
-rw-r--r--src/mainboard/tyan/s2891/auto.c3
-rw-r--r--src/mainboard/tyan/s2891/get_bus_conf.c3
-rw-r--r--src/mainboard/tyan/s2891/resourcemap.c2
-rw-r--r--src/mainboard/tyan/s2892/auto.c3
-rw-r--r--src/mainboard/tyan/s2892/get_bus_conf.c3
-rw-r--r--src/mainboard/tyan/s2892/resourcemap.c2
-rw-r--r--src/mainboard/tyan/s2895/auto.c3
-rw-r--r--src/mainboard/tyan/s2895/get_bus_conf.c3
-rw-r--r--src/mainboard/tyan/s2895/resourcemap.c2
-rw-r--r--src/mainboard/tyan/s2912/get_bus_conf.c3
-rw-r--r--src/mainboard/tyan/s2912/resourcemap.c2
-rw-r--r--src/mainboard/tyan/s2912_fam10/get_bus_conf.c3
-rw-r--r--src/mainboard/tyan/s2912_fam10/resourcemap.c2
-rw-r--r--src/mainboard/tyan/s4880/auto.c3
-rw-r--r--src/mainboard/tyan/s4880/cache_as_ram_auto.c3
-rw-r--r--src/mainboard/tyan/s4880/resourcemap.c2
-rw-r--r--src/mainboard/tyan/s4882/auto.c3
-rw-r--r--src/mainboard/tyan/s4882/resourcemap.c2
-rw-r--r--src/mainboard/via/epia-m/auto.c3
-rw-r--r--src/mainboard/via/epia/auto.c5
-rw-r--r--src/northbridge/amd/amdfam10/resourcemap.c2
-rw-r--r--src/northbridge/amd/amdk8/coherent_ht.c33
-rw-r--r--src/northbridge/amd/amdk8/raminit.c5
-rw-r--r--src/northbridge/amd/amdk8/raminit_f.c5
-rw-r--r--src/northbridge/amd/amdk8/raminit_test.c3
-rw-r--r--src/northbridge/amd/amdk8/resourcemap.c2
-rw-r--r--src/northbridge/amd/gx2/chipsetinit.c2
-rw-r--r--src/northbridge/intel/e7501/raminit.c3
-rw-r--r--src/northbridge/intel/e7520/raminit.c3
-rw-r--r--src/northbridge/intel/e7520/raminit_test.c3
-rw-r--r--src/northbridge/intel/e7525/raminit.c3
-rw-r--r--src/northbridge/intel/e7525/raminit_test.c3
-rw-r--r--src/northbridge/intel/i3100/raminit.c3
-rw-r--r--src/northbridge/intel/i440bx/raminit.c3
-rw-r--r--src/northbridge/intel/i855pm/raminit.c2
-rw-r--r--src/northbridge/via/vt8601/northbridge.c2
-rw-r--r--src/northbridge/via/vt8623/northbridge.c2
-rw-r--r--src/southbridge/amd/amd8111/amd8111_lpc.c3
-rw-r--r--src/southbridge/amd/cs5536/cs5536.c3
-rw-r--r--src/southbridge/amd/sb600/sb600_sm.c3
-rw-r--r--src/southbridge/nvidia/ck804/ck804_early_setup.c6
-rw-r--r--src/southbridge/nvidia/ck804/ck804_early_setup_car.c12
-rw-r--r--src/southbridge/nvidia/ck804/ck804_lpc.c3
-rw-r--r--src/southbridge/nvidia/mcp55/mcp55_early_setup_car.c14
-rw-r--r--src/southbridge/nvidia/mcp55/mcp55_lpc.c3
-rw-r--r--src/southbridge/sis/sis966/sis966_lpc.c3
-rw-r--r--src/stream/fs/vfs.c2
-rw-r--r--src/superio/ite/it8661f/superio.c3
-rw-r--r--src/superio/ite/it8671f/superio.c3
-rw-r--r--src/superio/ite/it8673f/superio.c3
-rw-r--r--src/superio/ite/it8705f/superio.c3
-rw-r--r--src/superio/ite/it8712f/superio.c3
-rw-r--r--src/superio/ite/it8716f/superio.c3
-rw-r--r--src/superio/ite/it8718f/superio.c3
-rw-r--r--src/superio/nsc/pc8374/superio.c3
-rw-r--r--src/superio/nsc/pc87309/superio.c3
-rw-r--r--src/superio/nsc/pc87351/superio.c3
-rw-r--r--src/superio/nsc/pc87360/superio.c3
-rw-r--r--src/superio/nsc/pc87366/superio.c3
-rw-r--r--src/superio/nsc/pc87417/superio.c3
-rw-r--r--src/superio/nsc/pc87427/superio.c3
-rw-r--r--src/superio/nsc/pc97307/superio.c3
-rw-r--r--src/superio/nsc/pc97317/superio.c3
-rw-r--r--src/superio/smsc/fdc37m60x/superio.c3
-rw-r--r--src/superio/smsc/lpc47b272/superio.c3
-rw-r--r--src/superio/smsc/lpc47b397/superio.c3
-rw-r--r--src/superio/smsc/lpc47m10x/superio.c3
-rw-r--r--src/superio/smsc/lpc47n217/superio.c3
-rw-r--r--src/superio/via/vt1211/vt1211.c3
-rw-r--r--src/superio/winbond/w83627ehg/superio.c5
-rw-r--r--src/superio/winbond/w83627hf/superio.c5
-rw-r--r--src/superio/winbond/w83627thf/superio.c3
-rw-r--r--src/superio/winbond/w83977f/superio.c3
-rw-r--r--src/superio/winbond/w83977tf/superio.c3
166 files changed, 326 insertions, 208 deletions
diff --git a/src/arch/i386/boot/acpi.c b/src/arch/i386/boot/acpi.c
index 46e3291641..a4d17c05bc 100644
--- a/src/arch/i386/boot/acpi.c
+++ b/src/arch/i386/boot/acpi.c
@@ -44,7 +44,7 @@ void acpi_add_table(acpi_rsdt_t *rsdt, void *table)
{
int i;
- int entries_num = sizeof(rsdt->entry)/sizeof(rsdt->entry[0]);
+ int entries_num = ARRAY_SIZE(rsdt->entry);
for (i=0; i<entries_num; i++) {
if(rsdt->entry[i]==0) {
diff --git a/src/arch/i386/boot/coreboot_table.c b/src/arch/i386/boot/coreboot_table.c
index 86cb9a388b..427b978d96 100644
--- a/src/arch/i386/boot/coreboot_table.c
+++ b/src/arch/i386/boot/coreboot_table.c
@@ -184,7 +184,7 @@ void lb_strings(struct lb_header *header)
{ LB_TAG_ASSEMBLER, coreboot_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);
diff --git a/src/arch/i386/lib/cpu.c b/src/arch/i386/lib/cpu.c
index c1b2e5fbf1..6deb1f9393 100644
--- a/src/arch/i386/lib/cpu.c
+++ b/src/arch/i386/lib/cpu.c
@@ -123,7 +123,7 @@ static const char *cpu_vendor_name(int vendor)
{
const char *name;
name = "<invalid cpu vendor>";
- if ((vendor < (sizeof(x86_vendor_name)/sizeof(x86_vendor_name[0]))) &&
+ if ((vendor < (ARRAY_SIZE(x86_vendor_name))) &&
(x86_vendor_name[vendor] != 0))
{
name = x86_vendor_name[vendor];
@@ -185,7 +185,7 @@ static void identify_cpu(struct device *cpu)
}
}
cpu->vendor = X86_VENDOR_UNKNOWN;
- for(i = 0; i < sizeof(x86_vendors)/sizeof(x86_vendors[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(x86_vendors); i++) {
if (memcmp(vendor_name, x86_vendors[i].name, 12) == 0) {
cpu->vendor = x86_vendors[i].vendor;
break;
diff --git a/src/arch/i386/lib/exception.c b/src/arch/i386/lib/exception.c
index 5f0c4e0563..2d68b918ed 100644
--- a/src/arch/i386/lib/exception.c
+++ b/src/arch/i386/lib/exception.c
@@ -377,7 +377,7 @@ void x86_exception(struct eregs *info)
gdb_stub_registers[CS] = info->cs;
gdb_stub_registers[PS] = info->eflags;
signo = GDB_UNKNOWN;
- if (info->vector < sizeof(exception_to_signal)/sizeof(exception_to_signal[0])) {
+ if (info->vector < ARRAY_SIZE(exception_to_signal)) {
signo = exception_to_signal[info->vector];
}
diff --git a/src/arch/i386/smp/ioapic.c b/src/arch/i386/smp/ioapic.c
index 87d9a46560..4e72f46f03 100644
--- a/src/arch/i386/smp/ioapic.c
+++ b/src/arch/i386/smp/ioapic.c
@@ -67,7 +67,7 @@ void setup_ioapic(void)
l[0] = 0x03;
l[4] = 1;
#endif /* i786 */
- for (i = 0; i < sizeof(ioapicregvalues) / sizeof(ioapicregvalues[0]);
+ for (i = 0; i < ARRAY_SIZE(ioapicregvalues);
i++, a++) {
l[0] = (a->reg * 2) + 0x10;
l[4] = a->value_low;
diff --git a/src/arch/ppc/boot/coreboot_table.c b/src/arch/ppc/boot/coreboot_table.c
index ea6b683dbc..b1420a7491 100644
--- a/src/arch/ppc/boot/coreboot_table.c
+++ b/src/arch/ppc/boot/coreboot_table.c
@@ -116,7 +116,7 @@ void lb_strings(struct lb_header *header)
{ LB_TAG_ASSEMBLER, coreboot_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);
diff --git a/src/cpu/amd/model_10xxx/init_cpus.c b/src/cpu/amd/model_10xxx/init_cpus.c
index 63859b004b..2b08b61791 100644
--- a/src/cpu/amd/model_10xxx/init_cpus.c
+++ b/src/cpu/amd/model_10xxx/init_cpus.c
@@ -522,7 +522,7 @@ static void setup_remote_node(u8 node)
printk_debug("setup_remote_node: %02x", node);
/* copy the default resource map from node 0 */
- for(i = 0; i < sizeof(pci_reg)/sizeof(pci_reg[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(pci_reg); i++) {
u32 value;
u16 reg;
reg = pci_reg[i];
@@ -852,7 +852,7 @@ void cpuSetAMDMSR(void)
revision = mctGetLogicalCPUID(0xFF);
platform = get_platform_type();
- for(i = 0; i < sizeof(fam10_msr_default)/sizeof(fam10_msr_default[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(fam10_msr_default); i++) {
if ((fam10_msr_default[i].revision & revision) &&
(fam10_msr_default[i].platform & platform)) {
msr = rdmsr(fam10_msr_default[i].msr);
@@ -889,7 +889,7 @@ void cpuSetAMDPCI(u8 node)
AMD_SetupPSIVID_d(platform, node); /* Set PSIVID offset which is not table driven */
- for(i = 0; i < sizeof(fam10_pci_default)/sizeof(fam10_pci_default[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(fam10_pci_default); i++) {
if ((fam10_pci_default[i].revision & revision) &&
(fam10_pci_default[i].platform & platform)) {
val = pci_read_config32(NODE_PCI(node,
@@ -903,7 +903,7 @@ void cpuSetAMDPCI(u8 node)
}
}
- for(i = 0; i < sizeof(fam10_htphy_default)/sizeof(fam10_htphy_default[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(fam10_htphy_default); i++) {
if ((fam10_htphy_default[i].revision & revision) &&
(fam10_htphy_default[i].platform & platform)) {
/* HT Phy settings either apply to both sublinks or have
diff --git a/src/cpu/amd/sc520/sc520.c b/src/cpu/amd/sc520/sc520.c
index 2ec3f5a47e..fef3c7f0ab 100644
--- a/src/cpu/amd/sc520/sc520.c
+++ b/src/cpu/amd/sc520/sc520.c
@@ -151,7 +151,7 @@ static void pci_domain_set_resources(device_t dev)
// int i;
int idx;
#if 0
- for(rambits = 0, i = 0; i < sizeof(ramregs)/sizeof(ramregs[0]); i++) {
+ for(rambits = 0, i = 0; i < ARRAY_SIZE(ramregs); i++) {
unsigned char reg;
reg = pci_read_config8(mc_dev, ramregs[i]);
/* these are ENDING addresses, not sizes.
diff --git a/src/cpu/emulation/qemu-x86/northbridge.c b/src/cpu/emulation/qemu-x86/northbridge.c
index ada22fe982..f005fab852 100644
--- a/src/cpu/emulation/qemu-x86/northbridge.c
+++ b/src/cpu/emulation/qemu-x86/northbridge.c
@@ -80,7 +80,7 @@ static void pci_domain_set_resources(device_t dev)
unsigned char rambits;
int i, idx;
- for(rambits = 0, i = 0; i < sizeof(ramregs)/sizeof(ramregs[0]); i++) {
+ for(rambits = 0, i = 0; i < ARRAY_SIZE(ramregs); i++) {
unsigned char reg;
reg = pci_read_config8(mc_dev, ramregs[i]);
/* these are ENDING addresses, not sizes.
diff --git a/src/drivers/ati/ragexl/xlinit.c b/src/drivers/ati/ragexl/xlinit.c
index 4a0f8b38e3..74a301fc5a 100644
--- a/src/drivers/ati/ragexl/xlinit.c
+++ b/src/drivers/ati/ragexl/xlinit.c
@@ -281,7 +281,7 @@ static int atyfb_xl_init(struct fb_info_aty *info)
aty_st_le32(0xEC, 0x00000000, info);
aty_st_le32(0xFC, 0x00000000, info);
- for (i=0; i<sizeof(lcd_tbl)/sizeof(lcd_tbl_t); i++) {
+ for (i=0; i<ARRAY_SIZE(lcd_tbl); i++) {
aty_st_lcd(lcd_tbl[i].lcd_reg, lcd_tbl[i].val, info);
}
@@ -547,7 +547,7 @@ static void ati_ragexl_init(device_t dev)
chip_id = aty_ld_le32(CONFIG_CHIP_ID, info);
type = chip_id & CFG_CHIP_TYPE;
rev = (chip_id & CFG_CHIP_REV)>>24;
- for (j = 0; j < (sizeof(aty_chips)/sizeof(*aty_chips)); j++)
+ for (j = 0; j < ARRAY_SIZE(aty_chips); j++)
if (type == aty_chips[j].chip_type &&
(rev & aty_chips[j].rev_mask) == aty_chips[j].rev_val) {
chipname = aty_chips[j].name;
diff --git a/src/mainboard/a-trend/atc-6220/auto.c b/src/mainboard/a-trend/atc-6220/auto.c
index ab12ab6abe..22ac2027d9 100644
--- a/src/mainboard/a-trend/atc-6220/auto.c
+++ b/src/mainboard/a-trend/atc-6220/auto.c
@@ -26,6 +26,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -67,6 +68,6 @@ static void main(unsigned long bist)
report_bist_failure(bist);
enable_smbus();
/* dump_spd_registers(&memctrl[0]); */
- sdram_initialize(sizeof(memctrl) / sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
/* ram_check(0, 640 * 1024); */
}
diff --git a/src/mainboard/agami/aruma/auto.c b/src/mainboard/agami/aruma/auto.c
index 48f83faadf..51954a9951 100644
--- a/src/mainboard/agami/aruma/auto.c
+++ b/src/mainboard/agami/aruma/auto.c
@@ -6,6 +6,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -171,7 +172,7 @@ static void main(unsigned long bist)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
#if 0
/* Check the first 1M */
diff --git a/src/mainboard/agami/aruma/get_bus_conf.c b/src/mainboard/agami/aruma/get_bus_conf.c
index 3a08b7ac8d..b224aa8945 100644
--- a/src/mainboard/agami/aruma/get_bus_conf.c
+++ b/src/mainboard/agami/aruma/get_bus_conf.c
@@ -3,6 +3,7 @@
#include <device/pci_ids.h>
#include <string.h>
#include <stdint.h>
+#include <stdlib.h>
#if CONFIG_LOGICAL_CPUS==1
#include <cpu/amd/dualcore.h>
#endif
@@ -62,7 +63,7 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- hc_possible_num = sizeof(pci1234) / sizeof(pci1234[0]);
+ hc_possible_num = ARRAY_SIZE(pci1234);
get_sblk_pci1234();
diff --git a/src/mainboard/agami/aruma/resourcemap.c b/src/mainboard/agami/aruma/resourcemap.c
index 0bd40c4662..a9ae3b4068 100644
--- a/src/mainboard/agami/aruma/resourcemap.c
+++ b/src/mainboard/agami/aruma/resourcemap.c
@@ -265,7 +265,7 @@ static void setup_aruma_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/amd/dbm690t/get_bus_conf.c b/src/mainboard/amd/dbm690t/get_bus_conf.c
index e94fdc3015..b776e21113 100644
--- a/src/mainboard/amd/dbm690t/get_bus_conf.c
+++ b/src/mainboard/amd/dbm690t/get_bus_conf.c
@@ -22,6 +22,7 @@
#include <device/pci_ids.h>
#include <string.h>
#include <stdint.h>
+#include <stdlib.h>
#if CONFIG_LOGICAL_CPUS==1
#include <cpu/amd/dualcore.h>
#endif
@@ -72,7 +73,7 @@ void get_bus_conf(void)
return; /* do it only once */
get_bus_conf_done = 1;
- sysconf.hc_possible_num = sizeof(pci1234x) / sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for (i = 0; i < sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/amd/dbm690t/resourcemap.c b/src/mainboard/amd/dbm690t/resourcemap.c
index 3664947052..d79e99f488 100644
--- a/src/mainboard/amd/dbm690t/resourcemap.c
+++ b/src/mainboard/amd/dbm690t/resourcemap.c
@@ -273,6 +273,6 @@ static void setup_dbm690t_resource_map(void)
};
int max;
- max = sizeof(register_values) / sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/amd/serengeti_cheetah/get_bus_conf.c b/src/mainboard/amd/serengeti_cheetah/get_bus_conf.c
index d76b1ef2b9..f1b374ae95 100644
--- a/src/mainboard/amd/serengeti_cheetah/get_bus_conf.c
+++ b/src/mainboard/amd/serengeti_cheetah/get_bus_conf.c
@@ -9,6 +9,7 @@
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
#include "mb_sysconf.h"
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -90,7 +91,7 @@ void get_bus_conf(void)
m = sysconf.mb;
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/amd/serengeti_cheetah/resourcemap.c b/src/mainboard/amd/serengeti_cheetah/resourcemap.c
index e5fc91b30e..9b19503360 100644
--- a/src/mainboard/amd/serengeti_cheetah/resourcemap.c
+++ b/src/mainboard/amd/serengeti_cheetah/resourcemap.c
@@ -258,7 +258,7 @@ static void setup_mb_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/amd/serengeti_cheetah_fam10/get_bus_conf.c b/src/mainboard/amd/serengeti_cheetah_fam10/get_bus_conf.c
index 68b9964edd..0eae634fd1 100644
--- a/src/mainboard/amd/serengeti_cheetah_fam10/get_bus_conf.c
+++ b/src/mainboard/amd/serengeti_cheetah_fam10/get_bus_conf.c
@@ -28,6 +28,7 @@
#include <cpu/amd/amdfam10_sysconf.h>
+#include <stdlib.h>
#include "mb_sysconf.h"
/* Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables */
@@ -111,7 +112,7 @@ void get_bus_conf(void)
m->bus_type[i] = 0;
}
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/amd/serengeti_cheetah_fam10/resourcemap.c b/src/mainboard/amd/serengeti_cheetah_fam10/resourcemap.c
index bfc03618b8..04698d7369 100644
--- a/src/mainboard/amd/serengeti_cheetah_fam10/resourcemap.c
+++ b/src/mainboard/amd/serengeti_cheetah_fam10/resourcemap.c
@@ -275,7 +275,7 @@ static void setup_mb_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/arima/hdama/auto.c b/src/mainboard/arima/hdama/auto.c
index b37469d65b..f1046a24fa 100644
--- a/src/mainboard/arima/hdama/auto.c
+++ b/src/mainboard/arima/hdama/auto.c
@@ -6,6 +6,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -157,11 +158,11 @@ static void main(unsigned long bist)
#endif
enable_smbus();
#if 0
- dump_spd_registers(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ dump_spd_registers(ARRAY_SIZE(cpu), cpu);
#endif
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
#if 0
dump_pci_devices();
diff --git a/src/mainboard/arima/hdama/cache_as_ram_auto.c b/src/mainboard/arima/hdama/cache_as_ram_auto.c
index 9100d6b510..438bc306bc 100644
--- a/src/mainboard/arima/hdama/cache_as_ram_auto.c
+++ b/src/mainboard/arima/hdama/cache_as_ram_auto.c
@@ -7,6 +7,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -215,7 +216,7 @@ void real_main(unsigned long bist, unsigned long cpu_init_detectedx)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
post_cache_as_ram();
diff --git a/src/mainboard/artecgroup/dbe61/cache_as_ram_auto.c b/src/mainboard/artecgroup/dbe61/cache_as_ram_auto.c
index 29f4a4cd7b..adfe71b336 100644
--- a/src/mainboard/artecgroup/dbe61/cache_as_ram_auto.c
+++ b/src/mainboard/artecgroup/dbe61/cache_as_ram_auto.c
@@ -26,6 +26,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -51,7 +52,7 @@ static int spd_read_byte(unsigned device, unsigned address)
int i;
if (device == DIMM0){
- for (i=0; i < (sizeof spd_table/sizeof spd_table[0]); i++){
+ for (i=0; i < (ARRAY_SIZE(spd_table)); i++){
if (spd_table[i].address == address){
return spd_table[i].data;
}
diff --git a/src/mainboard/asus/a8n_e/get_bus_conf.c b/src/mainboard/asus/a8n_e/get_bus_conf.c
index 141bd50402..8e4edb4750 100644
--- a/src/mainboard/asus/a8n_e/get_bus_conf.c
+++ b/src/mainboard/asus/a8n_e/get_bus_conf.c
@@ -31,6 +31,7 @@
#include <cpu/amd/dualcore.h>
#endif
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
/*
* Global variables for MB layouts and these will be shared by irqtable,
diff --git a/src/mainboard/asus/mew-vm/auto.c b/src/mainboard/asus/mew-vm/auto.c
index 406844ce0b..133b399de2 100644
--- a/src/mainboard/asus/mew-vm/auto.c
+++ b/src/mainboard/asus/mew-vm/auto.c
@@ -26,6 +26,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -77,7 +78,7 @@ static void main(unsigned long bist)
/* dump_spd_registers(&memctrl[0]); */
/* sdram_initialize() runs out of registers. */
- /* sdram_initialize(sizeof(memctrl) / sizeof(memctrl[0]), memctrl); */
+ /* sdram_initialize(ARRAY_SIZE(memctrl), memctrl); */
sdram_set_registers(memctrl);
sdram_set_spd_registers(memctrl);
diff --git a/src/mainboard/asus/p2b-f/auto.c b/src/mainboard/asus/p2b-f/auto.c
index ac69617108..acb3c2fb9f 100644
--- a/src/mainboard/asus/p2b-f/auto.c
+++ b/src/mainboard/asus/p2b-f/auto.c
@@ -26,6 +26,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -70,6 +71,6 @@ static void main(unsigned long bist)
report_bist_failure(bist);
enable_smbus();
/* dump_spd_registers(&memctrl[0]); */
- sdram_initialize(sizeof(memctrl) / sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
/* ram_check(0, 640 * 1024); */
}
diff --git a/src/mainboard/asus/p2b/auto.c b/src/mainboard/asus/p2b/auto.c
index ab12ab6abe..22ac2027d9 100644
--- a/src/mainboard/asus/p2b/auto.c
+++ b/src/mainboard/asus/p2b/auto.c
@@ -26,6 +26,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -67,6 +68,6 @@ static void main(unsigned long bist)
report_bist_failure(bist);
enable_smbus();
/* dump_spd_registers(&memctrl[0]); */
- sdram_initialize(sizeof(memctrl) / sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
/* ram_check(0, 640 * 1024); */
}
diff --git a/src/mainboard/asus/p3b-f/auto.c b/src/mainboard/asus/p3b-f/auto.c
index 5c313d1ab5..5de70fb521 100644
--- a/src/mainboard/asus/p3b-f/auto.c
+++ b/src/mainboard/asus/p3b-f/auto.c
@@ -26,6 +26,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -70,6 +71,6 @@ static void main(unsigned long bist)
report_bist_failure(bist);
enable_smbus();
/* dump_spd_registers(&memctrl[0]); */
- sdram_initialize(sizeof(memctrl) / sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
/* ram_check(0, 640 * 1024); */
}
diff --git a/src/mainboard/azza/pt-6ibd/auto.c b/src/mainboard/azza/pt-6ibd/auto.c
index 02a80f65ca..4d9f8f787a 100644
--- a/src/mainboard/azza/pt-6ibd/auto.c
+++ b/src/mainboard/azza/pt-6ibd/auto.c
@@ -26,6 +26,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -70,6 +71,6 @@ static void main(unsigned long bist)
report_bist_failure(bist);
enable_smbus();
/* dump_spd_registers(&memctrl[0]); */
- sdram_initialize(sizeof(memctrl) / sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
/* ram_check(0, 640 * 1024); */
}
diff --git a/src/mainboard/biostar/m6tba/auto.c b/src/mainboard/biostar/m6tba/auto.c
index fb4084d131..48e41f8f9f 100644
--- a/src/mainboard/biostar/m6tba/auto.c
+++ b/src/mainboard/biostar/m6tba/auto.c
@@ -26,6 +26,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -67,6 +68,6 @@ static void main(unsigned long bist)
report_bist_failure(bist);
enable_smbus();
/* dump_spd_registers(&memctrl[0]); */
- sdram_initialize(sizeof(memctrl) / sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
/* ram_check(0, 640 * 1024); */
}
diff --git a/src/mainboard/broadcom/blast/get_bus_conf.c b/src/mainboard/broadcom/blast/get_bus_conf.c
index 95f9d12175..b11d940399 100644
--- a/src/mainboard/broadcom/blast/get_bus_conf.c
+++ b/src/mainboard/broadcom/blast/get_bus_conf.c
@@ -8,6 +8,7 @@
#endif
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -61,7 +62,7 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/broadcom/blast/resourcemap.c b/src/mainboard/broadcom/blast/resourcemap.c
index 308b15d6e7..438605c701 100644
--- a/src/mainboard/broadcom/blast/resourcemap.c
+++ b/src/mainboard/broadcom/blast/resourcemap.c
@@ -259,7 +259,7 @@ static void setup_blast_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/compaq/deskpro_en_sff_p600/auto.c b/src/mainboard/compaq/deskpro_en_sff_p600/auto.c
index 71dee2c3e0..658151a86c 100644
--- a/src/mainboard/compaq/deskpro_en_sff_p600/auto.c
+++ b/src/mainboard/compaq/deskpro_en_sff_p600/auto.c
@@ -26,6 +26,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -70,6 +71,6 @@ static void main(unsigned long bist)
report_bist_failure(bist);
enable_smbus();
/* dump_spd_registers(&memctrl[0]); */
- sdram_initialize(sizeof(memctrl) / sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
/* ram_check(0, 640 * 1024); */
}
diff --git a/src/mainboard/dell/s1850/auto.c b/src/mainboard/dell/s1850/auto.c
index 78406138cb..627acb4ca5 100644
--- a/src/mainboard/dell/s1850/auto.c
+++ b/src/mainboard/dell/s1850/auto.c
@@ -5,6 +5,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -139,7 +140,7 @@ static void main(unsigned long bist)
// dump_ipmi_registers();
mainboard_set_e7520_leds();
// memreset_setup();
- sdram_initialize(sizeof(mch)/sizeof(mch[0]), mch);
+ sdram_initialize(ARRAY_SIZE(mch), mch);
#if 0
dump_pci_devices();
#endif
diff --git a/src/mainboard/digitallogic/adl855pc/auto.c b/src/mainboard/digitallogic/adl855pc/auto.c
index f1e831e947..04cf2a359f 100644
--- a/src/mainboard/digitallogic/adl855pc/auto.c
+++ b/src/mainboard/digitallogic/adl855pc/auto.c
@@ -10,6 +10,7 @@
#endif
#include <arch/hlt.h>
//#include "option_table.h"
+#include <stdlib.h>
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
@@ -100,7 +101,7 @@ static void main(unsigned long bist)
memreset_setup();
- sdram_initialize(sizeof(memctrl)/sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
}
#if 0
diff --git a/src/mainboard/eaglelion/5bcm/auto.c b/src/mainboard/eaglelion/5bcm/auto.c
index 9c08077388..ba7f77fcba 100644
--- a/src/mainboard/eaglelion/5bcm/auto.c
+++ b/src/mainboard/eaglelion/5bcm/auto.c
@@ -6,6 +6,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -48,7 +49,7 @@ static void main(unsigned long bist)
#endif
};
int i;
- for(i = 0; i < sizeof(check_addrs)/sizeof(check_addrs[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(check_addrs); i++) {
ram_check(check_addrs[i].lo, check_addrs[i].hi);
}
#endif
diff --git a/src/mainboard/gigabyte/ga-6bxc/auto.c b/src/mainboard/gigabyte/ga-6bxc/auto.c
index 0dd1129757..bfef2cc43e 100644
--- a/src/mainboard/gigabyte/ga-6bxc/auto.c
+++ b/src/mainboard/gigabyte/ga-6bxc/auto.c
@@ -26,6 +26,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -67,6 +68,6 @@ static void main(unsigned long bist)
report_bist_failure(bist);
enable_smbus();
/* dump_spd_registers(&memctrl[0]); */
- sdram_initialize(sizeof(memctrl) / sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
/* ram_check(0, 640 * 1024); */
}
diff --git a/src/mainboard/gigabyte/ga_2761gxdk/get_bus_conf.c b/src/mainboard/gigabyte/ga_2761gxdk/get_bus_conf.c
index 5ae3875015..08171d36a6 100644
--- a/src/mainboard/gigabyte/ga_2761gxdk/get_bus_conf.c
+++ b/src/mainboard/gigabyte/ga_2761gxdk/get_bus_conf.c
@@ -31,6 +31,7 @@
#endif
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -82,7 +83,7 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/gigabyte/ga_2761gxdk/resourcemap.c b/src/mainboard/gigabyte/ga_2761gxdk/resourcemap.c
index 7754471e94..43ff3ed11a 100644
--- a/src/mainboard/gigabyte/ga_2761gxdk/resourcemap.c
+++ b/src/mainboard/gigabyte/ga_2761gxdk/resourcemap.c
@@ -277,7 +277,7 @@ static void setup_mb_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/gigabyte/m57sli/fanctl.c b/src/mainboard/gigabyte/m57sli/fanctl.c
index 952392d9ef..e411d8faee 100644
--- a/src/mainboard/gigabyte/m57sli/fanctl.c
+++ b/src/mainboard/gigabyte/m57sli/fanctl.c
@@ -1,4 +1,5 @@
#include <arch/io.h>
+#include <stdlib.h>
static void write_index(uint16_t port_base, uint8_t reg, uint8_t value)
{
@@ -67,15 +68,13 @@ static const struct {
{ 0x13, 0x77}
};
-#define ARRAYSIZE(x) sizeof x/sizeof *x
-
/*
* Called from superio.c
*/
void init_ec(uint16_t base)
{
int i;
- for (i=0; i<ARRAYSIZE(sequence); i++) {
+ for (i=0; i<ARRAY_SIZE(sequence); i++) {
write_index(base, sequence[i].index, sequence[i].value);
}
}
diff --git a/src/mainboard/gigabyte/m57sli/get_bus_conf.c b/src/mainboard/gigabyte/m57sli/get_bus_conf.c
index 5d8e1d4edf..7076960298 100644
--- a/src/mainboard/gigabyte/m57sli/get_bus_conf.c
+++ b/src/mainboard/gigabyte/m57sli/get_bus_conf.c
@@ -29,6 +29,7 @@
#endif
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -80,7 +81,7 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/gigabyte/m57sli/resourcemap.c b/src/mainboard/gigabyte/m57sli/resourcemap.c
index a85b2edb77..847cd86e65 100644
--- a/src/mainboard/gigabyte/m57sli/resourcemap.c
+++ b/src/mainboard/gigabyte/m57sli/resourcemap.c
@@ -277,7 +277,7 @@ static void setup_mb_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/ibm/e325/auto.c b/src/mainboard/ibm/e325/auto.c
index ee1ce0323c..e171775d89 100644
--- a/src/mainboard/ibm/e325/auto.c
+++ b/src/mainboard/ibm/e325/auto.c
@@ -8,6 +8,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -163,7 +164,7 @@ static void main(unsigned long bist)
#endif
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
#if 0
dump_pci_devices();
diff --git a/src/mainboard/ibm/e325/cache_as_ram_auto.c b/src/mainboard/ibm/e325/cache_as_ram_auto.c
index 718358b943..e2002afa3b 100644
--- a/src/mainboard/ibm/e325/cache_as_ram_auto.c
+++ b/src/mainboard/ibm/e325/cache_as_ram_auto.c
@@ -7,6 +7,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -211,7 +212,7 @@ void real_main(unsigned long bist, unsigned long cpu_init_detectedx)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
post_cache_as_ram();
diff --git a/src/mainboard/ibm/e325/resourcemap.c b/src/mainboard/ibm/e325/resourcemap.c
index 52e85d5995..b80347eb0c 100644
--- a/src/mainboard/ibm/e325/resourcemap.c
+++ b/src/mainboard/ibm/e325/resourcemap.c
@@ -266,6 +266,6 @@ static void setup_ibm_e325_resource_map(void)
PCI_ADDR(0, 0x18, 1, 0xec), 0x0000FC88, 0,
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/ibm/e326/auto.c b/src/mainboard/ibm/e326/auto.c
index 225b058b3b..f5c415d110 100644
--- a/src/mainboard/ibm/e326/auto.c
+++ b/src/mainboard/ibm/e326/auto.c
@@ -8,6 +8,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -163,7 +164,7 @@ static void main(unsigned long bist)
#endif
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
#if 0
dump_pci_devices();
diff --git a/src/mainboard/ibm/e326/cache_as_ram_auto.c b/src/mainboard/ibm/e326/cache_as_ram_auto.c
index 2f6a93adfe..0c6b9b0418 100644
--- a/src/mainboard/ibm/e326/cache_as_ram_auto.c
+++ b/src/mainboard/ibm/e326/cache_as_ram_auto.c
@@ -7,6 +7,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -211,7 +212,7 @@ void real_main(unsigned long bist, unsigned long cpu_init_detectedx)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
post_cache_as_ram();
diff --git a/src/mainboard/ibm/e326/resourcemap.c b/src/mainboard/ibm/e326/resourcemap.c
index 8a19d786b6..a37496879b 100644
--- a/src/mainboard/ibm/e326/resourcemap.c
+++ b/src/mainboard/ibm/e326/resourcemap.c
@@ -266,6 +266,6 @@ static void setup_ibm_e326_resource_map(void)
PCI_ADDR(0, 0x18, 1, 0xec), 0x0000FC88, 0,
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/intel/jarrell/auto.c b/src/mainboard/intel/jarrell/auto.c
index d5e68e2343..61b066adfd 100644
--- a/src/mainboard/intel/jarrell/auto.c
+++ b/src/mainboard/intel/jarrell/auto.c
@@ -5,6 +5,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -120,7 +121,7 @@ static void main(unsigned long bist)
power_down_reset_check();
// dump_ipmi_registers();
mainboard_set_e7520_leds();
- sdram_initialize(sizeof(mch)/sizeof(mch[0]), mch);
+ sdram_initialize(ARRAY_SIZE(mch), mch);
ich5_watchdog_on();
#if 0
dump_pci_devices();
diff --git a/src/mainboard/intel/xe7501devkit/auto.c b/src/mainboard/intel/xe7501devkit/auto.c
index 1bd83a3187..b106595803 100644
--- a/src/mainboard/intel/xe7501devkit/auto.c
+++ b/src/mainboard/intel/xe7501devkit/auto.c
@@ -7,6 +7,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -83,7 +84,7 @@ static void main(unsigned long bist)
// dump_smbus_registers();
// memreset_setup(); No-op for this chipset
- sdram_initialize(sizeof(memctrl)/sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
}
// NOTE: ROMCC dies with an internal compiler error
diff --git a/src/mainboard/iwill/dk8_htx/get_bus_conf.c b/src/mainboard/iwill/dk8_htx/get_bus_conf.c
index 305dd2996f..d49333c261 100644
--- a/src/mainboard/iwill/dk8_htx/get_bus_conf.c
+++ b/src/mainboard/iwill/dk8_htx/get_bus_conf.c
@@ -9,6 +9,7 @@
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
#include "mb_sysconf.h"
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -90,7 +91,7 @@ void get_bus_conf(void)
m = sysconf.mb;
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/iwill/dk8_htx/resourcemap.c b/src/mainboard/iwill/dk8_htx/resourcemap.c
index 56af68e446..992510215c 100644
--- a/src/mainboard/iwill/dk8_htx/resourcemap.c
+++ b/src/mainboard/iwill/dk8_htx/resourcemap.c
@@ -258,7 +258,7 @@ static void setup_mb_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/iwill/dk8s2/auto.c b/src/mainboard/iwill/dk8s2/auto.c
index a78b34f9f2..b302b79adc 100644
--- a/src/mainboard/iwill/dk8s2/auto.c
+++ b/src/mainboard/iwill/dk8s2/auto.c
@@ -6,6 +6,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -149,7 +150,7 @@ static void main(unsigned long bist)
#endif
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
#if 0
dump_pci_devices();
diff --git a/src/mainboard/iwill/dk8x/auto.c b/src/mainboard/iwill/dk8x/auto.c
index 4cdf57716e..2d4d6f4d15 100644
--- a/src/mainboard/iwill/dk8x/auto.c
+++ b/src/mainboard/iwill/dk8x/auto.c
@@ -6,6 +6,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -148,7 +149,7 @@ static void main(unsigned long bist)
#endif
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
#if 1
dump_pci_devices();
@@ -181,7 +182,7 @@ static void main(unsigned long bist)
#endif
};
int i;
- for(i = 0; i < sizeof(check_addrs)/sizeof(check_addrs[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(check_addrs); i++) {
ram_check(check_addrs[i].lo, check_addrs[i].hi);
}
#endif
diff --git a/src/mainboard/msi/ms6178/auto.c b/src/mainboard/msi/ms6178/auto.c
index 966eff5c26..0ae4e0a1b8 100644
--- a/src/mainboard/msi/ms6178/auto.c
+++ b/src/mainboard/msi/ms6178/auto.c
@@ -26,6 +26,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -65,6 +66,6 @@ static void main(unsigned long bist)
console_init();
report_bist_failure(bist);
/* dump_spd_registers(&memctrl[0]); */
- sdram_initialize(sizeof(memctrl) / sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
/* ram_check(0, 640 * 1024); */
}
diff --git a/src/mainboard/msi/ms7135/get_bus_conf.c b/src/mainboard/msi/ms7135/get_bus_conf.c
index e2f868e566..90fa084217 100644
--- a/src/mainboard/msi/ms7135/get_bus_conf.c
+++ b/src/mainboard/msi/ms7135/get_bus_conf.c
@@ -32,6 +32,7 @@
#endif
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
/* Global variables for MB layouts and these will be shared by irqtable,
* mptable and acpi_tables.
@@ -67,8 +68,8 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- sysconf.hc_possible_num = sizeof(pci1234x) / sizeof(pci1234x[0]);
- sysconf.hc_possible_num = sizeof(pci1234x) / sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for (i = 0; i < sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/msi/ms7260/get_bus_conf.c b/src/mainboard/msi/ms7260/get_bus_conf.c
index 19d80f536d..47273cdaa4 100644
--- a/src/mainboard/msi/ms7260/get_bus_conf.c
+++ b/src/mainboard/msi/ms7260/get_bus_conf.c
@@ -28,6 +28,7 @@
#include <cpu/amd/dualcore.h>
#endif
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
/* Global variables for MB layouts (shared by irqtable/mptable/acpi_table). */
// busnum is default.
@@ -81,7 +82,7 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- sysconf.hc_possible_num = sizeof(pci1234x) / sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for (i = 0; i < sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/msi/ms7260/resourcemap.c b/src/mainboard/msi/ms7260/resourcemap.c
index 5035ac815c..d72530a3ae 100644
--- a/src/mainboard/msi/ms7260/resourcemap.c
+++ b/src/mainboard/msi/ms7260/resourcemap.c
@@ -278,6 +278,6 @@ static void setup_mb_resource_map(void)
};
- int max = sizeof(register_values) / sizeof(register_values[0]);
+ int max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/msi/ms9185/get_bus_conf.c b/src/mainboard/msi/ms9185/get_bus_conf.c
index 05d8fede53..43cc42fe99 100644
--- a/src/mainboard/msi/ms9185/get_bus_conf.c
+++ b/src/mainboard/msi/ms9185/get_bus_conf.c
@@ -32,6 +32,7 @@
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
#include "mb_sysconf.h"
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -82,7 +83,7 @@ void get_bus_conf(void)
m = sysconf.mb;
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
diff --git a/src/mainboard/msi/ms9185/resourcemap.c b/src/mainboard/msi/ms9185/resourcemap.c
index cec820bb37..01bd1f3e71 100644
--- a/src/mainboard/msi/ms9185/resourcemap.c
+++ b/src/mainboard/msi/ms9185/resourcemap.c
@@ -285,7 +285,7 @@ static void setup_ms9185_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/msi/ms9282/get_bus_conf.c b/src/mainboard/msi/ms9282/get_bus_conf.c
index 1a4a40a319..ed5bde722e 100644
--- a/src/mainboard/msi/ms9282/get_bus_conf.c
+++ b/src/mainboard/msi/ms9282/get_bus_conf.c
@@ -33,6 +33,7 @@
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
#include "mb_sysconf.h"
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -110,7 +111,7 @@ void get_bus_conf(void)
m = sysconf.mb;
memset(m, 0, sizeof(struct mb_sysconf_t));
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/msi/ms9282/resourcemap.c b/src/mainboard/msi/ms9282/resourcemap.c
index 0106797433..2099b961be 100644
--- a/src/mainboard/msi/ms9282/resourcemap.c
+++ b/src/mainboard/msi/ms9282/resourcemap.c
@@ -293,7 +293,7 @@ static void setup_ms9282_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/newisys/khepri/auto.c b/src/mainboard/newisys/khepri/auto.c
index a608d3a1c7..6d0a7455fc 100644
--- a/src/mainboard/newisys/khepri/auto.c
+++ b/src/mainboard/newisys/khepri/auto.c
@@ -6,6 +6,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -138,7 +139,7 @@ static void main(unsigned long bist)
dump_spd_registers(&cpu[0]);
#endif
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
#if 0
dump_pci_devices();
diff --git a/src/mainboard/newisys/khepri/resourcemap.c b/src/mainboard/newisys/khepri/resourcemap.c
index dcf9b4c258..d533b6357e 100644
--- a/src/mainboard/newisys/khepri/resourcemap.c
+++ b/src/mainboard/newisys/khepri/resourcemap.c
@@ -265,7 +265,7 @@ static void setup_khepri_resource_map(void)
PCI_ADDR(0, 0x18, 1, 0xEC), 0x0000FC88, 0x00000000,
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/nvidia/l1_2pvv/get_bus_conf.c b/src/mainboard/nvidia/l1_2pvv/get_bus_conf.c
index 2dcf49321e..3a8ce918e6 100644
--- a/src/mainboard/nvidia/l1_2pvv/get_bus_conf.c
+++ b/src/mainboard/nvidia/l1_2pvv/get_bus_conf.c
@@ -30,6 +30,7 @@
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
#include "mb_sysconf.h"
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -108,7 +109,7 @@ void get_bus_conf(void)
m = sysconf.mb;
memset(m, 0, sizeof(struct mb_sysconf_t));
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for (i = 0; i < sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
diff --git a/src/mainboard/nvidia/l1_2pvv/resourcemap.c b/src/mainboard/nvidia/l1_2pvv/resourcemap.c
index 4801643c93..f289ce7898 100644
--- a/src/mainboard/nvidia/l1_2pvv/resourcemap.c
+++ b/src/mainboard/nvidia/l1_2pvv/resourcemap.c
@@ -277,7 +277,7 @@ static void setup_mb_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/sunw/ultra40/auto.c b/src/mainboard/sunw/ultra40/auto.c
index 5b96d78c0a..db3de9c934 100644
--- a/src/mainboard/sunw/ultra40/auto.c
+++ b/src/mainboard/sunw/ultra40/auto.c
@@ -7,6 +7,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -191,7 +192,7 @@ static void main(unsigned long bist)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
diff --git a/src/mainboard/sunw/ultra40/get_bus_conf.c b/src/mainboard/sunw/ultra40/get_bus_conf.c
index 3decafb71e..7af7491243 100644
--- a/src/mainboard/sunw/ultra40/get_bus_conf.c
+++ b/src/mainboard/sunw/ultra40/get_bus_conf.c
@@ -6,6 +6,7 @@
#if CONFIG_LOGICAL_CPUS==1
#include <cpu/amd/dualcore.h>
#endif
+#include <stdlib.h>
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -75,7 +76,7 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- hc_possible_num = sizeof(pci1234)/sizeof(pci1234[0]);
+ hc_possible_num = ARRAY_SIZE(pci1234);
get_sblk_pci1234();
diff --git a/src/mainboard/sunw/ultra40/resourcemap.c b/src/mainboard/sunw/ultra40/resourcemap.c
index 08a0443ebe..726373093f 100644
--- a/src/mainboard/sunw/ultra40/resourcemap.c
+++ b/src/mainboard/sunw/ultra40/resourcemap.c
@@ -260,7 +260,7 @@ static void setup_ultra40_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/supermicro/h8dmr/get_bus_conf.c b/src/mainboard/supermicro/h8dmr/get_bus_conf.c
index fd02ae8d0f..3402d9d5f6 100644
--- a/src/mainboard/supermicro/h8dmr/get_bus_conf.c
+++ b/src/mainboard/supermicro/h8dmr/get_bus_conf.c
@@ -29,6 +29,7 @@
#endif
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -81,7 +82,7 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/supermicro/h8dmr/resourcemap.c b/src/mainboard/supermicro/h8dmr/resourcemap.c
index 58c586a6c5..fa22ee337b 100644
--- a/src/mainboard/supermicro/h8dmr/resourcemap.c
+++ b/src/mainboard/supermicro/h8dmr/resourcemap.c
@@ -277,7 +277,7 @@ static void setup_mb_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/supermicro/x6dai_g/auto.c b/src/mainboard/supermicro/x6dai_g/auto.c
index 9c5fce59a3..078296df42 100644
--- a/src/mainboard/supermicro/x6dai_g/auto.c
+++ b/src/mainboard/supermicro/x6dai_g/auto.c
@@ -5,6 +5,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -113,7 +114,7 @@ static void main(unsigned long bist)
}
#endif
disable_watchdogs();
- sdram_initialize(sizeof(mch)/sizeof(mch[0]), mch);
+ sdram_initialize(ARRAY_SIZE(mch), mch);
#if 1
dump_pci_device(PCI_DEV(0, 0x00, 0));
// dump_bar14(PCI_DEV(0, 0x00, 0));
diff --git a/src/mainboard/supermicro/x6dhe_g/auto.c b/src/mainboard/supermicro/x6dhe_g/auto.c
index fd78ab43d3..da340b73eb 100644
--- a/src/mainboard/supermicro/x6dhe_g/auto.c
+++ b/src/mainboard/supermicro/x6dhe_g/auto.c
@@ -5,6 +5,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -138,7 +139,7 @@ static void main(unsigned long bist)
// dump_ipmi_registers();
// mainboard_set_e7520_leds();
// memreset_setup();
- sdram_initialize(sizeof(mch)/sizeof(mch[0]), mch);
+ sdram_initialize(ARRAY_SIZE(mch), mch);
#if 0
dump_pci_devices();
#endif
diff --git a/src/mainboard/supermicro/x6dhe_g2/auto.c b/src/mainboard/supermicro/x6dhe_g2/auto.c
index afd389c03e..0622ab7ade 100644
--- a/src/mainboard/supermicro/x6dhe_g2/auto.c
+++ b/src/mainboard/supermicro/x6dhe_g2/auto.c
@@ -5,6 +5,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -139,7 +140,7 @@ static void main(unsigned long bist)
// dump_ipmi_registers();
// mainboard_set_e7520_leds();
// memreset_setup();
- sdram_initialize(sizeof(mch)/sizeof(mch[0]), mch);
+ sdram_initialize(ARRAY_SIZE(mch), mch);
#if 0
dump_pci_devices();
#endif
diff --git a/src/mainboard/supermicro/x6dhe_g2/auto.updated.c b/src/mainboard/supermicro/x6dhe_g2/auto.updated.c
index 934cdb4d28..fcf8b76c19 100644
--- a/src/mainboard/supermicro/x6dhe_g2/auto.updated.c
+++ b/src/mainboard/supermicro/x6dhe_g2/auto.updated.c
@@ -5,6 +5,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -139,7 +140,7 @@ static void main(unsigned long bist)
// dump_ipmi_registers();
// mainboard_set_e7520_leds();
// memreset_setup();
- sdram_initialize(sizeof(mch)/sizeof(mch[0]), mch);
+ sdram_initialize(ARRAY_SIZE(mch), mch);
#if 0
dump_pci_devices();
#endif
diff --git a/src/mainboard/supermicro/x6dhr_ig/auto.c b/src/mainboard/supermicro/x6dhr_ig/auto.c
index 41e85991ec..92020189d2 100644
--- a/src/mainboard/supermicro/x6dhr_ig/auto.c
+++ b/src/mainboard/supermicro/x6dhr_ig/auto.c
@@ -5,6 +5,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -139,7 +140,7 @@ static void main(unsigned long bist)
// dump_ipmi_registers();
mainboard_set_e7520_leds();
// memreset_setup();
- sdram_initialize(sizeof(mch)/sizeof(mch[0]), mch);
+ sdram_initialize(ARRAY_SIZE(mch), mch);
#if 1
dump_pci_devices();
#endif
diff --git a/src/mainboard/supermicro/x6dhr_ig2/auto.c b/src/mainboard/supermicro/x6dhr_ig2/auto.c
index 70607d016b..7be6250650 100644
--- a/src/mainboard/supermicro/x6dhr_ig2/auto.c
+++ b/src/mainboard/supermicro/x6dhr_ig2/auto.c
@@ -5,6 +5,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -139,7 +140,7 @@ static void main(unsigned long bist)
// dump_ipmi_registers();
mainboard_set_e7520_leds();
// memreset_setup();
- sdram_initialize(sizeof(mch)/sizeof(mch[0]), mch);
+ sdram_initialize(ARRAY_SIZE(mch), mch);
#if 0
dump_pci_devices();
#endif
diff --git a/src/mainboard/tyan/s1846/auto.c b/src/mainboard/tyan/s1846/auto.c
index 8b884a02d3..d80e23d9a2 100644
--- a/src/mainboard/tyan/s1846/auto.c
+++ b/src/mainboard/tyan/s1846/auto.c
@@ -26,6 +26,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -67,6 +68,6 @@ static void main(unsigned long bist)
report_bist_failure(bist);
enable_smbus();
/* dump_spd_registers(&memctrl[0]); */
- sdram_initialize(sizeof(memctrl) / sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
/* ram_check(0, 640 * 1024); */
}
diff --git a/src/mainboard/tyan/s2735/auto.c b/src/mainboard/tyan/s2735/auto.c
index 9cf5e50187..456c342b62 100644
--- a/src/mainboard/tyan/s2735/auto.c
+++ b/src/mainboard/tyan/s2735/auto.c
@@ -7,6 +7,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -96,7 +97,7 @@ static void main(unsigned long bist)
#endif
memreset_setup();
- sdram_initialize(sizeof(memctrl)/sizeof(memctrl[0]), memctrl);
+ sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
}
#if 0
else {
diff --git a/src/mainboard/tyan/s2850/auto.c b/src/mainboard/tyan/s2850/auto.c
index e0d85dbd56..bec1afabbd 100644
--- a/src/mainboard/tyan/s2850/auto.c
+++ b/src/mainboard/tyan/s2850/auto.c
@@ -6,6 +6,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -197,6 +198,6 @@ static void main(unsigned long bist)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu) / sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
diff --git a/src/mainboard/tyan/s2850/cache_as_ram_auto.c b/src/mainboard/tyan/s2850/cache_as_ram_auto.c
index bd53a693fc..318903d227 100644
--- a/src/mainboard/tyan/s2850/cache_as_ram_auto.c
+++ b/src/mainboard/tyan/s2850/cache_as_ram_auto.c
@@ -7,6 +7,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -206,7 +207,7 @@ void real_main(unsigned long bist, unsigned long cpu_init_detectedx)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
post_cache_as_ram();
}
diff --git a/src/mainboard/tyan/s2875/auto.c b/src/mainboard/tyan/s2875/auto.c
index 3f23f5a237..e988a005e7 100644
--- a/src/mainboard/tyan/s2875/auto.c
+++ b/src/mainboard/tyan/s2875/auto.c
@@ -7,6 +7,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -167,6 +168,6 @@ static void main(unsigned long bist)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
diff --git a/src/mainboard/tyan/s2875/cache_as_ram_auto.c b/src/mainboard/tyan/s2875/cache_as_ram_auto.c
index e825c6ce6b..2611162714 100644
--- a/src/mainboard/tyan/s2875/cache_as_ram_auto.c
+++ b/src/mainboard/tyan/s2875/cache_as_ram_auto.c
@@ -7,6 +7,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -203,7 +204,7 @@ void real_main(unsigned long bist, unsigned long cpu_init_detectedx)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
post_cache_as_ram();
diff --git a/src/mainboard/tyan/s2880/cache_as_ram_auto.c b/src/mainboard/tyan/s2880/cache_as_ram_auto.c
index bb423673d8..de4b4895f8 100644
--- a/src/mainboard/tyan/s2880/cache_as_ram_auto.c
+++ b/src/mainboard/tyan/s2880/cache_as_ram_auto.c
@@ -7,6 +7,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -205,7 +206,7 @@ void real_main(unsigned long bist, unsigned long cpu_init_detectedx)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
post_cache_as_ram();
}
diff --git a/src/mainboard/tyan/s2881/auto.c b/src/mainboard/tyan/s2881/auto.c
index 924d7589b2..ea339fe5bd 100644
--- a/src/mainboard/tyan/s2881/auto.c
+++ b/src/mainboard/tyan/s2881/auto.c
@@ -7,6 +7,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -172,6 +173,6 @@ static void main(unsigned long bist)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
diff --git a/src/mainboard/tyan/s2881/get_bus_conf.c b/src/mainboard/tyan/s2881/get_bus_conf.c
index 82de11317b..d4c01675ab 100644
--- a/src/mainboard/tyan/s2881/get_bus_conf.c
+++ b/src/mainboard/tyan/s2881/get_bus_conf.c
@@ -8,6 +8,7 @@
#endif
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -63,7 +64,7 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/tyan/s2881/resourcemap.c b/src/mainboard/tyan/s2881/resourcemap.c
index 22723eafad..cecb790795 100644
--- a/src/mainboard/tyan/s2881/resourcemap.c
+++ b/src/mainboard/tyan/s2881/resourcemap.c
@@ -258,7 +258,7 @@ static void setup_s2881_resource_map(void)
PCI_ADDR(0, 0x18, 1, 0xEC), 0x0000FC88, 0x00000000,
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/tyan/s2882/auto.c b/src/mainboard/tyan/s2882/auto.c
index befd4da097..53b25a2c24 100644
--- a/src/mainboard/tyan/s2882/auto.c
+++ b/src/mainboard/tyan/s2882/auto.c
@@ -7,6 +7,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -176,6 +177,6 @@ static void main(unsigned long bist)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
diff --git a/src/mainboard/tyan/s2882/cache_as_ram_auto.c b/src/mainboard/tyan/s2882/cache_as_ram_auto.c
index dd3e6251e1..a4b894cd0d 100644
--- a/src/mainboard/tyan/s2882/cache_as_ram_auto.c
+++ b/src/mainboard/tyan/s2882/cache_as_ram_auto.c
@@ -7,6 +7,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -208,7 +209,7 @@ void real_main(unsigned long bist, unsigned long cpu_init_detectedx)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
post_cache_as_ram();
diff --git a/src/mainboard/tyan/s2885/auto.c b/src/mainboard/tyan/s2885/auto.c
index 7b892d0527..c926487d5a 100644
--- a/src/mainboard/tyan/s2885/auto.c
+++ b/src/mainboard/tyan/s2885/auto.c
@@ -6,6 +6,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -178,7 +179,7 @@ static void main(unsigned long bist)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
diff --git a/src/mainboard/tyan/s2885/get_bus_conf.c b/src/mainboard/tyan/s2885/get_bus_conf.c
index 68ed3d2e87..b50f671f9b 100644
--- a/src/mainboard/tyan/s2885/get_bus_conf.c
+++ b/src/mainboard/tyan/s2885/get_bus_conf.c
@@ -8,6 +8,7 @@
#endif
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
//busnum is default
@@ -65,7 +66,7 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/tyan/s2885/resourcemap.c b/src/mainboard/tyan/s2885/resourcemap.c
index bc2a8ba673..4a686020c8 100644
--- a/src/mainboard/tyan/s2885/resourcemap.c
+++ b/src/mainboard/tyan/s2885/resourcemap.c
@@ -259,7 +259,7 @@ static void setup_s2885_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/tyan/s2891/auto.c b/src/mainboard/tyan/s2891/auto.c
index e264f366b1..aab040f6d2 100644
--- a/src/mainboard/tyan/s2891/auto.c
+++ b/src/mainboard/tyan/s2891/auto.c
@@ -6,6 +6,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -145,6 +146,6 @@ static void main(unsigned long bist)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
diff --git a/src/mainboard/tyan/s2891/get_bus_conf.c b/src/mainboard/tyan/s2891/get_bus_conf.c
index 1f8c8fe244..779f8885d0 100644
--- a/src/mainboard/tyan/s2891/get_bus_conf.c
+++ b/src/mainboard/tyan/s2891/get_bus_conf.c
@@ -8,6 +8,7 @@
#endif
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
//busnum is default
@@ -71,7 +72,7 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/tyan/s2891/resourcemap.c b/src/mainboard/tyan/s2891/resourcemap.c
index 312ce03ad7..f7929b96c0 100644
--- a/src/mainboard/tyan/s2891/resourcemap.c
+++ b/src/mainboard/tyan/s2891/resourcemap.c
@@ -260,7 +260,7 @@ static void setup_s2891_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/tyan/s2892/auto.c b/src/mainboard/tyan/s2892/auto.c
index 3bd9209f09..bce2bbda4d 100644
--- a/src/mainboard/tyan/s2892/auto.c
+++ b/src/mainboard/tyan/s2892/auto.c
@@ -6,6 +6,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -147,6 +148,6 @@ static void main(unsigned long bist)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
diff --git a/src/mainboard/tyan/s2892/get_bus_conf.c b/src/mainboard/tyan/s2892/get_bus_conf.c
index 4f215ce9ae..4869b31c46 100644
--- a/src/mainboard/tyan/s2892/get_bus_conf.c
+++ b/src/mainboard/tyan/s2892/get_bus_conf.c
@@ -8,6 +8,7 @@
#endif
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
//busnum is default
@@ -68,7 +69,7 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/tyan/s2892/resourcemap.c b/src/mainboard/tyan/s2892/resourcemap.c
index 04d3f59edd..53482cc33e 100644
--- a/src/mainboard/tyan/s2892/resourcemap.c
+++ b/src/mainboard/tyan/s2892/resourcemap.c
@@ -260,7 +260,7 @@ static void setup_s2892_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/tyan/s2895/auto.c b/src/mainboard/tyan/s2895/auto.c
index a4b86627e1..6663f23f3b 100644
--- a/src/mainboard/tyan/s2895/auto.c
+++ b/src/mainboard/tyan/s2895/auto.c
@@ -7,6 +7,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -172,6 +173,6 @@ static void main(unsigned long bist)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
diff --git a/src/mainboard/tyan/s2895/get_bus_conf.c b/src/mainboard/tyan/s2895/get_bus_conf.c
index c44095b2c3..04e9019355 100644
--- a/src/mainboard/tyan/s2895/get_bus_conf.c
+++ b/src/mainboard/tyan/s2895/get_bus_conf.c
@@ -8,6 +8,7 @@
#endif
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
//busnum is default
@@ -76,7 +77,7 @@ void get_bus_conf(void)
get_bus_conf_done = 1;
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/tyan/s2895/resourcemap.c b/src/mainboard/tyan/s2895/resourcemap.c
index 9de9b2e107..aed892acf1 100644
--- a/src/mainboard/tyan/s2895/resourcemap.c
+++ b/src/mainboard/tyan/s2895/resourcemap.c
@@ -261,7 +261,7 @@ static void setup_mb_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/tyan/s2912/get_bus_conf.c b/src/mainboard/tyan/s2912/get_bus_conf.c
index 7bb5f76788..9d6b9d7232 100644
--- a/src/mainboard/tyan/s2912/get_bus_conf.c
+++ b/src/mainboard/tyan/s2912/get_bus_conf.c
@@ -30,6 +30,7 @@
#include <cpu/amd/amdk8_sysconf.h>
+#include <stdlib.h>
#include "mb_sysconf.h"
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -107,7 +108,7 @@ void get_bus_conf(void)
m = sysconf.mb;
memset(m, 0, sizeof(struct mb_sysconf_t));
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/tyan/s2912/resourcemap.c b/src/mainboard/tyan/s2912/resourcemap.c
index 4801643c93..f289ce7898 100644
--- a/src/mainboard/tyan/s2912/resourcemap.c
+++ b/src/mainboard/tyan/s2912/resourcemap.c
@@ -277,7 +277,7 @@ static void setup_mb_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/tyan/s2912_fam10/get_bus_conf.c b/src/mainboard/tyan/s2912_fam10/get_bus_conf.c
index f1bb721be5..d1cec8d815 100644
--- a/src/mainboard/tyan/s2912_fam10/get_bus_conf.c
+++ b/src/mainboard/tyan/s2912_fam10/get_bus_conf.c
@@ -30,6 +30,7 @@
#include <cpu/amd/amdfam10_sysconf.h>
+#include <stdlib.h>
#include "mb_sysconf.h"
// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
@@ -83,7 +84,7 @@ void get_bus_conf(void)
m = sysconf.mb;
memset(m, 0, sizeof(struct mb_sysconf_t));
- sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
+ sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
for(i=0;i<sysconf.hc_possible_num; i++) {
sysconf.pci1234[i] = pci1234x[i];
sysconf.hcdn[i] = hcdnx[i];
diff --git a/src/mainboard/tyan/s2912_fam10/resourcemap.c b/src/mainboard/tyan/s2912_fam10/resourcemap.c
index cb135a3274..60633d5ef1 100644
--- a/src/mainboard/tyan/s2912_fam10/resourcemap.c
+++ b/src/mainboard/tyan/s2912_fam10/resourcemap.c
@@ -277,7 +277,7 @@ static void setup_mb_resource_map(void)
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/tyan/s4880/auto.c b/src/mainboard/tyan/s4880/auto.c
index 7598e14199..36115f6a0d 100644
--- a/src/mainboard/tyan/s4880/auto.c
+++ b/src/mainboard/tyan/s4880/auto.c
@@ -7,6 +7,7 @@
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
#include <arch/cpu.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -227,6 +228,6 @@ static void main(unsigned long bist)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
diff --git a/src/mainboard/tyan/s4880/cache_as_ram_auto.c b/src/mainboard/tyan/s4880/cache_as_ram_auto.c
index b7064778bb..2e8eb3bb48 100644
--- a/src/mainboard/tyan/s4880/cache_as_ram_auto.c
+++ b/src/mainboard/tyan/s4880/cache_as_ram_auto.c
@@ -7,6 +7,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -254,7 +255,7 @@ void real_main(unsigned long bist, unsigned long cpu_init_detectedx)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
post_cache_as_ram();
}
diff --git a/src/mainboard/tyan/s4880/resourcemap.c b/src/mainboard/tyan/s4880/resourcemap.c
index d9315a026a..cf45d55532 100644
--- a/src/mainboard/tyan/s4880/resourcemap.c
+++ b/src/mainboard/tyan/s4880/resourcemap.c
@@ -258,7 +258,7 @@ static void setup_s4880_resource_map(void)
PCI_ADDR(0, 0x18, 1, 0xEC), 0x0000FC88, 0x00000000,
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/tyan/s4882/auto.c b/src/mainboard/tyan/s4882/auto.c
index 6daa5d8a42..7576e4de26 100644
--- a/src/mainboard/tyan/s4882/auto.c
+++ b/src/mainboard/tyan/s4882/auto.c
@@ -6,6 +6,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "option_table.h"
#include "pc80/mc146818rtc_early.c"
#include "pc80/serial.c"
@@ -227,6 +228,6 @@ static void main(unsigned long bist)
enable_smbus();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
diff --git a/src/mainboard/tyan/s4882/resourcemap.c b/src/mainboard/tyan/s4882/resourcemap.c
index 8d9307c68f..0e5be61a7c 100644
--- a/src/mainboard/tyan/s4882/resourcemap.c
+++ b/src/mainboard/tyan/s4882/resourcemap.c
@@ -258,7 +258,7 @@ static void setup_s4882_resource_map(void)
PCI_ADDR(0, 0x18, 1, 0xEC), 0x0000FC88, 0x00000000,
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/mainboard/via/epia-m/auto.c b/src/mainboard/via/epia-m/auto.c
index c82be2e111..1f444d61b7 100644
--- a/src/mainboard/via/epia-m/auto.c
+++ b/src/mainboard/via/epia-m/auto.c
@@ -10,6 +10,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -146,7 +147,7 @@ static void main(unsigned long bist)
#endif
};
int i;
- for(i = 0; i < sizeof(check_addrs)/sizeof(check_addrs[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(check_addrs); i++) {
ram_check(check_addrs[i].lo, check_addrs[i].hi);
}
#endif
diff --git a/src/mainboard/via/epia/auto.c b/src/mainboard/via/epia/auto.c
index aec0dbff14..a45a32e6cf 100644
--- a/src/mainboard/via/epia/auto.c
+++ b/src/mainboard/via/epia/auto.c
@@ -6,6 +6,7 @@
#include <device/pnp_def.h>
#include <arch/romcc_io.h>
#include <arch/hlt.h>
+#include <stdlib.h>
#include "pc80/serial.c"
#include "arch/i386/lib/console.c"
#include "ram/ramtest.c"
@@ -107,7 +108,7 @@ static void main(unsigned long bist)
/*
this is way more generic than we need.
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
*/
sdram_set_registers((const struct mem_controller *) 0);
sdram_set_spd_registers((const struct mem_controller *) 0);
@@ -129,7 +130,7 @@ static void main(unsigned long bist)
#endif
};
int i;
- for(i = 0; i < sizeof(check_addrs)/sizeof(check_addrs[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(check_addrs); i++) {
ram_check(check_addrs[i].lo, check_addrs[i].hi);
}
#endif
diff --git a/src/northbridge/amd/amdfam10/resourcemap.c b/src/northbridge/amd/amdfam10/resourcemap.c
index cb445a1260..49d546861c 100644
--- a/src/northbridge/amd/amdfam10/resourcemap.c
+++ b/src/northbridge/amd/amdfam10/resourcemap.c
@@ -281,7 +281,7 @@ static void setup_default_resource_map(void)
};
u32 max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/northbridge/amd/amdk8/coherent_ht.c b/src/northbridge/amd/amdk8/coherent_ht.c
index 39602181c1..c331a1e53d 100644
--- a/src/northbridge/amd/amdk8/coherent_ht.c
+++ b/src/northbridge/amd/amdk8/coherent_ht.c
@@ -66,6 +66,7 @@
#include <device/pci_def.h>
#include <device/pci_ids.h>
#include <device/hypertransport_def.h>
+#include <stdlib.h>
#include "arch/romcc_io.h"
#include "amdk8.h"
@@ -510,7 +511,7 @@ static void setup_remote_node(u8 node)
print_spew("setup_remote_node: ");
/* copy the default resource map from node 0 */
- for(i = 0; i < sizeof(pci_reg)/sizeof(pci_reg[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(pci_reg); i++) {
uint32_t value;
uint8_t reg;
reg = pci_reg[i];
@@ -802,7 +803,7 @@ static unsigned setup_smp4(void)
};
#endif
- setup_row_indirect_group(conn4_1, sizeof(conn4_1)/sizeof(conn4_1[0]));
+ setup_row_indirect_group(conn4_1, ARRAY_SIZE(conn4_1));
setup_temp_row(0,2);
verify_connection(7);
@@ -893,7 +894,7 @@ static unsigned setup_smp4(void)
3,0,1,1,
};
#endif
- setup_remote_row_indirect_group(conn4_3, sizeof(conn4_3)/sizeof(conn4_3[0]));
+ setup_remote_row_indirect_group(conn4_3, ARRAY_SIZE(conn4_3));
/* ready to enable RT for Node 3 */
rename_temp_node(3);
@@ -909,7 +910,7 @@ static unsigned setup_smp4(void)
2,1,0,1,
};
#endif
- setup_row_indirect_group(conn4_2, sizeof(conn4_2)/sizeof(conn4_2[0]));
+ setup_row_indirect_group(conn4_2, ARRAY_SIZE(conn4_2));
#if 0
/*We need to do sth to reverse work for setup_temp_row (0,1) (1,3) */
@@ -974,7 +975,7 @@ static unsigned setup_smp6(void)
#endif
};
- setup_row_indirect_group(conn6_1, sizeof(conn6_1)/sizeof(conn6_1[0]));
+ setup_row_indirect_group(conn6_1, ARRAY_SIZE(conn6_1));
for(byte=0; byte<4; byte+=2) {
setup_temp_row(byte,byte+2);
@@ -998,7 +999,7 @@ static unsigned setup_smp6(void)
#endif
};
- setup_remote_row_indirect_group(conn6_2, sizeof(conn6_2)/sizeof(conn6_2[0]));
+ setup_remote_row_indirect_group(conn6_2, ARRAY_SIZE(conn6_2));
rename_temp_node(4);
enable_routing(4);
@@ -1084,7 +1085,7 @@ static unsigned setup_smp6(void)
#endif
};
- setup_remote_row_indirect_group(conn6_3, sizeof(conn6_3)/sizeof(conn6_3[0]));
+ setup_remote_row_indirect_group(conn6_3, ARRAY_SIZE(conn6_3));
/* ready to enable RT for 5 */
rename_temp_node(5);
@@ -1110,7 +1111,7 @@ static unsigned setup_smp6(void)
#endif
};
- setup_row_indirect_group(conn6_4, sizeof(conn6_4)/sizeof(conn6_4[0]));
+ setup_row_indirect_group(conn6_4, ARRAY_SIZE(conn6_4));
#if 0
/* We need to do sth about reverse about setup_temp_row (0,1), (2,4), (1, 3), (3,5)
@@ -1202,7 +1203,7 @@ static unsigned setup_smp8(void)
#endif
};
- setup_row_indirect_group(conn8_1,sizeof(conn8_1)/sizeof(conn8_1[0]));
+ setup_row_indirect_group(conn8_1,ARRAY_SIZE(conn8_1));
for(byte=0; byte<6; byte+=2) {
setup_temp_row(byte,byte+2);
@@ -1225,7 +1226,7 @@ static unsigned setup_smp8(void)
#endif
};
- setup_remote_row_indirect_group(conn8_2, sizeof(conn8_2)/sizeof(conn8_2[0]));
+ setup_remote_row_indirect_group(conn8_2, ARRAY_SIZE(conn8_2));
#if CROSS_BAR_47_56
//init 5, 6 here
@@ -1414,7 +1415,7 @@ static unsigned setup_smp8(void)
#endif
};
- setup_row_indirect_group(conn8_3, sizeof(conn8_3)/sizeof(conn8_3[0]));
+ setup_row_indirect_group(conn8_3, ARRAY_SIZE(conn8_3));
#if CROSS_BAR_47_56
/* for 47, 56, 57, 75, 46, 64 we need to substract another link to
@@ -1455,7 +1456,7 @@ static unsigned setup_smp8(void)
7, 3, 6,
};
- opt_broadcast_rt_group(conn8_4, sizeof(conn8_4)/sizeof(conn8_4[0]));
+ opt_broadcast_rt_group(conn8_4, ARRAY_SIZE(conn8_4));
static const u8 conn8_5[] = {
2, 7, 0,
@@ -1463,7 +1464,7 @@ static unsigned setup_smp8(void)
3, 6, 1,
};
- opt_broadcast_rt_plus_group(conn8_5, sizeof(conn8_5)/sizeof(conn8_5[0]));
+ opt_broadcast_rt_plus_group(conn8_5, ARRAY_SIZE(conn8_5));
#endif
@@ -1770,7 +1771,7 @@ static int optimize_link_coherent_ht(void)
1,3,
2,3,
};
- needs_reset |= optimize_connection_group(opt_conn4, sizeof(opt_conn4)/sizeof(opt_conn4[0]));
+ needs_reset |= optimize_connection_group(opt_conn4, ARRAY_SIZE(opt_conn4));
}
#endif
@@ -1783,7 +1784,7 @@ static int optimize_link_coherent_ht(void)
4, 5,
#endif
};
- needs_reset |= optimize_connection_group(opt_conn6, sizeof(opt_conn6)/sizeof(opt_conn6[0]));
+ needs_reset |= optimize_connection_group(opt_conn6, ARRAY_SIZE(opt_conn6));
}
#endif
@@ -1798,7 +1799,7 @@ static int optimize_link_coherent_ht(void)
5, 7,
6, 7,
};
- needs_reset |= optimize_connection_group(opt_conn8, sizeof(opt_conn8)/sizeof(opt_conn8[0]));
+ needs_reset |= optimize_connection_group(opt_conn8, ARRAY_SIZE(opt_conn8));
}
#endif
diff --git a/src/northbridge/amd/amdk8/raminit.c b/src/northbridge/amd/amdk8/raminit.c
index 2e05bffe0f..51c2321b44 100644
--- a/src/northbridge/amd/amdk8/raminit.c
+++ b/src/northbridge/amd/amdk8/raminit.c
@@ -10,6 +10,7 @@
#include <cpu/x86/mem.h>
#include <cpu/x86/cache.h>
#include <cpu/x86/mtrr.h>
+#include <stdlib.h>
#include "raminit.h"
#include "amdk8.h"
@@ -555,7 +556,7 @@ static void sdram_set_registers(const struct mem_controller *ctrl)
print_spew("setting up CPU");
print_spew_hex8(ctrl->node_id);
print_spew(" northbridge registers\r\n");
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
for(i = 0; i < max; i += 3) {
device_t dev;
unsigned where;
@@ -1303,7 +1304,7 @@ static long spd_enable_2channels(const struct mem_controller *ctrl, long dimm_ma
}
device0 = ctrl->channel0[i];
device1 = ctrl->channel1[i];
- for(j = 0; j < sizeof(addresses)/sizeof(addresses[0]); j++) {
+ for(j = 0; j < ARRAY_SIZE(addresses); j++) {
unsigned addr;
addr = addresses[j];
value0 = spd_read_byte(device0, addr);
diff --git a/src/northbridge/amd/amdk8/raminit_f.c b/src/northbridge/amd/amdk8/raminit_f.c
index 94b1d461ef..a883fa401d 100644
--- a/src/northbridge/amd/amdk8/raminit_f.c
+++ b/src/northbridge/amd/amdk8/raminit_f.c
@@ -25,6 +25,7 @@
#include <cpu/x86/mtrr.h>
#include <cpu/x86/tsc.h>
+#include <stdlib.h>
#include "raminit.h"
#include "amdk8_f.h"
#include "spd_ddr2.h"
@@ -715,7 +716,7 @@ static void sdram_set_registers(const struct mem_controller *ctrl, struct sys_in
print_spew("setting up CPU");
print_spew_hex8(ctrl->node_id);
print_spew(" northbridge registers\r\n");
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
for (i = 0; i < max; i += 3) {
device_t dev;
unsigned where;
@@ -1496,7 +1497,7 @@ static long spd_enable_2channels(const struct mem_controller *ctrl, struct mem_i
}
device0 = ctrl->channel0[i];
device1 = ctrl->channel1[i];
- for (j = 0; j < sizeof(addresses)/sizeof(addresses[0]); j++) {
+ for (j = 0; j < ARRAY_SIZE(addresses); j++) {
unsigned addr;
addr = addresses[j];
value0 = spd_read_byte(device0, addr);
diff --git a/src/northbridge/amd/amdk8/raminit_test.c b/src/northbridge/amd/amdk8/raminit_test.c
index 8e323ea859..b3a4641355 100644
--- a/src/northbridge/amd/amdk8/raminit_test.c
+++ b/src/northbridge/amd/amdk8/raminit_test.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <setjmp.h>
#include <device/pci_def.h>
+#include <stdlib.h>
#include "amdk8.h"
jmp_buf end_buf;
@@ -341,7 +342,7 @@ static void raminit_main(void)
};
console_init();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
diff --git a/src/northbridge/amd/amdk8/resourcemap.c b/src/northbridge/amd/amdk8/resourcemap.c
index 95ac3b6366..4b6833204c 100644
--- a/src/northbridge/amd/amdk8/resourcemap.c
+++ b/src/northbridge/amd/amdk8/resourcemap.c
@@ -253,6 +253,6 @@ static void setup_default_resource_map(void)
PCI_ADDR(0, 0x18, 1, 0xEC), 0x0000FC88, 0x00000000,
};
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
diff --git a/src/northbridge/amd/gx2/chipsetinit.c b/src/northbridge/amd/gx2/chipsetinit.c
index 4751886a45..e75135d719 100644
--- a/src/northbridge/amd/gx2/chipsetinit.c
+++ b/src/northbridge/amd/gx2/chipsetinit.c
@@ -177,7 +177,7 @@ struct FLASH_DEVICE FlashInitTable[] = {
{ FLASH_TYPE_NONE, 0, 0 }, /* CS3, or Flash Device 3 */
};
-#define FlashInitTableLen (sizeof(FlashInitTable)/sizeof(FlashInitTable[0]))
+#define FlashInitTableLen (ARRAY_SIZE(FlashInitTable))
uint32_t FlashPort[] = {
MDD_LBAR_FLSH0,
diff --git a/src/northbridge/intel/e7501/raminit.c b/src/northbridge/intel/e7501/raminit.c
index 1aeb4f05d9..4695915763 100644
--- a/src/northbridge/intel/e7501/raminit.c
+++ b/src/northbridge/intel/e7501/raminit.c
@@ -14,6 +14,7 @@
#include <assert.h>
#include <spd.h>
#include <sdram_mode.h>
+#include <stdlib.h>
#include "e7501.h"
// Uncomment this to enable run-time checking of DIMM parameters
@@ -1631,7 +1632,7 @@ static void RAM_RESET_DDR_PTR(const struct mem_controller *ctrl)
static void ram_set_d0f0_regs(const struct mem_controller *ctrl)
{
int i;
- int num_values = sizeof(constant_register_values)/sizeof(constant_register_values[0]);
+ int num_values = ARRAY_SIZE(constant_register_values);
ASSERT((num_values % 3) == 0); // Bad table?
diff --git a/src/northbridge/intel/e7520/raminit.c b/src/northbridge/intel/e7520/raminit.c
index 672a117d7e..27ed477d9a 100644
--- a/src/northbridge/intel/e7520/raminit.c
+++ b/src/northbridge/intel/e7520/raminit.c
@@ -21,6 +21,7 @@
#include <cpu/x86/mem.h>
#include <cpu/x86/mtrr.h>
#include <cpu/x86/cache.h>
+#include <stdlib.h>
#include "raminit.h"
#include "e7520.h"
@@ -62,7 +63,7 @@ static void sdram_set_registers(const struct mem_controller *ctrl)
int i;
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
for(i = 0; i < max; i += 3) {
device_t dev;
unsigned where;
diff --git a/src/northbridge/intel/e7520/raminit_test.c b/src/northbridge/intel/e7520/raminit_test.c
index a69bafdac9..4716a29430 100644
--- a/src/northbridge/intel/e7520/raminit_test.c
+++ b/src/northbridge/intel/e7520/raminit_test.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <setjmp.h>
#include <device/pci_def.h>
+#include <stdlib.h>
#include "e7520.h"
jmp_buf end_buf;
@@ -341,7 +342,7 @@ static void raminit_main(void)
};
console_init();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
diff --git a/src/northbridge/intel/e7525/raminit.c b/src/northbridge/intel/e7525/raminit.c
index 5b2d1dc2bd..313dc0f930 100644
--- a/src/northbridge/intel/e7525/raminit.c
+++ b/src/northbridge/intel/e7525/raminit.c
@@ -21,6 +21,7 @@
#include <cpu/x86/mem.h>
#include <cpu/x86/mtrr.h>
#include <cpu/x86/cache.h>
+#include <stdlib.h>
#include "raminit.h"
#include "e7525.h"
@@ -62,7 +63,7 @@ static void sdram_set_registers(const struct mem_controller *ctrl)
int i;
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
for(i = 0; i < max; i += 3) {
device_t dev;
unsigned where;
diff --git a/src/northbridge/intel/e7525/raminit_test.c b/src/northbridge/intel/e7525/raminit_test.c
index 2d44d25403..0fdb5848cc 100644
--- a/src/northbridge/intel/e7525/raminit_test.c
+++ b/src/northbridge/intel/e7525/raminit_test.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <setjmp.h>
#include <device/pci_def.h>
+#include <stdlib.h>
#include "e7525.h"
jmp_buf end_buf;
@@ -313,7 +314,7 @@ static void raminit_main(void)
};
console_init();
memreset_setup();
- sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
+ sdram_initialize(ARRAY_SIZE(cpu), cpu);
}
#endif
diff --git a/src/northbridge/intel/i3100/raminit.c b/src/northbridge/intel/i3100/raminit.c
index f6ddecb18f..af0f5d57b5 100644
--- a/src/northbridge/intel/i3100/raminit.c
+++ b/src/northbridge/intel/i3100/raminit.c
@@ -22,6 +22,7 @@
#include <cpu/x86/mem.h>
#include <cpu/x86/mtrr.h>
#include <cpu/x86/cache.h>
+#include <stdlib.h>
#include "raminit.h"
#include "i3100.h"
@@ -64,7 +65,7 @@ static void sdram_set_registers(const struct mem_controller *ctrl)
int i;
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
for(i = 0; i < max; i += 3) {
device_t dev;
u32 where;
diff --git a/src/northbridge/intel/i440bx/raminit.c b/src/northbridge/intel/i440bx/raminit.c
index 38470eab20..58a158c389 100644
--- a/src/northbridge/intel/i440bx/raminit.c
+++ b/src/northbridge/intel/i440bx/raminit.c
@@ -21,6 +21,7 @@
#include <spd.h>
#include <sdram_mode.h>
#include <delay.h>
+#include <stdlib.h>
#include "i440bx.h"
/*-----------------------------------------------------------------------------
@@ -430,7 +431,7 @@ static void sdram_set_registers(const struct mem_controller *ctrl)
PRINT_DEBUG("Northbridge prior to SDRAM init:\r\n");
DUMPNORTH();
- max = sizeof(register_values) / sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
/* Set registers as specified in the register_values[] array. */
for (i = 0; i < max; i += 3) {
diff --git a/src/northbridge/intel/i855pm/raminit.c b/src/northbridge/intel/i855pm/raminit.c
index 9a0f7c08d9..8e97c10bd0 100644
--- a/src/northbridge/intel/i855pm/raminit.c
+++ b/src/northbridge/intel/i855pm/raminit.c
@@ -384,7 +384,7 @@ static void ram_set_d0f0_regs(const struct mem_controller *ctrl) {
#endif
int i;
int max;
- max = sizeof(register_values)/sizeof(register_values[0]);
+ max = ARRAY_SIZE(register_values);
for(i = 0; i < max; i += 3) {
uint32_t reg;
#if DEBUG_RAM_CONFIG >=2
diff --git a/src/northbridge/via/vt8601/northbridge.c b/src/northbridge/via/vt8601/northbridge.c
index 76d93f0ddb..36a118ca71 100644
--- a/src/northbridge/via/vt8601/northbridge.c
+++ b/src/northbridge/via/vt8601/northbridge.c
@@ -115,7 +115,7 @@ static void pci_domain_set_resources(device_t dev)
unsigned char rambits;
int i, idx;
- for(rambits = 0, i = 0; i < sizeof(ramregs)/sizeof(ramregs[0]); i++) {
+ for(rambits = 0, i = 0; i < ARRAY_SIZE(ramregs); i++) {
unsigned char reg;
reg = pci_read_config8(mc_dev, ramregs[i]);
/* these are ENDING addresses, not sizes.
diff --git a/src/northbridge/via/vt8623/northbridge.c b/src/northbridge/via/vt8623/northbridge.c
index e2bab04afe..80a314c18a 100644
--- a/src/northbridge/via/vt8623/northbridge.c
+++ b/src/northbridge/via/vt8623/northbridge.c
@@ -287,7 +287,7 @@ static void pci_domain_set_resources(device_t dev)
unsigned char rambits;
int i, idx;
- for(rambits = 0, i = 0; i < sizeof(ramregs)/sizeof(ramregs[0]); i++) {
+ for(rambits = 0, i = 0; i < ARRAY_SIZE(ramregs); i++) {
unsigned char reg;
reg = pci_read_config8(mc_dev, ramregs[i]);
/* these are ENDING addresses, not sizes.
diff --git a/src/southbridge/amd/amd8111/amd8111_lpc.c b/src/southbridge/amd/amd8111/amd8111_lpc.c
index 65d3945fe5..802f3c1044 100644
--- a/src/southbridge/amd/amd8111/amd8111_lpc.c
+++ b/src/southbridge/amd/amd8111/amd8111_lpc.c
@@ -10,6 +10,7 @@
#include <pc80/mc146818rtc.h>
#include <pc80/isa-dma.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "amd8111.h"
#define NMI_OFF 0
@@ -77,7 +78,7 @@ static void setup_ioapic(void)
ioapicregvalues[0].value_high = bsp_apicid<<(56-32);
printk_debug("amd8111: ioapic bsp_apicid = %02x\n", bsp_apicid);
- for (i = 0; i < sizeof(ioapicregvalues) / sizeof(ioapicregvalues[0]);
+ for (i = 0; i < ARRAY_SIZE(ioapicregvalues);
i++, a++) {
l[0] = (a->reg * 2) + 0x10;
l[4] = a->value_low;
diff --git a/src/southbridge/amd/cs5536/cs5536.c b/src/southbridge/amd/cs5536/cs5536.c
index 51e9c6f788..0acc5ca5c2 100644
--- a/src/southbridge/amd/cs5536/cs5536.c
+++ b/src/southbridge/amd/cs5536/cs5536.c
@@ -29,6 +29,7 @@
#include <cpu/x86/msr.h>
#include <cpu/amd/vr.h>
#include <cpu/amd/geode_post_code.h>
+#include <stdlib.h>
#include "chip.h"
#include "cs5536.h"
@@ -93,7 +94,7 @@ struct FLASH_DEVICE FlashInitTable[] = {
{FLASH_TYPE_NONE, 0, 0}, /* CS3, or Flash Device 3 */
};
-#define FlashInitTableLen (sizeof(FlashInitTable)/sizeof(FlashInitTable[0]))
+#define FlashInitTableLen (ARRAY_SIZE(FlashInitTable))
uint32_t FlashPort[] = {
MDD_LBAR_FLSH0,
diff --git a/src/southbridge/amd/sb600/sb600_sm.c b/src/southbridge/amd/sb600/sb600_sm.c
index 67d02dc891..97ad48f398 100644
--- a/src/southbridge/amd/sb600/sb600_sm.c
+++ b/src/southbridge/amd/sb600/sb600_sm.c
@@ -27,6 +27,7 @@
#include <bitops.h>
#include <arch/io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "sb600.h"
#include "sb600_smbus.c"
@@ -101,7 +102,7 @@ static void setup_ioapic(unsigned long ioapic_base)
l = (unsigned long *)ioapic_base;
- for (i = 0; i < sizeof(ioapicregvalues) / sizeof(ioapicregvalues[0]);
+ for (i = 0; i < ARRAY_SIZE(ioapicregvalues);
i++, a++) {
l[0] = (a->reg * 2) + 0x10;
l[4] = a->value_low;
diff --git a/src/southbridge/nvidia/ck804/ck804_early_setup.c b/src/southbridge/nvidia/ck804/ck804_early_setup.c
index 6634161362..bbce8207de 100644
--- a/src/southbridge/nvidia/ck804/ck804_early_setup.c
+++ b/src/southbridge/nvidia/ck804/ck804_early_setup.c
@@ -102,7 +102,7 @@ static void ck804_early_set_port(void)
#endif
};
- setup_resource_map(ctrl_devport_conf, sizeof(ctrl_devport_conf)/sizeof(ctrl_devport_conf[0]));
+ setup_resource_map(ctrl_devport_conf, ARRAY_SIZE(ctrl_devport_conf));
}
@@ -121,7 +121,7 @@ static void ck804_early_clear_port(void)
#endif
};
- setup_resource_map(ctrl_devport_conf_clear, sizeof(ctrl_devport_conf_clear)/sizeof(ctrl_devport_conf_clear[0]));
+ setup_resource_map(ctrl_devport_conf_clear, ARRAY_SIZE(ctrl_devport_conf_clear));
}
@@ -324,7 +324,7 @@ static void ck804_early_setup(void)
- setup_resource_map_x(ctrl_conf, sizeof(ctrl_conf)/sizeof(ctrl_conf[0]));
+ setup_resource_map_x(ctrl_conf, ARRAY_SIZE(ctrl_conf));
setup_ss_table(ANACTRL_IO_BASE+0x40, ANACTRL_IO_BASE+0x44, ANACTRL_IO_BASE+0x48, pcie_ss_tbl, 64);
setup_ss_table(ANACTRL_IO_BASE+0xb0, ANACTRL_IO_BASE+0xb4, ANACTRL_IO_BASE+0xb8, sata_ss_tbl, 64);
diff --git a/src/southbridge/nvidia/ck804/ck804_early_setup_car.c b/src/southbridge/nvidia/ck804/ck804_early_setup_car.c
index 729a47f178..ec18ffc8b6 100644
--- a/src/southbridge/nvidia/ck804/ck804_early_setup_car.c
+++ b/src/southbridge/nvidia/ck804/ck804_early_setup_car.c
@@ -105,12 +105,12 @@ static void ck804_early_set_port(unsigned ck804_num, unsigned *busn, unsigned *i
for(j = 0; j < ck804_num; j++ ) {
if(busn[j]==0) { //sb chain
setup_resource_map_offset(ctrl_devport_conf,
- sizeof(ctrl_devport_conf)/sizeof(ctrl_devport_conf[0]),
+ ARRAY_SIZE(ctrl_devport_conf),
PCI_DEV(busn[j], 0, 0) , io_base[j]);
continue;
}
setup_resource_map_offset(ctrl_devport_conf_b,
- sizeof(ctrl_devport_conf_b)/sizeof(ctrl_devport_conf_b[0]),
+ ARRAY_SIZE(ctrl_devport_conf_b),
PCI_DEV(busn[j], 0, 0) , io_base[j]);
}
}
@@ -132,12 +132,12 @@ static void ck804_early_clear_port(unsigned ck804_num, unsigned *busn, unsigned
for(j = 0; j < ck804_num; j++ ) {
if(busn[j]==0) { //sb chain
setup_resource_map_offset(ctrl_devport_conf_clear,
- sizeof(ctrl_devport_conf_clear)/sizeof(ctrl_devport_conf_clear[0]),
+ ARRAY_SIZE(ctrl_devport_conf_clear),
PCI_DEV(busn[j], 0, 0) , io_base[j]);
continue;
}
setup_resource_map_offset(ctrl_devport_conf_clear_b,
- sizeof(ctrl_devport_conf_clear_b)/sizeof(ctrl_devport_conf_clear_b[0]),
+ ARRAY_SIZE(ctrl_devport_conf_clear_b),
PCI_DEV(busn[j], 0, 0) , io_base[j]);
}
@@ -327,13 +327,13 @@ static void ck804_early_setup(unsigned ck804_num, unsigned *busn, unsigned *io_b
for(j=0; j<ck804_num; j++) {
if(busn[j] == 0) {
- setup_resource_map_x_offset(ctrl_conf_master, sizeof(ctrl_conf_master)/sizeof(ctrl_conf_master[0]),
+ setup_resource_map_x_offset(ctrl_conf_master, ARRAY_SIZE(ctrl_conf_master),
PCI_DEV(busn[0],0,0), io_base[0]);
continue;
}
- setup_resource_map_x_offset(ctrl_conf_slave, sizeof(ctrl_conf_slave)/sizeof(ctrl_conf_slave[0]),
+ setup_resource_map_x_offset(ctrl_conf_slave, ARRAY_SIZE(ctrl_conf_slave),
PCI_DEV(busn[j],0,0), io_base[j]);
}
diff --git a/src/southbridge/nvidia/ck804/ck804_lpc.c b/src/southbridge/nvidia/ck804/ck804_lpc.c
index 69afb182ae..b06de3e558 100644
--- a/src/southbridge/nvidia/ck804/ck804_lpc.c
+++ b/src/southbridge/nvidia/ck804/ck804_lpc.c
@@ -15,6 +15,7 @@
#include <bitops.h>
#include <arch/io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "ck804.h"
#define CK804_CHIP_REV 2
@@ -82,7 +83,7 @@ static void setup_ioapic(unsigned long ioapic_base)
l = (unsigned long *) ioapic_base;
- for (i = 0; i < sizeof(ioapicregvalues) / sizeof(ioapicregvalues[0]);
+ for (i = 0; i < ARRAY_SIZE(ioapicregvalues);
i++, a++) {
l[0] = (a->reg * 2) + 0x10;
l[4] = a->value_low;
diff --git a/src/southbridge/nvidia/mcp55/mcp55_early_setup_car.c b/src/southbridge/nvidia/mcp55/mcp55_early_setup_car.c
index 48218558ee..64ec785781 100644
--- a/src/southbridge/nvidia/mcp55/mcp55_early_setup_car.c
+++ b/src/southbridge/nvidia/mcp55/mcp55_early_setup_car.c
@@ -106,7 +106,7 @@ static void mcp55_early_set_port(unsigned mcp55_num, unsigned *busn, unsigned *d
int j;
for(j = 0; j < mcp55_num; j++ ) {
setup_resource_map_offset(ctrl_devport_conf,
- sizeof(ctrl_devport_conf)/sizeof(ctrl_devport_conf[0]),
+ ARRAY_SIZE(ctrl_devport_conf),
PCI_DEV(busn[j], devn[j], 0) , io_base[j]);
}
}
@@ -123,7 +123,7 @@ static void mcp55_early_clear_port(unsigned mcp55_num, unsigned *busn, unsigned
int j;
for(j = 0; j < mcp55_num; j++ ) {
setup_resource_map_offset(ctrl_devport_conf_clear,
- sizeof(ctrl_devport_conf_clear)/sizeof(ctrl_devport_conf_clear[0]),
+ ARRAY_SIZE(ctrl_devport_conf_clear),
PCI_DEV(busn[j], devn[j], 0) , io_base[j]);
}
@@ -327,23 +327,23 @@ static void mcp55_early_setup(unsigned mcp55_num, unsigned *busn, unsigned *devn
for(j=0; j<mcp55_num; j++) {
mcp55_early_pcie_setup(busn[j], devn[j], io_base[j] + ANACTRL_IO_BASE, pci_e_x[j]);
- setup_resource_map_x_offset(ctrl_conf_1, sizeof(ctrl_conf_1)/sizeof(ctrl_conf_1[0]),
+ setup_resource_map_x_offset(ctrl_conf_1, ARRAY_SIZE(ctrl_conf_1),
PCI_DEV(busn[j], devn[j], 0), io_base[j]);
for(i=0; i<3; i++) { // three SATA
- setup_resource_map_x_offset(ctrl_conf_1_1, sizeof(ctrl_conf_1_1)/sizeof(ctrl_conf_1_1[0]),
+ setup_resource_map_x_offset(ctrl_conf_1_1, ARRAY_SIZE(ctrl_conf_1_1),
PCI_DEV(busn[j], devn[j], i), io_base[j]);
}
if(busn[j] == 0) {
- setup_resource_map_x_offset(ctrl_conf_mcp55_only, sizeof(ctrl_conf_mcp55_only)/sizeof(ctrl_conf_mcp55_only[0]),
+ setup_resource_map_x_offset(ctrl_conf_mcp55_only, ARRAY_SIZE(ctrl_conf_mcp55_only),
PCI_DEV(busn[j], devn[j], 0), io_base[j]);
}
if( (busn[j] == 0) && (mcp55_num>1) ) {
- setup_resource_map_x_offset(ctrl_conf_master_only, sizeof(ctrl_conf_master_only)/sizeof(ctrl_conf_master_only[0]),
+ setup_resource_map_x_offset(ctrl_conf_master_only, ARRAY_SIZE(ctrl_conf_master_only),
PCI_DEV(busn[j], devn[j], 0), io_base[j]);
}
- setup_resource_map_x_offset(ctrl_conf_2, sizeof(ctrl_conf_2)/sizeof(ctrl_conf_2[0]),
+ setup_resource_map_x_offset(ctrl_conf_2, ARRAY_SIZE(ctrl_conf_2),
PCI_DEV(busn[j], devn[j], 0), io_base[j]);
}
diff --git a/src/southbridge/nvidia/mcp55/mcp55_lpc.c b/src/southbridge/nvidia/mcp55/mcp55_lpc.c
index f4df404e13..3cfcd57a71 100644
--- a/src/southbridge/nvidia/mcp55/mcp55_lpc.c
+++ b/src/southbridge/nvidia/mcp55/mcp55_lpc.c
@@ -34,6 +34,7 @@
#include <bitops.h>
#include <arch/io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "mcp55.h"
#define NMI_OFF 0
@@ -106,7 +107,7 @@ static void setup_ioapic(unsigned long ioapic_base, int master)
l = (unsigned long *) ioapic_base;
- for (i = 0; i < sizeof(ioapicregvalues) / sizeof(ioapicregvalues[0]);
+ for (i = 0; i < ARRAY_SIZE(ioapicregvalues);
i++, a++) {
l[0] = (a->reg * 2) + 0x10;
l[4] = a->value_low;
diff --git a/src/southbridge/sis/sis966/sis966_lpc.c b/src/southbridge/sis/sis966/sis966_lpc.c
index 301d5b102f..4e1b3cd5bc 100644
--- a/src/southbridge/sis/sis966/sis966_lpc.c
+++ b/src/southbridge/sis/sis966/sis966_lpc.c
@@ -36,6 +36,7 @@
#include <bitops.h>
#include <arch/io.h>
#include <cpu/x86/lapic.h>
+#include <stdlib.h>
#include "sis966.h"
#include <pc80/keyboard.h>
@@ -102,7 +103,7 @@ static void setup_ioapic(unsigned long ioapic_base)
l = (unsigned long *) ioapic_base;
- for (i = 0; i < sizeof(ioapicregvalues) / sizeof(ioapicregvalues[0]);
+ for (i = 0; i < ARRAY_SIZE(ioapicregvalues);
i++, a++) {
l[0] = (a->reg * 2) + 0x10;
l[4] = a->value_low;
diff --git a/src/stream/fs/vfs.c b/src/stream/fs/vfs.c
index 5a37d6fb85..4a298cef2a 100644
--- a/src/stream/fs/vfs.c
+++ b/src/stream/fs/vfs.c
@@ -70,7 +70,7 @@ int mount_fs(void)
{
int i;
- for (i = 0; i < sizeof(fsys_table)/sizeof(fsys_table[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(fsys_table); i++) {
if (fsys_table[i].mount_func()) {
fsys = &fsys_table[i];
printk_info("Mounted %s\n", fsys->name);
diff --git a/src/superio/ite/it8661f/superio.c b/src/superio/ite/it8661f/superio.c
index 4666d21ec5..1acf7e3deb 100644
--- a/src/superio/ite/it8661f/superio.c
+++ b/src/superio/ite/it8661f/superio.c
@@ -23,6 +23,7 @@
#include <device/device.h>
#include <device/pnp.h>
#include <uart8250.h>
+#include <stdlib.h>
#include "chip.h"
#include "it8661f.h"
@@ -72,7 +73,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_ite_it8661f_ops = {
diff --git a/src/superio/ite/it8671f/superio.c b/src/superio/ite/it8671f/superio.c
index 0e00944f46..bc9716374e 100644
--- a/src/superio/ite/it8671f/superio.c
+++ b/src/superio/ite/it8671f/superio.c
@@ -22,6 +22,7 @@
#include <device/pnp.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "it8671f.h"
@@ -77,7 +78,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_ite_it8671f_ops = {
diff --git a/src/superio/ite/it8673f/superio.c b/src/superio/ite/it8673f/superio.c
index 03b9811e4c..12f7fcfc38 100644
--- a/src/superio/ite/it8673f/superio.c
+++ b/src/superio/ite/it8673f/superio.c
@@ -22,6 +22,7 @@
#include <device/pnp.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "it8673f.h"
@@ -79,7 +80,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_ite_it8673f_ops = {
diff --git a/src/superio/ite/it8705f/superio.c b/src/superio/ite/it8705f/superio.c
index f646e5407c..095e39a7df 100644
--- a/src/superio/ite/it8705f/superio.c
+++ b/src/superio/ite/it8705f/superio.c
@@ -23,6 +23,7 @@
#include <device/device.h>
#include <device/pnp.h>
#include <uart8250.h>
+#include <stdlib.h>
#include "chip.h"
#include "it8705f.h"
@@ -80,7 +81,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_ite_it8705f_ops = {
diff --git a/src/superio/ite/it8712f/superio.c b/src/superio/ite/it8712f/superio.c
index c90c900914..cf57c2ecdf 100644
--- a/src/superio/ite/it8712f/superio.c
+++ b/src/superio/ite/it8712f/superio.c
@@ -24,6 +24,7 @@
#include <uart8250.h>
#include <pc80/keyboard.h>
#include <arch/io.h>
+#include <stdlib.h>
#include "chip.h"
#include "it8712f.h"
@@ -134,7 +135,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_ite_it8712f_ops = {
diff --git a/src/superio/ite/it8716f/superio.c b/src/superio/ite/it8716f/superio.c
index 51f2eb4105..63744ddfbc 100644
--- a/src/superio/ite/it8716f/superio.c
+++ b/src/superio/ite/it8716f/superio.c
@@ -27,6 +27,7 @@
#include <uart8250.h>
#include <pc80/keyboard.h>
#include <arch/io.h>
+#include <stdlib.h>
#include "chip.h"
#include "it8716f.h"
@@ -165,7 +166,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &ops,
- sizeof(pnp_dev_info) / sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_ite_it8716f_ops = {
diff --git a/src/superio/ite/it8718f/superio.c b/src/superio/ite/it8718f/superio.c
index e46426ba87..13930f41de 100644
--- a/src/superio/ite/it8718f/superio.c
+++ b/src/superio/ite/it8718f/superio.c
@@ -22,6 +22,7 @@
#include <device/pnp.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "it8718f.h"
@@ -81,7 +82,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_ite_it8718f_ops = {
diff --git a/src/superio/nsc/pc8374/superio.c b/src/superio/nsc/pc8374/superio.c
index ccbd0f2114..0d8854fe83 100644
--- a/src/superio/nsc/pc8374/superio.c
+++ b/src/superio/nsc/pc8374/superio.c
@@ -10,6 +10,7 @@
#include <bitops.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "pc8374.h"
@@ -64,7 +65,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_nsc_pc8374_ops = {
diff --git a/src/superio/nsc/pc87309/superio.c b/src/superio/nsc/pc87309/superio.c
index 92a54556f7..7f98523ad5 100644
--- a/src/superio/nsc/pc87309/superio.c
+++ b/src/superio/nsc/pc87309/superio.c
@@ -23,6 +23,7 @@
#include <device/pnp.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "pc87309.h"
@@ -73,7 +74,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info) / sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_nsc_pc87309_ops = {
diff --git a/src/superio/nsc/pc87351/superio.c b/src/superio/nsc/pc87351/superio.c
index 675b01c40e..c5bdeda7d1 100644
--- a/src/superio/nsc/pc87351/superio.c
+++ b/src/superio/nsc/pc87351/superio.c
@@ -16,6 +16,7 @@
#include <bitops.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "pc87351.h"
@@ -71,7 +72,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_nsc_pc87351_ops = {
diff --git a/src/superio/nsc/pc87360/superio.c b/src/superio/nsc/pc87360/superio.c
index c6dd896d81..a332a27064 100644
--- a/src/superio/nsc/pc87360/superio.c
+++ b/src/superio/nsc/pc87360/superio.c
@@ -10,6 +10,7 @@
#include <bitops.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "pc87360.h"
@@ -67,7 +68,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_nsc_pc87360_ops = {
diff --git a/src/superio/nsc/pc87366/superio.c b/src/superio/nsc/pc87366/superio.c
index 1bec4100f8..03cc6a9863 100644
--- a/src/superio/nsc/pc87366/superio.c
+++ b/src/superio/nsc/pc87366/superio.c
@@ -10,6 +10,7 @@
#include <bitops.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "pc87366.h"
@@ -67,7 +68,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_nsc_pc87366_ops = {
diff --git a/src/superio/nsc/pc87417/superio.c b/src/superio/nsc/pc87417/superio.c
index 364bbc32f7..1eea29d0ca 100644
--- a/src/superio/nsc/pc87417/superio.c
+++ b/src/superio/nsc/pc87417/superio.c
@@ -12,6 +12,7 @@
#include <bitops.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "pc87417.h"
@@ -68,7 +69,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_nsc_pc87417_ops = {
diff --git a/src/superio/nsc/pc87427/superio.c b/src/superio/nsc/pc87427/superio.c
index 0363a9e18f..b8fe32c2e3 100644
--- a/src/superio/nsc/pc87427/superio.c
+++ b/src/superio/nsc/pc87427/superio.c
@@ -8,6 +8,7 @@
#include <console/console.h>
#include <string.h>
#include <bitops.h>
+#include <stdlib.h>
#include "chip.h"
#include "pc87427.h"
@@ -68,7 +69,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_nsc_pc87427_ops = {
diff --git a/src/superio/nsc/pc97307/superio.c b/src/superio/nsc/pc97307/superio.c
index db954c9a0c..5b75943f26 100644
--- a/src/superio/nsc/pc97307/superio.c
+++ b/src/superio/nsc/pc97307/superio.c
@@ -5,6 +5,7 @@
#include <console/console.h>
#include <device/device.h>
#include <device/pnp.h>
+#include <stdlib.h>
#include "chip.h"
#include "pc97307.h"
@@ -79,7 +80,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_nsc_pc97307_ops = {
diff --git a/src/superio/nsc/pc97317/superio.c b/src/superio/nsc/pc97317/superio.c
index 052e122a79..7945564bf3 100644
--- a/src/superio/nsc/pc97317/superio.c
+++ b/src/superio/nsc/pc97317/superio.c
@@ -5,6 +5,7 @@
#include <console/console.h>
#include <device/device.h>
#include <device/pnp.h>
+#include <stdlib.h>
#include "chip.h"
#include "pc97317.h"
@@ -81,7 +82,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_nsc_pc97317_ops = {
diff --git a/src/superio/smsc/fdc37m60x/superio.c b/src/superio/smsc/fdc37m60x/superio.c
index 33d8587b59..716cb8b2cb 100644
--- a/src/superio/smsc/fdc37m60x/superio.c
+++ b/src/superio/smsc/fdc37m60x/superio.c
@@ -22,6 +22,7 @@
#include <device/pnp.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "fdc37m60x.h"
@@ -77,7 +78,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_smsc_fdc37m60x_ops = {
diff --git a/src/superio/smsc/lpc47b272/superio.c b/src/superio/smsc/lpc47b272/superio.c
index 6c3d97d6f5..e8fc7bddb0 100644
--- a/src/superio/smsc/lpc47b272/superio.c
+++ b/src/superio/smsc/lpc47b272/superio.c
@@ -32,6 +32,7 @@
#include <bitops.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "lpc47b272.h"
@@ -84,7 +85,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(device_t dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]),
+ ARRAY_SIZE(pnp_dev_info),
pnp_dev_info);
}
diff --git a/src/superio/smsc/lpc47b397/superio.c b/src/superio/smsc/lpc47b397/superio.c
index 6400b03c37..e1dafc918a 100644
--- a/src/superio/smsc/lpc47b397/superio.c
+++ b/src/superio/smsc/lpc47b397/superio.c
@@ -14,6 +14,7 @@
#include <bitops.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "lpc47b397.h"
@@ -207,7 +208,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_smsc_lpc47b397_ops = {
diff --git a/src/superio/smsc/lpc47m10x/superio.c b/src/superio/smsc/lpc47m10x/superio.c
index 89d086401c..ec72beaa34 100644
--- a/src/superio/smsc/lpc47m10x/superio.c
+++ b/src/superio/smsc/lpc47m10x/superio.c
@@ -31,6 +31,7 @@
#include <bitops.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "lpc47m10x.h"
@@ -82,7 +83,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(device_t dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]),
+ ARRAY_SIZE(pnp_dev_info),
pnp_dev_info);
}
diff --git a/src/superio/smsc/lpc47n217/superio.c b/src/superio/smsc/lpc47n217/superio.c
index 06c026509f..3c0056cb70 100644
--- a/src/superio/smsc/lpc47n217/superio.c
+++ b/src/superio/smsc/lpc47n217/superio.c
@@ -33,6 +33,7 @@
#include <bitops.h>
#include <uart8250.h>
#include <assert.h>
+#include <stdlib.h>
#include "chip.h"
#include "lpc47n217.h"
@@ -86,7 +87,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(device_t dev)
{
pnp_enable_devices(dev, &pnp_ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]),
+ ARRAY_SIZE(pnp_dev_info),
pnp_dev_info);
}
diff --git a/src/superio/via/vt1211/vt1211.c b/src/superio/via/vt1211/vt1211.c
index 49e11ce039..be29c76e67 100644
--- a/src/superio/via/vt1211/vt1211.c
+++ b/src/superio/via/vt1211/vt1211.c
@@ -26,6 +26,7 @@
#include <device/device.h>
#include <device/pnp.h>
#include <uart8250.h>
+#include <stdlib.h>
#include "vt1211.h"
#include "chip.h"
@@ -212,7 +213,7 @@ static void enable_dev(struct device *dev)
printk_debug("vt1211 enabling PNP devices.\n");
pnp_enable_devices(dev,
&ops,
- sizeof(pnp_dev_info) / sizeof(pnp_dev_info[0]),
+ ARRAY_SIZE(pnp_dev_info),
pnp_dev_info);
}
diff --git a/src/superio/winbond/w83627ehg/superio.c b/src/superio/winbond/w83627ehg/superio.c
index 019f510358..d12bb67be3 100644
--- a/src/superio/winbond/w83627ehg/superio.c
+++ b/src/superio/winbond/w83627ehg/superio.c
@@ -30,6 +30,7 @@
#include <uart8250.h>
#include <pc80/keyboard.h>
#include <pc80/mc146818rtc.h>
+#include <stdlib.h>
#include "chip.h"
#include "w83627ehg.h"
@@ -93,7 +94,7 @@ static void init_hwm(unsigned long base)
0x48, 0x7f, 0x2a, /* Set SMBus base to 0x54 >> 1. */
};
- 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]));
@@ -200,7 +201,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_winbond_w83627ehg_ops = {
diff --git a/src/superio/winbond/w83627hf/superio.c b/src/superio/winbond/w83627hf/superio.c
index 93c5f6dac2..5f26768adf 100644
--- a/src/superio/winbond/w83627hf/superio.c
+++ b/src/superio/winbond/w83627hf/superio.c
@@ -13,6 +13,7 @@
#include <uart8250.h>
#include <pc80/keyboard.h>
#include <pc80/mc146818rtc.h>
+#include <stdlib.h>
#include "chip.h"
#include "w83627hf.h"
@@ -83,7 +84,7 @@ static void init_hwm(unsigned long base)
};
- 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];
@@ -189,7 +190,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
pnp_enable_devices(dev, &ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_winbond_w83627hf_ops = {
diff --git a/src/superio/winbond/w83627thf/superio.c b/src/superio/winbond/w83627thf/superio.c
index 6b08f8746c..28fd72f6df 100644
--- a/src/superio/winbond/w83627thf/superio.c
+++ b/src/superio/winbond/w83627thf/superio.c
@@ -12,6 +12,7 @@
#include <bitops.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "w83627thf.h"
@@ -101,7 +102,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(device_t dev)
{
pnp_enable_devices(dev, &ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_winbond_w83627thf_ops = {
diff --git a/src/superio/winbond/w83977f/superio.c b/src/superio/winbond/w83977f/superio.c
index 417fee8058..64cdc5da1a 100644
--- a/src/superio/winbond/w83977f/superio.c
+++ b/src/superio/winbond/w83977f/superio.c
@@ -26,6 +26,7 @@
#include <bitops.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "w83977f.h"
@@ -109,7 +110,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(device_t dev)
{
pnp_enable_devices(dev, &ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_winbond_w83977f_ops = {
diff --git a/src/superio/winbond/w83977tf/superio.c b/src/superio/winbond/w83977tf/superio.c
index e7d155a701..fca98ca59e 100644
--- a/src/superio/winbond/w83977tf/superio.c
+++ b/src/superio/winbond/w83977tf/superio.c
@@ -19,6 +19,7 @@
#include <bitops.h>
#include <uart8250.h>
#include <pc80/keyboard.h>
+#include <stdlib.h>
#include "chip.h"
#include "w83977tf.h"
@@ -105,7 +106,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(device_t dev)
{
pnp_enable_devices(dev, &ops,
- sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+ ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_winbond_w83977tf_ops = {