mtd: rawnand: txx9ndfmc: convert driver to nand_scan()
Two helpers have been added to the core to do all kind of controller side configuration/initialization between the detection phase and the final NAND scan. Implement these hooks so that we can convert the driver to just use nand_scan() instead of the nand_scan_ident() + nand_scan_tail() pair. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
This commit is contained in:
parent
abe23d1c5c
commit
ee1af8296d
|
@ -254,13 +254,10 @@ static void txx9ndfmc_initialize(struct platform_device *dev)
|
||||||
#define TXX9NDFMC_NS_TO_CYC(gbusclk, ns) \
|
#define TXX9NDFMC_NS_TO_CYC(gbusclk, ns) \
|
||||||
DIV_ROUND_UP((ns) * DIV_ROUND_UP(gbusclk, 1000), 1000000)
|
DIV_ROUND_UP((ns) * DIV_ROUND_UP(gbusclk, 1000), 1000000)
|
||||||
|
|
||||||
static int txx9ndfmc_nand_scan(struct mtd_info *mtd)
|
static int txx9ndfmc_attach_chip(struct nand_chip *chip)
|
||||||
{
|
{
|
||||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
struct mtd_info *mtd = nand_to_mtd(chip);
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = nand_scan_ident(mtd, 1, NULL);
|
|
||||||
if (!ret) {
|
|
||||||
if (mtd->writesize >= 512) {
|
if (mtd->writesize >= 512) {
|
||||||
chip->ecc.size = 512;
|
chip->ecc.size = 512;
|
||||||
chip->ecc.bytes = 6;
|
chip->ecc.bytes = 6;
|
||||||
|
@ -269,11 +266,13 @@ static int txx9ndfmc_nand_scan(struct mtd_info *mtd)
|
||||||
chip->ecc.bytes = 3;
|
chip->ecc.bytes = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = nand_scan_tail(mtd);
|
return 0;
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct nand_controller_ops txx9ndfmc_controller_ops = {
|
||||||
|
.attach_chip = txx9ndfmc_attach_chip,
|
||||||
|
};
|
||||||
|
|
||||||
static int __init txx9ndfmc_probe(struct platform_device *dev)
|
static int __init txx9ndfmc_probe(struct platform_device *dev)
|
||||||
{
|
{
|
||||||
struct txx9ndfmc_platform_data *plat = dev_get_platdata(&dev->dev);
|
struct txx9ndfmc_platform_data *plat = dev_get_platdata(&dev->dev);
|
||||||
|
@ -307,6 +306,7 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)
|
||||||
(gbusclk + 500000) / 1000000, hold, spw);
|
(gbusclk + 500000) / 1000000, hold, spw);
|
||||||
|
|
||||||
nand_controller_init(&drvdata->controller);
|
nand_controller_init(&drvdata->controller);
|
||||||
|
drvdata->controller.ops = &txx9ndfmc_controller_ops;
|
||||||
|
|
||||||
platform_set_drvdata(dev, drvdata);
|
platform_set_drvdata(dev, drvdata);
|
||||||
txx9ndfmc_initialize(dev);
|
txx9ndfmc_initialize(dev);
|
||||||
|
@ -359,7 +359,7 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)
|
||||||
if (plat->wide_mask & (1 << i))
|
if (plat->wide_mask & (1 << i))
|
||||||
chip->options |= NAND_BUSWIDTH_16;
|
chip->options |= NAND_BUSWIDTH_16;
|
||||||
|
|
||||||
if (txx9ndfmc_nand_scan(mtd)) {
|
if (nand_scan(mtd, 1)) {
|
||||||
kfree(txx9_priv->mtdname);
|
kfree(txx9_priv->mtdname);
|
||||||
kfree(txx9_priv);
|
kfree(txx9_priv);
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue