Patchwork [U-Boot,5/5] mmc: don't support write & erase for SPL builds

login
register
mail settings
Submitter Paul Burton
Date Sept. 4, 2013, 3:14 p.m.
Message ID <1378307643-17095-1-git-send-email-paul.burton@imgtec.com>
Download mbox | patch
Permalink /patch/272652/
State Superseded
Delegated to: Pantelis Antoniou
Headers show

Comments

Paul Burton - Sept. 4, 2013, 3:14 p.m.
For SPL builds this is just dead code since we'll only need to read.
Eliminating it results in a significant size reduction for the SPL
binary.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---
 drivers/mmc/mmc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
Pantelis Antoniou - Sept. 6, 2013, 12:56 p.m.
Hi Paul,

On Sep 4, 2013, at 6:14 PM, Paul Burton wrote:

> For SPL builds this is just dead code since we'll only need to read.
> Eliminating it results in a significant size reduction for the SPL
> binary.
> 
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> ---

I understand what you're trying to do, but I don't like the #ifdef thing.

I'd prefer moving the mmc_berase & mmc_bwrite in a different file that's
only built for non-SPL and then use the a conditional macro in a header
file.

I.e. 

#ifndef CONFIG_SPL_BUILD
extern unsigned long mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt);
#else
#define mmc_berase(dev_num, start, blkcnt) /* nothing */
#endif

Etc.

Regards

-- Pantelis


> drivers/mmc/mmc.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 30a985b..d305257 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -248,6 +248,7 @@ err_out:
> static unsigned long
> mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt)
> {
> +#ifndef CONFIG_SPL_BUILD
> 	int err = 0;
> 	struct mmc *mmc = find_mmc_device(dev_num);
> 	lbaint_t blk = 0, blk_r = 0;
> @@ -281,6 +282,9 @@ mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt)
> 	}
> 
> 	return blk;
> +#else /* CONFIG_SPL_BUILD */
> +	return -1;
> +#endif
> }
> 
> static ulong
> @@ -349,6 +353,7 @@ mmc_write_blocks(struct mmc *mmc, lbaint_t start, lbaint_t blkcnt, const void*sr
> static ulong
> mmc_bwrite(int dev_num, lbaint_t start, lbaint_t blkcnt, const void*src)
> {
> +#ifndef CONFIG_SPL_BUILD
> 	lbaint_t cur, blocks_todo = blkcnt;
> 
> 	struct mmc *mmc = find_mmc_device(dev_num);
> @@ -368,6 +373,9 @@ mmc_bwrite(int dev_num, lbaint_t start, lbaint_t blkcnt, const void*src)
> 	} while (blocks_todo > 0);
> 
> 	return blkcnt;
> +#else /* CONFIG_SPL_BUILD */
> +	return 0;
> +#endif
> }
> 
> static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
> -- 
> 1.8.3.4
> 
>

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 30a985b..d305257 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -248,6 +248,7 @@  err_out:
 static unsigned long
 mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt)
 {
+#ifndef CONFIG_SPL_BUILD
 	int err = 0;
 	struct mmc *mmc = find_mmc_device(dev_num);
 	lbaint_t blk = 0, blk_r = 0;
@@ -281,6 +282,9 @@  mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt)
 	}
 
 	return blk;
+#else /* CONFIG_SPL_BUILD */
+	return -1;
+#endif
 }
 
 static ulong
@@ -349,6 +353,7 @@  mmc_write_blocks(struct mmc *mmc, lbaint_t start, lbaint_t blkcnt, const void*sr
 static ulong
 mmc_bwrite(int dev_num, lbaint_t start, lbaint_t blkcnt, const void*src)
 {
+#ifndef CONFIG_SPL_BUILD
 	lbaint_t cur, blocks_todo = blkcnt;
 
 	struct mmc *mmc = find_mmc_device(dev_num);
@@ -368,6 +373,9 @@  mmc_bwrite(int dev_num, lbaint_t start, lbaint_t blkcnt, const void*src)
 	} while (blocks_todo > 0);
 
 	return blkcnt;
+#else /* CONFIG_SPL_BUILD */
+	return 0;
+#endif
 }
 
 static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,