Skip to content

Commit

Permalink
Merge tag 'for-linus-20131008' of git://git.infradead.org/linux-mtd
Browse files Browse the repository at this point in the history
Pull MTD fixes from Brian Norris:
 - fix a small memory leak in some new ONFI code
 - account for additional odd variations of Micron SPI flash

Acked by David Woodhouse.

* tag 'for-linus-20131008' of git://git.infradead.org/linux-mtd:
  mtd: m25p80: Fix 4 byte addressing mode for Micron devices.
  mtd: nand: fix memory leak in ONFI extended parameter page
  • Loading branch information
torvalds committed Oct 10, 2013
2 parents 0e7a3ed + 2b468ef commit b291a22
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
17 changes: 15 additions & 2 deletions drivers/mtd/devices/m25p80.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,25 @@ static inline int write_disable(struct m25p *flash)
*/
static inline int set_4byte(struct m25p *flash, u32 jedec_id, int enable)
{
int status;
bool need_wren = false;

switch (JEDEC_MFR(jedec_id)) {
case CFI_MFR_MACRONIX:
case CFI_MFR_ST: /* Micron, actually */
/* Some Micron need WREN command; all will accept it */
need_wren = true;
case CFI_MFR_MACRONIX:
case 0xEF /* winbond */:
if (need_wren)
write_enable(flash);

flash->command[0] = enable ? OPCODE_EN4B : OPCODE_EX4B;
return spi_write(flash->spi, flash->command, 1);
status = spi_write(flash->spi, flash->command, 1);

if (need_wren)
write_disable(flash);

return status;
default:
/* Spansion style */
flash->command[0] = OPCODE_BRWR;
Expand Down
8 changes: 3 additions & 5 deletions drivers/mtd/nand/nand_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -2869,10 +2869,8 @@ static int nand_flash_detect_ext_param_page(struct mtd_info *mtd,

len = le16_to_cpu(p->ext_param_page_length) * 16;
ep = kmalloc(len, GFP_KERNEL);
if (!ep) {
ret = -ENOMEM;
goto ext_out;
}
if (!ep)
return -ENOMEM;

/* Send our own NAND_CMD_PARAM. */
chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1);
Expand Down Expand Up @@ -2920,7 +2918,7 @@ static int nand_flash_detect_ext_param_page(struct mtd_info *mtd,
}

pr_info("ONFI extended param page detected.\n");
return 0;
ret = 0;

ext_out:
kfree(ep);
Expand Down

0 comments on commit b291a22

Please sign in to comment.