public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [POWERPC v2] mgsuvd: fix coding style
Date: Fri, 17 Oct 2008 13:52:21 +0200	[thread overview]
Message-ID: <48F87C75.1080107@denx.de> (raw)


Signed-off-by: Heiko Schocher <hs@denx.de>
---
 board/keymile/mgsuvd/mgsuvd.c |   98 +++++++++++++----------------------------
 include/configs/mgsuvd.h      |   10 ++---
 2 files changed, 35 insertions(+), 73 deletions(-)

diff --git a/board/keymile/mgsuvd/mgsuvd.c b/board/keymile/mgsuvd/mgsuvd.c
index 912e177..d74cb92 100644
--- a/board/keymile/mgsuvd/mgsuvd.c
+++ b/board/keymile/mgsuvd/mgsuvd.c
@@ -20,11 +20,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  * MA 02111-1307 USA
  */
-
-#if 0
-#define DEBUG
-#endif
-
 #include <common.h>
 #include <mpc8xx.h>

@@ -154,83 +149,52 @@ int hush_init_var (void)
 }

 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
+
+#define FDT_SET_NODE_VALUE(nodename, reg, var, size) \
+	nodeoffset = fdt_path_offset (blob, nodename); \
+	if (nodeoffset >= 0) { \
+		ret = fdt_setprop (blob, nodeoffset, reg, var, \
+					size); \
+		if (ret < 0) \
+			printf("ft_blob_update(): cannot set %s/%s " \
+				"property err:%s\n", nodename, reg, \
+				fdt_strerror (ret)); \
+		} else { \
+			printf("ft_blob_update(): cannot find %s node " \
+				"err:%s\n", nodename, fdt_strerror (nodeoffset)); \
+	}
+
 /*
  * update "memory" property in the blob
  */
-void ft_blob_update(void *blob, bd_t *bd)
+void ft_blob_update (void *blob, bd_t *bd)
 {
 	int ret, nodeoffset = 0;
 	ulong brg_data[1] = {0};
 	ulong memory_data[2] = {0};
 	ulong flash_data[4] = {0};

-	memory_data[0] = cpu_to_be32(bd->bi_memstart);
-	memory_data[1] = cpu_to_be32(bd->bi_memsize);
-
-		nodeoffset = fdt_path_offset (blob, "/memory");
-		if (nodeoffset >= 0) {
-			ret = fdt_setprop(blob, nodeoffset, "reg", memory_data,
-						sizeof(memory_data));
-		if (ret < 0)
-			printf("ft_blob_update(): cannot set /memory/reg "
-				"property err:%s\n", fdt_strerror(ret));
-		}
-		else {
-			/* memory node is required in dts */
-			printf("ft_blob_update(): cannot find /memory node "
-			"err:%s\n", fdt_strerror(nodeoffset));
-	}
-
-	flash_data[2] = cpu_to_be32(bd->bi_flashstart);
-	flash_data[3] = cpu_to_be32(bd->bi_flashsize);
-	nodeoffset = fdt_path_offset (blob, "/localbus");
-	if (nodeoffset >= 0) {
-		ret = fdt_setprop(blob, nodeoffset, "ranges", flash_data,
-					sizeof(flash_data));
-	if (ret < 0)
-		printf("ft_blob_update(): cannot set /localbus/ranges "
-			"property err:%s\n", fdt_strerror(ret));
-	}
-	else {
-		/* memory node is required in dts */
-		printf("ft_blob_update(): cannot find /localbus node "
-		"err:%s\n", fdt_strerror(nodeoffset));
-	}
+	memory_data[0] = cpu_to_be32 (bd->bi_memstart);
+	memory_data[1] = cpu_to_be32 (bd->bi_memsize);
+	FDT_SET_NODE_VALUE("/memory", "reg", memory_data, sizeof (memory_data))
+
+	flash_data[2] = cpu_to_be32 (bd->bi_flashstart);
+	flash_data[3] = cpu_to_be32 (bd->bi_flashsize);
+	FDT_SET_NODE_VALUE("/localbus", "ranges", flash_data,
+				sizeof (flash_data))
 	/* BRG */
-	brg_data[0] = cpu_to_be32(bd->bi_busfreq);
-	nodeoffset = fdt_path_offset (blob, "/soc/cpm");
-	if (nodeoffset >= 0) {
-		ret = fdt_setprop(blob, nodeoffset, "brg-frequency", brg_data,
-					sizeof(brg_data));
-	if (ret < 0)
-		printf("ft_blob_update(): cannot set /soc/cpm/brg-frequency "
-			"property err:%s\n", fdt_strerror(ret));
-	}
-	else {
-		/* memory node is required in dts */
-		printf("ft_blob_update(): cannot find /soc/cpm node "
-		"err:%s\n", fdt_strerror(nodeoffset));
-	}
+	brg_data[0] = cpu_to_be32 (bd->bi_busfreq);
+	FDT_SET_NODE_VALUE("/soc/cpm", "brg-frequency", brg_data,
+				sizeof (brg_data))
 	/* MAC Adresse */
-	nodeoffset = fdt_path_offset (blob, "/soc/cpm/ethernet");
-	if (nodeoffset >= 0) {
-		ret = fdt_setprop(blob, nodeoffset, "mac-address", bd->bi_enetaddr,
-					sizeof(uchar) * 6);
-	if (ret < 0)
-		printf("ft_blob_update(): cannot set /soc/cpm/scc/mac-address "
-			"property err:%s\n", fdt_strerror(ret));
-	}
-	else {
-		/* memory node is required in dts */
-		printf("ft_blob_update(): cannot find /soc/cpm/ethernet node "
-		"err:%s\n", fdt_strerror(nodeoffset));
-	}
+	FDT_SET_NODE_VALUE("/soc/cpm/ethernet", "mac-address",
+				bd->bi_enetaddr, sizeof (uchar) * 6)
 }

 void ft_board_setup(void *blob, bd_t *bd)
 {
-	ft_cpu_setup( blob, bd);
-	ft_blob_update(blob, bd);
+	ft_cpu_setup (blob, bd);
+	ft_blob_update (blob, bd);
 }
 #endif /* defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) */

diff --git a/include/configs/mgsuvd.h b/include/configs/mgsuvd.h
index 7a80dad..416e4db 100644
--- a/include/configs/mgsuvd.h
+++ b/include/configs/mgsuvd.h
@@ -359,18 +359,16 @@
 #define I2C_READ	i2c_soft_read_pin ()
 #define I2C_SDA(bit)	if(bit) { \
 				*(unsigned short *)(I2C_BASE_DIR) &=  ~SDA_CONF; \
-				} \
-			else    { \
+			} else { \
 				*(unsigned char *)(I2C_BASE_PORT) &= ~SDA_BIT; \
 				*(unsigned short *)(I2C_BASE_DIR) |= SDA_CONF; \
-				}
+			}
 #define I2C_SCL(bit)	if(bit) { \
 				*(unsigned short *)(I2C_BASE_DIR) &=  ~SCL_CONF; \
-				} \
-			else    { \
+			} else { \
 				*(unsigned char *)(I2C_BASE_PORT) &= ~SCL_BIT; \
 				*(unsigned short *)(I2C_BASE_DIR) |= SCL_CONF; \
-				}
+			}
 #define I2C_DELAY	udelay(50)	/* 1/4 I2C clock duration */

 #define CONFIG_I2C_MULTI_BUS	1
-- 
1.5.6.1

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

                 reply	other threads:[~2008-10-17 11:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48F87C75.1080107@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox