Skip to content

Commit 533a014

Browse files
David BrownellDavid Woodhouse
authored andcommitted
mtd: nand: minor davinci_nand cleanup
Make the DaVinci NAND driver require platform_data with board-specific configuration. We can't actually do any kind of sane job of configuring it otherwise. Also fix the comment about picking the "best" ECC mode. We can't do those any more; that relied on knowing what kind of CPU we're using (they don't all support 4-bit ECC), and current policy is that drivers not have cpu_is_*() checks. Signed-off-by: David Brownell <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
1 parent 81d19b0 commit 533a014

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

drivers/mtd/nand/davinci_nand.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
306306
uint32_t val;
307307
nand_ecc_modes_t ecc_mode;
308308

309+
/* insist on board-specific configuration */
310+
if (!pdata)
311+
return -ENODEV;
312+
309313
/* which external chipselect will we be managing? */
310314
if (pdev->id < 0 || pdev->id > 3)
311315
return -ENODEV;
@@ -351,7 +355,7 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
351355
info->chip.select_chip = nand_davinci_select_chip;
352356

353357
/* options such as NAND_USE_FLASH_BBT or 16-bit widths */
354-
info->chip.options = pdata ? pdata->options : 0;
358+
info->chip.options = pdata->options;
355359

356360
info->ioaddr = (uint32_t __force) vaddr;
357361

@@ -360,14 +364,8 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
360364
info->mask_chipsel = pdata->mask_chipsel;
361365

362366
/* use nandboot-capable ALE/CLE masks by default */
363-
if (pdata && pdata->mask_ale)
364-
info->mask_ale = pdata->mask_cle;
365-
else
366-
info->mask_ale = MASK_ALE;
367-
if (pdata && pdata->mask_cle)
368-
info->mask_cle = pdata->mask_cle;
369-
else
370-
info->mask_cle = MASK_CLE;
367+
info->mask_ale = pdata->mask_cle ? : MASK_ALE;
368+
info->mask_cle = pdata->mask_cle ? : MASK_CLE;
371369

372370
/* Set address of hardware control function */
373371
info->chip.cmd_ctrl = nand_davinci_hwcontrol;
@@ -377,11 +375,8 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
377375
info->chip.read_buf = nand_davinci_read_buf;
378376
info->chip.write_buf = nand_davinci_write_buf;
379377

380-
/* use board-specific ECC config; else, the best available */
381-
if (pdata)
382-
ecc_mode = pdata->ecc_mode;
383-
else
384-
ecc_mode = NAND_ECC_HW;
378+
/* Use board-specific ECC config */
379+
ecc_mode = pdata->ecc_mode;
385380

386381
switch (ecc_mode) {
387382
case NAND_ECC_NONE:
@@ -469,7 +464,7 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
469464
info->mtd.name = master_name;
470465
}
471466

472-
if (mtd_parts_nb <= 0 && pdata) {
467+
if (mtd_parts_nb <= 0) {
473468
mtd_parts = pdata->parts;
474469
mtd_parts_nb = pdata->nr_parts;
475470
}
@@ -482,7 +477,7 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
482477
info->partitioned = true;
483478
}
484479

485-
} else if (pdata && pdata->nr_parts) {
480+
} else if (pdata->nr_parts) {
486481
dev_warn(&pdev->dev, "ignoring %d default partitions on %s\n",
487482
pdata->nr_parts, info->mtd.name);
488483
}

0 commit comments

Comments
 (0)