Commit 45240367 authored by Boris Brezillon's avatar Boris Brezillon Committed by Miquel Raynal

mtd: rawnand: Deprecate ->{set,get}_features() hooks

Those hooks should be replaced by a proper ->exec_op() implementation.
Move them to the nand_legacy struct to make it clear.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent f9ebd1bb
...@@ -390,8 +390,8 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n) ...@@ -390,8 +390,8 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n)
b47n->nand_chip.legacy.read_byte = bcm47xxnflash_ops_bcm4706_read_byte; b47n->nand_chip.legacy.read_byte = bcm47xxnflash_ops_bcm4706_read_byte;
b47n->nand_chip.legacy.read_buf = bcm47xxnflash_ops_bcm4706_read_buf; b47n->nand_chip.legacy.read_buf = bcm47xxnflash_ops_bcm4706_read_buf;
b47n->nand_chip.legacy.write_buf = bcm47xxnflash_ops_bcm4706_write_buf; b47n->nand_chip.legacy.write_buf = bcm47xxnflash_ops_bcm4706_write_buf;
b47n->nand_chip.set_features = nand_get_set_features_notsupp; b47n->nand_chip.legacy.set_features = nand_get_set_features_notsupp;
b47n->nand_chip.get_features = nand_get_set_features_notsupp; b47n->nand_chip.legacy.get_features = nand_get_set_features_notsupp;
nand_chip->chip_delay = 50; nand_chip->chip_delay = 50;
b47n->nand_chip.bbt_options = NAND_BBT_USE_FLASH; b47n->nand_chip.bbt_options = NAND_BBT_USE_FLASH;
......
...@@ -709,8 +709,8 @@ static int cafe_nand_probe(struct pci_dev *pdev, ...@@ -709,8 +709,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
cafe->nand.legacy.read_buf = cafe_read_buf; cafe->nand.legacy.read_buf = cafe_read_buf;
cafe->nand.legacy.write_buf = cafe_write_buf; cafe->nand.legacy.write_buf = cafe_write_buf;
cafe->nand.select_chip = cafe_select_chip; cafe->nand.select_chip = cafe_select_chip;
cafe->nand.set_features = nand_get_set_features_notsupp; cafe->nand.legacy.set_features = nand_get_set_features_notsupp;
cafe->nand.get_features = nand_get_set_features_notsupp; cafe->nand.legacy.get_features = nand_get_set_features_notsupp;
cafe->nand.chip_delay = 0; cafe->nand.chip_delay = 0;
......
...@@ -782,8 +782,8 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv) ...@@ -782,8 +782,8 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
chip->select_chip = fsl_elbc_select_chip; chip->select_chip = fsl_elbc_select_chip;
chip->legacy.cmdfunc = fsl_elbc_cmdfunc; chip->legacy.cmdfunc = fsl_elbc_cmdfunc;
chip->legacy.waitfunc = fsl_elbc_wait; chip->legacy.waitfunc = fsl_elbc_wait;
chip->set_features = nand_get_set_features_notsupp; chip->legacy.set_features = nand_get_set_features_notsupp;
chip->get_features = nand_get_set_features_notsupp; chip->legacy.get_features = nand_get_set_features_notsupp;
chip->bbt_td = &bbt_main_descr; chip->bbt_td = &bbt_main_descr;
chip->bbt_md = &bbt_mirror_descr; chip->bbt_md = &bbt_mirror_descr;
......
...@@ -867,8 +867,8 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) ...@@ -867,8 +867,8 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
chip->select_chip = fsl_ifc_select_chip; chip->select_chip = fsl_ifc_select_chip;
chip->legacy.cmdfunc = fsl_ifc_cmdfunc; chip->legacy.cmdfunc = fsl_ifc_cmdfunc;
chip->legacy.waitfunc = fsl_ifc_wait; chip->legacy.waitfunc = fsl_ifc_wait;
chip->set_features = nand_get_set_features_notsupp; chip->legacy.set_features = nand_get_set_features_notsupp;
chip->get_features = nand_get_set_features_notsupp; chip->legacy.get_features = nand_get_set_features_notsupp;
chip->bbt_td = &bbt_main_descr; chip->bbt_td = &bbt_main_descr;
chip->bbt_md = &bbt_mirror_descr; chip->bbt_md = &bbt_mirror_descr;
......
...@@ -788,8 +788,8 @@ static int hisi_nfc_probe(struct platform_device *pdev) ...@@ -788,8 +788,8 @@ static int hisi_nfc_probe(struct platform_device *pdev)
chip->legacy.write_buf = hisi_nfc_write_buf; chip->legacy.write_buf = hisi_nfc_write_buf;
chip->legacy.read_buf = hisi_nfc_read_buf; chip->legacy.read_buf = hisi_nfc_read_buf;
chip->chip_delay = HINFC504_CHIP_DELAY; chip->chip_delay = HINFC504_CHIP_DELAY;
chip->set_features = nand_get_set_features_notsupp; chip->legacy.set_features = nand_get_set_features_notsupp;
chip->get_features = nand_get_set_features_notsupp; chip->legacy.get_features = nand_get_set_features_notsupp;
hisi_nfc_host_init(host); hisi_nfc_host_init(host);
......
...@@ -698,8 +698,8 @@ static int mpc5121_nfc_probe(struct platform_device *op) ...@@ -698,8 +698,8 @@ static int mpc5121_nfc_probe(struct platform_device *op)
chip->legacy.read_buf = mpc5121_nfc_read_buf; chip->legacy.read_buf = mpc5121_nfc_read_buf;
chip->legacy.write_buf = mpc5121_nfc_write_buf; chip->legacy.write_buf = mpc5121_nfc_write_buf;
chip->select_chip = mpc5121_nfc_select_chip; chip->select_chip = mpc5121_nfc_select_chip;
chip->set_features = nand_get_set_features_notsupp; chip->legacy.set_features = nand_get_set_features_notsupp;
chip->get_features = nand_get_set_features_notsupp; chip->legacy.get_features = nand_get_set_features_notsupp;
chip->bbt_options = NAND_BBT_USE_FLASH; chip->bbt_options = NAND_BBT_USE_FLASH;
chip->ecc.mode = NAND_ECC_SOFT; chip->ecc.mode = NAND_ECC_SOFT;
chip->ecc.algo = NAND_ECC_HAMMING; chip->ecc.algo = NAND_ECC_HAMMING;
......
...@@ -1778,8 +1778,8 @@ static int mxcnd_probe(struct platform_device *pdev) ...@@ -1778,8 +1778,8 @@ static int mxcnd_probe(struct platform_device *pdev)
this->legacy.read_byte = mxc_nand_read_byte; this->legacy.read_byte = mxc_nand_read_byte;
this->legacy.write_buf = mxc_nand_write_buf; this->legacy.write_buf = mxc_nand_write_buf;
this->legacy.read_buf = mxc_nand_read_buf; this->legacy.read_buf = mxc_nand_read_buf;
this->set_features = mxc_nand_set_features; this->legacy.set_features = mxc_nand_set_features;
this->get_features = mxc_nand_get_features; this->legacy.get_features = mxc_nand_get_features;
host->clk = devm_clk_get(&pdev->dev, NULL); host->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(host->clk)) if (IS_ERR(host->clk))
......
...@@ -1175,44 +1175,6 @@ static bool nand_supports_set_features(struct nand_chip *chip, int addr) ...@@ -1175,44 +1175,6 @@ static bool nand_supports_set_features(struct nand_chip *chip, int addr)
test_bit(addr, chip->parameters.set_feature_list)); test_bit(addr, chip->parameters.set_feature_list));
} }
/**
* nand_get_features - wrapper to perform a GET_FEATURE
* @chip: NAND chip info structure
* @addr: feature address
* @subfeature_param: the subfeature parameters, a four bytes array
*
* Returns 0 for success, a negative error otherwise. Returns -ENOTSUPP if the
* operation cannot be handled.
*/
int nand_get_features(struct nand_chip *chip, int addr,
u8 *subfeature_param)
{
if (!nand_supports_get_features(chip, addr))
return -ENOTSUPP;
return chip->get_features(chip, addr, subfeature_param);
}
EXPORT_SYMBOL_GPL(nand_get_features);
/**
* nand_set_features - wrapper to perform a SET_FEATURE
* @chip: NAND chip info structure
* @addr: feature address
* @subfeature_param: the subfeature parameters, a four bytes array
*
* Returns 0 for success, a negative error otherwise. Returns -ENOTSUPP if the
* operation cannot be handled.
*/
int nand_set_features(struct nand_chip *chip, int addr,
u8 *subfeature_param)
{
if (!nand_supports_set_features(chip, addr))
return -ENOTSUPP;
return chip->set_features(chip, addr, subfeature_param);
}
EXPORT_SYMBOL_GPL(nand_set_features);
/** /**
* nand_reset_data_interface - Reset data interface and timings * nand_reset_data_interface - Reset data interface and timings
* @chip: The NAND chip * @chip: The NAND chip
...@@ -2833,6 +2795,50 @@ int nand_reset(struct nand_chip *chip, int chipnr) ...@@ -2833,6 +2795,50 @@ int nand_reset(struct nand_chip *chip, int chipnr)
} }
EXPORT_SYMBOL_GPL(nand_reset); EXPORT_SYMBOL_GPL(nand_reset);
/**
* nand_get_features - wrapper to perform a GET_FEATURE
* @chip: NAND chip info structure
* @addr: feature address
* @subfeature_param: the subfeature parameters, a four bytes array
*
* Returns 0 for success, a negative error otherwise. Returns -ENOTSUPP if the
* operation cannot be handled.
*/
int nand_get_features(struct nand_chip *chip, int addr,
u8 *subfeature_param)
{
if (!nand_supports_get_features(chip, addr))
return -ENOTSUPP;
if (chip->legacy.get_features)
return chip->legacy.get_features(chip, addr, subfeature_param);
return nand_get_features_op(chip, addr, subfeature_param);
}
EXPORT_SYMBOL_GPL(nand_get_features);
/**
* nand_set_features - wrapper to perform a SET_FEATURE
* @chip: NAND chip info structure
* @addr: feature address
* @subfeature_param: the subfeature parameters, a four bytes array
*
* Returns 0 for success, a negative error otherwise. Returns -ENOTSUPP if the
* operation cannot be handled.
*/
int nand_set_features(struct nand_chip *chip, int addr,
u8 *subfeature_param)
{
if (!nand_supports_set_features(chip, addr))
return -ENOTSUPP;
if (chip->legacy.set_features)
return chip->legacy.set_features(chip, addr, subfeature_param);
return nand_set_features_op(chip, addr, subfeature_param);
}
EXPORT_SYMBOL_GPL(nand_set_features);
/** /**
* nand_check_erased_buf - check if a buffer contains (almost) only 0xff data * nand_check_erased_buf - check if a buffer contains (almost) only 0xff data
* @buf: buffer to test * @buf: buffer to test
...@@ -4864,30 +4870,6 @@ static int nand_max_bad_blocks(struct mtd_info *mtd, loff_t ofs, size_t len) ...@@ -4864,30 +4870,6 @@ static int nand_max_bad_blocks(struct mtd_info *mtd, loff_t ofs, size_t len)
return chip->max_bb_per_die * (part_end_die - part_start_die + 1); return chip->max_bb_per_die * (part_end_die - part_start_die + 1);
} }
/**
* nand_default_set_features- [REPLACEABLE] set NAND chip features
* @chip: nand chip info structure
* @addr: feature address.
* @subfeature_param: the subfeature parameters, a four bytes array.
*/
static int nand_default_set_features(struct nand_chip *chip, int addr,
uint8_t *subfeature_param)
{
return nand_set_features_op(chip, addr, subfeature_param);
}
/**
* nand_default_get_features- [REPLACEABLE] get NAND chip features
* @chip: nand chip info structure
* @addr: feature address.
* @subfeature_param: the subfeature parameters, a four bytes array.
*/
static int nand_default_get_features(struct nand_chip *chip, int addr,
uint8_t *subfeature_param)
{
return nand_get_features_op(chip, addr, subfeature_param);
}
/** /**
* nand_get_set_features_notsupp - set/get features stub returning -ENOTSUPP * nand_get_set_features_notsupp - set/get features stub returning -ENOTSUPP
* @chip: nand chip info structure * @chip: nand chip info structure
...@@ -4958,12 +4940,6 @@ static void nand_set_defaults(struct nand_chip *chip) ...@@ -4958,12 +4940,6 @@ static void nand_set_defaults(struct nand_chip *chip)
if (!chip->select_chip) if (!chip->select_chip)
chip->select_chip = nand_select_chip; chip->select_chip = nand_select_chip;
/* set for ONFI nand */
if (!chip->set_features)
chip->set_features = nand_default_set_features;
if (!chip->get_features)
chip->get_features = nand_default_get_features;
/* If called twice, pointers that depend on busw may need to be reset */ /* If called twice, pointers that depend on busw may need to be reset */
if (!chip->legacy.read_byte || chip->legacy.read_byte == nand_read_byte) if (!chip->legacy.read_byte || chip->legacy.read_byte == nand_read_byte)
chip->legacy.read_byte = busw ? nand_read_byte16 : nand_read_byte; chip->legacy.read_byte = busw ? nand_read_byte16 : nand_read_byte;
......
...@@ -2808,8 +2808,8 @@ static int qcom_nand_host_init_and_register(struct qcom_nand_controller *nandc, ...@@ -2808,8 +2808,8 @@ static int qcom_nand_host_init_and_register(struct qcom_nand_controller *nandc,
chip->legacy.read_byte = qcom_nandc_read_byte; chip->legacy.read_byte = qcom_nandc_read_byte;
chip->legacy.read_buf = qcom_nandc_read_buf; chip->legacy.read_buf = qcom_nandc_read_buf;
chip->legacy.write_buf = qcom_nandc_write_buf; chip->legacy.write_buf = qcom_nandc_write_buf;
chip->set_features = nand_get_set_features_notsupp; chip->legacy.set_features = nand_get_set_features_notsupp;
chip->get_features = nand_get_set_features_notsupp; chip->legacy.get_features = nand_get_set_features_notsupp;
/* /*
* the bad block marker is readable only when we read the last codeword * the bad block marker is readable only when we read the last codeword
......
...@@ -1185,8 +1185,8 @@ static int flctl_probe(struct platform_device *pdev) ...@@ -1185,8 +1185,8 @@ static int flctl_probe(struct platform_device *pdev)
nand->legacy.read_buf = flctl_read_buf; nand->legacy.read_buf = flctl_read_buf;
nand->select_chip = flctl_select_chip; nand->select_chip = flctl_select_chip;
nand->legacy.cmdfunc = flctl_cmdfunc; nand->legacy.cmdfunc = flctl_cmdfunc;
nand->set_features = nand_get_set_features_notsupp; nand->legacy.set_features = nand_get_set_features_notsupp;
nand->get_features = nand_get_set_features_notsupp; nand->legacy.get_features = nand_get_set_features_notsupp;
if (pdata->flcmncr_val & SEL_16BIT) if (pdata->flcmncr_val & SEL_16BIT)
nand->options |= NAND_BUSWIDTH_16; nand->options |= NAND_BUSWIDTH_16;
......
...@@ -922,8 +922,8 @@ static int spinand_probe(struct spi_device *spi_nand) ...@@ -922,8 +922,8 @@ static int spinand_probe(struct spi_device *spi_nand)
chip->legacy.waitfunc = spinand_wait; chip->legacy.waitfunc = spinand_wait;
chip->options |= NAND_CACHEPRG; chip->options |= NAND_CACHEPRG;
chip->select_chip = spinand_select_chip; chip->select_chip = spinand_select_chip;
chip->set_features = nand_get_set_features_notsupp; chip->legacy.set_features = nand_get_set_features_notsupp;
chip->get_features = nand_get_set_features_notsupp; chip->legacy.get_features = nand_get_set_features_notsupp;
mtd = nand_to_mtd(chip); mtd = nand_to_mtd(chip);
......
...@@ -1190,6 +1190,8 @@ int nand_op_parser_exec_op(struct nand_chip *chip, ...@@ -1190,6 +1190,8 @@ int nand_op_parser_exec_op(struct nand_chip *chip,
* @block_bad: check if a block is bad, using OOB markers * @block_bad: check if a block is bad, using OOB markers
* @block_markbad: mark a block bad * @block_markbad: mark a block bad
* @erase: erase function * @erase: erase function
* @set_features: set the NAND chip features
* @get_features: get the NAND chip features
* *
* If you look at this structure you're already wrong. These fields/hooks are * If you look at this structure you're already wrong. These fields/hooks are
* all deprecated. * all deprecated.
...@@ -1209,6 +1211,10 @@ struct nand_legacy { ...@@ -1209,6 +1211,10 @@ struct nand_legacy {
int (*block_bad)(struct nand_chip *chip, loff_t ofs); int (*block_bad)(struct nand_chip *chip, loff_t ofs);
int (*block_markbad)(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 (*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,
u8 *subfeature_para);
}; };
/** /**
...@@ -1279,8 +1285,6 @@ struct nand_legacy { ...@@ -1279,8 +1285,6 @@ struct nand_legacy {
* @blocks_per_die: [INTERN] The number of PEBs in a die * @blocks_per_die: [INTERN] The number of PEBs in a die
* @data_interface: [INTERN] NAND interface timing information * @data_interface: [INTERN] NAND interface timing information
* @read_retries: [INTERN] the number of read retry modes supported * @read_retries: [INTERN] the number of read retry modes supported
* @set_features: [REPLACEABLE] set the NAND chip features
* @get_features: [REPLACEABLE] get the NAND chip features
* @setup_data_interface: [OPTIONAL] setup the data interface and timing. If * @setup_data_interface: [OPTIONAL] setup the data interface and timing. If
* chipnr is set to %NAND_DATA_IFACE_CHECK_ONLY this * chipnr is set to %NAND_DATA_IFACE_CHECK_ONLY this
* means the configuration should not be applied but * means the configuration should not be applied but
...@@ -1309,10 +1313,6 @@ struct nand_chip { ...@@ -1309,10 +1313,6 @@ struct nand_chip {
int (*exec_op)(struct nand_chip *chip, int (*exec_op)(struct nand_chip *chip,
const struct nand_operation *op, const struct nand_operation *op,
bool check_only); bool check_only);
int (*set_features)(struct nand_chip *chip, int feature_addr,
uint8_t *subfeature_para);
int (*get_features)(struct nand_chip *chip, int feature_addr,
uint8_t *subfeature_para);
int (*setup_read_retry)(struct nand_chip *chip, int retry_mode); int (*setup_read_retry)(struct nand_chip *chip, int retry_mode);
int (*setup_data_interface)(struct nand_chip *chip, int chipnr, int (*setup_data_interface)(struct nand_chip *chip, int chipnr,
const struct nand_data_interface *conf); const struct nand_data_interface *conf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment