提交 a61ae81a 编写于 作者: B Brian Norris

mtd: nand: drop unnecessary partition parser data

All of these drivers set up a parser data struct just to communicate DT
partition data. This field has been deprecated and is instead supported
by telling nand_scan_ident() about the 'flash_node'.

This patch:
 * sets chip->flash_node for those drivers that didn't already (but used
   OF partitioning)
 * drops the parser data
 * switches to the simpler mtd_device_register() where possible, now
   that we've eliminated one of the auxiliary parameters

Now that we've assigned chip->flash_node for these drivers, we can
probably rely on nand_dt_init() to do more of the DT parsing for us, but
for now, I don't want to fiddle with each of these drivers. The parsing
is done in duplicate for now on some drivers. I don't think this should
break things. (Famous last words.)

(Rolled in some changes by Boris Brezillon)
Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
Reviewed-by: NBoris Brezillon <boris.brezillon@free-electrons.com>
上级 9c7d7875
...@@ -2093,7 +2093,6 @@ static int atmel_nand_probe(struct platform_device *pdev) ...@@ -2093,7 +2093,6 @@ static int atmel_nand_probe(struct platform_device *pdev)
struct mtd_info *mtd; struct mtd_info *mtd;
struct nand_chip *nand_chip; struct nand_chip *nand_chip;
struct resource *mem; struct resource *mem;
struct mtd_part_parser_data ppdata = {};
int res, irq; int res, irq;
/* Allocate memory for the device structure (and zero it) */ /* Allocate memory for the device structure (and zero it) */
...@@ -2117,6 +2116,7 @@ static int atmel_nand_probe(struct platform_device *pdev) ...@@ -2117,6 +2116,7 @@ static int atmel_nand_probe(struct platform_device *pdev)
nand_chip = &host->nand_chip; nand_chip = &host->nand_chip;
host->dev = &pdev->dev; host->dev = &pdev->dev;
if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) { if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
nand_set_flash_node(nand_chip, pdev->dev.of_node);
/* Only when CONFIG_OF is enabled of_node can be parsed */ /* Only when CONFIG_OF is enabled of_node can be parsed */
res = atmel_of_init_port(host, pdev->dev.of_node); res = atmel_of_init_port(host, pdev->dev.of_node);
if (res) if (res)
...@@ -2259,9 +2259,8 @@ static int atmel_nand_probe(struct platform_device *pdev) ...@@ -2259,9 +2259,8 @@ static int atmel_nand_probe(struct platform_device *pdev)
} }
mtd->name = "atmel_nand"; mtd->name = "atmel_nand";
ppdata.of_node = pdev->dev.of_node; res = mtd_device_register(mtd, host->board.parts,
res = mtd_device_parse_register(mtd, NULL, &ppdata, host->board.num_parts);
host->board.parts, host->board.num_parts);
if (!res) if (!res)
return res; return res;
......
...@@ -1914,7 +1914,6 @@ static int brcmnand_init_cs(struct brcmnand_host *host) ...@@ -1914,7 +1914,6 @@ static int brcmnand_init_cs(struct brcmnand_host *host)
struct nand_chip *chip; struct nand_chip *chip;
int ret; int ret;
u16 cfg_offs; u16 cfg_offs;
struct mtd_part_parser_data ppdata = { .of_node = dn };
ret = of_property_read_u32(dn, "reg", &host->cs); ret = of_property_read_u32(dn, "reg", &host->cs);
if (ret) { if (ret) {
...@@ -1993,7 +1992,7 @@ static int brcmnand_init_cs(struct brcmnand_host *host) ...@@ -1993,7 +1992,7 @@ static int brcmnand_init_cs(struct brcmnand_host *host)
if (nand_scan_tail(mtd)) if (nand_scan_tail(mtd))
return -ENXIO; return -ENXIO;
return mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); return mtd_device_register(mtd, NULL, 0);
} }
static void brcmnand_save_restore_cs_config(struct brcmnand_host *host, static void brcmnand_save_restore_cs_config(struct brcmnand_host *host,
......
...@@ -684,6 +684,7 @@ static int nand_davinci_probe(struct platform_device *pdev) ...@@ -684,6 +684,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
info->mtd.priv = &info->chip; info->mtd.priv = &info->chip;
info->mtd.dev.parent = &pdev->dev; info->mtd.dev.parent = &pdev->dev;
nand_set_flash_node(&info->chip, pdev->dev.of_node);
info->chip.IO_ADDR_R = vaddr; info->chip.IO_ADDR_R = vaddr;
info->chip.IO_ADDR_W = vaddr; info->chip.IO_ADDR_W = vaddr;
...@@ -839,13 +840,8 @@ static int nand_davinci_probe(struct platform_device *pdev) ...@@ -839,13 +840,8 @@ static int nand_davinci_probe(struct platform_device *pdev)
if (pdata->parts) if (pdata->parts)
ret = mtd_device_parse_register(&info->mtd, NULL, NULL, ret = mtd_device_parse_register(&info->mtd, NULL, NULL,
pdata->parts, pdata->nr_parts); pdata->parts, pdata->nr_parts);
else { else
struct mtd_part_parser_data ppdata; ret = mtd_device_register(&info->mtd, NULL, 0);
ppdata.of_node = pdev->dev.of_node;
ret = mtd_device_parse_register(&info->mtd, NULL, &ppdata,
NULL, 0);
}
if (ret < 0) if (ret < 0)
goto err; goto err;
......
...@@ -748,6 +748,7 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv) ...@@ -748,6 +748,7 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
/* Fill in fsl_elbc_mtd structure */ /* Fill in fsl_elbc_mtd structure */
priv->mtd.priv = chip; priv->mtd.priv = chip;
priv->mtd.dev.parent = priv->dev; priv->mtd.dev.parent = priv->dev;
nand_set_flash_node(chip, priv->dev->of_node);
/* set timeout to maximum */ /* set timeout to maximum */
priv->fmr = 15 << FMR_CWTO_SHIFT; priv->fmr = 15 << FMR_CWTO_SHIFT;
...@@ -823,9 +824,7 @@ static int fsl_elbc_nand_probe(struct platform_device *pdev) ...@@ -823,9 +824,7 @@ static int fsl_elbc_nand_probe(struct platform_device *pdev)
int bank; int bank;
struct device *dev; struct device *dev;
struct device_node *node = pdev->dev.of_node; struct device_node *node = pdev->dev.of_node;
struct mtd_part_parser_data ppdata;
ppdata.of_node = pdev->dev.of_node;
if (!fsl_lbc_ctrl_dev || !fsl_lbc_ctrl_dev->regs) if (!fsl_lbc_ctrl_dev || !fsl_lbc_ctrl_dev->regs)
return -ENODEV; return -ENODEV;
lbc = fsl_lbc_ctrl_dev->regs; lbc = fsl_lbc_ctrl_dev->regs;
...@@ -911,7 +910,7 @@ static int fsl_elbc_nand_probe(struct platform_device *pdev) ...@@ -911,7 +910,7 @@ static int fsl_elbc_nand_probe(struct platform_device *pdev)
/* First look for RedBoot table or partitions on the command /* First look for RedBoot table or partitions on the command
* line, these take precedence over device tree information */ * line, these take precedence over device tree information */
mtd_device_parse_register(&priv->mtd, part_probe_types, &ppdata, mtd_device_parse_register(&priv->mtd, part_probe_types, NULL,
NULL, 0); NULL, 0);
printk(KERN_INFO "eLBC NAND device at 0x%llx, bank %d\n", printk(KERN_INFO "eLBC NAND device at 0x%llx, bank %d\n",
......
...@@ -883,6 +883,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) ...@@ -883,6 +883,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
/* Fill in fsl_ifc_mtd structure */ /* Fill in fsl_ifc_mtd structure */
priv->mtd.priv = chip; priv->mtd.priv = chip;
priv->mtd.dev.parent = priv->dev; priv->mtd.dev.parent = priv->dev;
nand_set_flash_node(chip, priv->dev->of_node);
/* fill in nand_chip structure */ /* fill in nand_chip structure */
/* set up function call table */ /* set up function call table */
...@@ -1030,9 +1031,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev) ...@@ -1030,9 +1031,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
int ret; int ret;
int bank; int bank;
struct device_node *node = dev->dev.of_node; struct device_node *node = dev->dev.of_node;
struct mtd_part_parser_data ppdata;
ppdata.of_node = dev->dev.of_node;
if (!fsl_ifc_ctrl_dev || !fsl_ifc_ctrl_dev->regs) if (!fsl_ifc_ctrl_dev || !fsl_ifc_ctrl_dev->regs)
return -ENODEV; return -ENODEV;
ifc = fsl_ifc_ctrl_dev->regs; ifc = fsl_ifc_ctrl_dev->regs;
...@@ -1128,7 +1127,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev) ...@@ -1128,7 +1127,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
/* First look for RedBoot table or partitions on the command /* First look for RedBoot table or partitions on the command
* line, these take precedence over device tree information */ * line, these take precedence over device tree information */
mtd_device_parse_register(&priv->mtd, part_probe_types, &ppdata, mtd_device_parse_register(&priv->mtd, part_probe_types, NULL,
NULL, 0); NULL, 0);
dev_info(priv->dev, "IFC NAND device at 0x%llx, bank %d\n", dev_info(priv->dev, "IFC NAND device at 0x%llx, bank %d\n",
......
...@@ -159,7 +159,6 @@ static int fun_chip_init(struct fsl_upm_nand *fun, ...@@ -159,7 +159,6 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
{ {
int ret; int ret;
struct device_node *flash_np; struct device_node *flash_np;
struct mtd_part_parser_data ppdata;
fun->chip.IO_ADDR_R = fun->io_base; fun->chip.IO_ADDR_R = fun->io_base;
fun->chip.IO_ADDR_W = fun->io_base; fun->chip.IO_ADDR_W = fun->io_base;
...@@ -182,6 +181,7 @@ static int fun_chip_init(struct fsl_upm_nand *fun, ...@@ -182,6 +181,7 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
if (!flash_np) if (!flash_np)
return -ENODEV; return -ENODEV;
nand_set_flash_node(&fun->chip, flash_np);
fun->mtd.name = kasprintf(GFP_KERNEL, "0x%llx.%s", (u64)io_res->start, fun->mtd.name = kasprintf(GFP_KERNEL, "0x%llx.%s", (u64)io_res->start,
flash_np->name); flash_np->name);
if (!fun->mtd.name) { if (!fun->mtd.name) {
...@@ -193,8 +193,7 @@ static int fun_chip_init(struct fsl_upm_nand *fun, ...@@ -193,8 +193,7 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
if (ret) if (ret)
goto err; goto err;
ppdata.of_node = flash_np; ret = mtd_device_register(&fun->mtd, NULL, 0);
ret = mtd_device_parse_register(&fun->mtd, NULL, &ppdata, NULL, 0);
err: err:
of_node_put(flash_np); of_node_put(flash_np);
if (ret) if (ret)
......
...@@ -926,7 +926,6 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) ...@@ -926,7 +926,6 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
{ {
struct fsmc_nand_platform_data *pdata = dev_get_platdata(&pdev->dev); struct fsmc_nand_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct device_node __maybe_unused *np = pdev->dev.of_node; struct device_node __maybe_unused *np = pdev->dev.of_node;
struct mtd_part_parser_data ppdata = {};
struct fsmc_nand_data *host; struct fsmc_nand_data *host;
struct mtd_info *mtd; struct mtd_info *mtd;
struct nand_chip *nand; struct nand_chip *nand;
...@@ -1016,6 +1015,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) ...@@ -1016,6 +1015,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
nand = &host->nand; nand = &host->nand;
mtd->priv = nand; mtd->priv = nand;
nand->priv = host; nand->priv = host;
nand_set_flash_node(nand, np);
host->mtd.dev.parent = &pdev->dev; host->mtd.dev.parent = &pdev->dev;
nand->IO_ADDR_R = host->data_va; nand->IO_ADDR_R = host->data_va;
...@@ -1175,9 +1175,8 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) ...@@ -1175,9 +1175,8 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
* Check for partition info passed * Check for partition info passed
*/ */
host->mtd.name = "nand"; host->mtd.name = "nand";
ppdata.of_node = np; ret = mtd_device_register(&host->mtd, host->partitions,
ret = mtd_device_parse_register(&host->mtd, NULL, &ppdata, host->nr_partitions);
host->partitions, host->nr_partitions);
if (ret) if (ret)
goto err_probe; goto err_probe;
......
...@@ -209,7 +209,6 @@ static int gpio_nand_probe(struct platform_device *pdev) ...@@ -209,7 +209,6 @@ static int gpio_nand_probe(struct platform_device *pdev)
struct gpiomtd *gpiomtd; struct gpiomtd *gpiomtd;
struct nand_chip *chip; struct nand_chip *chip;
struct resource *res; struct resource *res;
struct mtd_part_parser_data ppdata = {};
int ret = 0; int ret = 0;
if (!pdev->dev.of_node && !dev_get_platdata(&pdev->dev)) if (!pdev->dev.of_node && !dev_get_platdata(&pdev->dev))
...@@ -268,6 +267,7 @@ static int gpio_nand_probe(struct platform_device *pdev) ...@@ -268,6 +267,7 @@ static int gpio_nand_probe(struct platform_device *pdev)
chip->dev_ready = gpio_nand_devready; chip->dev_ready = gpio_nand_devready;
} }
nand_set_flash_node(chip, pdev->dev.of_node);
chip->IO_ADDR_W = chip->IO_ADDR_R; chip->IO_ADDR_W = chip->IO_ADDR_R;
chip->ecc.mode = NAND_ECC_SOFT; chip->ecc.mode = NAND_ECC_SOFT;
chip->options = gpiomtd->plat.options; chip->options = gpiomtd->plat.options;
...@@ -291,10 +291,8 @@ static int gpio_nand_probe(struct platform_device *pdev) ...@@ -291,10 +291,8 @@ static int gpio_nand_probe(struct platform_device *pdev)
gpiomtd->plat.adjust_parts(&gpiomtd->plat, gpiomtd->plat.adjust_parts(&gpiomtd->plat,
gpiomtd->mtd_info.size); gpiomtd->mtd_info.size);
ppdata.of_node = pdev->dev.of_node; ret = mtd_device_register(&gpiomtd->mtd_info, gpiomtd->plat.parts,
ret = mtd_device_parse_register(&gpiomtd->mtd_info, NULL, &ppdata, gpiomtd->plat.num_parts);
gpiomtd->plat.parts,
gpiomtd->plat.num_parts);
if (!ret) if (!ret)
return 0; return 0;
......
...@@ -1888,7 +1888,6 @@ static int gpmi_nand_init(struct gpmi_nand_data *this) ...@@ -1888,7 +1888,6 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
{ {
struct mtd_info *mtd = &this->mtd; struct mtd_info *mtd = &this->mtd;
struct nand_chip *chip = &this->nand; struct nand_chip *chip = &this->nand;
struct mtd_part_parser_data ppdata = {};
int ret; int ret;
/* init current chip */ /* init current chip */
...@@ -1901,6 +1900,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this) ...@@ -1901,6 +1900,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
/* init the nand_chip{}, we don't support a 16-bit NAND Flash bus. */ /* init the nand_chip{}, we don't support a 16-bit NAND Flash bus. */
chip->priv = this; chip->priv = this;
nand_set_flash_node(chip, this->pdev->dev.of_node);
chip->select_chip = gpmi_select_chip; chip->select_chip = gpmi_select_chip;
chip->cmd_ctrl = gpmi_cmd_ctrl; chip->cmd_ctrl = gpmi_cmd_ctrl;
chip->dev_ready = gpmi_dev_ready; chip->dev_ready = gpmi_dev_ready;
...@@ -1954,8 +1954,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this) ...@@ -1954,8 +1954,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
if (ret) if (ret)
goto err_out; goto err_out;
ppdata.of_node = this->pdev->dev.of_node; ret = mtd_device_register(mtd, NULL, 0);
ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
if (ret) if (ret)
goto err_out; goto err_out;
return 0; return 0;
......
...@@ -704,7 +704,6 @@ static int hisi_nfc_probe(struct platform_device *pdev) ...@@ -704,7 +704,6 @@ static int hisi_nfc_probe(struct platform_device *pdev)
struct mtd_info *mtd; struct mtd_info *mtd;
struct resource *res; struct resource *res;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct mtd_part_parser_data ppdata;
host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL);
if (!host) if (!host)
...@@ -742,6 +741,7 @@ static int hisi_nfc_probe(struct platform_device *pdev) ...@@ -742,6 +741,7 @@ static int hisi_nfc_probe(struct platform_device *pdev)
mtd->dev.parent = &pdev->dev; mtd->dev.parent = &pdev->dev;
chip->priv = host; chip->priv = host;
nand_set_flash_node(chip, np);
chip->cmdfunc = hisi_nfc_cmdfunc; chip->cmdfunc = hisi_nfc_cmdfunc;
chip->select_chip = hisi_nfc_select_chip; chip->select_chip = hisi_nfc_select_chip;
chip->read_byte = hisi_nfc_read_byte; chip->read_byte = hisi_nfc_read_byte;
...@@ -805,8 +805,7 @@ static int hisi_nfc_probe(struct platform_device *pdev) ...@@ -805,8 +805,7 @@ static int hisi_nfc_probe(struct platform_device *pdev)
goto err_res; goto err_res;
} }
ppdata.of_node = np; ret = mtd_device_register(mtd, NULL, 0);
ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
if (ret) { if (ret) {
dev_err(dev, "Err MTD partition=%d\n", ret); dev_err(dev, "Err MTD partition=%d\n", ret);
goto err_mtd; goto err_mtd;
......
...@@ -647,7 +647,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) ...@@ -647,7 +647,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
struct nand_chip *nand_chip; struct nand_chip *nand_chip;
struct resource *rc; struct resource *rc;
int res; int res;
struct mtd_part_parser_data ppdata = {};
/* Allocate memory for the device structure (and zero it) */ /* Allocate memory for the device structure (and zero it) */
host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
...@@ -682,6 +681,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) ...@@ -682,6 +681,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
host->pdata = dev_get_platdata(&pdev->dev); host->pdata = dev_get_platdata(&pdev->dev);
nand_chip->priv = host; /* link the private data structures */ nand_chip->priv = host; /* link the private data structures */
nand_set_flash_node(nand_chip, pdev->dev.of_node);
mtd->priv = nand_chip; mtd->priv = nand_chip;
mtd->dev.parent = &pdev->dev; mtd->dev.parent = &pdev->dev;
...@@ -786,9 +786,8 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) ...@@ -786,9 +786,8 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
mtd->name = DRV_NAME; mtd->name = DRV_NAME;
ppdata.of_node = pdev->dev.of_node; res = mtd_device_register(mtd, host->ncfg->parts,
res = mtd_device_parse_register(mtd, NULL, &ppdata, host->ncfg->parts, host->ncfg->num_parts);
host->ncfg->num_parts);
if (!res) if (!res)
return res; return res;
......
...@@ -763,7 +763,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) ...@@ -763,7 +763,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
struct mtd_info *mtd; struct mtd_info *mtd;
struct nand_chip *chip; struct nand_chip *chip;
struct resource *rc; struct resource *rc;
struct mtd_part_parser_data ppdata = {};
int res; int res;
rc = platform_get_resource(pdev, IORESOURCE_MEM, 0); rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
...@@ -803,6 +802,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) ...@@ -803,6 +802,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
mtd = &host->mtd; mtd = &host->mtd;
chip = &host->nand_chip; chip = &host->nand_chip;
chip->priv = host; chip->priv = host;
nand_set_flash_node(chip, pdev->dev.of_node);
mtd->priv = chip; mtd->priv = chip;
mtd->owner = THIS_MODULE; mtd->owner = THIS_MODULE;
mtd->dev.parent = &pdev->dev; mtd->dev.parent = &pdev->dev;
...@@ -908,9 +908,8 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) ...@@ -908,9 +908,8 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
} }
mtd->name = "nxp_lpc3220_slc"; mtd->name = "nxp_lpc3220_slc";
ppdata.of_node = pdev->dev.of_node; res = mtd_device_register(mtd, host->ncfg->parts,
res = mtd_device_parse_register(mtd, NULL, &ppdata, host->ncfg->parts, host->ncfg->num_parts);
host->ncfg->num_parts);
if (!res) if (!res)
return res; return res;
......
...@@ -639,7 +639,6 @@ static int mpc5121_nfc_probe(struct platform_device *op) ...@@ -639,7 +639,6 @@ static int mpc5121_nfc_probe(struct platform_device *op)
int resettime = 0; int resettime = 0;
int retval = 0; int retval = 0;
int rev, len; int rev, len;
struct mtd_part_parser_data ppdata;
/* /*
* Check SoC revision. This driver supports only NFC * Check SoC revision. This driver supports only NFC
...@@ -661,6 +660,7 @@ static int mpc5121_nfc_probe(struct platform_device *op) ...@@ -661,6 +660,7 @@ static int mpc5121_nfc_probe(struct platform_device *op)
mtd->priv = chip; mtd->priv = chip;
mtd->dev.parent = dev; mtd->dev.parent = dev;
chip->priv = prv; chip->priv = prv;
nand_set_flash_node(chip, dn);
prv->dev = dev; prv->dev = dev;
/* Read NFC configuration from Reset Config Word */ /* Read NFC configuration from Reset Config Word */
...@@ -703,7 +703,6 @@ static int mpc5121_nfc_probe(struct platform_device *op) ...@@ -703,7 +703,6 @@ static int mpc5121_nfc_probe(struct platform_device *op)
} }
mtd->name = "MPC5121 NAND"; mtd->name = "MPC5121 NAND";
ppdata.of_node = dn;
chip->dev_ready = mpc5121_nfc_dev_ready; chip->dev_ready = mpc5121_nfc_dev_ready;
chip->cmdfunc = mpc5121_nfc_command; chip->cmdfunc = mpc5121_nfc_command;
chip->read_byte = mpc5121_nfc_read_byte; chip->read_byte = mpc5121_nfc_read_byte;
...@@ -815,7 +814,7 @@ static int mpc5121_nfc_probe(struct platform_device *op) ...@@ -815,7 +814,7 @@ static int mpc5121_nfc_probe(struct platform_device *op)
dev_set_drvdata(dev, mtd); dev_set_drvdata(dev, mtd);
/* Register device in MTD */ /* Register device in MTD */
retval = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); retval = mtd_device_register(mtd, NULL, 0);
if (retval) { if (retval) {
dev_err(dev, "Error adding MTD device!\n"); dev_err(dev, "Error adding MTD device!\n");
goto error; goto error;
......
...@@ -1524,6 +1524,7 @@ static int mxcnd_probe(struct platform_device *pdev) ...@@ -1524,6 +1524,7 @@ static int mxcnd_probe(struct platform_device *pdev)
this->chip_delay = 5; this->chip_delay = 5;
this->priv = host; this->priv = host;
nand_set_flash_node(this, pdev->dev.of_node),
this->dev_ready = mxc_nand_dev_ready; this->dev_ready = mxc_nand_dev_ready;
this->cmdfunc = mxc_nand_command; this->cmdfunc = mxc_nand_command;
this->read_byte = mxc_nand_read_byte; this->read_byte = mxc_nand_read_byte;
...@@ -1683,9 +1684,7 @@ static int mxcnd_probe(struct platform_device *pdev) ...@@ -1683,9 +1684,7 @@ static int mxcnd_probe(struct platform_device *pdev)
/* Register the partitions */ /* Register the partitions */
mtd_device_parse_register(mtd, part_probes, mtd_device_parse_register(mtd, part_probes,
&(struct mtd_part_parser_data){ NULL,
.of_node = pdev->dev.of_node,
},
host->pdata.parts, host->pdata.parts,
host->pdata.nr_parts); host->pdata.nr_parts);
......
...@@ -147,7 +147,6 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc, ...@@ -147,7 +147,6 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
{ {
struct device_node *flash_np; struct device_node *flash_np;
struct nand_chip *chip = &ndfc->chip; struct nand_chip *chip = &ndfc->chip;
struct mtd_part_parser_data ppdata;
int ret; int ret;
chip->IO_ADDR_R = ndfc->ndfcbase + NDFC_DATA; chip->IO_ADDR_R = ndfc->ndfcbase + NDFC_DATA;
...@@ -174,8 +173,8 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc, ...@@ -174,8 +173,8 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
flash_np = of_get_next_child(node, NULL); flash_np = of_get_next_child(node, NULL);
if (!flash_np) if (!flash_np)
return -ENODEV; return -ENODEV;
nand_set_flash_node(chip, flash_np);
ppdata.of_node = flash_np;
ndfc->mtd.name = kasprintf(GFP_KERNEL, "%s.%s", ndfc->mtd.name = kasprintf(GFP_KERNEL, "%s.%s",
dev_name(&ndfc->ofdev->dev), flash_np->name); dev_name(&ndfc->ofdev->dev), flash_np->name);
if (!ndfc->mtd.name) { if (!ndfc->mtd.name) {
...@@ -187,7 +186,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc, ...@@ -187,7 +186,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
if (ret) if (ret)
goto err; goto err;
ret = mtd_device_parse_register(&ndfc->mtd, NULL, &ppdata, NULL, 0); ret = mtd_device_register(&ndfc->mtd, NULL, 0);
err: err:
of_node_put(flash_np); of_node_put(flash_np);
......
...@@ -1663,7 +1663,6 @@ static int omap_nand_probe(struct platform_device *pdev) ...@@ -1663,7 +1663,6 @@ static int omap_nand_probe(struct platform_device *pdev)
unsigned sig; unsigned sig;
unsigned oob_index; unsigned oob_index;
struct resource *res; struct resource *res;
struct mtd_part_parser_data ppdata = {};
pdata = dev_get_platdata(&pdev->dev); pdata = dev_get_platdata(&pdev->dev);
if (pdata == NULL) { if (pdata == NULL) {
...@@ -1688,6 +1687,7 @@ static int omap_nand_probe(struct platform_device *pdev) ...@@ -1688,6 +1687,7 @@ static int omap_nand_probe(struct platform_device *pdev)
mtd->dev.parent = &pdev->dev; mtd->dev.parent = &pdev->dev;
nand_chip = &info->nand; nand_chip = &info->nand;
nand_chip->ecc.priv = NULL; nand_chip->ecc.priv = NULL;
nand_set_flash_node(nand_chip, pdata->of_node);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
nand_chip->IO_ADDR_R = devm_ioremap_resource(&pdev->dev, res); nand_chip->IO_ADDR_R = devm_ioremap_resource(&pdev->dev, res);
...@@ -2037,9 +2037,7 @@ static int omap_nand_probe(struct platform_device *pdev) ...@@ -2037,9 +2037,7 @@ static int omap_nand_probe(struct platform_device *pdev)
goto return_error; goto return_error;
} }
ppdata.of_node = pdata->of_node; mtd_device_register(mtd, pdata->parts, pdata->nr_parts);
mtd_device_parse_register(mtd, NULL, &ppdata, pdata->parts,
pdata->nr_parts);
platform_set_drvdata(pdev, mtd); platform_set_drvdata(pdev, mtd);
......
...@@ -76,7 +76,6 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) ...@@ -76,7 +76,6 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
static int __init orion_nand_probe(struct platform_device *pdev) static int __init orion_nand_probe(struct platform_device *pdev)
{ {
struct mtd_info *mtd; struct mtd_info *mtd;
struct mtd_part_parser_data ppdata = {};
struct nand_chip *nc; struct nand_chip *nc;
struct orion_nand_data *board; struct orion_nand_data *board;
struct resource *res; struct resource *res;
...@@ -127,6 +126,7 @@ static int __init orion_nand_probe(struct platform_device *pdev) ...@@ -127,6 +126,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
mtd->dev.parent = &pdev->dev; mtd->dev.parent = &pdev->dev;
nc->priv = board; nc->priv = board;
nand_set_flash_node(nc, pdev->dev.of_node);
nc->IO_ADDR_R = nc->IO_ADDR_W = io_base; nc->IO_ADDR_R = nc->IO_ADDR_W = io_base;
nc->cmd_ctrl = orion_nand_cmd_ctrl; nc->cmd_ctrl = orion_nand_cmd_ctrl;
nc->read_buf = orion_nand_read_buf; nc->read_buf = orion_nand_read_buf;
...@@ -161,9 +161,7 @@ static int __init orion_nand_probe(struct platform_device *pdev) ...@@ -161,9 +161,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
} }
mtd->name = "orion_nand"; mtd->name = "orion_nand";
ppdata.of_node = pdev->dev.of_node; ret = mtd_device_register(mtd, board->parts, board->nr_parts);
ret = mtd_device_parse_register(mtd, NULL, &ppdata,
board->parts, board->nr_parts);
if (ret) { if (ret) {
nand_release(mtd); nand_release(mtd);
goto no_dev; goto no_dev;
......
...@@ -30,7 +30,6 @@ struct plat_nand_data { ...@@ -30,7 +30,6 @@ struct plat_nand_data {
static int plat_nand_probe(struct platform_device *pdev) static int plat_nand_probe(struct platform_device *pdev)
{ {
struct platform_nand_data *pdata = dev_get_platdata(&pdev->dev); struct platform_nand_data *pdata = dev_get_platdata(&pdev->dev);
struct mtd_part_parser_data ppdata;
struct plat_nand_data *data; struct plat_nand_data *data;
struct resource *res; struct resource *res;
const char **part_types; const char **part_types;
...@@ -58,6 +57,7 @@ static int plat_nand_probe(struct platform_device *pdev) ...@@ -58,6 +57,7 @@ static int plat_nand_probe(struct platform_device *pdev)
return PTR_ERR(data->io_base); return PTR_ERR(data->io_base);
data->chip.priv = &data; data->chip.priv = &data;
nand_set_flash_node(&data->chip, pdev->dev.of_node);
data->mtd.priv = &data->chip; data->mtd.priv = &data->chip;
data->mtd.dev.parent = &pdev->dev; data->mtd.dev.parent = &pdev->dev;
...@@ -94,8 +94,7 @@ static int plat_nand_probe(struct platform_device *pdev) ...@@ -94,8 +94,7 @@ static int plat_nand_probe(struct platform_device *pdev)
part_types = pdata->chip.part_probe_types; part_types = pdata->chip.part_probe_types;
ppdata.of_node = pdev->dev.of_node; err = mtd_device_parse_register(&data->mtd, part_types, NULL,
err = mtd_device_parse_register(&data->mtd, part_types, &ppdata,
pdata->chip.partitions, pdata->chip.partitions,
pdata->chip.nr_partitions); pdata->chip.nr_partitions);
......
...@@ -1697,6 +1697,7 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd) ...@@ -1697,6 +1697,7 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
static int alloc_nand_resource(struct platform_device *pdev) static int alloc_nand_resource(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node;
struct pxa3xx_nand_platform_data *pdata; struct pxa3xx_nand_platform_data *pdata;
struct pxa3xx_nand_info *info; struct pxa3xx_nand_info *info;
struct pxa3xx_nand_host *host; struct pxa3xx_nand_host *host;
...@@ -1725,6 +1726,8 @@ static int alloc_nand_resource(struct platform_device *pdev) ...@@ -1725,6 +1726,8 @@ static int alloc_nand_resource(struct platform_device *pdev)
host->info_data = info; host->info_data = info;
mtd->priv = host; mtd->priv = host;
mtd->dev.parent = &pdev->dev; mtd->dev.parent = &pdev->dev;
/* FIXME: all chips use the same device tree partitions */
nand_set_flash_node(chip, np);
chip->ecc.read_page = pxa3xx_nand_read_page_hwecc; chip->ecc.read_page = pxa3xx_nand_read_page_hwecc;
chip->ecc.write_page = pxa3xx_nand_write_page_hwecc; chip->ecc.write_page = pxa3xx_nand_write_page_hwecc;
...@@ -1886,7 +1889,6 @@ static int pxa3xx_nand_probe_dt(struct platform_device *pdev) ...@@ -1886,7 +1889,6 @@ static int pxa3xx_nand_probe_dt(struct platform_device *pdev)
static int pxa3xx_nand_probe(struct platform_device *pdev) static int pxa3xx_nand_probe(struct platform_device *pdev)
{ {
struct pxa3xx_nand_platform_data *pdata; struct pxa3xx_nand_platform_data *pdata;
struct mtd_part_parser_data ppdata = {};
struct pxa3xx_nand_info *info; struct pxa3xx_nand_info *info;
int ret, cs, probe_success, dma_available; int ret, cs, probe_success, dma_available;
...@@ -1933,10 +1935,8 @@ static int pxa3xx_nand_probe(struct platform_device *pdev) ...@@ -1933,10 +1935,8 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
continue; continue;
} }
ppdata.of_node = pdev->dev.of_node; ret = mtd_device_register(mtd, pdata->parts[cs],
ret = mtd_device_parse_register(mtd, NULL, pdata->nr_parts[cs]);
&ppdata, pdata->parts[cs],
pdata->nr_parts[cs]);
if (!ret) if (!ret)
probe_success = 1; probe_success = 1;
} }
......
...@@ -1086,7 +1086,6 @@ static int flctl_probe(struct platform_device *pdev) ...@@ -1086,7 +1086,6 @@ static int flctl_probe(struct platform_device *pdev)
struct sh_flctl_platform_data *pdata; struct sh_flctl_platform_data *pdata;
int ret; int ret;
int irq; int irq;
struct mtd_part_parser_data ppdata = {};
flctl = devm_kzalloc(&pdev->dev, sizeof(struct sh_flctl), GFP_KERNEL); flctl = devm_kzalloc(&pdev->dev, sizeof(struct sh_flctl), GFP_KERNEL);
if (!flctl) if (!flctl)
...@@ -1123,6 +1122,7 @@ static int flctl_probe(struct platform_device *pdev) ...@@ -1123,6 +1122,7 @@ static int flctl_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, flctl); platform_set_drvdata(pdev, flctl);
flctl_mtd = &flctl->mtd; flctl_mtd = &flctl->mtd;
nand = &flctl->chip; nand = &flctl->chip;
nand_set_flash_node(nand, pdev->dev.of_node);
flctl_mtd->priv = nand; flctl_mtd->priv = nand;
flctl_mtd->dev.parent = &pdev->dev; flctl_mtd->dev.parent = &pdev->dev;
flctl->pdev = pdev; flctl->pdev = pdev;
...@@ -1163,9 +1163,7 @@ static int flctl_probe(struct platform_device *pdev) ...@@ -1163,9 +1163,7 @@ static int flctl_probe(struct platform_device *pdev)
if (ret) if (ret)
goto err_chip; goto err_chip;
ppdata.of_node = pdev->dev.of_node; ret = mtd_device_register(flctl_mtd, pdata->parts, pdata->nr_parts);
ret = mtd_device_parse_register(flctl_mtd, NULL, &ppdata, pdata->parts,
pdata->nr_parts);
return 0; return 0;
......
...@@ -147,7 +147,6 @@ static int socrates_nand_probe(struct platform_device *ofdev) ...@@ -147,7 +147,6 @@ static int socrates_nand_probe(struct platform_device *ofdev)
struct mtd_info *mtd; struct mtd_info *mtd;
struct nand_chip *nand_chip; struct nand_chip *nand_chip;
int res; int res;
struct mtd_part_parser_data ppdata;
/* Allocate memory for the device structure (and zero it) */ /* Allocate memory for the device structure (and zero it) */
host = devm_kzalloc(&ofdev->dev, sizeof(*host), GFP_KERNEL); host = devm_kzalloc(&ofdev->dev, sizeof(*host), GFP_KERNEL);
...@@ -165,10 +164,10 @@ static int socrates_nand_probe(struct platform_device *ofdev) ...@@ -165,10 +164,10 @@ static int socrates_nand_probe(struct platform_device *ofdev)
host->dev = &ofdev->dev; host->dev = &ofdev->dev;
nand_chip->priv = host; /* link the private data structures */ nand_chip->priv = host; /* link the private data structures */
nand_set_flash_node(nand_chip, ofdev->dev.of_node);
mtd->priv = nand_chip; mtd->priv = nand_chip;
mtd->name = "socrates_nand"; mtd->name = "socrates_nand";
mtd->dev.parent = &ofdev->dev; mtd->dev.parent = &ofdev->dev;
ppdata.of_node = ofdev->dev.of_node;
/*should never be accessed directly */ /*should never be accessed directly */
nand_chip->IO_ADDR_R = (void *)0xdeadbeef; nand_chip->IO_ADDR_R = (void *)0xdeadbeef;
...@@ -200,7 +199,7 @@ static int socrates_nand_probe(struct platform_device *ofdev) ...@@ -200,7 +199,7 @@ static int socrates_nand_probe(struct platform_device *ofdev)
goto out; goto out;
} }
res = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); res = mtd_device_register(mtd, NULL, 0);
if (!res) if (!res)
return res; return res;
......
...@@ -1232,7 +1232,6 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, ...@@ -1232,7 +1232,6 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
{ {
const struct nand_sdr_timings *timings; const struct nand_sdr_timings *timings;
struct sunxi_nand_chip *chip; struct sunxi_nand_chip *chip;
struct mtd_part_parser_data ppdata;
struct mtd_info *mtd; struct mtd_info *mtd;
struct nand_chip *nand; struct nand_chip *nand;
int nsels; int nsels;
...@@ -1366,8 +1365,7 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, ...@@ -1366,8 +1365,7 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
return ret; return ret;
} }
ppdata.of_node = np; ret = mtd_device_register(mtd, NULL, 0);
ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
if (ret) { if (ret) {
dev_err(dev, "failed to register mtd device: %d\n", ret); dev_err(dev, "failed to register mtd device: %d\n", ret);
nand_release(mtd); nand_release(mtd);
......
...@@ -811,11 +811,7 @@ static int vf610_nfc_probe(struct platform_device *pdev) ...@@ -811,11 +811,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, mtd); platform_set_drvdata(pdev, mtd);
/* Register device in MTD */ /* Register device in MTD */
return mtd_device_parse_register(mtd, NULL, return mtd_device_register(mtd, NULL, 0);
&(struct mtd_part_parser_data){
.of_node = chip->flash_node,
},
NULL, 0);
error: error:
of_node_put(chip->flash_node); of_node_put(chip->flash_node);
......
...@@ -853,7 +853,6 @@ static int spinand_probe(struct spi_device *spi_nand) ...@@ -853,7 +853,6 @@ static int spinand_probe(struct spi_device *spi_nand)
struct nand_chip *chip; struct nand_chip *chip;
struct spinand_info *info; struct spinand_info *info;
struct spinand_state *state; struct spinand_state *state;
struct mtd_part_parser_data ppdata;
info = devm_kzalloc(&spi_nand->dev, sizeof(struct spinand_info), info = devm_kzalloc(&spi_nand->dev, sizeof(struct spinand_info),
GFP_KERNEL); GFP_KERNEL);
...@@ -897,6 +896,7 @@ static int spinand_probe(struct spi_device *spi_nand) ...@@ -897,6 +896,7 @@ static int spinand_probe(struct spi_device *spi_nand)
pr_info("%s: disable ecc failed!\n", __func__); pr_info("%s: disable ecc failed!\n", __func__);
#endif #endif
nand_set_flash_node(chip, spi_nand->dev.of_node);
chip->priv = info; chip->priv = info;
chip->read_buf = spinand_read_buf; chip->read_buf = spinand_read_buf;
chip->write_buf = spinand_write_buf; chip->write_buf = spinand_write_buf;
...@@ -919,8 +919,7 @@ static int spinand_probe(struct spi_device *spi_nand) ...@@ -919,8 +919,7 @@ static int spinand_probe(struct spi_device *spi_nand)
if (nand_scan(mtd, 1)) if (nand_scan(mtd, 1))
return -ENXIO; return -ENXIO;
ppdata.of_node = spi_nand->dev.of_node; return mtd_device_register(mtd, NULL, 0);
return mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册