提交 19763671 编写于 作者: B Brian Norris

mtd: spi-nor: embed struct mtd_info within struct spi_nor

This reflects the proper layering, so let's do it.
Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
Tested-by: NJoachim Eastwood <manabian@gmail.com>
上级 a39f1d5e
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
struct m25p { struct m25p {
struct spi_device *spi; struct spi_device *spi;
struct spi_nor spi_nor; struct spi_nor spi_nor;
struct mtd_info mtd;
u8 command[MAX_CMD_SIZE]; u8 command[MAX_CMD_SIZE];
}; };
...@@ -159,7 +158,7 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset) ...@@ -159,7 +158,7 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)
struct m25p *flash = nor->priv; struct m25p *flash = nor->priv;
dev_dbg(nor->dev, "%dKiB at 0x%08x\n", dev_dbg(nor->dev, "%dKiB at 0x%08x\n",
flash->mtd.erasesize / 1024, (u32)offset); flash->spi_nor.mtd.erasesize / 1024, (u32)offset);
/* Set up command buffer. */ /* Set up command buffer. */
flash->command[0] = nor->erase_opcode; flash->command[0] = nor->erase_opcode;
...@@ -201,7 +200,6 @@ static int m25p_probe(struct spi_device *spi) ...@@ -201,7 +200,6 @@ static int m25p_probe(struct spi_device *spi)
nor->read_reg = m25p80_read_reg; nor->read_reg = m25p80_read_reg;
nor->dev = &spi->dev; nor->dev = &spi->dev;
nor->mtd = &flash->mtd;
nor->priv = flash; nor->priv = flash;
spi_set_drvdata(spi, flash); spi_set_drvdata(spi, flash);
...@@ -213,7 +211,7 @@ static int m25p_probe(struct spi_device *spi) ...@@ -213,7 +211,7 @@ static int m25p_probe(struct spi_device *spi)
mode = SPI_NOR_DUAL; mode = SPI_NOR_DUAL;
if (data && data->name) if (data && data->name)
flash->mtd.name = data->name; nor->mtd.name = data->name;
/* For some (historical?) reason many platforms provide two different /* For some (historical?) reason many platforms provide two different
* names in flash_platform_data: "name" and "type". Quite often name is * names in flash_platform_data: "name" and "type". Quite often name is
...@@ -231,7 +229,7 @@ static int m25p_probe(struct spi_device *spi) ...@@ -231,7 +229,7 @@ static int m25p_probe(struct spi_device *spi)
ppdata.of_node = spi->dev.of_node; ppdata.of_node = spi->dev.of_node;
return mtd_device_parse_register(&flash->mtd, NULL, &ppdata, return mtd_device_parse_register(&nor->mtd, NULL, &ppdata,
data ? data->parts : NULL, data ? data->parts : NULL,
data ? data->nr_parts : 0); data ? data->nr_parts : 0);
} }
...@@ -242,7 +240,7 @@ static int m25p_remove(struct spi_device *spi) ...@@ -242,7 +240,7 @@ static int m25p_remove(struct spi_device *spi)
struct m25p *flash = spi_get_drvdata(spi); struct m25p *flash = spi_get_drvdata(spi);
/* Clean up MTD stuff. */ /* Clean up MTD stuff. */
return mtd_device_unregister(&flash->mtd); return mtd_device_unregister(&flash->spi_nor.mtd);
} }
/* /*
......
...@@ -259,7 +259,6 @@ static struct fsl_qspi_devtype_data imx6ul_data = { ...@@ -259,7 +259,6 @@ static struct fsl_qspi_devtype_data imx6ul_data = {
#define FSL_QSPI_MAX_CHIP 4 #define FSL_QSPI_MAX_CHIP 4
struct fsl_qspi { struct fsl_qspi {
struct mtd_info mtd[FSL_QSPI_MAX_CHIP];
struct spi_nor nor[FSL_QSPI_MAX_CHIP]; struct spi_nor nor[FSL_QSPI_MAX_CHIP];
void __iomem *iobase; void __iomem *iobase;
void __iomem *ahb_addr; void __iomem *ahb_addr;
...@@ -888,7 +887,7 @@ static int fsl_qspi_erase(struct spi_nor *nor, loff_t offs) ...@@ -888,7 +887,7 @@ static int fsl_qspi_erase(struct spi_nor *nor, loff_t offs)
int ret; int ret;
dev_dbg(nor->dev, "%dKiB at 0x%08x:0x%08x\n", dev_dbg(nor->dev, "%dKiB at 0x%08x:0x%08x\n",
nor->mtd->erasesize / 1024, q->chip_base_addr, (u32)offs); nor->mtd.erasesize / 1024, q->chip_base_addr, (u32)offs);
ret = fsl_qspi_runcmd(q, nor->erase_opcode, offs, 0); ret = fsl_qspi_runcmd(q, nor->erase_opcode, offs, 0);
if (ret) if (ret)
...@@ -1013,9 +1012,8 @@ static int fsl_qspi_probe(struct platform_device *pdev) ...@@ -1013,9 +1012,8 @@ static int fsl_qspi_probe(struct platform_device *pdev)
i *= 2; i *= 2;
nor = &q->nor[i]; nor = &q->nor[i];
mtd = &q->mtd[i]; mtd = &nor->mtd;
nor->mtd = mtd;
nor->dev = dev; nor->dev = dev;
nor->priv = q; nor->priv = q;
...@@ -1086,7 +1084,7 @@ static int fsl_qspi_probe(struct platform_device *pdev) ...@@ -1086,7 +1084,7 @@ static int fsl_qspi_probe(struct platform_device *pdev)
/* skip the holes */ /* skip the holes */
if (!q->has_second_chip) if (!q->has_second_chip)
i *= 2; i *= 2;
mtd_device_unregister(&q->mtd[i]); mtd_device_unregister(&q->nor[i].mtd);
} }
mutex_failed: mutex_failed:
mutex_destroy(&q->lock); mutex_destroy(&q->lock);
...@@ -1106,7 +1104,7 @@ static int fsl_qspi_remove(struct platform_device *pdev) ...@@ -1106,7 +1104,7 @@ static int fsl_qspi_remove(struct platform_device *pdev)
/* skip the holes */ /* skip the holes */
if (!q->has_second_chip) if (!q->has_second_chip)
i *= 2; i *= 2;
mtd_device_unregister(&q->mtd[i]); mtd_device_unregister(&q->nor[i].mtd);
} }
/* disable the hardware */ /* disable the hardware */
......
...@@ -60,7 +60,6 @@ struct nxp_spifi { ...@@ -60,7 +60,6 @@ struct nxp_spifi {
struct clk *clk_reg; struct clk *clk_reg;
void __iomem *io_base; void __iomem *io_base;
void __iomem *flash_base; void __iomem *flash_base;
struct mtd_info mtd;
struct spi_nor nor; struct spi_nor nor;
bool memory_mode; bool memory_mode;
u32 mcmd; u32 mcmd;
...@@ -331,7 +330,6 @@ static int nxp_spifi_setup_flash(struct nxp_spifi *spifi, ...@@ -331,7 +330,6 @@ static int nxp_spifi_setup_flash(struct nxp_spifi *spifi,
writel(ctrl, spifi->io_base + SPIFI_CTRL); writel(ctrl, spifi->io_base + SPIFI_CTRL);
spifi->nor.mtd = &spifi->mtd;
spifi->nor.dev = spifi->dev; spifi->nor.dev = spifi->dev;
spifi->nor.priv = spifi; spifi->nor.priv = spifi;
spifi->nor.read = nxp_spifi_read; spifi->nor.read = nxp_spifi_read;
...@@ -364,7 +362,7 @@ static int nxp_spifi_setup_flash(struct nxp_spifi *spifi, ...@@ -364,7 +362,7 @@ static int nxp_spifi_setup_flash(struct nxp_spifi *spifi,
} }
ppdata.of_node = np; ppdata.of_node = np;
ret = mtd_device_parse_register(&spifi->mtd, NULL, &ppdata, NULL, 0); ret = mtd_device_parse_register(&spifi->nor.mtd, NULL, &ppdata, NULL, 0);
if (ret) { if (ret) {
dev_err(spifi->dev, "mtd device parse failed\n"); dev_err(spifi->dev, "mtd device parse failed\n");
return ret; return ret;
...@@ -453,7 +451,7 @@ static int nxp_spifi_remove(struct platform_device *pdev) ...@@ -453,7 +451,7 @@ static int nxp_spifi_remove(struct platform_device *pdev)
{ {
struct nxp_spifi *spifi = platform_get_drvdata(pdev); struct nxp_spifi *spifi = platform_get_drvdata(pdev);
mtd_device_unregister(&spifi->mtd); mtd_device_unregister(&spifi->nor.mtd);
clk_disable_unprepare(spifi->clk_spifi); clk_disable_unprepare(spifi->clk_spifi);
clk_disable_unprepare(spifi->clk_reg); clk_disable_unprepare(spifi->clk_reg);
......
...@@ -265,7 +265,7 @@ static int spi_nor_wait_till_ready(struct spi_nor *nor) ...@@ -265,7 +265,7 @@ static int spi_nor_wait_till_ready(struct spi_nor *nor)
*/ */
static int erase_chip(struct spi_nor *nor) static int erase_chip(struct spi_nor *nor)
{ {
dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd->size >> 10)); dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd.size >> 10));
return nor->write_reg(nor, SPINOR_OP_CHIP_ERASE, NULL, 0, 0); return nor->write_reg(nor, SPINOR_OP_CHIP_ERASE, NULL, 0, 0);
} }
...@@ -373,7 +373,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) ...@@ -373,7 +373,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
{ {
struct mtd_info *mtd = nor->mtd; struct mtd_info *mtd = &nor->mtd;
uint32_t offset = ofs; uint32_t offset = ofs;
uint8_t status_old, status_new; uint8_t status_old, status_new;
int ret = 0; int ret = 0;
...@@ -407,7 +407,7 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) ...@@ -407,7 +407,7 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
{ {
struct mtd_info *mtd = nor->mtd; struct mtd_info *mtd = &nor->mtd;
uint32_t offset = ofs; uint32_t offset = ofs;
uint8_t status_old, status_new; uint8_t status_old, status_new;
int ret = 0; int ret = 0;
...@@ -1004,7 +1004,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) ...@@ -1004,7 +1004,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
{ {
const struct flash_info *info = NULL; const struct flash_info *info = NULL;
struct device *dev = nor->dev; struct device *dev = nor->dev;
struct mtd_info *mtd = nor->mtd; struct mtd_info *mtd = &nor->mtd;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
int ret; int ret;
int i; int i;
......
...@@ -162,7 +162,7 @@ struct mtd_info; ...@@ -162,7 +162,7 @@ struct mtd_info;
* @priv: the private data * @priv: the private data
*/ */
struct spi_nor { struct spi_nor {
struct mtd_info *mtd; struct mtd_info mtd;
struct mutex lock; struct mutex lock;
struct device *dev; struct device *dev;
u32 page_size; u32 page_size;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册