Skip to content

Commit eb94555

Browse files
miquelraynalBoris Brezillon
authored and
Boris Brezillon
committed
mtd: nand: use usual return values for the ->erase() hook
Avoid using specific defined values for checking returned status of the ->erase() hook. Instead, use usual negative error values on failure, zero otherwise. Signed-off-by: Miquel Raynal <[email protected]> Acked-by: Masahiro Yamada <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
1 parent 8a8c8ba commit eb94555

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

drivers/mtd/nand/denali.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ static int denali_erase(struct mtd_info *mtd, int page)
951951
irq_status = denali_wait_for_irq(denali,
952952
INTR__ERASE_COMP | INTR__ERASE_FAIL);
953953

954-
return irq_status & INTR__ERASE_COMP ? 0 : NAND_STATUS_FAIL;
954+
return irq_status & INTR__ERASE_COMP ? 0 : -EIO;
955955
}
956956

957957
static int denali_setup_data_interface(struct mtd_info *mtd, int chipnr,

drivers/mtd/nand/docg4.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ static int docg4_erase_block(struct mtd_info *mtd, int page)
900900
struct docg4_priv *doc = nand_get_controller_data(nand);
901901
void __iomem *docptr = doc->virtadr;
902902
uint16_t g4_page;
903+
int status;
903904

904905
dev_dbg(doc->dev, "%s: page %04x\n", __func__, page);
905906

@@ -939,7 +940,11 @@ static int docg4_erase_block(struct mtd_info *mtd, int page)
939940
poll_status(doc);
940941
write_nop(docptr);
941942

942-
return nand->waitfunc(mtd, nand);
943+
status = nand->waitfunc(mtd, nand);
944+
if (status < 0)
945+
return status;
946+
947+
return status & NAND_STATUS_FAIL ? -EIO : 0;
943948
}
944949

945950
static int write_page(struct mtd_info *mtd, struct nand_chip *nand,

drivers/mtd/nand/nand_base.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,11 +2989,17 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to,
29892989
static int single_erase(struct mtd_info *mtd, int page)
29902990
{
29912991
struct nand_chip *chip = mtd_to_nand(mtd);
2992+
int status;
2993+
29922994
/* Send commands to erase a block */
29932995
chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page);
29942996
chip->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1);
29952997

2996-
return chip->waitfunc(mtd, chip);
2998+
status = chip->waitfunc(mtd, chip);
2999+
if (status < 0)
3000+
return status;
3001+
3002+
return status & NAND_STATUS_FAIL ? -EIO : 0;
29973003
}
29983004

29993005
/**
@@ -3077,7 +3083,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
30773083
status = chip->erase(mtd, page & chip->pagemask);
30783084

30793085
/* See if block erase succeeded */
3080-
if (status & NAND_STATUS_FAIL) {
3086+
if (status) {
30813087
pr_debug("%s: failed erase, page 0x%08x\n",
30823088
__func__, page);
30833089
instr->state = MTD_ERASE_FAILED;

0 commit comments

Comments
 (0)