mtd: spi-nor: Added support for n25q00a.
[linux-2.6-block.git] / drivers / mtd / spi-nor / spi-nor.c
index fe55b48be5b3c52d911cc7e45ad5905d6882970c..ddce5fdf9ec78733351a551fbc7421cfa347f370 100644 (file)
@@ -661,7 +661,7 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
        status_new = (status_old & ~mask & ~SR_TB) | val;
 
        /* Don't protect status register if we're fully unlocked */
-       if (lock_len == mtd->size)
+       if (lock_len == 0)
                status_new &= ~SR_SRWD;
 
        if (!use_top)
@@ -871,6 +871,7 @@ static const struct flash_info spi_nor_ids[] = {
        { "n25q512a",    INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
        { "n25q512ax3",  INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
        { "n25q00",      INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
+       { "n25q00a",     INFO(0x20bb21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
 
        /* PMC */
        { "pm25lv512",   INFO(0,        0, 32 * 1024,    2, SECT_4K_PMC) },
@@ -1031,14 +1032,27 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
        if (ret)
                return ret;
 
-       ret = nor->read(nor, from, len, buf);
+       while (len) {
+               ret = nor->read(nor, from, len, buf);
+               if (ret == 0) {
+                       /* We shouldn't see 0-length reads */
+                       ret = -EIO;
+                       goto read_err;
+               }
+               if (ret < 0)
+                       goto read_err;
 
-       spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_READ);
-       if (ret < 0)
-               return ret;
+               WARN_ON(ret > len);
+               *retlen += ret;
+               buf += ret;
+               from += ret;
+               len -= ret;
+       }
+       ret = 0;
 
-       *retlen += ret;
-       return 0;
+read_err:
+       spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_READ);
+       return ret;
 }
 
 static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,