From a62cd29c985cf87b55a76f47582609119bd4b7a1 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 3 Jul 2013 11:24:18 +0800 Subject: net: Use ARRAY_SIZE at appropriate places Use ARRAY_SIZE instead of having similar implementation in each drivers. The NUMELEMS defined in drivers/net/npe/include/IxOsalTypes.h is not used at all, so this patch removes it instead of converting it to use ARRAY_SIZE. Signed-off-by: Axel Lin Cc: Albert Aribaud Cc: Ben Warren Cc: Jean-Christophe PLAGNIOL-VILLARD Cc: Joe Hershberger Cc: Marek Vasut Cc: Mike Frysinger Cc: Nobuhiro Iwamatsu Cc: TsiChungLiew Cc: Wolfgang Denk Cc: York Sun --- drivers/net/npe/IxEthDBFeatures.c | 4 ++-- drivers/net/npe/IxOsalIoMem.c | 3 +-- drivers/net/npe/include/IxEthDBPortDefs.h | 2 +- drivers/net/npe/include/IxOsalTypes.h | 6 ------ 4 files changed, 4 insertions(+), 11 deletions(-) (limited to 'drivers/net/npe') diff --git a/drivers/net/npe/IxEthDBFeatures.c b/drivers/net/npe/IxEthDBFeatures.c index c5b680a742..ecabec5b1b 100644 --- a/drivers/net/npe/IxEthDBFeatures.c +++ b/drivers/net/npe/IxEthDBFeatures.c @@ -144,7 +144,7 @@ void ixEthDBFeatureCapabilityScan(void) /* find the traffic class definition index compatible with the current NPE A functionality ID */ for (trafficClassDefinitionIndex = 0 ; - trafficClassDefinitionIndex < sizeof (ixEthDBTrafficClassDefinitions) / sizeof (ixEthDBTrafficClassDefinitions[0]); + trafficClassDefinitionIndex < ARRAY_SIZE(ixEthDBTrafficClassDefinitions); trafficClassDefinitionIndex++) { if (ixEthDBTrafficClassDefinitions[trafficClassDefinitionIndex][IX_ETH_DB_NPE_A_FUNCTIONALITY_ID_INDEX] == npeAImageId.functionalityId) @@ -155,7 +155,7 @@ void ixEthDBFeatureCapabilityScan(void) } /* select the default case if we went over the array boundary */ - if (trafficClassDefinitionIndex == sizeof (ixEthDBTrafficClassDefinitions) / sizeof (ixEthDBTrafficClassDefinitions[0])) + if (trafficClassDefinitionIndex == ARRAY_SIZE(ixEthDBTrafficClassDefinitions)) { trafficClassDefinitionIndex = 0; /* the first record is the default case */ } diff --git a/drivers/net/npe/IxOsalIoMem.c b/drivers/net/npe/IxOsalIoMem.c index 34df92bf79..087fdf3ba1 100644 --- a/drivers/net/npe/IxOsalIoMem.c +++ b/drivers/net/npe/IxOsalIoMem.c @@ -66,8 +66,7 @@ ixOsalMemMapFind (UINT32 requestedAddress, { UINT32 mapIndex; - UINT32 numMapElements = - sizeof (ixOsalGlobalMemoryMap) / sizeof (IxOsalMemoryMap); + UINT32 numMapElements = ARRAY_SIZE(ixOsalGlobalMemoryMap); for (mapIndex = 0; mapIndex < numMapElements; mapIndex++) { diff --git a/drivers/net/npe/include/IxEthDBPortDefs.h b/drivers/net/npe/include/IxEthDBPortDefs.h index c3acbdddef..eac48cbb38 100644 --- a/drivers/net/npe/include/IxEthDBPortDefs.h +++ b/drivers/net/npe/include/IxEthDBPortDefs.h @@ -106,7 +106,7 @@ static const IxEthDBPortDefinition ixEthDBPortDefinitions[] = * @def IX_ETH_DB_NUMBER_OF_PORTS * @brief number of supported ports */ -#define IX_ETH_DB_NUMBER_OF_PORTS (sizeof (ixEthDBPortDefinitions) / sizeof (ixEthDBPortDefinitions[0])) +#define IX_ETH_DB_NUMBER_OF_PORTS ARRAY_SIZE(ixEthDBPortDefinitions) /** * @def IX_ETH_DB_UNKNOWN_PORT diff --git a/drivers/net/npe/include/IxOsalTypes.h b/drivers/net/npe/include/IxOsalTypes.h index 06e71debfb..00a49ada05 100644 --- a/drivers/net/npe/include/IxOsalTypes.h +++ b/drivers/net/npe/include/IxOsalTypes.h @@ -91,12 +91,6 @@ typedef volatile UINT32 VUINT32; */ typedef volatile INT32 VINT32; - -#ifndef NUMELEMS -#define NUMELEMS(x) (sizeof(x) / sizeof((x)[0])) -#endif - - /** * @ingroup IxOsalTypes * -- cgit