[U-Boot] [PATCH v4 07/10] mmc: allow to compile out the error messages

Jean-Jacques Hiblot jjhiblot at ti.com
Wed Nov 29 14:29:52 UTC 2017


Error messages may not be as valued as code space. Allow to compile out
most of them to free space.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
---
 drivers/mmc/Kconfig |  1 +
 drivers/mmc/mmc.c   | 44 ++++++++++++++++++++------------------------
 2 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index dbbef5a..7a45d4b 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -60,6 +60,7 @@ config MMC_VERBOSE
 
 config SPL_MMC_VERBOSE
 	bool "Output more information about the MMC in SPL"
+	depends on SPL_LIBCOMMON_SUPPORT
 	default n
 	help
 	  Enable the output of more information about the card such as the
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 13979a5..af303b3 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -22,6 +22,12 @@
 #include <div64.h>
 #include "mmc_private.h"
 
+#if CONFIG_IS_ENABLED(MMC_VERBOSE)
+#define error printf
+#else
+#define error(...)
+#endif
+
 static const unsigned int sd_au_size[] = {
 	0,		SZ_16K / 512,		SZ_32K / 512,
 	SZ_64K / 512,	SZ_128K / 512,		SZ_256K / 512,
@@ -250,10 +256,8 @@ int mmc_send_status(struct mmc *mmc, int timeout)
 				break;
 
 			if (cmd.response[0] & MMC_STATUS_MASK) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-				printf("Status Error: 0x%08X\n",
-					cmd.response[0]);
-#endif
+				error("Status Error: 0x%08X\n",
+				      cmd.response[0]);
 				return -ECOMM;
 			}
 		} else if (--retries < 0)
@@ -267,9 +271,7 @@ int mmc_send_status(struct mmc *mmc, int timeout)
 
 	mmc_trace_state(mmc, &cmd);
 	if (timeout <= 0) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-		printf("Timeout waiting card ready\n");
-#endif
+		error("Timeout waiting card ready\n");
 		return -ETIMEDOUT;
 	}
 
@@ -407,9 +409,7 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
 		cmd.cmdarg = 0;
 		cmd.resp_type = MMC_RSP_R1b;
 		if (mmc_send_cmd(mmc, &cmd, NULL)) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-			printf("mmc fail to send stop cmd\n");
-#endif
+			error("mmc fail to send stop cmd\n");
 			return 0;
 		}
 	}
@@ -447,10 +447,8 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
 		return 0;
 
 	if ((start + blkcnt) > block_dev->lba) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-		printf("MMC: block number 0x" LBAF " exceeds max(0x" LBAF ")\n",
-			start + blkcnt, block_dev->lba);
-#endif
+		error("MMC: block number 0x" LBAF " exceeds max(0x" LBAF ")\n",
+		      start + blkcnt, block_dev->lba);
 		return 0;
 	}
 
@@ -828,7 +826,7 @@ static int mmc_get_capabilities(struct mmc *mmc)
 		return 0;
 
 	if (!ext_csd) {
-		printf("No ext_csd found!\n"); /* this should enver happen */
+		error("No ext_csd found!\n"); /* this should enver happen */
 		return -ENOTSUPP;
 	}
 
@@ -1433,7 +1431,7 @@ static inline int bus_width(uint cap)
 		return 4;
 	if (cap == MMC_MODE_1BIT)
 		return 1;
-	printf("invalid bus witdh capability 0x%x\n", cap);
+	debug("invalid bus witdh capability 0x%x\n", cap);
 	return 0;
 }
 
@@ -1632,7 +1630,7 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps)
 				if (!err)
 					return 0;
 
-				printf("bad ssr\n");
+				error("bad ssr\n");
 
 error:
 				/* revert to a safer bus speed */
@@ -1642,7 +1640,7 @@ error:
 		}
 	}
 
-	printf("unable to select a mode\n");
+	error("unable to select a mode\n");
 	return -ENOTSUPP;
 }
 
@@ -1856,7 +1854,7 @@ error:
 		}
 	}
 
-	printf("unable to select a mode\n");
+	error("unable to select a mode\n");
 
 	return -ENOTSUPP;
 }
@@ -2188,7 +2186,7 @@ static int mmc_startup(struct mmc *mmc)
 		cmd.cmdarg = (mmc->dsr & 0xffff) << 16;
 		cmd.resp_type = MMC_RSP_NONE;
 		if (mmc_send_cmd(mmc, &cmd, NULL))
-			printf("MMC: SET_DSR failed\n");
+			error("MMC: SET_DSR failed\n");
 	}
 
 	/* Select the card, and put it into Transfer Mode */
@@ -2341,7 +2339,7 @@ static void mmc_set_initial_state(struct mmc *mmc)
 	if (err != 0)
 		err = mmc_set_signal_voltage(mmc, MMC_SIGNAL_VOLTAGE_180);
 	if (err != 0)
-		printf("mmc: failed to set signal voltage\n");
+		debug("mmc: failed to set signal voltage\n");
 
 	mmc_select_mode(mmc, MMC_LEGACY);
 	mmc_set_bus_width(mmc, 1);
@@ -2489,9 +2487,7 @@ retry:
 		err = mmc_send_op_cond(mmc);
 
 		if (err) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-			printf("Card did not respond to voltage select!\n");
-#endif
+			error("Card did not respond to voltage select!\n");
 			return -EOPNOTSUPP;
 		}
 	}
-- 
1.9.1



More information about the U-Boot mailing list