[PATCH v3 08/12] mtd: spinand: add parameter page fixup function

From: Shivamurthy Shastri (sshivamurthy)
Date: Mon Jun 03 2019 - 08:48:01 EST


Parameter page not following any standard. Hence, manufacturers may
interpret parameters differently, and it is better to have a fixup
function.

Signed-off-by: Shivamurthy Shastri <sshivamurthy@xxxxxxxxxx>
---
drivers/mtd/nand/spi/core.c | 6 ++++++
include/linux/mtd/spinand.h | 2 ++
2 files changed, 8 insertions(+)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index b031c4a2cdf9..cdf578c45c08 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -479,6 +479,12 @@ static int check_version(struct nand_device *base,
static int spinand_intf_data(struct nand_device *base,
struct nand_onfi_params *p)
{
+ struct spinand_device *spinand = nand_to_spinand(base);
+
+ /* Manufacturers may interpret the parameter page differently */
+ if (spinand->manufacturer->ops->fixup_param_page)
+ spinand->manufacturer->ops->fixup_param_page(spinand, p);
+
return 0;
}

diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
index 507f7e289bd1..41a03d59f003 100644
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -179,6 +179,8 @@ struct spinand_manufacturer_ops {
int (*detect)(struct spinand_device *spinand);
int (*init)(struct spinand_device *spinand);
void (*cleanup)(struct spinand_device *spinand);
+ void (*fixup_param_page)(struct spinand_device *spinand,
+ struct nand_onfi_params *p);
};

/**
--
2.17.1