Commit e5763300 authored by Brian Norris's avatar Brian Norris

mtd: merge MTD development from v4.4 into for-v4.5 development

Small conflict between some bugfixes for 4.4 and some refactoring for
4.5.
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parents 887e9d3a a32d5b72
...@@ -427,15 +427,6 @@ int add_mtd_device(struct mtd_info *mtd) ...@@ -427,15 +427,6 @@ int add_mtd_device(struct mtd_info *mtd)
mtd->erasesize_mask = (1 << mtd->erasesize_shift) - 1; mtd->erasesize_mask = (1 << mtd->erasesize_shift) - 1;
mtd->writesize_mask = (1 << mtd->writesize_shift) - 1; mtd->writesize_mask = (1 << mtd->writesize_shift) - 1;
if (mtd->dev.parent) {
if (!mtd->owner && mtd->dev.parent->driver)
mtd->owner = mtd->dev.parent->driver->owner;
if (!mtd->name)
mtd->name = dev_name(mtd->dev.parent);
} else {
pr_debug("mtd device won't show a device symlink in sysfs\n");
}
/* Some chips always power up locked. Unlock them now */ /* Some chips always power up locked. Unlock them now */
if ((mtd->flags & MTD_WRITEABLE) && (mtd->flags & MTD_POWERUP_LOCK)) { if ((mtd->flags & MTD_WRITEABLE) && (mtd->flags & MTD_POWERUP_LOCK)) {
error = mtd_unlock(mtd, 0, mtd->size); error = mtd_unlock(mtd, 0, mtd->size);
...@@ -554,6 +545,21 @@ static int mtd_add_device_partitions(struct mtd_info *mtd, ...@@ -554,6 +545,21 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
return 0; return 0;
} }
/*
* Set a few defaults based on the parent devices, if not provided by the
* driver
*/
static void mtd_set_dev_defaults(struct mtd_info *mtd)
{
if (mtd->dev.parent) {
if (!mtd->owner && mtd->dev.parent->driver)
mtd->owner = mtd->dev.parent->driver->owner;
if (!mtd->name)
mtd->name = dev_name(mtd->dev.parent);
} else {
pr_debug("mtd device won't show a device symlink in sysfs\n");
}
}
/** /**
* mtd_device_parse_register - parse partitions and register an MTD device. * mtd_device_parse_register - parse partitions and register an MTD device.
...@@ -592,6 +598,8 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types, ...@@ -592,6 +598,8 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
struct mtd_partitions parsed; struct mtd_partitions parsed;
int ret; int ret;
mtd_set_dev_defaults(mtd);
memset(&parsed, 0, sizeof(parsed)); memset(&parsed, 0, sizeof(parsed));
ret = parse_mtd_partitions(mtd, types, &parsed, parser_data); ret = parse_mtd_partitions(mtd, types, &parsed, parser_data);
......
...@@ -539,8 +539,8 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) ...@@ -539,8 +539,8 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
return status_old; return status_old;
/* Cannot unlock; would unlock larger region than requested */ /* Cannot unlock; would unlock larger region than requested */
if (stm_is_locked_sr(nor, status_old, ofs - mtd->erasesize, if (stm_is_locked_sr(nor, ofs - mtd->erasesize, mtd->erasesize,
mtd->erasesize)) status_old))
return -EINVAL; return -EINVAL;
/* /*
...@@ -1225,8 +1225,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) ...@@ -1225,8 +1225,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
if (JEDEC_MFR(info) == SNOR_MFR_ATMEL || if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
JEDEC_MFR(info) == SNOR_MFR_INTEL || JEDEC_MFR(info) == SNOR_MFR_INTEL ||
JEDEC_MFR(info) == SNOR_MFR_SST || JEDEC_MFR(info) == SNOR_MFR_SST) {
JEDEC_MFR(info) == SNOR_MFR_WINBOND) {
write_enable(nor); write_enable(nor);
write_sr(nor, 0); write_sr(nor, 0);
} }
...@@ -1242,8 +1241,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) ...@@ -1242,8 +1241,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
mtd->_read = spi_nor_read; mtd->_read = spi_nor_read;
/* NOR protection support for STmicro/Micron chips and similar */ /* NOR protection support for STmicro/Micron chips and similar */
if (JEDEC_MFR(info) == SNOR_MFR_MICRON || if (JEDEC_MFR(info) == SNOR_MFR_MICRON) {
JEDEC_MFR(info) == SNOR_MFR_WINBOND) {
nor->flash_lock = stm_lock; nor->flash_lock = stm_lock;
nor->flash_unlock = stm_unlock; nor->flash_unlock = stm_unlock;
nor->flash_is_locked = stm_is_locked; nor->flash_is_locked = stm_is_locked;
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#define SNOR_MFR_MACRONIX CFI_MFR_MACRONIX #define SNOR_MFR_MACRONIX CFI_MFR_MACRONIX
#define SNOR_MFR_SPANSION CFI_MFR_AMD #define SNOR_MFR_SPANSION CFI_MFR_AMD
#define SNOR_MFR_SST CFI_MFR_SST #define SNOR_MFR_SST CFI_MFR_SST
#define SNOR_MFR_WINBOND 0xef #define SNOR_MFR_WINBOND 0xef /* Also used by some Spansion */
/* /*
* Note on opcode nomenclature: some opcodes have a format like * Note on opcode nomenclature: some opcodes have a format like
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment