Skip to contentSkip to conversation

spi-nor: add chip_name to struct spi_nor

PATCH Superseded Heiner Kallweit 2 participants 2 messages Feb 1, 2015 – Feb 3, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 spi-nor: add chip_name to struct spi_nor

The caller of spi_nor_scan might be interested in the exact chip type. This especially applies to these cases:
- spi_nor_scan is called with a null name parameter and auto-detects the chip
- spi_nor_scan detects a chipset which is different from the provided one

Therefore add chip_name to struct spi_nor.

---
 drivers/mtd/spi-nor/spi-nor.c | 1 +
 include/linux/mtd/spi-nor.h   | 2 ++
 2 files changed, 3 insertions(+)
drivers/mtd/spi-nor/spi-nor.c +1 -0
index b6a5a0c..712b47b 100644
@@ -1160,6 +1160,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 	}
 
 	nor->read_dummy = spi_nor_read_dummy_cycles(nor);
+	nor->chip_name = id->name;
 
 	dev_info(dev, "%s (%lld Kbytes)\n", id->name,
 			(long long)mtd->size >> 10);
include/linux/mtd/spi-nor.h +2 -0
index 4720b86..468098a 100644
@@ -143,6 +143,7 @@ enum spi_nor_option_flags {
  * @flags:		flag options for the current SPI-NOR (SNOR_F_*)
  * @cfg:		used by the read_xfer/write_xfer
  * @cmd_buf:		used by the write_reg
+ * @chip_name:		the name of the SPI NOR chip
  * @prepare:		[OPTIONAL] do some preparations for the
  *			read/write/erase/lock/unlock operations
  * @unprepare:		[OPTIONAL] do some post work after the
@@ -172,6 +173,7 @@ struct spi_nor {
 	u32			flags;
 	struct spi_nor_xfer_cfg	cfg;
 	u8			cmd_buf[SPI_NOR_MAX_CMD_SIZE];
+	const char		*chip_name;
 
 	int (*prepare)(struct spi_nor *nor, enum spi_nor_ops ops);
 	void (*unprepare)(struct spi_nor *nor, enum spi_nor_ops ops);
Signature · 1 line
2.2.2
#1 lore raw
Quoted 6 lines · Heiner Kallweit

The caller of spi_nor_scan might be interested in the exact chip type. This especially applies to these cases:
- spi_nor_scan is called with a null name parameter and auto-detects the chip
- spi_nor_scan detects a chipset which is different from the provided one

Therefore add chip_name to struct spi_nor.

I'll comment on patch 2, which demonstrates your alleged need for this, but I don't think the users of spi-nor.c need to know exactly which flash is being used.

Brian

Quoted 38 lines
---
 drivers/mtd/spi-nor/spi-nor.c | 1 +
 include/linux/mtd/spi-nor.h   | 2 ++
 2 files changed, 3 insertions(+)
drivers/mtd/spi-nor/spi-nor.c +1 -0
index b6a5a0c..712b47b 100644
@@ -1160,6 +1160,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 	}
 
 	nor->read_dummy = spi_nor_read_dummy_cycles(nor);
+	nor->chip_name = id->name;
 
 	dev_info(dev, "%s (%lld Kbytes)\n", id->name,
 			(long long)mtd->size >> 10);
include/linux/mtd/spi-nor.h +2 -0
index 4720b86..468098a 100644
@@ -143,6 +143,7 @@ enum spi_nor_option_flags {
  * @flags:		flag options for the current SPI-NOR (SNOR_F_*)
  * @cfg:		used by the read_xfer/write_xfer
  * @cmd_buf:		used by the write_reg
+ * @chip_name:		the name of the SPI NOR chip
  * @prepare:		[OPTIONAL] do some preparations for the
  *			read/write/erase/lock/unlock operations
  * @unprepare:		[OPTIONAL] do some post work after the
@@ -172,6 +173,7 @@ struct spi_nor {
 	u32			flags;
 	struct spi_nor_xfer_cfg	cfg;
 	u8			cmd_buf[SPI_NOR_MAX_CMD_SIZE];
+	const char		*chip_name;
 
 	int (*prepare)(struct spi_nor *nor, enum spi_nor_ops ops);
 	void (*unprepare)(struct spi_nor *nor, enum spi_nor_ops ops);