diff mbox series

[v2] spl: Move check for SPL_LIBCOMMON support to header

Message ID 20200107233623.21587-1-afd@ti.com
State New
Headers show
Series [v2] spl: Move check for SPL_LIBCOMMON support to header | expand

Commit Message

Andrew Davis Jan. 7, 2020, 11:36 p.m. UTC
Print statements in SPL depend on lib/common support, due to this many
such print statements are ifdef'd. Instead of checking at each call site
move the check to the common.h header and remove these inline checks.

Signed-off-by: Andrew F. Davis <afd at ti.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
 common/common_fit.c      |  2 --
 common/spl/spl.c         |  2 --
 common/spl/spl_ext.c     |  8 --------
 common/spl/spl_fat.c     |  6 ------
 common/spl/spl_mmc.c     | 18 ------------------
 common/spl/spl_sata.c    |  2 --
 common/spl/spl_usb.c     |  2 --
 drivers/mmc/mmc-uclass.c |  2 --
 drivers/mmc/mmc.c        | 12 ------------
 drivers/mmc/mmc_legacy.c |  2 --
 include/stdio.h          |  5 ++---
 11 files changed, 2 insertions(+), 59 deletions(-)

Comments

Lokesh Vutla Jan. 8, 2020, 4:16 a.m. UTC | #1
On 08/01/20 5:06 AM, Andrew F. Davis wrote:
> Print statements in SPL depend on lib/common support, due to this many
> such print statements are ifdef'd. Instead of checking at each call site
> move the check to the common.h header and remove these inline checks.
> 
> Signed-off-by: Andrew F. Davis <afd at ti.com>
> Reviewed-by: Simon Glass <sjg at chromium.org>

Nice cleanup..!!

Reviewed-by: Lokesh Vutla <lokeshvutla at ti.com>

Thanks and regards,
Lokesh
Tom Rini Jan. 22, 2020, 11:25 p.m. UTC | #2
On Tue, Jan 07, 2020 at 06:36:23PM -0500, Andrew F. Davis wrote:

> Print statements in SPL depend on lib/common support, due to this many
> such print statements are ifdef'd. Instead of checking at each call site
> move the check to the common.h header and remove these inline checks.
> 
> Signed-off-by: Andrew F. Davis <afd at ti.com>
> Reviewed-by: Simon Glass <sjg at chromium.org>
> Reviewed-by: Lokesh Vutla <lokeshvutla at ti.com>

This breaks a number of platforms as can be seen on Travis/GitLab/Azure.
I bisected down to this commit while testing by using the firefly-px30
board.
diff mbox series

Patch

diff --git a/common/common_fit.c b/common/common_fit.c
index 41305d8aa6..a8a1fb8e5f 100644
--- a/common/common_fit.c
+++ b/common/common_fit.c
@@ -48,10 +48,8 @@  int fit_find_config_node(const void *fdt)
 	     node = fdt_next_subnode(fdt, node)) {
 		name = fdt_getprop(fdt, node, "description", &len);
 		if (!name) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 			printf("%s: Missing FDT description in DTB\n",
 			       __func__);
-#endif
 			return -EINVAL;
 		}
 
diff --git a/common/spl/spl.c b/common/spl/spl.c
index c1fce62b91..5b6f33c6b8 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -577,12 +577,10 @@  static int boot_from_devices(struct spl_image_info *spl_image,
 		struct spl_image_loader *loader;
 
 		loader = spl_ll_find_loader(spl_boot_list[i]);
-#if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
 		if (loader)
 			printf("Trying to boot from %s\n", loader->name);
 		else
 			puts(SPL_TPL_PROMPT "Unsupported Boot Device!\n");
-#endif
 		if (loader && !spl_load_image(spl_image, loader)) {
 			spl_image->boot_device = spl_boot_list[i];
 			return 0;
diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index 2a6252229c..6d96901365 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -28,9 +28,7 @@  int spl_load_image_ext(struct spl_image_info *spl_image,
 
 	err = ext4fs_mount(0);
 	if (!err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("%s: ext4fs mount err - %d\n", __func__, err);
-#endif
 		goto end;
 	}
 
@@ -54,11 +52,9 @@  int spl_load_image_ext(struct spl_image_info *spl_image,
 	err = ext4fs_read((char *)spl_image->load_addr, 0, filelen, &actlen);
 
 end:
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 	if (err < 0)
 		printf("%s: error reading image %s, err - %d\n",
 		       __func__, filename, err);
-#endif
 
 	return err < 0;
 }
@@ -81,9 +77,7 @@  int spl_load_image_ext_os(struct spl_image_info *spl_image,
 
 	err = ext4fs_mount(0);
 	if (!err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("%s: ext4fs mount err - %d\n", __func__, err);
-#endif
 		return -1;
 	}
 #if defined(CONFIG_SPL_ENV_SUPPORT)
@@ -126,10 +120,8 @@  defaults:
 
 	err = ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR, 0, filelen, &actlen);
 	if (err < 0) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("%s: error reading image %s, err - %d\n",
 		       __func__, CONFIG_SPL_FS_LOAD_ARGS_NAME, err);
-#endif
 		return -1;
 	}
 
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index aa371ab52c..bef2b30376 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -28,9 +28,7 @@  static int spl_register_fat_device(struct blk_desc *block_dev, int partition)
 
 	err = fat_register_device(block_dev, partition);
 	if (err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("%s: fat register err - %d\n", __func__, err);
-#endif
 		return err;
 	}
 
@@ -102,11 +100,9 @@  int spl_load_image_fat(struct spl_image_info *spl_image,
 	}
 
 end:
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 	if (err <= 0)
 		printf("%s: error reading image %s, err - %d\n",
 		       __func__, filename, err);
-#endif
 
 	return (err <= 0);
 }
@@ -152,10 +148,8 @@  defaults:
 	err = file_fat_read(CONFIG_SPL_FS_LOAD_ARGS_NAME,
 			    (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0);
 	if (err <= 0) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("%s: error reading image %s, err - %d\n",
 		       __func__, CONFIG_SPL_FS_LOAD_ARGS_NAME, err);
-#endif
 		return -1;
 	}
 
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 2ede096e61..3c89b2741e 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -95,9 +95,7 @@  int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
 
 end:
 	if (ret) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		puts("mmc_load_image_raw_sector: mmc block read error\n");
-#endif
 		return -1;
 	}
 
@@ -114,9 +112,7 @@  static int spl_mmc_get_device_index(u32 boot_device)
 		return 1;
 	}
 
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 	printf("spl: unsupported mmc boot device.\n");
-#endif
 
 	return -ENODEV;
 }
@@ -135,18 +131,14 @@  static int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device)
 	err = mmc_initialize(NULL);
 #endif /* DM_MMC */
 	if (err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("spl: could not initialize mmc. error: %d\n", err);
-#endif
 		return err;
 	}
 	*mmcp = find_mmc_device(mmc_dev);
 	err = *mmcp ? 0 : -ENODEV;
 	if (err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("spl: could not find mmc device %d. error: %d\n",
 		       mmc_dev, err);
-#endif
 		return err;
 	}
 
@@ -178,9 +170,7 @@  static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
 
 	err = part_get_info(mmc_get_blk_desc(mmc), partition, &info);
 	if (err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		puts("spl: partition error\n");
-#endif
 		return -1;
 	}
 
@@ -206,9 +196,7 @@  static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
 		CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS,
 		(void *) CONFIG_SYS_SPL_ARGS_ADDR);
 	if (count != CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		puts("mmc_load_image_raw_os: mmc block read error\n");
-#endif
 		return -1;
 	}
 #endif	/* CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR */
@@ -336,9 +324,7 @@  int spl_mmc_load(struct spl_image_info *spl_image,
 		err = mmc_init(mmc);
 		if (err) {
 			mmc = NULL;
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 			printf("spl: mmc init failed with error: %d\n", err);
-#endif
 			return err;
 		}
 	}
@@ -367,9 +353,7 @@  int spl_mmc_load(struct spl_image_info *spl_image,
 			err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), part);
 
 		if (err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 			puts("spl: mmc partition switch failed\n");
-#endif
 			return err;
 		}
 		/* Fall through */
