diff options
author | Huang Shijie <shijie8@gmail.com> | 2013-12-20 11:02:27 -0500 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2014-01-11 15:20:06 -0500 |
commit | a5900554a8b5fbc4fb731c6f9896ed265683f94e (patch) | |
tree | 7d4eaf624ac4d10d1a1d3e1e094f9df3d2d863d3 /drivers/mtd/nand/mxc_nand.c | |
parent | 2fec386a94bbe8a02d0669d9fcb32e6a69918d9f (diff) |
mtd: mxc-nand: kill the NAND_MAX_PAGESIZE/NAND_MAX_OOBSIZE
We kill the NAND_MAX_PAGESIZE/NAND_MAX_OOBSIZE by the following way:
1.) Before we call the nand_scan_ident, we allocate a temporary buffer
whose size is PAGE_SIZE.
2.) After we finish the nand_scan_ident, we have already getten the
page size and oob size. We will allocate the right buffer size
again.
Signed-off-by: Huang Shijie <shijie8@gmail.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd/nand/mxc_nand.c')
-rw-r--r-- | drivers/mtd/nand/mxc_nand.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index 567a5e56660c..e9a4835c4dd9 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
@@ -1399,12 +1399,15 @@ static int mxcnd_probe(struct platform_device *pdev) | |||
1399 | int err = 0; | 1399 | int err = 0; |
1400 | 1400 | ||
1401 | /* Allocate memory for MTD device structure and private data */ | 1401 | /* Allocate memory for MTD device structure and private data */ |
1402 | host = devm_kzalloc(&pdev->dev, sizeof(struct mxc_nand_host) + | 1402 | host = devm_kzalloc(&pdev->dev, sizeof(struct mxc_nand_host), |
1403 | NAND_MAX_PAGESIZE + NAND_MAX_OOBSIZE, GFP_KERNEL); | 1403 | GFP_KERNEL); |
1404 | if (!host) | 1404 | if (!host) |
1405 | return -ENOMEM; | 1405 | return -ENOMEM; |
1406 | 1406 | ||
1407 | host->data_buf = (uint8_t *)(host + 1); | 1407 | /* allocate a temporary buffer for the nand_scan_ident() */ |
1408 | host->data_buf = devm_kzalloc(&pdev->dev, PAGE_SIZE, GFP_KERNEL); | ||
1409 | if (!host->data_buf) | ||
1410 | return -ENOMEM; | ||
1408 | 1411 | ||
1409 | host->dev = &pdev->dev; | 1412 | host->dev = &pdev->dev; |
1410 | /* structures must be linked */ | 1413 | /* structures must be linked */ |
@@ -1532,6 +1535,15 @@ static int mxcnd_probe(struct platform_device *pdev) | |||
1532 | goto escan; | 1535 | goto escan; |
1533 | } | 1536 | } |
1534 | 1537 | ||
1538 | /* allocate the right size buffer now */ | ||
1539 | devm_kfree(&pdev->dev, (void *)host->data_buf); | ||
1540 | host->data_buf = devm_kzalloc(&pdev->dev, mtd->writesize + mtd->oobsize, | ||
1541 | GFP_KERNEL); | ||
1542 | if (!host->data_buf) { | ||
1543 | err = -ENOMEM; | ||
1544 | goto escan; | ||
1545 | } | ||
1546 | |||
1535 | /* Call preset again, with correct writesize this time */ | 1547 | /* Call preset again, with correct writesize this time */ |
1536 | host->devtype_data->preset(mtd); | 1548 | host->devtype_data->preset(mtd); |
1537 | 1549 | ||