mtd: m25p80: drop erase() callback
[cascardo/linux.git] / drivers / mtd / devices / m25p80.c
index fcf171a..6077c4a 100644 (file)
@@ -31,7 +31,6 @@
 struct m25p {
        struct spi_device       *spi;
        struct spi_nor          spi_nor;
-       struct mtd_info         mtd;
        u8                      command[MAX_CMD_SIZE];
 };
 
@@ -62,8 +61,7 @@ static int m25p_cmdsz(struct spi_nor *nor)
        return 1 + nor->addr_width;
 }
 
-static int m25p80_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len,
-                       int wr_en)
+static int m25p80_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
 {
        struct m25p *flash = nor->priv;
        struct spi_device *spi = flash->spi;
@@ -154,22 +152,6 @@ static int m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
        return 0;
 }
 
-static int m25p80_erase(struct spi_nor *nor, loff_t offset)
-{
-       struct m25p *flash = nor->priv;
-
-       dev_dbg(nor->dev, "%dKiB at 0x%08x\n",
-               flash->mtd.erasesize / 1024, (u32)offset);
-
-       /* Set up command buffer. */
-       flash->command[0] = nor->erase_opcode;
-       m25p_addr2cmd(nor, offset, flash->command);
-
-       spi_write(flash->spi, flash->command, m25p_cmdsz(nor));
-
-       return 0;
-}
-
 /*
  * board specific setup should have ensured the SPI clock used here
  * matches what the READ command supports, at least until this driver
@@ -177,7 +159,6 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)
  */
 static int m25p_probe(struct spi_device *spi)
 {
-       struct mtd_part_parser_data     ppdata;
        struct flash_platform_data      *data;
        struct m25p *flash;
        struct spi_nor *nor;
@@ -196,16 +177,14 @@ static int m25p_probe(struct spi_device *spi)
        /* install the hooks */
        nor->read = m25p80_read;
        nor->write = m25p80_write;
-       nor->erase = m25p80_erase;
        nor->write_reg = m25p80_write_reg;
        nor->read_reg = m25p80_read_reg;
 
        nor->dev = &spi->dev;
-       nor->mtd = &flash->mtd;
+       spi_nor_set_flash_node(nor, spi->dev.of_node);
        nor->priv = flash;
 
        spi_set_drvdata(spi, flash);
-       flash->mtd.priv = nor;
        flash->spi = spi;
 
        if (spi->mode & SPI_RX_QUAD)
@@ -214,7 +193,7 @@ static int m25p_probe(struct spi_device *spi)
                mode = SPI_NOR_DUAL;
 
        if (data && data->name)
-               flash->mtd.name = data->name;
+               nor->mtd.name = data->name;
 
        /* For some (historical?) reason many platforms provide two different
         * names in flash_platform_data: "name" and "type". Quite often name is
@@ -230,11 +209,8 @@ static int m25p_probe(struct spi_device *spi)
        if (ret)
                return ret;
 
-       ppdata.of_node = spi->dev.of_node;
-
-       return mtd_device_parse_register(&flash->mtd, NULL, &ppdata,
-                       data ? data->parts : NULL,
-                       data ? data->nr_parts : 0);
+       return mtd_device_register(&nor->mtd, data ? data->parts : NULL,
+                                  data ? data->nr_parts : 0);
 }
 
 
@@ -243,7 +219,7 @@ static int m25p_remove(struct spi_device *spi)
        struct m25p     *flash = spi_get_drvdata(spi);
 
        /* Clean up MTD stuff. */
-       return mtd_device_unregister(&flash->mtd);
+       return mtd_device_unregister(&flash->spi_nor.mtd);
 }
 
 /*