From ae5fd3453a61d95b9f786b4412cb1705563e81cb Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Thu, 20 Nov 2014 19:58:09 +1100 Subject: northbridge/amd/agesa/family1{4,5,5tn,6kb}: Reduce differences MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lets cut down on whitespace differences, fix some typos and indents. Also make use of ARRAY_SIZE() macro instead of a local redefinition. Fix NULL pointer checks ordering and not to use zero. Change-Id: I93f344d300c04570d795659d848255cb1832e1d8 Signed-off-by: Edward O'Callaghan Reviewed-on: http://review.coreboot.org/7528 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi Reviewed-by: Kyösti Mälkki --- src/northbridge/amd/agesa/family16kb/dimmSpd.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/northbridge/amd/agesa/family16kb/dimmSpd.c') diff --git a/src/northbridge/amd/agesa/family16kb/dimmSpd.c b/src/northbridge/amd/agesa/family16kb/dimmSpd.c index 8991bdb69e..6ffdf5d985 100644 --- a/src/northbridge/amd/agesa/family16kb/dimmSpd.c +++ b/src/northbridge/amd/agesa/family16kb/dimmSpd.c @@ -19,6 +19,7 @@ #include #include +#include /* warning: Porting.h includes an open #pragma pack(1) */ #include "Porting.h" @@ -26,28 +27,33 @@ #include "amdlib.h" #include "chip.h" -#include "northbridge/amd/agesa/dimmSpd.h" - -#define DIMENSION(array)(sizeof (array)/ sizeof (array [0])) +#include +/** + * Gets the SMBus address for an SPD from the array in devicetree.cb + * then read the SPD into the supplied buffer. + */ AGESA_STATUS AmdMemoryReadSPD (UINT32 unused1, UINT32 unused2, AGESA_READ_SPD_PARAMS *info) { - int spdAddress; + UINT8 spdAddress; + ROMSTAGE_CONST struct device *dev = dev_find_slot(0, PCI_DEVFN(0x18, 2)); - ROMSTAGE_CONST struct northbridge_amd_agesa_family16kb_config *config = dev->chip_info; + if (dev == NULL) + return AGESA_ERROR; - if ((dev == 0) || (config == 0)) + ROMSTAGE_CONST struct northbridge_amd_agesa_family16kb_config *config = dev->chip_info; + if (config == NULL) return AGESA_ERROR; - if (info->SocketId >= DIMENSION(config->spdAddrLookup )) + if (info->SocketId >= ARRAY_SIZE(config->spdAddrLookup)) return AGESA_ERROR; - if (info->MemChannelId >= DIMENSION(config->spdAddrLookup[0] )) + if (info->MemChannelId >= ARRAY_SIZE(config->spdAddrLookup[0])) return AGESA_ERROR; - if (info->DimmId >= DIMENSION(config->spdAddrLookup[0][0])) + if (info->DimmId >= ARRAY_SIZE(config->spdAddrLookup[0][0])) return AGESA_ERROR; spdAddress = config->spdAddrLookup - [info->SocketId] [info->MemChannelId] [info->DimmId]; + [info->SocketId][info->MemChannelId][info->DimmId]; if (spdAddress == 0) return AGESA_ERROR; -- cgit v1.2.3