From: Paul Burton <paul.burton@imgtec.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] mmc: don't support write & erase for SPL builds
Date: Mon, 9 Sep 2013 09:14:53 +0100 [thread overview]
Message-ID: <522D837D.5030809@imgtec.com> (raw)
In-Reply-To: <522C39D4.50800@googlemail.com>
On Sun 08 Sep 2013 09:48:20 BST, Andreas Bie?mann wrote:
>
> Dear Paul Burton,
>
> On 06.09.13 15:43, 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, which may be critical for certain platforms where the binary
>> size is highly constrained.
>>
>> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
>> ---
>> Changes in v2:
>> - Move the mmc_bwrite & mmc_berase functions to a new mmc_write.c
>> file which is only compiled for non-SPL builds, as per a request
>> from Pantelis Antoniou. This requires that a few formerly static
>> functions in mmc.c be accessible to the new file, so they are
>> declared in a new mmc_private.h header along with the write &
>> erase functions. For what it's worth I prefered v1, but hey ho.
>> ---
>> drivers/mmc/Makefile | 2 +
>> drivers/mmc/mmc.c | 186 +--------------------------------------------
>> drivers/mmc/mmc_private.h | 45 +++++++++++
>> drivers/mmc/mmc_write.c | 189
>> ++++++++++++++++++++++++++++++++++++++++++++++
>> 4 files changed, 240 insertions(+), 182 deletions(-)
>> create mode 100644 drivers/mmc/mmc_private.h
>> create mode 100644 drivers/mmc/mmc_write.c
>
>
> <snip>
>
>>
>> diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c
>> new file mode 100644
>> index 0000000..dde5cf2
>> --- /dev/null
>> +++ b/drivers/mmc/mmc_write.c
>> @@ -0,0 +1,189 @@
>> +/*
>> + * Copyright 2008, Freescale Semiconductor, Inc
>> + * Andy Fleming
>> + *
>> + * Based vaguely on the Linux code
>> + *
>> + * SPDX-License-Identifier: GPL-2.0+
>> + */
>> +
>> +#include <config.h>
>> +#include <common.h>
>> +#include <part.h>
>> +#include "mmc_private.h"
>> +
>> +static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt)
>> +{
>> + struct mmc_cmd cmd;
>> + ulong end;
>> + int err, start_cmd, end_cmd;
>> +
>> + if (mmc->high_capacity) {
>> + end = start + blkcnt - 1;
>> + } else {
>> + end = (start + blkcnt - 1) * mmc->write_bl_len;
>> + start *= mmc->write_bl_len;
>> + }
>> +
>> + if (IS_SD(mmc)) {
>> + start_cmd = SD_CMD_ERASE_WR_BLK_START;
>> + end_cmd = SD_CMD_ERASE_WR_BLK_END;
>> + } else {
>> + start_cmd = MMC_CMD_ERASE_GROUP_START;
>> + end_cmd = MMC_CMD_ERASE_GROUP_END;
>> + }
>> +
>> + cmd.cmdidx = start_cmd;
>> + cmd.cmdarg = start;
>> + cmd.resp_type = MMC_RSP_R1;
>> +
>> + err = mmc_send_cmd(mmc, &cmd, NULL);
>> + if (err)
>> + goto err_out;
>> +
>> + cmd.cmdidx = end_cmd;
>> + cmd.cmdarg = end;
>> +
>> + err = mmc_send_cmd(mmc, &cmd, NULL);
>> + if (err)
>> + goto err_out;
>> +
>> + cmd.cmdidx = MMC_CMD_ERASE;
>> + cmd.cmdarg = SECURE_ERASE;
>> + cmd.resp_type = MMC_RSP_R1b;
>> +
>> + err = mmc_send_cmd(mmc, &cmd, NULL);
>> + if (err)
>> + goto err_out;
>> +
>> + return 0;
>> +
>> +err_out:
>> +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
>> + puts("mmc erase failed\n");
>> +#endif
>
>
> this conditional compile in of puts/printf for SPL are no longer
> required, I'd prefere to remove them globally in mmc_write.c.
Ah, yes good point, I'll remove that.
>
>>
>> + return err;
>> +}
>
>
> Rest of this patch looks good to me.
>
> Best regards
>
> Andreas Bie?mann
Thanks for looking at it!
Paul
next prev parent reply other threads:[~2013-09-09 8:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-04 15:12 [U-Boot] [PATCH 0/5] SPL/MMC size fixes Paul Burton
2013-09-04 15:12 ` [U-Boot] [PATCH 1/5] spl: remove unnecessary (& ARM specific) include of asm/utils.h Paul Burton
2013-09-04 15:12 ` [U-Boot] [PATCH 2/5] spl_mmc: only call printf or puts with CONFIG_SPL_LIBCOMMON_SUPPORT Paul Burton
2013-09-04 15:12 ` [U-Boot] [PATCH 3/5] mmc: don't call *printf or puts when SPL & !CONFIG_SPL_LIBCOMMON_SUPPORT Paul Burton
2013-09-06 12:48 ` Pantelis Antoniou
2013-09-06 12:51 ` Paul Burton
2013-09-06 12:55 ` Pantelis Antoniou
2013-09-04 15:12 ` [U-Boot] [PATCH 4/5] mmc: size optimization when !CONFIG_MMC_SPI Paul Burton
2013-09-04 15:14 ` [U-Boot] [PATCH 5/5] mmc: don't support write & erase for SPL builds Paul Burton
2013-09-06 12:56 ` Pantelis Antoniou
2013-09-06 13:43 ` [U-Boot] [PATCH v2] " Paul Burton
2013-09-06 13:54 ` Pantelis Antoniou
2013-09-08 8:48 ` Andreas Bießmann
2013-09-09 8:14 ` Paul Burton [this message]
2013-09-09 8:27 ` Pantelis Antoniou
2013-09-09 14:30 ` [U-Boot] [PATCH v3] " Paul Burton
2013-09-04 15:15 ` [U-Boot] [PATCH 0/5] SPL/MMC size fixes Paul Burton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=522D837D.5030809@imgtec.com \
--to=paul.burton@imgtec.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.