mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
Add an ARRAY_SIZE() macro which returns the size of an array, regardless
of the data types of the individual array elements. The macro is defined in lib.h, so code which uses it must include lib.h. Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@413 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
9b9e190491
commit
c81aa82942
5 changed files with 13 additions and 8 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <device/device.h>
|
||||
#include <tables.h>
|
||||
#include <mc146818rtc.h>
|
||||
#include <lib.h>
|
||||
//#include <cpu/cpu.h>
|
||||
//#include <pirq_routing.h>
|
||||
//#include <smp/mpspec.h>
|
||||
|
@ -159,7 +160,7 @@ void lb_strings(struct lb_header *header)
|
|||
{ LB_TAG_ASSEMBLER, (const u8 *)LINUXBIOS_ASSEMBLER },
|
||||
};
|
||||
unsigned int i;
|
||||
for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
|
||||
for(i = 0; i < ARRAY_SIZE(strings); i++) {
|
||||
struct lb_string *rec;
|
||||
size_t len;
|
||||
rec = (struct lb_string *)lb_new_record(header);
|
||||
|
|
|
@ -21,6 +21,12 @@
|
|||
#ifndef LIB_H
|
||||
#define LIB_H
|
||||
|
||||
/**
|
||||
* Return the size of a given array, no matter of which data type
|
||||
* the individual array elements are.
|
||||
*/
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
int log2(unsigned int n);
|
||||
|
||||
void udelay(unsigned int usecs);
|
||||
|
|
|
@ -120,7 +120,7 @@ struct wmsr {
|
|||
static void dbe61_msr_init(void)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < sizeof(dbe61_msr)/sizeof(dbe61_msr[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(dbe61_msr); i++)
|
||||
wrmsr(dbe61_msr[i].reg, dbe61_msr[i].msr);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,8 +93,6 @@ struct FLASH_DEVICE FlashInitTable[] = {
|
|||
{FLASH_TYPE_NONE, 0, 0}, /* CS3, or Flash Device 3 */
|
||||
};
|
||||
|
||||
#define FlashInitTableLen (sizeof(FlashInitTable)/sizeof(FlashInitTable[0]))
|
||||
|
||||
u32 FlashPort[] = {
|
||||
MDD_LBAR_FLSH0,
|
||||
MDD_LBAR_FLSH1,
|
||||
|
@ -149,7 +147,7 @@ static void chipset_flash_setup(void)
|
|||
int numEnabled = 0;
|
||||
|
||||
printk(BIOS_DEBUG, "chipset_flash_setup: Start\n");
|
||||
for (i = 0; i < FlashInitTableLen; i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(FlashInitTable); i++) {
|
||||
if (FlashInitTable[i].fType != FLASH_TYPE_NONE) {
|
||||
printk(BIOS_DEBUG, "Enable CS%d\n", i);
|
||||
/* we need to configure the memory/IO mask */
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include <io.h>
|
||||
#include <lib.h>
|
||||
#include <device/device.h>
|
||||
#include <device/pnp.h>
|
||||
#include <console.h>
|
||||
|
@ -99,7 +100,7 @@ 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];
|
||||
|
@ -207,8 +208,7 @@ static struct pnp_info pnp_dev_info[] = {
|
|||
|
||||
static void phase2_setup_scan_bus(struct device *dev)
|
||||
{
|
||||
pnp_enable_devices(dev, &ops,
|
||||
sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
|
||||
pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
|
||||
}
|
||||
|
||||
static struct device_operations ops = {
|
||||
|
|
Loading…
Add table
Reference in a new issue