Now that the last user of this hook, denali.c, stopped using it,
we can remove the erase hook from nand_legacy.
I squashed single_erase() because only the difference between
single_erase() and nand_erase_op() is the number of bit shifts.
The status/ret conversion in nand_erase_nand() is unneeded since
commit eb94555e9e97 ("mtd: nand: use usual return values for the
->erase() hook"). Cleaned it up now.
Signed-off-by: Masahiro Yamada <[email protected]>
---
This depends on the denali patch:
http://patchwork.ozlabs.org/patch/1028264/
Changes in v2:
- I noticed the masking by chip->pagemask is still needed
drivers/mtd/nand/raw/nand_base.c | 31 ++++---------------------------
include/linux/mtd/rawnand.h | 2 --
2 files changed, 4 insertions(+), 29 deletions(-)
diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index cca4b24..7ea3f10 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -4155,23 +4155,6 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to,
}
/**
- * single_erase - [GENERIC] NAND standard block erase command function
- * @chip: NAND chip object
- * @page: the page address of the block which will be erased
- *
- * Standard erase command for NAND chips. Returns NAND status.
- */
-static int single_erase(struct nand_chip *chip, int page)
-{
- unsigned int eraseblock;
-
- /* Send commands to erase a block */
- eraseblock = page >> (chip->phys_erase_shift - chip->page_shift);
-
- return nand_erase_op(chip, eraseblock);
-}
-
-/**
* nand_erase - [MTD Interface] erase block(s)
* @mtd: MTD device structure
* @instr: erase instruction
@@ -4194,7 +4177,7 @@ static int nand_erase(struct mtd_info *mtd, struct erase_info *instr)
int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr,
int allowbbt)
{
- int page, status, pages_per_block, ret, chipnr;
+ int page, pages_per_block, ret, chipnr;
loff_t len;
pr_debug("%s: start = 0x%012llx, len = %llu\n",
@@ -4246,17 +4229,11 @@ int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr,
(page + pages_per_block))
chip->pagebuf = -1;
- if (chip->legacy.erase)
- status = chip->legacy.erase(chip,
- page & chip->pagemask);
- else
- status = single_erase(chip, page & chip->pagemask);
-
- /* See if block erase succeeded */
- if (status) {
+ ret = nand_erase_op(chip, (page & chip->pagemask) >>
+ (chip->phys_erase_shift - chip->page_shift));
+ if (ret) {
pr_debug("%s: failed erase, page 0x%08x\n",
__func__, page);
- ret = -EIO;
instr->fail_addr =
((loff_t)page << chip->page_shift);
goto erase_exit;
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index 33e240a..5e37534 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -936,7 +936,6 @@ static inline void nand_controller_init(struct nand_controller *nfc)
* @waitfunc: hardware specific function for wait on ready.
* @block_bad: check if a block is bad, using OOB markers
* @block_markbad: mark a block bad
- * @erase: erase function
* @set_features: set the NAND chip features
* @get_features: get the NAND chip features
* @chip_delay: chip dependent delay for transferring data from array to read
@@ -962,7 +961,6 @@ struct nand_legacy {
int (*waitfunc)(struct nand_chip *chip);
int (*block_bad)(struct nand_chip *chip, loff_t ofs);
int (*block_markbad)(struct nand_chip *chip, loff_t ofs);
- int (*erase)(struct nand_chip *chip, int page);
int (*set_features)(struct nand_chip *chip, int feature_addr,
u8 *subfeature_para);
int (*get_features)(struct nand_chip *chip, int feature_addr,
--
2.7.4
On Mon, 21 Jan 2019 15:32:07 +0900
Masahiro Yamada <[email protected]> wrote:
> Now that the last user of this hook, denali.c, stopped using it,
> we can remove the erase hook from nand_legacy.
>
> I squashed single_erase() because only the difference between
> single_erase() and nand_erase_op() is the number of bit shifts.
>
> The status/ret conversion in nand_erase_nand() is unneeded since
> commit eb94555e9e97 ("mtd: nand: use usual return values for the
> ->erase() hook"). Cleaned it up now.
Yeah! One less field in nand_legacy :-).
>
> Signed-off-by: Masahiro Yamada <[email protected]>
Reviewed-by: Boris Brezillon <[email protected]>
> ---
>
> This depends on the denali patch:
> http://patchwork.ozlabs.org/patch/1028264/
>
>
> Changes in v2:
> - I noticed the masking by chip->pagemask is still needed
>
> drivers/mtd/nand/raw/nand_base.c | 31 ++++---------------------------
> include/linux/mtd/rawnand.h | 2 --
> 2 files changed, 4 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index cca4b24..7ea3f10 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -4155,23 +4155,6 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to,
> }
>
> /**
> - * single_erase - [GENERIC] NAND standard block erase command function
> - * @chip: NAND chip object
> - * @page: the page address of the block which will be erased
> - *
> - * Standard erase command for NAND chips. Returns NAND status.
> - */
> -static int single_erase(struct nand_chip *chip, int page)
> -{
> - unsigned int eraseblock;
> -
> - /* Send commands to erase a block */
> - eraseblock = page >> (chip->phys_erase_shift - chip->page_shift);
> -
> - return nand_erase_op(chip, eraseblock);
> -}
> -
> -/**
> * nand_erase - [MTD Interface] erase block(s)
> * @mtd: MTD device structure
> * @instr: erase instruction
> @@ -4194,7 +4177,7 @@ static int nand_erase(struct mtd_info *mtd, struct erase_info *instr)
> int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr,
> int allowbbt)
> {
> - int page, status, pages_per_block, ret, chipnr;
> + int page, pages_per_block, ret, chipnr;
> loff_t len;
>
> pr_debug("%s: start = 0x%012llx, len = %llu\n",
> @@ -4246,17 +4229,11 @@ int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr,
> (page + pages_per_block))
> chip->pagebuf = -1;
>
> - if (chip->legacy.erase)
> - status = chip->legacy.erase(chip,
> - page & chip->pagemask);
> - else
> - status = single_erase(chip, page & chip->pagemask);
> -
> - /* See if block erase succeeded */
> - if (status) {
> + ret = nand_erase_op(chip, (page & chip->pagemask) >>
> + (chip->phys_erase_shift - chip->page_shift));
> + if (ret) {
> pr_debug("%s: failed erase, page 0x%08x\n",
> __func__, page);
> - ret = -EIO;
> instr->fail_addr =
> ((loff_t)page << chip->page_shift);
> goto erase_exit;
> diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
> index 33e240a..5e37534 100644
> --- a/include/linux/mtd/rawnand.h
> +++ b/include/linux/mtd/rawnand.h
> @@ -936,7 +936,6 @@ static inline void nand_controller_init(struct nand_controller *nfc)
> * @waitfunc: hardware specific function for wait on ready.
> * @block_bad: check if a block is bad, using OOB markers
> * @block_markbad: mark a block bad
> - * @erase: erase function
> * @set_features: set the NAND chip features
> * @get_features: get the NAND chip features
> * @chip_delay: chip dependent delay for transferring data from array to read
> @@ -962,7 +961,6 @@ struct nand_legacy {
> int (*waitfunc)(struct nand_chip *chip);
> int (*block_bad)(struct nand_chip *chip, loff_t ofs);
> int (*block_markbad)(struct nand_chip *chip, loff_t ofs);
> - int (*erase)(struct nand_chip *chip, int page);
> int (*set_features)(struct nand_chip *chip, int feature_addr,
> u8 *subfeature_para);
> int (*get_features)(struct nand_chip *chip, int feature_addr,
Hi Masahiro,
I love your patch! Yet something to improve:
[auto build test ERROR on v5.0-rc2]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Masahiro-Yamada/mtd-rawnand-remove-legacy-erase-and-single_erase/20190122-040438
config: sh-allyesconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=8.2.0 make.cross ARCH=sh
All errors (new ones prefixed by >>):
drivers/mtd/nand/raw/denali.c: In function 'denali_attach_chip':
>> drivers/mtd/nand/raw/denali.c:1247:14: error: 'struct nand_legacy' has no member named 'erase'
chip->legacy.erase = denali_erase;
^
vim +1247 drivers/mtd/nand/raw/denali.c
6da27b469 drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1168
d03af162b drivers/mtd/nand/raw/denali.c Miquel Raynal 2018-07-20 1169 static int denali_attach_chip(struct nand_chip *chip)
ce082596a drivers/mtd/nand/denali.c Jason Roberts 2010-05-13 1170 {
1394a7265 drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1171 struct mtd_info *mtd = nand_to_mtd(chip);
d03af162b drivers/mtd/nand/raw/denali.c Miquel Raynal 2018-07-20 1172 struct denali_nand_info *denali = mtd_to_denali(mtd);
2a0a288ec drivers/mtd/nand/denali.c Dinh Nguyen 2012-09-27 1173 int ret;
ce082596a drivers/mtd/nand/denali.c Jason Roberts 2010-05-13 1174
0d3a966d2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-16 1175 if (ioread32(denali->reg + FEATURES) & FEATURES__DMA)
26d266e10 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1176 denali->dma_avail = 1;
26d266e10 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1177
26d266e10 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1178 if (denali->dma_avail) {
26d266e10 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1179 int dma_bit = denali->caps & DENALI_CAP_DMA_64BIT ? 64 : 32;
26d266e10 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1180
26d266e10 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1181 ret = dma_set_mask(denali->dev, DMA_BIT_MASK(dma_bit));
e07caa368 drivers/mtd/nand/denali.c Huang Shijie 2013-12-21 1182 if (ret) {
26d266e10 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1183 dev_info(denali->dev,
26d266e10 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1184 "Failed to set DMA mask. Disabling DMA.\n");
26d266e10 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1185 denali->dma_avail = 0;
26d266e10 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1186 }
e07caa368 drivers/mtd/nand/denali.c Huang Shijie 2013-12-21 1187 }
e07caa368 drivers/mtd/nand/denali.c Huang Shijie 2013-12-21 1188
26d266e10 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1189 if (denali->dma_avail) {
997cde2a2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1190 chip->options |= NAND_USE_BOUNCE_BUFFER;
997cde2a2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1191 chip->buf_align = 16;
89dcb27b0 drivers/mtd/nand/denali.c Masahiro Yamada 2017-09-22 1192 if (denali->caps & DENALI_CAP_DMA_64BIT)
89dcb27b0 drivers/mtd/nand/denali.c Masahiro Yamada 2017-09-22 1193 denali->setup_dma = denali_setup_dma64;
89dcb27b0 drivers/mtd/nand/denali.c Masahiro Yamada 2017-09-22 1194 else
89dcb27b0 drivers/mtd/nand/denali.c Masahiro Yamada 2017-09-22 1195 denali->setup_dma = denali_setup_dma32;
66406524e drivers/mtd/nand/denali.c Chuanxiao.Dong 2010-08-06 1196 }
66406524e drivers/mtd/nand/denali.c Chuanxiao.Dong 2010-08-06 1197
1394a7265 drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1198 chip->bbt_options |= NAND_BBT_USE_FLASH;
777f2d49e drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1199 chip->bbt_options |= NAND_BBT_NO_OOB;
1394a7265 drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1200 chip->ecc.mode = NAND_ECC_HW_SYNDROME;
1394a7265 drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1201 chip->options |= NAND_NO_SUBPAGE_WRITE;
d99d72829 drivers/mtd/nand/denali.c Graham Moore 2015-01-14 1202
f9801fda9 drivers/mtd/nand/raw/denali.c Abhishek Sahu 2018-06-20 1203 ret = nand_ecc_choose_conf(chip, denali->ecc_caps,
f9801fda9 drivers/mtd/nand/raw/denali.c Abhishek Sahu 2018-06-20 1204 mtd->oobsize - denali->oob_skip_bytes);
7de117fd5 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-07 1205 if (ret) {
7de117fd5 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-07 1206 dev_err(denali->dev, "Failed to setup ECC settings.\n");
d03af162b drivers/mtd/nand/raw/denali.c Miquel Raynal 2018-07-20 1207 return ret;
ce082596a drivers/mtd/nand/denali.c Jason Roberts 2010-05-13 1208 }
ce082596a drivers/mtd/nand/denali.c Jason Roberts 2010-05-13 1209
7de117fd5 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-07 1210 dev_dbg(denali->dev,
7de117fd5 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-07 1211 "chosen ECC settings: step=%d, strength=%d, bytes=%d\n",
7de117fd5 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-07 1212 chip->ecc.size, chip->ecc.strength, chip->ecc.bytes);
7de117fd5 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-07 1213
e0d53b3f8 drivers/mtd/nand/denali.c Masahiro Yamada 2017-09-22 1214 iowrite32(FIELD_PREP(ECC_CORRECTION__ERASE_THRESHOLD, 1) |
e0d53b3f8 drivers/mtd/nand/denali.c Masahiro Yamada 2017-09-22 1215 FIELD_PREP(ECC_CORRECTION__VALUE, chip->ecc.strength),
0d3a966d2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-16 1216 denali->reg + ECC_CORRECTION);
0615e7ad5 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-07 1217 iowrite32(mtd->erasesize / mtd->writesize,
0d3a966d2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-16 1218 denali->reg + PAGES_PER_BLOCK);
0615e7ad5 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-07 1219 iowrite32(chip->options & NAND_BUSWIDTH_16 ? 1 : 0,
0d3a966d2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-16 1220 denali->reg + DEVICE_WIDTH);
a3750a642 drivers/mtd/nand/denali.c Masahiro Yamada 2017-09-13 1221 iowrite32(chip->options & NAND_ROW_ADDR_3 ? 0 : TWO_ROW_ADDR_CYCLES__FLAG,
a3750a642 drivers/mtd/nand/denali.c Masahiro Yamada 2017-09-13 1222 denali->reg + TWO_ROW_ADDR_CYCLES);
0d3a966d2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-16 1223 iowrite32(mtd->writesize, denali->reg + DEVICE_MAIN_AREA_SIZE);
0d3a966d2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-16 1224 iowrite32(mtd->oobsize, denali->reg + DEVICE_SPARE_AREA_SIZE);
7de117fd5 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-07 1225
0d3a966d2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-16 1226 iowrite32(chip->ecc.size, denali->reg + CFG_DATA_BLOCK_SIZE);
0d3a966d2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-16 1227 iowrite32(chip->ecc.size, denali->reg + CFG_LAST_DATA_BLOCK_SIZE);
7de117fd5 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-07 1228 /* chip->ecc.steps is set by nand_scan_tail(); not available here */
7de117fd5 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-07 1229 iowrite32(mtd->writesize / chip->ecc.size,
0d3a966d2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-16 1230 denali->reg + CFG_NUM_DATA_BLOCKS);
7de117fd5 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-07 1231
14fad62b6 drivers/mtd/nand/denali.c Boris Brezillon 2016-02-03 1232 mtd_set_ooblayout(mtd, &denali_ooblayout_ops);
db9a32104 drivers/mtd/nand/denali.c Chuanxiao Dong 2010-08-06 1233
fa6134e54 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1234 if (chip->options & NAND_BUSWIDTH_16) {
716bbbabc drivers/mtd/nand/raw/denali.c Boris Brezillon 2018-09-07 1235 chip->legacy.read_buf = denali_read_buf16;
716bbbabc drivers/mtd/nand/raw/denali.c Boris Brezillon 2018-09-07 1236 chip->legacy.write_buf = denali_write_buf16;
fa6134e54 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1237 } else {
716bbbabc drivers/mtd/nand/raw/denali.c Boris Brezillon 2018-09-07 1238 chip->legacy.read_buf = denali_read_buf;
716bbbabc drivers/mtd/nand/raw/denali.c Boris Brezillon 2018-09-07 1239 chip->legacy.write_buf = denali_write_buf;
fa6134e54 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1240 }
1394a7265 drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1241 chip->ecc.read_page = denali_read_page;
1394a7265 drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1242 chip->ecc.read_page_raw = denali_read_page_raw;
1394a7265 drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1243 chip->ecc.write_page = denali_write_page;
1394a7265 drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1244 chip->ecc.write_page_raw = denali_write_page_raw;
1394a7265 drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1245 chip->ecc.read_oob = denali_read_oob;
1394a7265 drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1246 chip->ecc.write_oob = denali_write_oob;
f9ebd1bb4 drivers/mtd/nand/raw/denali.c Boris Brezillon 2018-09-07 @1247 chip->legacy.erase = denali_erase;
ce082596a drivers/mtd/nand/denali.c Jason Roberts 2010-05-13 1248
e93c1640e drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1249 ret = denali_multidev_fixup(denali);
e93c1640e drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1250 if (ret)
d03af162b drivers/mtd/nand/raw/denali.c Miquel Raynal 2018-07-20 1251 return ret;
6da27b469 drivers/mtd/nand/denali.c Masahiro Yamada 2017-03-23 1252
7d370b2c2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1253 /*
7d370b2c2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1254 * This buffer is DMA-mapped by denali_{read,write}_page_raw. Do not
7d370b2c2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1255 * use devm_kmalloc() because the memory allocated by devm_ does not
7d370b2c2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1256 * guarantee DMA-safe alignment.
7d370b2c2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1257 */
7d370b2c2 drivers/mtd/nand/denali.c Masahiro Yamada 2017-06-13 1258 denali->buf = kmalloc(mtd->writesize + mtd->oobsize, GFP_KERNEL);
d03af162b drivers/mtd/nand/raw/denali.c Miquel Raynal 2018-07-20 1259 if (!denali->buf)
d03af162b drivers/mtd/nand/raw/denali.c Miquel Raynal 2018-07-20 1260 return -ENOMEM;
d03af162b drivers/mtd/nand/raw/denali.c Miquel Raynal 2018-07-20 1261
d03af162b drivers/mtd/nand/raw/denali.c Miquel Raynal 2018-07-20 1262 return 0;
d03af162b drivers/mtd/nand/raw/denali.c Miquel Raynal 2018-07-20 1263 }
d03af162b drivers/mtd/nand/raw/denali.c Miquel Raynal 2018-07-20 1264
:::::: The code at line 1247 was first introduced by commit
:::::: f9ebd1bb41031afc162e9acda7ad044a35bccf82 mtd: rawnand: Deprecate ->erase()
:::::: TO: Boris Brezillon <[email protected]>
:::::: CC: Miquel Raynal <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi Masahiro,
Masahiro Yamada <[email protected]> wrote on Mon, 21 Jan
2019 15:32:07 +0900:
> Now that the last user of this hook, denali.c, stopped using it,
> we can remove the erase hook from nand_legacy.
>
> I squashed single_erase() because only the difference between
> single_erase() and nand_erase_op() is the number of bit shifts.
>
> The status/ret conversion in nand_erase_nand() is unneeded since
> commit eb94555e9e97 ("mtd: nand: use usual return values for the
> ->erase() hook"). Cleaned it up now.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
Applied to nand/next.
Thanks,
Miquèl