Skip to contentSkip to conversation

keystone2: replace printf on puts where it's possible

PATCH New Ivan Khoronzhuk 2 participants 3 messages Nov 3, 2014 – Nov 4, 2014 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 keystone2: replace printf on puts where it's possible

It is better to use simple puts() function instead of printf() when it's possible. Also remove redundant sprintf().

---
 arch/arm/cpu/armv7/keystone/ddr3.c     |  2 +-
 arch/arm/cpu/armv7/keystone/keystone.c |  4 ++--
 board/ti/ks2_evm/board.c               |  7 ++-----
 board/ti/ks2_evm/ddr3_k2e.c            |  4 ++--
 board/ti/ks2_evm/ddr3_k2hk.c           | 10 +++++-----
 board/ti/ks2_evm/ddr3_k2l.c            |  2 +-
 6 files changed, 13 insertions(+), 16 deletions(-)
arch/arm/cpu/armv7/keystone/ddr3.c +1 -1
index 923906a..3e65c2e 100644
@@ -352,7 +352,7 @@ void ddr3_err_reset_workaround(void)
 	tmp_b = __raw_readl(KS2_DDR3B_DDRPHYC + KS2_DDRPHY_PGSR0_OFFSET);
 
 	if (((tmp_a & 0x0FE00000) != 0) || ((tmp_b & 0x0FE00000) != 0)) {
-		printf("DDR Leveling Error Detected!\n");
+		puts("DDR Leveling Error Detected!\n");
 		printf("DDR3A PGSR0 = 0x%x\n", tmp_a);
 		printf("DDR3B PGSR0 = 0x%x\n", tmp_b);
 
arch/arm/cpu/armv7/keystone/keystone.c +2 -2
index 11a9357..52cb6fc 100644
@@ -32,7 +32,7 @@ int cpu_to_bus(u32 *ptr, u32 length)
 
 static int turn_off_myself(void)
 {
-	printf("Turning off ourselves\r\n");
+	puts("Turning off ourselves\r\n");
 	mon_power_off(0);
 
 	psc_disable_module(KS2_LPSC_TETRIS);
@@ -42,7 +42,7 @@ static int turn_off_myself(void)
 		      "dsb\n"
 		      "wfi\n");
 
-	printf("What! Should not see that\n");
+	puts("What! Should not see that\n");
 	return 0;
 }
 
board/ti/ks2_evm/board.c +2 -5
index 4029493..ff7bc4b 100644
@@ -122,7 +122,6 @@ void ft_board_setup(void *blob, bd_t *bd)
 	int nbanks;
 	u64 size[2];
 	u64 start[2];
-	char name[32];
 	int nodeoffset;
 	u32 ddr3a_size;
 	int unitrd_fixup = 0;
@@ -158,15 +157,13 @@ void ft_board_setup(void *blob, bd_t *bd)
 	}
 
 	/* reserve memory at start of bank */
-	sprintf(name, "mem_reserve_head");
-	env = getenv(name);
+	env = getenv("mem_reserve_head");
 	if (env) {
 		start[0] += ustrtoul(env, &endp, 0);
 		size[0] -= ustrtoul(env, &endp, 0);
 	}
 
-	sprintf(name, "mem_reserve");
-	env = getenv(name);
+	env = getenv("mem_reserve");
 	if (env)
 		size[0] -= ustrtoul(env, &endp, 0);
 
board/ti/ks2_evm/ddr3_k2e.c +2 -2
index 40fd966..3f100ed 100644
@@ -31,7 +31,7 @@ void ddr3_init(void)
 	if (!strcmp(dimm_name, "18KSF1G72HZ-1G6E2 ")) {
 		/* 8G SO-DIMM */
 		ddr3_size = 8;
-		printf("DRAM: 8 GiB\n");
+		puts("DRAM: 8 GiB\n");
 		ddr3phy_1600_8g.zq0cr1 |= 0x10000;
 		ddr3phy_1600_8g.zq1cr1 |= 0x10000;
 		ddr3phy_1600_8g.zq2cr1 |= 0x10000;
@@ -40,7 +40,7 @@ void ddr3_init(void)
 	} else if (!strcmp(dimm_name, "18KSF51272HZ-1G6K2")) {
 		/* 4G SO-DIMM */
 		ddr3_size = 4;
-		printf("DRAM: 4 GiB\n");
+		puts("DRAM: 4 GiB\n");
 		ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_1600_4g);
 		ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_1600_4g);
 	}
board/ti/ks2_evm/ddr3_k2hk.c +5 -5
index a1c3d05..115aed7 100644
@@ -45,14 +45,14 @@ void ddr3_init(void)
 
 			ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE,
 					  &ddr3_1600_8g);
-			printf("DRAM:  Capacity 8 GiB (includes reported below)\n");
+			puts("DRAM:  Capacity 8 GiB (includes reported below)\n");
 			ddr3_size = 8;
 		} else {
 			ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_1600_8g);
 			ddr3_1600_8g.sdcfg |= 0x1000;
 			ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE,
 					  &ddr3_1600_8g);
