diff mbox series

[v2,6/6] mtd: spi-nor: introduce support for displaying deprecation message

Message ID 20240419141249.609534-7-mwalle@kernel.org
State Changes Requested
Headers show
Series mtd: spi-nor: spring cleaning | expand

Commit Message

Michael Walle April 19, 2024, 2:12 p.m. UTC
SPI-NOR will automatically detect the attached flash device most of the
time. We cannot easily find out if boards are using a given flash.
Therefore, add a .deprecation_version to the flash_info struct which
indicates the kernel version after which the driver support will be
removed.

Signed-off-by: Michael Walle <mwalle@kernel.org>
---
 drivers/mtd/spi-nor/core.c | 11 ++++++++++-
 drivers/mtd/spi-nor/core.h |  3 +++
 2 files changed, 13 insertions(+), 1 deletion(-)

Comments

Pratyush Yadav April 19, 2024, 6:38 p.m. UTC | #1
On Fri, Apr 19 2024, Michael Walle wrote:

> SPI-NOR will automatically detect the attached flash device most of the
> time. We cannot easily find out if boards are using a given flash.
> Therefore, add a .deprecation_version to the flash_info struct which
> indicates the kernel version after which the driver support will be
> removed.
>
> Signed-off-by: Michael Walle <mwalle@kernel.org>

Reviewed-by: Pratyush Yadav <pratyush@kernel.org>

Would also like to get an ACK from Tudor for this patch.
Tudor Ambarus April 22, 2024, 6:06 a.m. UTC | #2
On 4/19/24 15:12, Michael Walle wrote:
> SPI-NOR will automatically detect the attached flash device most of the

SPI NOR. Looks good. Please follow up with a patch in the same patch set
to use deprecation_version, otherwise we introduce code that's not used
and we risk to get patches removing it.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Tudor Ambarus April 22, 2024, 6:42 a.m. UTC | #3
On 4/19/24 15:12, Michael Walle wrote:
> +	if (info && info->deprecation_version)

and here you won't need to check for info again
Michael Walle April 22, 2024, 10 a.m. UTC | #4
On Mon Apr 22, 2024 at 8:06 AM CEST, Tudor Ambarus wrote:
> On 4/19/24 15:12, Michael Walle wrote:
> > SPI-NOR will automatically detect the attached flash device most of the
>
> SPI NOR. Looks good. Please follow up with a patch in the same patch set
> to use deprecation_version, otherwise we introduce code that's not used
> and we risk to get patches removing it.

I missed the RFC tag this time. My plan was actually to have this
patch already reviewed and then repost it with a deprecation of
some flashes.

But apart from that, it's the nature of this flag that it might be
unused from time to time.

> Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>

Thanks!

-michael
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 8e4ae1317870..bed5209b94de 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3323,7 +3323,16 @@  static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor,
 	 * some partitions may be marked read-only, and we don't want to loose
 	 * that information, even if it's not 100% accurate.
 	 */
-	return jinfo ?: info;
+	if (jinfo)
+		info = jinfo;
+
+	if (info && info->deprecation_version)
+		pr_warn("Your board is using a SPI NOR flash (%s) with deprecated driver\n"
+			"support. It will be removed after kernel version %s.\n"
+			"If you feel this shouldn't be the case, please contact us at\n"
+			"linux-mtd@lists.infradead.org\n",
+			info->name, info->deprecation_version);
+	return info;
 }
 
 static u32
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index 1516b6d0dc37..984155d10fd8 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -447,6 +447,8 @@  struct spi_nor_id {
  * @id:   pointer to struct spi_nor_id or NULL, which means "no ID" (mostly
  *        older chips).
  * @name: (obsolete) the name of the flash. Do not set it for new additions.
+ * @deprecation_version:      the kernel version after which the support for
+ *	                      this flash will be removed.
  * @size:           the size of the flash in bytes.
  * @sector_size:    (optional) the size listed here is what works with
  *                  SPINOR_OP_SE, which isn't necessarily called a "sector" by
@@ -504,6 +506,7 @@  struct spi_nor_id {
 struct flash_info {
 	char *name;
 	const struct spi_nor_id *id;
+	const char *deprecation_version;
 	size_t size;
 	unsigned sector_size;
 	u16 page_size;