mtd: rawnand: Pass a nand_chip object to nand_scan()

Let's make the raw NAND API consistent by patching all helpers to take
a nand_chip object instead of an mtd_info one.

We start with nand_scan().

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:
Boris Brezillon 2018-09-06 14:05:14 +02:00 committed by Miquel Raynal
parent 47bd59e538
commit 00ad378f30
52 changed files with 64 additions and 64 deletions

View File

@ -246,7 +246,7 @@ necessary information about the device.
this->eccmode = NAND_ECC_SOFT;
/* Scan to find existence of the device */
if (nand_scan (board_mtd, 1)) {
if (nand_scan (this, 1)) {
err = -ENXIO;
goto out_ior;
}

View File

@ -235,7 +235,7 @@ static int ams_delta_init(struct platform_device *pdev)
goto out_gpio;
/* Scan to find existence of the device */
err = nand_scan(ams_delta_mtd, 1);
err = nand_scan(this, 1);
if (err)
goto out_mtd;

View File

@ -1683,7 +1683,7 @@ atmel_nand_controller_add_nand(struct atmel_nand_controller *nc,
nc->caps->ops->nand_init(nc, nand);
ret = nand_scan(mtd, nand->numcs);
ret = nand_scan(chip, nand->numcs);
if (ret) {
dev_err(nc->dev, "NAND scan failed: %d\n", ret);
return ret;

View File

@ -451,7 +451,7 @@ static int au1550nd_probe(struct platform_device *pdev)
this->write_buf = (pd->devwidth) ? au_write_buf16 : au_write_buf;
this->read_buf = (pd->devwidth) ? au_read_buf16 : au_read_buf;
ret = nand_scan(mtd, 1);
ret = nand_scan(this, 1);
if (ret) {
dev_err(&pdev->dev, "NAND scan failed with %d\n", ret);
goto out3;

View File

@ -423,7 +423,7 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n)
(w4 << 24 | w3 << 18 | w2 << 12 | w1 << 6 | w0));
/* Scan NAND */
err = nand_scan(nand_to_mtd(&b47n->nand_chip), 1);
err = nand_scan(&b47n->nand_chip, 1);
if (err) {
pr_err("Could not scan NAND flash: %d\n", err);
goto exit;

View File

@ -2301,7 +2301,7 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)
nand_writereg(ctrl, cfg_offs,
nand_readreg(ctrl, cfg_offs) & ~CFG_BUS_WIDTH);
ret = nand_scan(mtd, 1);
ret = nand_scan(chip, 1);
if (ret)
return ret;

View File

@ -783,7 +783,7 @@ static int cafe_nand_probe(struct pci_dev *pdev,
/* Scan to find existence of the device */
cafe->nand.dummy_controller.ops = &cafe_nand_controller_ops;
err = nand_scan(mtd, 2);
err = nand_scan(&cafe->nand, 2);
if (err)
goto out_irq;

View File

@ -193,7 +193,7 @@ static int __init cmx270_init(void)
this->write_buf = cmx270_write_buf;
/* Scan to find existence of the device */
ret = nand_scan(cmx270_nand_mtd, 1);
ret = nand_scan(this, 1);
if (ret) {
pr_notice("No NAND device\n");
goto err_scan;

View File

@ -241,7 +241,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
}
/* Scan to find existence of the device */
err = nand_scan(new_mtd, 1);
err = nand_scan(this, 1);
if (err)
goto out_free;

View File

@ -807,7 +807,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
/* Scan to find existence of the device(s) */
info->chip.dummy_controller.ops = &davinci_nand_controller_ops;
ret = nand_scan(mtd, pdata->mask_chipsel ? 2 : 1);
ret = nand_scan(&info->chip, pdata->mask_chipsel ? 2 : 1);
if (ret < 0) {
dev_dbg(&pdev->dev, "no NAND chip(s) found\n");
return ret;

View File

@ -1355,7 +1355,7 @@ int denali_init(struct denali_nand_info *denali)
chip->setup_data_interface = denali_setup_data_interface;
chip->dummy_controller.ops = &denali_controller_ops;
ret = nand_scan(mtd, denali->max_banks);
ret = nand_scan(chip, denali->max_banks);
if (ret)
goto disable_irq;

View File

@ -1620,7 +1620,7 @@ static int __init doc_probe(unsigned long physadr)
else
numchips = doc2001_init(mtd);
if ((ret = nand_scan(mtd, numchips)) || (ret = doc->late_init(mtd))) {
if ((ret = nand_scan(nand, numchips)) || (ret = doc->late_init(mtd))) {
/* DBB note: i believe nand_release is necessary here, as
buffers may have been allocated in nand_base. Check with
Thomas. FIX ME! */

View File

@ -1391,7 +1391,7 @@ static int __init probe_docg4(struct platform_device *pdev)
* ->attach_chip callback.
*/
nand->dummy_controller.ops = &docg4_controller_ops;
retval = nand_scan(mtd, 0);
retval = nand_scan(nand, 0);
if (retval)
goto free_nand;

View File

@ -915,7 +915,7 @@ static int fsl_elbc_nand_probe(struct platform_device *pdev)
goto err;
priv->chip.controller->ops = &fsl_elbc_controller_ops;
ret = nand_scan(mtd, 1);
ret = nand_scan(&priv->chip, 1);
if (ret)
goto err;

View File

@ -1079,7 +1079,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
goto err;
priv->chip.controller->ops = &fsl_ifc_controller_ops;
ret = nand_scan(mtd, 1);
ret = nand_scan(&priv->chip, 1);
if (ret)
goto err;

View File

@ -191,7 +191,7 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
goto err;
}
ret = nand_scan(mtd, fun->mchip_count);
ret = nand_scan(&fun->chip, fun->mchip_count);
if (ret)
goto err;

View File

@ -1125,7 +1125,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
* Scan to find existence of the device
*/
nand->dummy_controller.ops = &fsmc_nand_controller_ops;
ret = nand_scan(mtd, 1);
ret = nand_scan(nand, 1);
if (ret)
goto release_dma_write_chan;

View File

@ -289,7 +289,7 @@ static int gpio_nand_probe(struct platform_device *pdev)
if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp))
gpiod_direction_output(gpiomtd->nwp, 1);
ret = nand_scan(mtd, 1);
ret = nand_scan(chip, 1);
if (ret)
goto err_wp;

View File

@ -1934,7 +1934,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
goto err_out;
chip->dummy_controller.ops = &gpmi_nand_controller_ops;
ret = nand_scan(mtd, GPMI_IS_MX6(this) ? 2 : 1);
ret = nand_scan(chip, GPMI_IS_MX6(this) ? 2 : 1);
if (ret)
goto err_out;

View File

@ -801,7 +801,7 @@ static int hisi_nfc_probe(struct platform_device *pdev)
}
chip->dummy_controller.ops = &hisi_nfc_controller_ops;
ret = nand_scan(mtd, max_chips);
ret = nand_scan(chip, max_chips);
if (ret)
return ret;

View File

@ -331,7 +331,7 @@ static int jz_nand_detect_bank(struct platform_device *pdev,
if (chipnr == 0) {
/* Detect first chip. */
ret = nand_scan(mtd, 1);
ret = nand_scan(chip, 1);
if (ret)
goto notfound_id;

View File

@ -286,7 +286,7 @@ static int jz4780_nand_init_chip(struct platform_device *pdev,
nand_set_flash_node(chip, np);
chip->controller->ops = &jz4780_nand_controller_ops;
ret = nand_scan(mtd, 1);
ret = nand_scan(chip, 1);
if (ret)
return ret;

View File

@ -802,7 +802,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
* SMALL block or LARGE block.
*/
nand_chip->dummy_controller.ops = &lpc32xx_nand_controller_ops;
res = nand_scan(mtd, 1);
res = nand_scan(nand_chip, 1);
if (res)
goto free_irq;

View File

@ -925,7 +925,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
/* Find NAND device */
chip->dummy_controller.ops = &lpc32xx_nand_controller_ops;
res = nand_scan(mtd, 1);
res = nand_scan(chip, 1);
if (res)
goto release_dma;

View File

@ -2605,7 +2605,7 @@ static int marvell_nand_chip_init(struct device *dev, struct marvell_nfc *nfc,
chip->options |= NAND_BUSWIDTH_AUTO;
ret = nand_scan(mtd, marvell_nand->nsels);
ret = nand_scan(chip, marvell_nand->nsels);
if (ret) {
dev_err(dev, "could not scan the nand chip\n");
return ret;

View File

@ -767,7 +767,7 @@ static int mpc5121_nfc_probe(struct platform_device *op)
}
/* Detect NAND chips */
retval = nand_scan(mtd, be32_to_cpup(chips_no));
retval = nand_scan(chip, be32_to_cpup(chips_no));
if (retval) {
dev_err(dev, "NAND Flash not found !\n");
goto error;

View File

@ -1365,7 +1365,7 @@ static int mtk_nfc_nand_chip_init(struct device *dev, struct mtk_nfc *nfc,
mtk_nfc_hw_init(nfc);
ret = nand_scan(mtd, nsels);
ret = nand_scan(nand, nsels);
if (ret)
return ret;

View File

@ -1887,7 +1887,7 @@ static int mxcnd_probe(struct platform_device *pdev)
/* Scan the NAND device */
this->dummy_controller.ops = &mxcnd_controller_ops;
err = nand_scan(mtd, is_imx25_nfc(host) ? 4 : 1);
err = nand_scan(this, is_imx25_nfc(host) ? 4 : 1);
if (err)
goto escan;

View File

@ -5960,7 +5960,7 @@ static int nand_dt_init(struct nand_chip *chip)
/**
* nand_scan_ident - Scan for the NAND device
* @mtd: MTD device structure
* @chip: NAND chip object
* @maxchips: number of chips to scan for
* @table: alternative NAND ID table
*
@ -5972,11 +5972,11 @@ static int nand_dt_init(struct nand_chip *chip)
* prevented dynamic allocations during this phase which was unconvenient and
* as been banned for the benefit of the ->init_ecc()/cleanup_ecc() hooks.
*/
static int nand_scan_ident(struct mtd_info *mtd, int maxchips,
static int nand_scan_ident(struct nand_chip *chip, int maxchips,
struct nand_flash_dev *table)
{
struct mtd_info *mtd = nand_to_mtd(chip);
int i, nand_maf_id, nand_dev_id;
struct nand_chip *chip = mtd_to_nand(mtd);
int ret;
/* Enforce the right timings for reset/detection */
@ -6430,15 +6430,15 @@ static bool nand_ecc_strength_good(struct mtd_info *mtd)
/**
* nand_scan_tail - Scan for the NAND device
* @mtd: MTD device structure
* @chip: NAND chip object
*
* This is the second phase of the normal nand_scan() function. It fills out
* all the uninitialized function pointers with the defaults and scans for a
* bad block table if appropriate.
*/
static int nand_scan_tail(struct mtd_info *mtd)
static int nand_scan_tail(struct nand_chip *chip)
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct mtd_info *mtd = nand_to_mtd(chip);
struct nand_ecc_ctrl *ecc = &chip->ecc;
int ret, i;
@ -6777,7 +6777,7 @@ static void nand_detach(struct nand_chip *chip)
/**
* nand_scan_with_ids - [NAND Interface] Scan for the NAND device
* @mtd: MTD device structure
* @chip: NAND chip object
* @maxchips: number of chips to scan for. @nand_scan_ident() will not be run if
* this parameter is zero (useful for specific drivers that must
* handle this part of the process themselves, e.g docg4).
@ -6787,14 +6787,13 @@ static void nand_detach(struct nand_chip *chip)
* The flash ID is read and the mtd/chip structures are filled with the
* appropriate values.
*/
int nand_scan_with_ids(struct mtd_info *mtd, int maxchips,
int nand_scan_with_ids(struct nand_chip *chip, int maxchips,
struct nand_flash_dev *ids)
{
struct nand_chip *chip = mtd_to_nand(mtd);
int ret;
if (maxchips) {
ret = nand_scan_ident(mtd, maxchips, ids);
ret = nand_scan_ident(chip, maxchips, ids);
if (ret)
return ret;
}
@ -6803,7 +6802,7 @@ int nand_scan_with_ids(struct mtd_info *mtd, int maxchips,
if (ret)
goto cleanup_ident;
ret = nand_scan_tail(mtd);
ret = nand_scan_tail(chip);
if (ret)
goto detach_chip;

View File

@ -2309,7 +2309,7 @@ static int __init ns_init_module(void)
goto error;
chip->dummy_controller.ops = &ns_controller_ops;
retval = nand_scan(nsmtd, 1);
retval = nand_scan(chip, 1);
if (retval) {
NS_ERR("Could not scan NAND Simulator device\n");
goto error;

View File

@ -181,7 +181,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
goto err;
}
ret = nand_scan(mtd, 1);
ret = nand_scan(chip, 1);
if (ret)
goto err;

View File

@ -270,7 +270,7 @@ static int nuc900_nand_probe(struct platform_device *pdev)
nuc900_nand_enable(nuc900_nand);
if (nand_scan(mtd, 1))
if (nand_scan(chip, 1))
return -ENXIO;
mtd_device_register(mtd, partitions, ARRAY_SIZE(partitions));

View File

@ -2254,7 +2254,7 @@ static int omap_nand_probe(struct platform_device *pdev)
/* scan NAND device connected to chip controller */
nand_chip->options |= info->devsize & NAND_BUSWIDTH_16;
err = nand_scan(mtd, 1);
err = nand_scan(nand_chip, 1);
if (err)
goto return_error;

View File

@ -174,7 +174,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
return ret;
}
ret = nand_scan(mtd, 1);
ret = nand_scan(nc, 1);
if (ret)
goto no_dev;

View File

@ -142,7 +142,7 @@ static int oxnas_nand_probe(struct platform_device *pdev)
chip->chip_delay = 30;
/* Scan to find existence of the device */
err = nand_scan(mtd, 1);
err = nand_scan(chip, 1);
if (err)
goto err_clk_unprepare;

View File

@ -156,7 +156,7 @@ static int pasemi_nand_probe(struct platform_device *ofdev)
chip->bbt_options = NAND_BBT_USE_FLASH;
/* Scan to find existence of the device */
err = nand_scan(pasemi_nand_mtd, 1);
err = nand_scan(chip, 1);
if (err)
goto out_lpc;

View File

@ -131,7 +131,7 @@ static int plat_nand_probe(struct platform_device *pdev)
}
/* Scan to find existence of the device */
err = nand_scan(mtd, pdata->chip.nr_chips);
err = nand_scan(&data->chip, pdata->chip.nr_chips);
if (err)
goto out;

View File

@ -2834,7 +2834,7 @@ static int qcom_nand_host_init_and_register(struct qcom_nand_controller *nandc,
/* set up initial status value */
host->status = NAND_STATUS_READY | NAND_STATUS_WP;
ret = nand_scan(mtd, 1);
ret = nand_scan(chip, 1);
if (ret)
return ret;

View File

@ -1170,7 +1170,7 @@ static int s3c24xx_nand_probe(struct platform_device *pdev)
mtd->dev.parent = &pdev->dev;
s3c2410_nand_init_chip(info, nmtd, sets);
err = nand_scan(mtd, sets ? sets->nr_chips : 1);
err = nand_scan(&nmtd->chip, sets ? sets->nr_chips : 1);
if (err)
goto exit_error;

View File

@ -1193,7 +1193,7 @@ static int flctl_probe(struct platform_device *pdev)
flctl_setup_dma(flctl);
nand->dummy_controller.ops = &flctl_nand_controller_ops;
ret = nand_scan(flctl_mtd, 1);
ret = nand_scan(nand, 1);
if (ret)
goto err_chip;

View File

@ -171,7 +171,7 @@ static int sharpsl_nand_probe(struct platform_device *pdev)
this->ecc.correct = nand_correct_data;
/* Scan to find existence of the device */
err = nand_scan(mtd, 1);
err = nand_scan(this, 1);
if (err)
goto err_scan;

View File

@ -195,7 +195,7 @@ int sm_register_device(struct mtd_info *mtd, int smartmedia)
/* Scan for card properties */
chip->dummy_controller.ops = &sm_controller_ops;
flash_ids = smartmedia ? nand_smartmedia_flash_ids : nand_xd_flash_ids;
ret = nand_scan_with_ids(mtd, 1, flash_ids);
ret = nand_scan_with_ids(chip, 1, flash_ids);
if (ret)
return ret;

View File

@ -173,7 +173,7 @@ static int socrates_nand_probe(struct platform_device *ofdev)
dev_set_drvdata(&ofdev->dev, host);
res = nand_scan(mtd, 1);
res = nand_scan(nand_chip, 1);
if (res)
goto out;

View File

@ -1940,7 +1940,7 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
mtd = nand_to_mtd(nand);
mtd->dev.parent = dev;
ret = nand_scan(mtd, nsels);
ret = nand_scan(nand, nsels);
if (ret)
return ret;

View File

@ -588,7 +588,7 @@ static int chip_init(struct device *dev, struct device_node *np)
mtd_set_ooblayout(mtd, &tango_nand_ooblayout_ops);
mtd->dev.parent = dev;
err = nand_scan(mtd, 1);
err = nand_scan(chip, 1);
if (err)
return err;

View File

@ -1119,7 +1119,7 @@ static int tegra_nand_chips_init(struct device *dev,
chip->select_chip = tegra_nand_select_chip;
chip->setup_data_interface = tegra_nand_setup_data_interface;
ret = nand_scan(mtd, 1);
ret = nand_scan(chip, 1);
if (ret)
return ret;

View File

@ -436,7 +436,7 @@ static int tmio_probe(struct platform_device *dev)
nand_chip->waitfunc = tmio_nand_wait;
/* Scan to find existence of the device */
retval = nand_scan(mtd, 1);
retval = nand_scan(nand_chip, 1);
if (retval)
goto err_irq;

View File

@ -359,7 +359,7 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)
if (plat->wide_mask & (1 << i))
chip->options |= NAND_BUSWIDTH_16;
if (nand_scan(mtd, 1)) {
if (nand_scan(chip, 1)) {
kfree(txx9_priv->mtdname);
kfree(txx9_priv);
continue;

View File

@ -892,7 +892,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
/* Scan the NAND chip */
chip->dummy_controller.ops = &vf610_nfc_controller_ops;
err = nand_scan(mtd, 1);
err = nand_scan(chip, 1);
if (err)
goto err_disable_clk;

View File

@ -205,7 +205,7 @@ static int xway_nand_probe(struct platform_device *pdev)
| cs_flag, EBU_NAND_CON);
/* Scan to find existence of the device */
err = nand_scan(mtd, 1);
err = nand_scan(&data->chip, 1);
if (err)
return err;

View File

@ -934,7 +934,7 @@ static int spinand_probe(struct spi_device *spi_nand)
mtd_set_ooblayout(mtd, &spinand_oob_64_ops);
#endif
if (nand_scan(mtd, 1))
if (nand_scan(chip, 1))
return -ENXIO;
return mtd_device_register(mtd, NULL, 0);

View File

@ -24,15 +24,16 @@
#include <linux/of.h>
#include <linux/types.h>
struct nand_chip;
struct nand_flash_dev;
/* Scan and identify a NAND device */
int nand_scan_with_ids(struct mtd_info *mtd, int max_chips,
int nand_scan_with_ids(struct nand_chip *chip, int max_chips,
struct nand_flash_dev *ids);
static inline int nand_scan(struct mtd_info *mtd, int max_chips)
static inline int nand_scan(struct nand_chip *chip, int max_chips)
{
return nand_scan_with_ids(mtd, max_chips, NULL);
return nand_scan_with_ids(chip, max_chips, NULL);
}
/* Internal helper for board drivers which need to override command function */