Skip to content

Commit 7854643

Browse files
Chen GongDavid Woodhouse
authored andcommitted
[MTD] m25p80: chip erase != block erase != sector erase
This fixes broken terminology added in the "m25p80.c erase enhance" patch, which added a chip erase command but called it "block erase". There are already two block erase commands; blocks are 4KiB or 32KiB. There's also a sector erase (usually 64 KiB). Chip erase typically covers Megabytes. OPCODE_BE ==> OPCODE_CHIP_ERASE erase_block ==> erase_chip [dbrownell@users.sourceforge.net: update sector erase comments too ] Signed-off-by: Chen Gong <clumsycg@gmail.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 9168ab8 commit 7854643

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

‎drivers/mtd/devices/m25p80.c‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
#define OPCODE_NORM_READ 0x03 /* Read data bytes (low frequency) */
3838
#define OPCODE_FAST_READ 0x0b /* Read data bytes (high frequency) */
3939
#define OPCODE_PP 0x02 /* Page program (up to 256 bytes) */
40-
#define OPCODE_BE_4K 0x20 /* Erase 4KiB block */
40+
#define OPCODE_BE_4K 0x20 /* Erase 4KiB block */
4141
#define OPCODE_BE_32K 0x52 /* Erase 32KiB block */
42-
#define OPCODE_BE 0xc7 /* Erase whole flash block */
42+
#define OPCODE_CHIP_ERASE 0xc7 /* Erase whole flash chip */
4343
#define OPCODE_SE 0xd8 /* Sector erase (usually 64KiB) */
4444
#define OPCODE_RDID 0x9f /* Read JEDEC ID */
4545

@@ -167,7 +167,7 @@ static int wait_till_ready(struct m25p *flash)
167167
*
168168
* Returns 0 if successful, non-zero otherwise.
169169
*/
170-
static int erase_block(struct m25p *flash)
170+
static int erase_chip(struct m25p *flash)
171171
{
172172
DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %dKiB\n",
173173
flash->spi->dev.bus_id, __func__,
@@ -181,7 +181,7 @@ static int erase_block(struct m25p *flash)
181181
write_enable(flash);
182182

183183
/* Set up command buffer. */
184-
flash->command[0] = OPCODE_BE;
184+
flash->command[0] = OPCODE_CHIP_ERASE;
185185

186186
spi_write(flash->spi, flash->command, 1);
187187

@@ -250,15 +250,18 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr)
250250

251251
mutex_lock(&flash->lock);
252252

253-
/* REVISIT in some cases we could speed up erasing large regions
254-
* by using OPCODE_SE instead of OPCODE_BE_4K
255-
*/
256-
257-
/* now erase those sectors */
258-
if (len == flash->mtd.size && erase_block(flash)) {
253+
/* whole-chip erase? */
254+
if (len == flash->mtd.size && erase_chip(flash)) {
259255
instr->state = MTD_ERASE_FAILED;
260256
mutex_unlock(&flash->lock);
261257
return -EIO;
258+
259+
/* REVISIT in some cases we could speed up erasing large regions
260+
* by using OPCODE_SE instead of OPCODE_BE_4K. We may have set up
261+
* to use "small sector erase", but that's not always optimal.
262+
*/
263+
264+
/* "sector"-at-a-time erase */
262265
} else {
263266
while (len) {
264267
if (erase_sector(flash, addr)) {

0 commit comments

Comments
 (0)