-			printf("DRAM:  Capacity 4 GiB (includes reported below)\n");
+			puts("DRAM:  Capacity 4 GiB (includes reported below)\n");
 			ddr3_size = 4;
 		}
 	} else if (!strcmp(dimm_name, "SQR-SD3T-2G1333SED")) {
@@ -75,17 +75,17 @@ void ddr3_init(void)
 			ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE,
 					  &ddr3_1333_2g);
 			ddr3_size = 2;
-			printf("DRAM:  2 GiB");
+			puts("DRAM:  2 GiB\n");
 		} else {
 			ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_1333_2g);
 			ddr3_1333_2g.sdcfg |= 0x1000;
 			ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE,
 					  &ddr3_1333_2g);
 			ddr3_size = 1;
-			printf("DRAM:  1 GiB");
+			puts("DRAM:  1 GiB\n");
 		}
 	} else {
-		printf("Unknown SO-DIMM. Cannot configure DDR3\n");
+		puts("Unknown SO-DIMM. Cannot configure DDR3\n");
 		while (1)
 			;
 	}
board/ti/ks2_evm/ddr3_k2l.c +1 -1
index 15a14f2..32fb4b7 100644
@@ -19,7 +19,7 @@ void ddr3_init(void)
 	init_pll(&ddr3_400);
 
 	/* No SO-DIMM, 2GB discreet DDR */
-	printf("DRAM: 2 GiB\n");
+	puts("DRAM: 2 GiB\n");
 	ddr3_size = 2;
 
 	/* Reset DDR3 PHY after PLL enabled */
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 keystone2: replace printf on puts where it's possible

Quoted 4 lines · Ivan Khoronzhuk

It is better to use simple puts() function instead of printf() when it's possible. Also remove redundant sprintf().

One of the outcomes of the mini-summit and I think was summarized on the list as well was that we're going to stop with the "use puts instead of printf!" thing as it ends up being more annoying to contributors than useful in terms of functionality and code size.

Quoted 19 lines
board/ti/ks2_evm/board.c +1 -3
index 4029493..ff7bc4b 100644
@@ -122,7 +122,6 @@ void ft_board_setup(void *blob, bd_t *bd)
 	int nbanks;
 	u64 size[2];
 	u64 start[2];
-	char name[32];
 	int nodeoffset;
 	u32 ddr3a_size;
 	int unitrd_fixup = 0;
@@ -158,15 +157,13 @@ void ft_board_setup(void *blob, bd_t *bd)
 	}
 
 	/* reserve memory at start of bank */
-	sprintf(name, "mem_reserve_head");
-	env = getenv(name);
+	env = getenv("mem_reserve_head");

board/ti/ks2_evm/board.c void ft_board_setup(void *blob, bd_t *bd) · line 168

Quoted 10 lines
board/ti/ks2_evm/board.c +1 -2
 	if (env) {
 		start[0] += ustrtoul(env, &endp, 0);
 		size[0] -= ustrtoul(env, &endp, 0);
 	}
 
-	sprintf(name, "mem_reserve");
-	env = getenv(name);
+	env = getenv("mem_reserve");
 	if (env)
 		size[0] -= ustrtoul(env, &endp, 0);

This is good to fix however.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20141104/74beee07/attachment.pgp>
#2 lore raw

PATCH 1/1 keystone2: replace printf on puts where it's possible

Quoted 35 lines · Tom Rini
Quoted 4 lines · Ivan Khoronzhuk

It is better to use simple puts() function instead of printf() when it's possible. Also remove redundant sprintf().

One of the outcomes of the mini-summit and I think was summarized on the list as well was that we're going to stop with the "use puts instead of printf!" thing as it ends up being more annoying to contributors than useful in terms of functionality and code size.

Quoted 24 lines
board/ti/ks2_evm/board.c +1 -3
index 4029493..ff7bc4b 100644
@@ -122,7 +122,6 @@ void ft_board_setup(void *blob, bd_t *bd)
  	int nbanks;
  	u64 size[2];
  	u64 start[2];
-	char name[32];
  	int nodeoffset;
  	u32 ddr3a_size;
  	int unitrd_fixup = 0;
@@ -158,15 +157,13 @@ void ft_board_setup(void *blob, bd_t *bd)
  	}
 
  	/* reserve memory at start of bank */
-	sprintf(name, "mem_reserve_head");
-	env = getenv(name);
+	env = getenv("mem_reserve_head");
  	if (env) {
  		start[0] += ustrtoul(env, &endp, 0);
  		size[0] -= ustrtoul(env, &endp, 0);
  	}
 
Quoted 7 lines

board/ti/ks2_evm/board.c void ft_board_setup(void *blob, bd_t *bd) · line 168

Quoted 5 lines
board/ti/ks2_evm/board.c +1 -2
-	sprintf(name, "mem_reserve");
-	env = getenv(name);
+	env = getenv("mem_reserve");
  	if (env)
  		size[0] -= ustrtoul(env, &endp, 0);

This is good to fix however.

Ok,
Reject this patch.
I will send new patch that delete only sprintf.
Thanks!

Signature · 2 lines
Regards,
Ivan Khoronzhuk