linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Michal Suchanek <msuchanek@suse.de>
To: linux-sunxi@lists.linux.dev
Cc: Michal Suchanek <msuchanek@suse.de>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Tudor Ambarus <tudor.ambarus@microchip.com>,
	Pratyush Yadav <p.yadav@ti.com>, Michael Walle <michael@walle.cc>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org
Subject: [PATCH 1/2] mtd: spi-nor: When a flash memory is missing do not report an error
Date: Thu, 14 Jul 2022 21:19:47 +0200	[thread overview]
Message-ID: <701967b0c418db333c66b48d225df60aa9d03ead.1657826188.git.msuchanek@suse.de> (raw)

It is normal that devices are designed with multiple types of storage,
and only some types of storage are present.

The kernel can handle this situation gracefully for many types of
storage devices such as mmc or ata but it reports and error when spi
flash is not present.

Only print a notice that the storage device is missing when no response
to the identify command is received.

Consider reply buffers with all bits set to the same value no response.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 502967c76c5f..6bab540171a4 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1652,6 +1652,24 @@ static const struct flash_info *spi_nor_match_id(struct spi_nor *nor,
 	return NULL;
 }
 
+static const bool buffer_uniform(const u8 *buffer, size_t length)
+{
+	bool all0;
+	size_t i;
+
+	for (all0 = true, i = 0; i < length; i++)
+		if (buffer[i] != 0) {
+			all0 = false;
+			break;
+		}
+	if (all0)
+		return true;
+	for (i = 0; i < length; i++)
+		if (buffer[i] != 0xff)
+			return false;
+	return true;
+}
+
 static const struct flash_info *spi_nor_detect(struct spi_nor *nor)
 {
 	const struct flash_info *info;
@@ -1666,8 +1684,11 @@ static const struct flash_info *spi_nor_detect(struct spi_nor *nor)
 
 	info = spi_nor_match_id(nor, id);
 	if (!info) {
-		dev_err(nor->dev, "unrecognized JEDEC id bytes: %*ph\n",
-			SPI_NOR_MAX_ID_LEN, id);
+		if (buffer_uniform(id, SPI_NOR_MAX_ID_LEN))
+			dev_info(nor->dev, "No flash memory detected.\n");
+		else
+			dev_err(nor->dev, "unrecognized JEDEC id bytes: %*ph\n",
+				SPI_NOR_MAX_ID_LEN, id);
 		return ERR_PTR(-ENODEV);
 	}
 	return info;
-- 
2.35.3


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

             reply	other threads:[~2022-07-14 19:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14 19:19 Michal Suchanek [this message]
2022-07-14 19:19 ` [PATCH resend 2/2] ARM: dts: sunxi: Enable optional SPI flash on Orange Pi Zero board Michal Suchanek
2022-07-14 19:41 ` [PATCH 1/2] mtd: spi-nor: When a flash memory is missing do not report an error Michael Walle
2022-07-14 20:55   ` Michal Suchánek
2022-07-14 21:51     ` Michael Walle
2022-07-14 22:07       ` Michal Suchánek
2022-07-15  9:20         ` Pratyush Yadav
2022-07-16  8:20           ` Michal Suchánek
2022-07-16  9:30             ` Michael Walle
2022-07-16  9:38               ` Michal Suchánek
2022-07-16  9:44                 ` Michael Walle
2022-07-24 15:59                   ` Michal Suchánek
2022-07-15 12:20         ` Andre Przywara
2022-07-16  2:28           ` Samuel Holland
2022-07-16 10:58             ` Andre Przywara
2022-07-24 18:28               ` Michal Suchánek
2022-07-16  7:54           ` Michal Suchánek
2022-07-16 10:49             ` Andre Przywara
2022-07-15  0:43 ` kernel test robot

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=701967b0c418db333c66b48d225df60aa9d03ead.1657826188.git.msuchanek@suse.de \
    --to=msuchanek@suse.de \
    --cc=devicetree@vger.kernel.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=michael@walle.cc \
    --cc=miquel.raynal@bootlin.com \
    --cc=p.yadav@ti.com \
    --cc=richard@nod.at \
    --cc=robh+dt@kernel.org \
    --cc=samuel@sholland.org \
    --cc=tudor.ambarus@microchip.com \
    --cc=vigneshr@ti.com \
    --cc=wens@csie.org \
    /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;
as well as URLs for NNTP newsgroup(s).