Commit 4a78cc64 authored by Boris Brezillon's avatar Boris Brezillon
Browse files

mtd: nand: Make sure drivers not supporting SET/GET_FEATURES return -ENOTSUPP



A lot of drivers are providing their own ->cmdfunc(), and most of the
time this implementation does not support all possible NAND operations.
But since ->cmdfunc() cannot return an error code, the core has no way
to know that the operation it requested is not supported.

This is a problem we cannot address for all kind of operations with the
current design, but we can prevent these silent failures for the
GET/SET FEATURES operation by overloading the default
->onfi_{set,get}_features() methods with one returning -ENOTSUPP.

Reported-by: default avatarChris Packham <Chris.Packham@alliedtelesis.co.nz>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Tested-by: default avatarChris Packham <Chris.Packham@alliedtelesis.co.nz>
parent cc0f51ec
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -392,6 +392,8 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n)
	b47n->nand_chip.read_byte = bcm47xxnflash_ops_bcm4706_read_byte;
	b47n->nand_chip.read_buf = bcm47xxnflash_ops_bcm4706_read_buf;
	b47n->nand_chip.write_buf = bcm47xxnflash_ops_bcm4706_write_buf;
	b47n->nand_chip.onfi_set_features = nand_onfi_get_set_features_notsupp;
	b47n->nand_chip.onfi_get_features = nand_onfi_get_set_features_notsupp;

	nand_chip->chip_delay = 50;
	b47n->nand_chip.bbt_options = NAND_BBT_USE_FLASH;
+2 −0
Original line number Diff line number Diff line
@@ -654,6 +654,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
	cafe->nand.read_buf = cafe_read_buf;
	cafe->nand.write_buf = cafe_write_buf;
	cafe->nand.select_chip = cafe_select_chip;
	cafe->nand.onfi_set_features = nand_onfi_get_set_features_notsupp;
	cafe->nand.onfi_get_features = nand_onfi_get_set_features_notsupp;

	cafe->nand.chip_delay = 0;

+2 −0
Original line number Diff line number Diff line
@@ -1531,6 +1531,8 @@ int denali_init(struct denali_nand_info *denali)
	chip->cmdfunc = denali_cmdfunc;
	chip->read_byte = denali_read_byte;
	chip->waitfunc = denali_waitfunc;
	chip->onfi_set_features = nand_onfi_get_set_features_notsupp;
	chip->onfi_get_features = nand_onfi_get_set_features_notsupp;

	/*
	 * scan for NAND devices attached to the controller
+2 −0
Original line number Diff line number Diff line
@@ -1260,6 +1260,8 @@ static void __init init_mtd_structs(struct mtd_info *mtd)
	nand->read_buf = docg4_read_buf;
	nand->write_buf = docg4_write_buf16;
	nand->erase = docg4_erase_block;
	nand->onfi_set_features = nand_onfi_get_set_features_notsupp;
	nand->onfi_get_features = nand_onfi_get_set_features_notsupp;
	nand->ecc.read_page = docg4_read_page;
	nand->ecc.write_page = docg4_write_page;
	nand->ecc.read_page_raw = docg4_read_page_raw;
+2 −0
Original line number Diff line number Diff line
@@ -775,6 +775,8 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
	chip->select_chip = fsl_elbc_select_chip;
	chip->cmdfunc = fsl_elbc_cmdfunc;
	chip->waitfunc = fsl_elbc_wait;
	chip->onfi_set_features = nand_onfi_get_set_features_notsupp;
	chip->onfi_get_features = nand_onfi_get_set_features_notsupp;

	chip->bbt_td = &bbt_main_descr;
	chip->bbt_md = &bbt_mirror_descr;
Loading