public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Jagan Teki <jagan@amarulasolutions.com>, Tom Rini <trini@konsulko.com>
Cc: u-boot@lists.denx.de,
	"Patrick Delaunay" <patrick.delaunay@st.com>,
	"Pali Rohár" <pali@kernel.org>,
	"Patrice Chotard" <patrice.chotard@foss.st.com>,
	"Marek Vasut" <marex@denx.de>, "Pratyush Yadav" <p.yadav@ti.com>,
	"Marek Behún" <marek.behun@nic.cz>
Subject: [PATCH u-boot-spi v3 06/10] mtd: spi-nor-core: Don't check for zero length in spi_nor_write() / spi_nor_erase()
Date: Tue,  5 Oct 2021 15:56:02 +0200	[thread overview]
Message-ID: <20211005135606.2246-7-kabel@kernel.org> (raw)
In-Reply-To: <20211005135606.2246-1-kabel@kernel.org>

From: Marek Behún <marek.behun@nic.cz>

This check is already done in all callers: mtdcore's mtd_write() /
mtd_erase(), legacy spi_nor_write() / spi_flash_erase(). No reason to do
this here as well.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---

Changes since v2:
- remove check for zero length also from spi_nor_write()

---
 drivers/mtd/spi/spi-nor-core.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index d49f7faf99..4c2590d0c5 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -914,9 +914,6 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
 	dev_dbg(nor->dev, "at 0x%llx, len %lld\n", (long long)instr->addr,
 		(long long)instr->len);
 
-	if (!instr->len)
-		return 0;
-
 	div_u64_rem(instr->len, mtd->erasesize, &rem);
 	if (rem)
 		return -EINVAL;
@@ -1671,9 +1668,6 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 
 	dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len);
 
-	if (!len)
-		return 0;
-
 	for (i = 0; i < len; ) {
 		ssize_t written;
 		loff_t addr = to + i;
-- 
2.32.0


  parent reply	other threads:[~2021-10-05 13:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 13:55 [PATCH u-boot-spi v3 00/10] Fix `mtd erase` when used with mtdpart Marek Behún
2021-10-05 13:55 ` [PATCH u-boot-spi v3 01/10] mtd: spi-nor-core: Try cleaning up in case writing BAR failed Marek Behún
2021-10-05 13:55 ` [PATCH u-boot-spi v3 02/10] mtd: spi-nor-core: Check return value of write_enable() in spi_nor_erase() Marek Behún
2021-10-05 13:55 ` [PATCH u-boot-spi v3 03/10] mtd: spi-nor-core: Don't overwrite return value if it is non-zero Marek Behún
2021-10-05 13:56 ` [PATCH u-boot-spi v3 04/10] mtd: spi-nor-core: Check return value of write_disable() in spi_nor_erase() Marek Behún
2021-10-05 13:56 ` [PATCH u-boot-spi v3 05/10] mtd: spi-flash: Check for zero length in legacy spi_flash_*() Marek Behún
2021-10-05 13:56 ` Marek Behún [this message]
2021-10-05 13:56 ` [PATCH u-boot-spi v3 07/10] mtd: spi-nor-core: Call mtd_erase_callback() from spi_nor_erase() Marek Behún
2021-10-05 13:56 ` [PATCH u-boot-spi v3 08/10] mtd: spi-nor-core: Check for ctrlc() in spi_nor_erase() Marek Behún
2021-10-05 13:56 ` [PATCH u-boot-spi v3 09/10] mtd: mtdpart: Make mtdpart's _erase method sane Marek Behún
2021-10-05 13:56 ` [PATCH u-boot-spi v3 10/10] mtd: Remove mtd_erase_callback() entirely Marek Behún

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=20211005135606.2246-7-kabel@kernel.org \
    --to=kabel@kernel.org \
    --cc=jagan@amarulasolutions.com \
    --cc=marek.behun@nic.cz \
    --cc=marex@denx.de \
    --cc=p.yadav@ti.com \
    --cc=pali@kernel.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@st.com \
    --cc=trini@konsulko.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox