spl: Move check for SPL_LIBCOMMON support to header
PATCH 1/1 spl: Move check for SPL_LIBCOMMON support to header
From: "Andrew F. Davis" <[email protected]>
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.
--- boot/common_fit.c | 2 -- common/spl/spl.c | 4 +--- common/spl/spl_ext.c | 8 -------- common/spl/spl_fat.c | 6 ------ common/spl/spl_mmc.c | 18 ------------------ 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 ++--- 10 files changed, 3 insertions(+), 58 deletions(-)
boot/common_fit.c +0 -2
@@ -54,10 +54,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 ; }
common/spl/spl.c +1 -3
@@ -682,9 +682,7 @@ static int boot_from_devices(struct spl_image_info *spl_image,if (CONFIG_IS_ENABLED (SHOW_ERRORS )) ret = -ENXIO ; loader =spl_ll_find_loader (bootdev); -if (CONFIG_IS_ENABLED (SERIAL ) && -CONFIG_IS_ENABLED (LIBCOMMON_SUPPORT ) && - !IS_ENABLED (CONFIG_SILENT_CONSOLE )) { +if (!IS_ENABLED (CONFIG_SILENT_CONSOLE )) {if (loader)printf ("Trying to boot from %s\n" ,spl_loader_name (loader));
common/spl/spl_ext.c +0 -8
@@ -30,9 +30,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 return -1 ; }
@@ -56,11 +54,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 ; }
@@ -84,9 +80,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 )
@@ -129,10 +123,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 ; }
common/spl/spl_fat.c +0 -6
@@ -29,9 +29,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; }
@@ -104,11 +102,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 ); }
@@ -155,10 +151,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 ; }
common/spl/spl_mmc.c +0 -18
@@ -124,9 +124,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 ; }
@@ -143,9 +141,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 ; }
@@ -164,18 +160,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; }
@@ -208,9 +200,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 ; }
@@ -237,9 +227,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 */
@@ -418,9 +406,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; } }
@@ -437,9 +423,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 */
@@ -476,10 +460,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;
common/spl/spl_usb.c +0 -2
@@ -33,9 +33,7 @@ int spl_usb_load(struct spl_image_info *spl_image, }if (err) { -#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf ("%s: usb init failed: err - %d\n" , __func__, err); -#endif return err; }
drivers/mmc/mmc-uclass.c +0 -2
@@ -293,9 +293,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 ; }
drivers/mmc/mmc.c +0 -12
@@ -291,9 +291,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 ; }
@@ -304,9 +302,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 ; }
@@ -429,9 +425,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 ; } }
@@ -480,10 +474,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 ; }
@@ -2846,10 +2838,8 @@ retry: err =mmc_send_op_cond (mmc);if (err) { -#if !defined(CONFIG_SPL_BUILD ) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT )if (!quiet)pr_err ("Card did not respond to voltage select! : %d\n" , err); -#endif return -EOPNOTSUPP ; } }
@@ -2900,9 +2890,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 ; }
drivers/mmc/mmc_legacy.c +0 -2
@@ -45,9 +45,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 ; }
include/stdio.h +2 -3
@@ -10,9 +10,8 @@ int tstc(void);/* stdout */ #if !defined(CONFIG_SPL_BUILD ) || \ - (defined(CONFIG_TPL_BUILD ) && defined(CONFIG_TPL_SERIAL )) || \ - (defined(CONFIG_SPL_BUILD ) && !defined(CONFIG_TPL_BUILD ) && \ - defined(CONFIG_SPL_SERIAL )) + (defined(CONFIG_TPL_BUILD ) && defined(CONFIG_TPL_SERIAL ) && defined(CONFIG_TPL_LIBCOMMON_SUPPORT )) || \ + (defined(CONFIG_SPL_BUILD ) && defined(CONFIG_SPL_SERIAL ) && 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, ...);
Signature · 1 line
2.36.1
Hi Andrew,
Quoted 6 lines · Andrew Davis
From: "Andrew F. Davis" <[email protected]>
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.hheader and remove these inline checks.
nit: stdio.h I think?
Quoted 16 lines
Signed-off-by Andrew F. Davis <[email protected]>Reviewed-by Simon Glass <[email protected]>--- boot/common_fit.c | 2 -- common/spl/spl.c | 4 +--- common/spl/spl_ext.c | 8 -------- common/spl/spl_fat.c | 6 ------ common/spl/spl_mmc.c | 18 ------------------ 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 ++--- 10 files changed, 3 insertions(+), 58 deletions(-)
Regards,
Simon
Quoted 4 lines · Simon Glass
Hi Andrew,
Quoted 1 line · Andrew Davis
Quoted 8 lines
Quoted 5 lines
From: "Andrew F. Davis" <[email protected]>
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.hheader and remove these inline checks.nit:
stdio.hI think?
Ah yes, looks like this header got renamed since I wrote this patch. Will fix if v2 is needed.
Thanks,
Andrew
Quoted 19 lines
Quoted 16 lines
Signed-off-by Andrew F. Davis <[email protected]>Reviewed-by Simon Glass <[email protected]>--- boot/common_fit.c | 2 -- common/spl/spl.c | 4 +--- common/spl/spl_ext.c | 8 -------- common/spl/spl_fat.c | 6 ------ common/spl/spl_mmc.c | 18 ------------------ 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 ++--- 10 files changed, 3 insertions(+), 58 deletions(-)Regards,
Simon
Quoted 8 lines · Andrew Davis
From: "Andrew F. Davis" <[email protected]>
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.hheader and remove these inline checks.Signed-off-by Andrew F. Davis <[email protected]>Reviewed-by Simon Glass <[email protected]>
I thought we had this already, but I guess not. That said:
[snip]
include/stdio.h int tstc(void); · line 14
Quoted 13 lines
include/stdio.h +2
-3@@ -10,9 +10,8 @@ int tstc(void);/* stdout */ #if !defined(CONFIG_SPL_BUILD ) || \ - (defined(CONFIG_TPL_BUILD ) && defined(CONFIG_TPL_SERIAL )) || \ - (defined(CONFIG_SPL_BUILD ) && !defined(CONFIG_TPL_BUILD ) && \ - defined(CONFIG_SPL_SERIAL )) + (defined(CONFIG_TPL_BUILD ) && defined(CONFIG_TPL_SERIAL ) && defined(CONFIG_TPL_LIBCOMMON_SUPPORT )) || \ + (defined(CONFIG_SPL_BUILD ) && defined(CONFIG_SPL_SERIAL ) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT ) && !defined(CONFIG_TPL_BUILD ))
Can we write this as something like:
#if !defined(CONFIG_SPL_BUILD) || \ (CONFIG_IS_ENABLED(BUILD) && CONFIG_IS_ENABLED(SERIAL) && CONFIG_IS_ENABLED(LIBCOMMON_SUPPORT))
? I'm not 100% sure it will work for CONFIG_SPL_BUILD / CONFIG_TPL_BUILD but it should for the rest and mean we can slightly clean it up.
Signature · 1 line
Tom
Quoted 8 lines · Andrew Davis
From: "Andrew F. Davis" <[email protected]>
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.hheader and remove these inline checks.Signed-off-by Andrew F. Davis <[email protected]>Reviewed-by Simon Glass <[email protected]>
This leads to a number of different cases of build failure. Looking at evb-px30 and P1010RDB-PA_36BIT_NAND show I think two different ones. Using the public CI infrastructure to ensure a clean world build is strongly advised for the next iteration of this, thanks!
Signature · 1 line
Tom