Patchwork [U-Boot] serial: Use ARRAY_SIZE instead of reinventing it

login
register
mail settings
Submitter Axel Lin
Date June 22, 2013, 4:46 p.m.
Message ID <1371919601.31971.1.camel@phoenix>
Download mbox | patch
Permalink /patch/253417/
State Accepted
Delegated to: Tom Rini
Headers show

Comments

Axel Lin - June 22, 2013, 4:46 p.m.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/serial/serial.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Tom Rini - June 26, 2013, 8:25 p.m.
On Sun, Jun 23, 2013 at 12:46:41AM +0800, Axel Lin wrote:

> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> 
> ---
> drivers/serial/serial.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Applied to u-boot/master, thanks!

Patch

diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index daa8003..a19cec5 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -37,7 +37,6 @@  static struct serial_device *serial_current;
  * Table with supported baudrates (defined in config_xyz.h)
  */
 static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE;
-#define	N_BAUDRATES (sizeof(baudrate_table) / sizeof(baudrate_table[0]))
 
 /**
  * serial_null() - Void registration routine of a serial driver
@@ -74,11 +73,11 @@  static int on_baudrate(const char *name, const char *value, enum env_op op,
 		if (gd->baudrate == baudrate)
 			return 0;
 
-		for (i = 0; i < N_BAUDRATES; ++i) {
+		for (i = 0; i < ARRAY_SIZE(baudrate_table); ++i) {
 			if (baudrate == baudrate_table[i])
 				break;
 		}
-		if (i == N_BAUDRATES) {
+		if (i == ARRAY_SIZE(baudrate_table)) {
 			if ((flags & H_FORCE) == 0)
 				printf("## Baudrate %d bps not supported\n",
 					baudrate);