@@ -404,10 +388,8 @@  int spl_mmc_load(struct spl_image_info *spl_image,
 			return err;
 
 		break;
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 	default:
 		puts("spl: mmc: wrong boot mode\n");
-#endif
 	}
 
 	return err;
diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c
index e108af0576..216a738915 100644
--- a/common/spl/spl_sata.c
+++ b/common/spl/spl_sata.c
@@ -66,9 +66,7 @@  static int spl_sata_load_image(struct spl_image_info *spl_image,
 	err = init_sata(CONFIG_SPL_SATA_BOOT_DEVICE);
 #endif
 	if (err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("spl: sata init failed: err - %d\n", err);
-#endif
 		return err;
 	} else {
 		/* try to recognize storage devices immediately */
diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c
index e29d579b0d..0599ed6820 100644
--- a/common/spl/spl_usb.c
+++ b/common/spl/spl_usb.c
@@ -26,9 +26,7 @@  static int spl_usb_load_image(struct spl_image_info *spl_image,
 	usb_stop();
 	err = usb_init();
 	if (err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("%s: usb init failed: err - %d\n", __func__, err);
-#endif
 		return err;
 	}
 
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index c7a832ca90..1e6b7caa22 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -225,9 +225,7 @@  struct mmc *find_mmc_device(int dev_num)
 	ret = blk_find_device(IF_TYPE_MMC, dev_num, &dev);
 
 	if (ret) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
 		printf("MMC Device %d not found\n", dev_num);
-#endif
 		return NULL;
 	}
 
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index f683b52ead..dde299b3eb 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -250,9 +250,7 @@  int mmc_poll_for_busy(struct mmc *mmc, int timeout_ms)
 			break;
 
 		if (status & MMC_STATUS_MASK) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
 			pr_err("Status Error: 0x%08x\n", status);
-#endif
 			return -ECOMM;
 		}
 
@@ -263,9 +261,7 @@  int mmc_poll_for_busy(struct mmc *mmc, int timeout_ms)
 	}
 
 	if (timeout_ms <= 0) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
 		pr_err("Timeout waiting card ready\n");
-#endif
 		return -ETIMEDOUT;
 	}
 
@@ -405,9 +401,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)
 			pr_err("mmc fail to send stop cmd\n");
-#endif
 			return 0;
 		}
 	}
@@ -445,10 +439,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)
 		pr_err("MMC: block number 0x" LBAF " exceeds max(0x" LBAF ")\n",
 		       start + blkcnt, block_dev->lba);
-#endif
 		return 0;
 	}
 
@@ -2811,9 +2803,7 @@  retry:
 		err = mmc_send_op_cond(mmc);
 
 		if (err) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
 			pr_err("Card did not respond to voltage select!\n");
-#endif
 			return -EOPNOTSUPP;
 		}
 	}
@@ -2844,9 +2834,7 @@  int mmc_start_init(struct mmc *mmc)
 #endif
 	if (no_card) {
 		mmc->has_init = 0;
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
 		pr_err("MMC: no card present\n");
-#endif
 		return -ENOMEDIUM;
 	}
 
diff --git a/drivers/mmc/mmc_legacy.c b/drivers/mmc/mmc_legacy.c
index b0f5cf58a2..7c09f7844b 100644
--- a/drivers/mmc/mmc_legacy.c
+++ b/drivers/mmc/mmc_legacy.c
@@ -46,9 +46,7 @@  struct mmc *find_mmc_device(int dev_num)
 			return m;
 	}
 
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
 	printf("MMC Device %d not found\n", dev_num);
-#endif
 
 	return NULL;
 }
diff --git a/include/stdio.h b/include/stdio.h
index aedf374452..2d5d549fe3 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -10,9 +10,8 @@  int tstc(void);
 
 /* stdout */
 #if !defined(CONFIG_SPL_BUILD) || \
-	(defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_SERIAL_SUPPORT)) || \
-	(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) && \
-		defined(CONFIG_SPL_SERIAL_SUPPORT))
+	(defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_SERIAL_SUPPORT) && defined(CONFIG_TPL_LIBCOMMON_SUPPORT)) || \
+	(defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT) && !defined(CONFIG_TPL_BUILD))
 void putc(const char c);
 void puts(const char *s);
 int __printf(1, 2) printf(const char *fmt, ...);