Skip to content

Commit db2b6c8

Browse files
author
Jon Lin
committed
drivers: rkflash: Add more information for SPI Nand MTD debug
1.Add more information for SPI Nand MTD debug 2.Return program result Change-Id: I3fc7d63955355ad88adfbd02f0b67fc16c9d76d5 Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
1 parent 03a8eda commit db2b6c8

1 file changed

Lines changed: 26 additions & 11 deletions

File tree

drivers/rkflash/sfc_nand_mtd.c

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ static inline struct snand_mtd_dev *mtd_to_priv(struct mtd_info *ptr_mtd)
2626

2727
int sfc_nand_erase_mtd(struct mtd_info *mtd, u32 addr)
2828
{
29-
return sfc_nand_erase_block(0, addr >> mtd->writesize_shift);
29+
int ret;
30+
31+
ret = sfc_nand_erase_block(0, addr >> mtd->writesize_shift);
32+
if (ret) {
33+
rkflash_print_error("%s fail ret= %d\n", __func__, ret);
34+
ret = -EIO;
35+
}
36+
37+
return ret;
3038
}
3139

3240
static int sfc_nand_write_mtd(struct mtd_info *mtd, loff_t to,
@@ -52,8 +60,9 @@ static int sfc_nand_write_mtd(struct mtd_info *mtd, loff_t to,
5260
ret = sfc_nand_prog_page_raw(0, to >> mtd->writesize_shift,
5361
(u32 *)p_dev->dma_buf);
5462
if (ret != SFC_OK) {
55-
rkflash_print_dio("%s addr %llx ret= %d\n",
56-
__func__, to, ret);
63+
rkflash_print_error("%s addr %llx ret= %d\n",
64+
__func__, to, ret);
65+
ret = -EIO;
5766
break;
5867
}
5968

@@ -63,7 +72,7 @@ static int sfc_nand_write_mtd(struct mtd_info *mtd, loff_t to,
6372
to += mtd->writesize;
6473
}
6574

66-
return 0;
75+
return ret;
6776
}
6877

6978
static int sfc_nand_read_mtd(struct mtd_info *mtd, loff_t from,
@@ -92,11 +101,11 @@ static int sfc_nand_read_mtd(struct mtd_info *mtd, loff_t from,
92101

93102
ret = sfc_nand_read(page, (u32 *)data, off, real_size);
94103
if (ret == SFC_NAND_HW_ERROR) {
104+
rkflash_print_error("%s addr %llx ret= %d\n",
105+
__func__, from, ret);
95106
ret = -EIO;
96107
break;
97-
}
98-
99-
if (ret == SFC_NAND_ECC_ERROR) {
108+
} else if (ret == SFC_NAND_ECC_ERROR) {
100109
rkflash_print_error("%s addr %llx ret= %d\n",
101110
__func__, from, ret);
102111
ecc_failed = true;
@@ -127,8 +136,11 @@ int sfc_nand_isbad_mtd(struct mtd_info *mtd, loff_t ofs)
127136
struct snand_mtd_dev *p_dev = mtd_to_priv(mtd);
128137

129138
rkflash_print_dio("%s %llx\n", __func__, ofs);
130-
if (ofs & mtd->writesize_mask)
139+
if (ofs & mtd->writesize_mask) {
140+
rkflash_print_error("%s %llx input error\n", __func__, ofs);
141+
131142
return -EINVAL;
143+
}
132144

133145
if (snanddev_bbt_is_initialized(p_dev)) {
134146
unsigned int entry;
@@ -167,8 +179,11 @@ static int sfc_nand_markbad_mtd(struct mtd_info *mtd, loff_t ofs)
167179
unsigned int entry;
168180

169181
rkflash_print_error("%s %llx\n", __func__, ofs);
170-
if (ofs & mtd->erasesize_mask)
182+
if (ofs & mtd->erasesize_mask) {
183+
rkflash_print_error("%s %llx input error\n", __func__, ofs);
184+
171185
return -EINVAL;
186+
}
172187

173188
if (sfc_nand_isbad_mtd(mtd, ofs))
174189
return 0;
@@ -228,8 +243,8 @@ static int sfc_erase_mtd(struct mtd_info *mtd, struct erase_info *instr)
228243
ret = snanddev_bbt_get_block_status(nand, addr >> mtd->erasesize_shift);
229244
if (ret == NAND_BBT_BLOCK_WORN ||
230245
ret == NAND_BBT_BLOCK_FACTORY_BAD) {
231-
pr_warn("attempt to erase a bad/reserved block @%llx\n",
232-
addr >> mtd->erasesize_shift);
246+
rkflash_print_error("attempt to erase a bad/reserved block @%llx\n",
247+
addr >> mtd->erasesize_shift);
233248
addr += mtd->erasesize;
234249
remaining -= mtd->erasesize;
235250
continue;

0 commit comments

Comments
 (0)