[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210621152320.3811194-2-linux@rasmusvillemoes.dk>
Date: Mon, 21 Jun 2021 17:23:18 +0200
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: linux-mtd@...ts.infradead.org
Cc: Frieder Schrempf <frieder.schrempf@...tron.de>,
Boris Brezillon <bbrezillon@...nel.org>,
Tudor Ambarus <tudor.ambarus@...rochip.com>,
Michael Walle <michael@...le.cc>,
Pratyush Yadav <p.yadav@...com>, linux-kernel@...r.kernel.org,
Esben Haabendal <esben@...nix.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>
Subject: [RFC 1/3] mtd: spi-nor: core: create helper to compare JEDEC id to struct flash_info
This check will be used elsewhere in a later patch, so factor out the
logic to a helper function.
Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.dk>
---
drivers/mtd/spi-nor/core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index bd2c7717eb10..6a1adef0fe9f 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1850,6 +1850,11 @@ static const struct spi_nor_manufacturer *manufacturers[] = {
&spi_nor_xmc,
};
+static bool spi_nor_match_part(const struct flash_info *part, const u8 *id)
+{
+ return part->id_len && !memcmp(part->id, id, part->id_len);
+}
+
static const struct flash_info *
spi_nor_search_part_by_id(const struct flash_info *parts, unsigned int nparts,
const u8 *id)
@@ -1857,8 +1862,7 @@ spi_nor_search_part_by_id(const struct flash_info *parts, unsigned int nparts,
unsigned int i;
for (i = 0; i < nparts; i++) {
- if (parts[i].id_len &&
- !memcmp(parts[i].id, id, parts[i].id_len))
+ if (spi_nor_match_part(&parts[i], id))
return &parts[i];
}
--
2.31.1
Powered by blists - more mailing lists