[U-Boot] [PATCH v7 27/34] sf: Drop SPI_FLASH_MTD driver

Jagan Teki jteki at openedev.com
Thu Nov 26 13:04:11 CET 2015


Now MTD core has been added as part of spi-flash layer,
so there is no need for explicit driver for handling
mtd stuff, hence removed all neccessary code regarding
SPI_FLASH_MTD driver.

Cc: Heiko Schocher <hs at denx.de>
Signed-off-by: Jagan Teki <jteki at openedev.com>
---
 drivers/mtd/spi/Kconfig       |  12 -----
 drivers/mtd/spi/Makefile      |   1 -
 drivers/mtd/spi/sf_internal.h |   5 --
 drivers/mtd/spi/sf_mtd.c      | 104 ------------------------------------------
 4 files changed, 122 deletions(-)
 delete mode 100644 drivers/mtd/spi/sf_mtd.c

diff --git a/drivers/mtd/spi/Kconfig b/drivers/mtd/spi/Kconfig
index 3f7433c..78932a4 100644
--- a/drivers/mtd/spi/Kconfig
+++ b/drivers/mtd/spi/Kconfig
@@ -116,16 +116,4 @@ config SPI_FLASH_DATAFLASH
 
 	  If unsure, say N
 
-config SPI_FLASH_MTD
-	bool "SPI Flash MTD support"
-	depends on SPI_FLASH
-	help
-          Enable the MTD support for spi flash layer, this adapter is for
-	  translating mtd_read/mtd_write commands into spi_flash_read/write
-	  commands. It is not intended to use it within sf_cmd or the SPI
-	  flash subsystem. Such an adapter is needed for subsystems like
-	  UBI which can only operate on top of the MTD layer.
-
-	  If unsure, say N
-
 endmenu # menu "SPI Flash Support"
diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile
index a24f761..5eb4417 100644
--- a/drivers/mtd/spi/Makefile
+++ b/drivers/mtd/spi/Makefile
@@ -14,5 +14,4 @@ endif
 
 obj-$(CONFIG_SPI_FLASH) += sf_probe.o sf_ops.o sf_params.o sf.o
 obj-$(CONFIG_SPI_FLASH_DATAFLASH) += sf_dataflash.o
-obj-$(CONFIG_SPI_FLASH_MTD) += sf_mtd.o
 obj-$(CONFIG_SPI_FLASH_SANDBOX) += sandbox.o
diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index 1402220..77ad8e8 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -189,11 +189,6 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
 int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
 		size_t cmd_len, void *data, size_t data_len);
 
-#ifdef CONFIG_SPI_FLASH_MTD
-int spi_flash_mtd_register(struct spi_flash *flash);
-void spi_flash_mtd_unregister(void);
-#endif
-
 /**
  * spi_flash_scan - scan the SPI FLASH
  * @flash:	the spi flash structure
diff --git a/drivers/mtd/spi/sf_mtd.c b/drivers/mtd/spi/sf_mtd.c
deleted file mode 100644
index 0b9cb62..0000000
--- a/drivers/mtd/spi/sf_mtd.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Daniel Schwierzeck, daniel.schwierzeck at gmail.com
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#include <common.h>
-#include <malloc.h>
-#include <asm/errno.h>
-#include <linux/mtd/mtd.h>
-#include <spi_flash.h>
-
-static struct mtd_info sf_mtd_info;
-static char sf_mtd_name[8];
-
-static int spi_flash_mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
-{
-	struct spi_flash *flash = mtd->priv;
-	int err;
-
-	instr->state = MTD_ERASING;
-
-	err = spi_flash_erase(flash, instr->addr, instr->len);
-	if (err) {
-		instr->state = MTD_ERASE_FAILED;
-		instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
-		return -EIO;
-	}
-
-	instr->state = MTD_ERASE_DONE;
-	mtd_erase_callback(instr);
-
-	return 0;
-}
-
-static int spi_flash_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
-	size_t *retlen, u_char *buf)
-{
-	struct spi_flash *flash = mtd->priv;
-	int err;
-
-	err = spi_flash_read(flash, from, len, buf);
-	if (!err)
-		*retlen = len;
-
-	return err;
-}
-
-static int spi_flash_mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
-	size_t *retlen, const u_char *buf)
-{
-	struct spi_flash *flash = mtd->priv;
-	int err;
-
-	err = spi_flash_write(flash, to, len, buf);
-	if (!err)
-		*retlen = len;
-
-	return err;
-}
-
-static void spi_flash_mtd_sync(struct mtd_info *mtd)
-{
-}
-
-static int spi_flash_mtd_number(void)
-{
-#ifdef CONFIG_SYS_MAX_FLASH_BANKS
-	return CONFIG_SYS_MAX_FLASH_BANKS;
-#else
-	return 0;
-#endif
-}
-
-int spi_flash_mtd_register(struct spi_flash *flash)
-{
-	memset(&sf_mtd_info, 0, sizeof(sf_mtd_info));
-	sprintf(sf_mtd_name, "nor%d", spi_flash_mtd_number());
-
-	sf_mtd_info.name = sf_mtd_name;
-	sf_mtd_info.type = MTD_NORFLASH;
-	sf_mtd_info.flags = MTD_CAP_NORFLASH;
-	sf_mtd_info.writesize = 1;
-	sf_mtd_info.writebufsize = flash->page_size;
-
-	sf_mtd_info._erase = spi_flash_mtd_erase;
-	sf_mtd_info._read = spi_flash_mtd_read;
-	sf_mtd_info._write = spi_flash_mtd_write;
-	sf_mtd_info._sync = spi_flash_mtd_sync;
-
-	sf_mtd_info.size = flash->size;
-	sf_mtd_info.priv = flash;
-
-	/* Only uniform flash devices for now */
-	sf_mtd_info.numeraseregions = 0;
-	sf_mtd_info.erasesize = flash->sector_size;
-
-	return add_mtd_device(&sf_mtd_info);
-}
-
-void spi_flash_mtd_unregister(void)
-{
-	del_mtd_device(&sf_mtd_info);
-}
-- 
1.9.1



More information about the U-Boot mailing list