2022-08-10 22:27:49

by Michael Walle

[permalink] [raw]
Subject: [PATCH v2 0/7] mtd: spi-nor: generic flash driver

Add a generic flash driver, which is used when we don't find a matching
flash in our database. All the basic features of a flash can be discovered
by SFDP and most (if not all) newer flashes support it.

changes since v1:
- fix doc prototype mistake reported by the kernel test robot
- preset page_size to 256 to support flashes which just have
SFDP data corresponding to JESD216A
- add new patch
mtd: spi-nor: fix select_uniform_erase to skip 0 erase size
- add function doc to explain wanted_size=0 in
spi_nor_select_uniform_erase()

Michael Walle (7):
mtd: spi-nor: hide jedec_id sysfs attribute if not present
mtd: spi-nor: sysfs: hide manufacturer if it is not set
mtd: spi-nor: remember full JEDEC flash ID
mtd: spi-nor: move function declaration out of sfdp.h
mtd: spi-nor: fix select_uniform_erase to skip 0 erase size
mtd: spi-nor: add generic flash driver
mtd: spi-nor: sysfs: print JEDEC ID for generic flash driver

.../ABI/testing/sysfs-bus-spi-devices-spi-nor | 6 ++++
drivers/mtd/spi-nor/core.c | 35 +++++++++++++++++--
drivers/mtd/spi-nor/core.h | 3 ++
drivers/mtd/spi-nor/debugfs.c | 2 +-
drivers/mtd/spi-nor/sfdp.c | 27 ++++++++++++++
drivers/mtd/spi-nor/sfdp.h | 2 --
drivers/mtd/spi-nor/sysfs.c | 20 ++++++++++-
include/linux/mtd/spi-nor.h | 3 ++
8 files changed, 92 insertions(+), 6 deletions(-)

--
2.30.2


2022-08-10 22:57:23

by Michael Walle

[permalink] [raw]
Subject: [PATCH v2 4/7] mtd: spi-nor: move function declaration out of sfdp.h

sfdp.h should only contain constants related to the JEDEC SFDP
specification(s).

Signed-off-by: Michael Walle <[email protected]>
Reviewed-by: Takahiro Kuwano <[email protected]>
---
drivers/mtd/spi-nor/core.h | 2 ++
drivers/mtd/spi-nor/sfdp.h | 2 --
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index 85b0cf254e97..68aaccaa12d8 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -701,6 +701,8 @@ int spi_nor_controller_ops_read_reg(struct spi_nor *nor, u8 opcode,
int spi_nor_controller_ops_write_reg(struct spi_nor *nor, u8 opcode,
const u8 *buf, size_t len);

+int spi_nor_parse_sfdp(struct spi_nor *nor);
+
static inline struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd)
{
return container_of(mtd, struct spi_nor, mtd);
diff --git a/drivers/mtd/spi-nor/sfdp.h b/drivers/mtd/spi-nor/sfdp.h
index bbf80d2990ab..c1969f0a2f46 100644
--- a/drivers/mtd/spi-nor/sfdp.h
+++ b/drivers/mtd/spi-nor/sfdp.h
@@ -107,6 +107,4 @@ struct sfdp_parameter_header {
u8 id_msb;
};

-int spi_nor_parse_sfdp(struct spi_nor *nor);
-
#endif /* __LINUX_MTD_SFDP_H */
--
2.30.2

2022-08-10 22:59:46

by Michael Walle

[permalink] [raw]
Subject: [PATCH v2 2/7] mtd: spi-nor: sysfs: hide manufacturer if it is not set

The manufacturer may be optional when pure SFDP flashes are supported.
Hide the sysfs property if no manufacturer is set.

Signed-off-by: Michael Walle <[email protected]>
Reviewed-by: Takahiro Kuwano <[email protected]>
---
Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor | 3 +++
drivers/mtd/spi-nor/sysfs.c | 2 ++
2 files changed, 5 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor b/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
index e9ef69aef20b..c800621eff95 100644
--- a/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
+++ b/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
@@ -15,6 +15,9 @@ KernelVersion: 5.14
Contact: [email protected]
Description: (RO) Manufacturer of the SPI NOR flash.

+ The attribute is not present if the flash device isn't
+ known to the kernel and is only probed by its SFDP
+ tables.

What: /sys/bus/spi/devices/.../spi-nor/partname
Date: April 2021
diff --git a/drivers/mtd/spi-nor/sysfs.c b/drivers/mtd/spi-nor/sysfs.c
index 4c3b351aef24..20563c1926f4 100644
--- a/drivers/mtd/spi-nor/sysfs.c
+++ b/drivers/mtd/spi-nor/sysfs.c
@@ -74,6 +74,8 @@ static umode_t spi_nor_sysfs_is_visible(struct kobject *kobj,
struct spi_mem *spimem = spi_get_drvdata(spi);
struct spi_nor *nor = spi_mem_get_drvdata(spimem);

+ if (attr == &dev_attr_manufacturer.attr && !nor->manufacturer)
+ return 0;
if (attr == &dev_attr_jedec_id.attr && !nor->info->id_len)
return 0;

--
2.30.2

2022-11-21 14:25:37

by Tudor Ambarus

[permalink] [raw]
Subject: Re: [PATCH v2 0/7] mtd: spi-nor: generic flash driver

On Thu, 11 Aug 2022 00:06:47 +0200, Michael Walle wrote:
> Add a generic flash driver, which is used when we don't find a matching
> flash in our database. All the basic features of a flash can be discovered
> by SFDP and most (if not all) newer flashes support it.
>
> changes since v1:
> - fix doc prototype mistake reported by the kernel test robot
> - preset page_size to 256 to support flashes which just have
> SFDP data corresponding to JESD216A
> - add new patch
> mtd: spi-nor: fix select_uniform_erase to skip 0 erase size
> - add function doc to explain wanted_size=0 in
> spi_nor_select_uniform_erase()
>
> [...]

Applied to spi-nor/next, thanks!

[1/7] mtd: spi-nor: hide jedec_id sysfs attribute if not present
https://git.kernel.org/mtd/c/7d388551b688
[2/7] mtd: spi-nor: sysfs: hide manufacturer if it is not set
https://git.kernel.org/mtd/c/0d9270f2762b
[3/7] mtd: spi-nor: remember full JEDEC flash ID
https://git.kernel.org/mtd/c/28ef7670414e
[4/7] mtd: spi-nor: move function declaration out of sfdp.h
https://git.kernel.org/mtd/c/fa06bb26a40c
[5/7] mtd: spi-nor: fix select_uniform_erase to skip 0 erase size
https://git.kernel.org/mtd/c/39eece67a3cf
[6/7] mtd: spi-nor: add generic flash driver
https://git.kernel.org/mtd/c/773bbe104497
[7/7] mtd: spi-nor: sysfs: print JEDEC ID for generic flash driver
https://git.kernel.org/mtd/c/0a92de16b61b

Best regards,
--
Tudor Ambarus <[email protected]>