diff options
Diffstat (limited to 'drivers/mtd')
28 files changed, 140 insertions, 214 deletions
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig index 4dd3b38ddac0..557bec599f4f 100644 --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig | |||
@@ -291,7 +291,7 @@ config SSFDC | |||
291 | 291 | ||
292 | config SM_FTL | 292 | config SM_FTL |
293 | tristate "SmartMedia/xD new translation layer" | 293 | tristate "SmartMedia/xD new translation layer" |
294 | depends on EXPERIMENTAL && BLOCK | 294 | depends on BLOCK |
295 | select MTD_BLKDEVS | 295 | select MTD_BLKDEVS |
296 | select MTD_NAND_ECC | 296 | select MTD_NAND_ECC |
297 | help | 297 | help |
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c index 9bcec8f22bbb..63feb75cc8e0 100644 --- a/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/mtd/mtd.h> | 15 | #include <linux/mtd/mtd.h> |
16 | #include <linux/mtd/partitions.h> | 16 | #include <linux/mtd/partitions.h> |
17 | #include <asm/mach-bcm47xx/nvram.h> | 17 | #include <bcm47xx_nvram.h> |
18 | 18 | ||
19 | /* 10 parts were found on sflash on Netgear WNDR4500 */ | 19 | /* 10 parts were found on sflash on Netgear WNDR4500 */ |
20 | #define BCM47XXPART_MAX_PARTS 12 | 20 | #define BCM47XXPART_MAX_PARTS 12 |
diff --git a/drivers/mtd/chips/Kconfig b/drivers/mtd/chips/Kconfig index e469b01d40d2..c219e3d098d9 100644 --- a/drivers/mtd/chips/Kconfig +++ b/drivers/mtd/chips/Kconfig | |||
@@ -225,7 +225,7 @@ config MTD_ABSENT | |||
225 | 225 | ||
226 | config MTD_XIP | 226 | config MTD_XIP |
227 | bool "XIP aware MTD support" | 227 | bool "XIP aware MTD support" |
228 | depends on !SMP && (MTD_CFI_INTELEXT || MTD_CFI_AMDSTD) && EXPERIMENTAL && ARCH_MTD_XIP | 228 | depends on !SMP && (MTD_CFI_INTELEXT || MTD_CFI_AMDSTD) && ARCH_MTD_XIP |
229 | default y if XIP_KERNEL | 229 | default y if XIP_KERNEL |
230 | help | 230 | help |
231 | This allows MTD support to work with flash memory which is also | 231 | This allows MTD support to work with flash memory which is also |
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig index 46dcb54c32ec..12311f506ca1 100644 --- a/drivers/mtd/devices/Kconfig +++ b/drivers/mtd/devices/Kconfig | |||
@@ -52,7 +52,7 @@ config MTD_MS02NV | |||
52 | 52 | ||
53 | config MTD_DATAFLASH | 53 | config MTD_DATAFLASH |
54 | tristate "Support for AT45xxx DataFlash" | 54 | tristate "Support for AT45xxx DataFlash" |
55 | depends on SPI_MASTER && EXPERIMENTAL | 55 | depends on SPI_MASTER |
56 | help | 56 | help |
57 | This enables access to AT45xxx DataFlash chips, using SPI. | 57 | This enables access to AT45xxx DataFlash chips, using SPI. |
58 | Sometimes DataFlash chips are packaged inside MMC-format | 58 | Sometimes DataFlash chips are packaged inside MMC-format |
@@ -81,7 +81,7 @@ config MTD_DATAFLASH_OTP | |||
81 | 81 | ||
82 | config MTD_M25P80 | 82 | config MTD_M25P80 |
83 | tristate "Support most SPI Flash chips (AT26DF, M25P, W25X, ...)" | 83 | tristate "Support most SPI Flash chips (AT26DF, M25P, W25X, ...)" |
84 | depends on SPI_MASTER && EXPERIMENTAL | 84 | depends on SPI_MASTER |
85 | help | 85 | help |
86 | This enables access to most modern SPI flash chips, used for | 86 | This enables access to most modern SPI flash chips, used for |
87 | program and data storage. Series supported include Atmel AT26DF, | 87 | program and data storage. Series supported include Atmel AT26DF, |
diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c index 2aabd96bf0ff..8a82b8bc21e1 100644 --- a/drivers/mtd/devices/spear_smi.c +++ b/drivers/mtd/devices/spear_smi.c | |||
@@ -949,10 +949,9 @@ static int spear_smi_probe(struct platform_device *pdev) | |||
949 | 949 | ||
950 | smi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 950 | smi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
951 | 951 | ||
952 | dev->io_base = devm_request_and_ioremap(&pdev->dev, smi_base); | 952 | dev->io_base = devm_ioremap_resource(&pdev->dev, smi_base); |
953 | if (!dev->io_base) { | 953 | if (IS_ERR(dev->io_base)) { |
954 | ret = -EIO; | 954 | ret = PTR_ERR(dev->io_base); |
955 | dev_err(&pdev->dev, "devm_request_and_ioremap fail\n"); | ||
956 | goto err; | 955 | goto err; |
957 | } | 956 | } |
958 | 957 | ||
diff --git a/drivers/mtd/maps/autcpu12-nvram.c b/drivers/mtd/maps/autcpu12-nvram.c index a2dc2ae4b24e..c3525d2a2fa8 100644 --- a/drivers/mtd/maps/autcpu12-nvram.c +++ b/drivers/mtd/maps/autcpu12-nvram.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | */ | 18 | */ |
19 | #include <linux/err.h> | ||
19 | #include <linux/sizes.h> | 20 | #include <linux/sizes.h> |
20 | 21 | ||
21 | #include <linux/types.h> | 22 | #include <linux/types.h> |
@@ -55,12 +56,10 @@ static int autcpu12_nvram_probe(struct platform_device *pdev) | |||
55 | priv->map.bankwidth = 4; | 56 | priv->map.bankwidth = 4; |
56 | priv->map.phys = res->start; | 57 | priv->map.phys = res->start; |
57 | priv->map.size = resource_size(res); | 58 | priv->map.size = resource_size(res); |
58 | priv->map.virt = devm_request_and_ioremap(&pdev->dev, res); | 59 | priv->map.virt = devm_ioremap_resource(&pdev->dev, res); |
59 | strcpy((char *)priv->map.name, res->name); | 60 | strcpy((char *)priv->map.name, res->name); |
60 | if (!priv->map.virt) { | 61 | if (IS_ERR(priv->map.virt)) |
61 | dev_err(&pdev->dev, "failed to remap mem resource\n"); | 62 | return PTR_ERR(priv->map.virt); |
62 | return -EBUSY; | ||
63 | } | ||
64 | 63 | ||
65 | simple_map_init(&priv->map); | 64 | simple_map_init(&priv->map); |
66 | 65 | ||
diff --git a/drivers/mtd/maps/lantiq-flash.c b/drivers/mtd/maps/lantiq-flash.c index 3c3c791eb96a..d1da6ede3845 100644 --- a/drivers/mtd/maps/lantiq-flash.c +++ b/drivers/mtd/maps/lantiq-flash.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * Copyright (C) 2010 John Crispin <blogic@openwrt.org> | 7 | * Copyright (C) 2010 John Crispin <blogic@openwrt.org> |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/err.h> | ||
10 | #include <linux/module.h> | 11 | #include <linux/module.h> |
11 | #include <linux/types.h> | 12 | #include <linux/types.h> |
12 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
@@ -136,10 +137,9 @@ ltq_mtd_probe(struct platform_device *pdev) | |||
136 | ltq_mtd->map = kzalloc(sizeof(struct map_info), GFP_KERNEL); | 137 | ltq_mtd->map = kzalloc(sizeof(struct map_info), GFP_KERNEL); |
137 | ltq_mtd->map->phys = ltq_mtd->res->start; | 138 | ltq_mtd->map->phys = ltq_mtd->res->start; |
138 | ltq_mtd->map->size = resource_size(ltq_mtd->res); | 139 | ltq_mtd->map->size = resource_size(ltq_mtd->res); |
139 | ltq_mtd->map->virt = devm_request_and_ioremap(&pdev->dev, ltq_mtd->res); | 140 | ltq_mtd->map->virt = devm_ioremap_resource(&pdev->dev, ltq_mtd->res); |
140 | if (!ltq_mtd->map->virt) { | 141 | if (IS_ERR(ltq_mtd->map->virt)) { |
141 | dev_err(&pdev->dev, "failed to remap mem resource\n"); | 142 | err = PTR_ERR(ltq_mtd->map->virt); |
142 | err = -EBUSY; | ||
143 | goto err_out; | 143 | goto err_out; |
144 | } | 144 | } |
145 | 145 | ||
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c index 500d7f4f8028..363939dfad05 100644 --- a/drivers/mtd/maps/physmap_of.c +++ b/drivers/mtd/maps/physmap_of.c | |||
@@ -167,7 +167,7 @@ static int of_flash_probe(struct platform_device *dev) | |||
167 | resource_size_t res_size; | 167 | resource_size_t res_size; |
168 | struct mtd_part_parser_data ppdata; | 168 | struct mtd_part_parser_data ppdata; |
169 | bool map_indirect; | 169 | bool map_indirect; |
170 | const char *mtd_name; | 170 | const char *mtd_name = NULL; |
171 | 171 | ||
172 | match = of_match_device(of_flash_match, &dev->dev); | 172 | match = of_match_device(of_flash_match, &dev->dev); |
173 | if (!match) | 173 | if (!match) |
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index ec794a72975d..61d5f56473e1 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -349,13 +349,8 @@ int add_mtd_device(struct mtd_info *mtd) | |||
349 | BUG_ON(mtd->writesize == 0); | 349 | BUG_ON(mtd->writesize == 0); |
350 | mutex_lock(&mtd_table_mutex); | 350 | mutex_lock(&mtd_table_mutex); |
351 | 351 | ||
352 | do { | 352 | i = idr_alloc(&mtd_idr, mtd, 0, 0, GFP_KERNEL); |
353 | if (!idr_pre_get(&mtd_idr, GFP_KERNEL)) | 353 | if (i < 0) |
354 | goto fail_locked; | ||
355 | error = idr_get_new(&mtd_idr, mtd, &i); | ||
356 | } while (error == -EAGAIN); | ||
357 | |||
358 | if (error) | ||
359 | goto fail_locked; | 354 | goto fail_locked; |
360 | 355 | ||
361 | mtd->index = i; | 356 | mtd->index = i; |
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index 5819eb575210..81bf5e52601e 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig | |||
@@ -260,8 +260,7 @@ config MTD_NAND_S3C2410_CLKSTOP | |||
260 | approximately 5mA of power when there is nothing happening. | 260 | approximately 5mA of power when there is nothing happening. |
261 | 261 | ||
262 | config MTD_NAND_DISKONCHIP | 262 | config MTD_NAND_DISKONCHIP |
263 | tristate "DiskOnChip 2000, Millennium and Millennium Plus (NAND reimplementation) (EXPERIMENTAL)" | 263 | tristate "DiskOnChip 2000, Millennium and Millennium Plus (NAND reimplementation)" |
264 | depends on EXPERIMENTAL | ||
265 | depends on HAS_IOMEM | 264 | depends on HAS_IOMEM |
266 | select REED_SOLOMON | 265 | select REED_SOLOMON |
267 | select REED_SOLOMON_DEC16 | 266 | select REED_SOLOMON_DEC16 |
@@ -331,8 +330,8 @@ config MTD_NAND_DISKONCHIP_BBTWRITE | |||
331 | parameter "inftl_bbt_write=1". | 330 | parameter "inftl_bbt_write=1". |
332 | 331 | ||
333 | config MTD_NAND_DOCG4 | 332 | config MTD_NAND_DOCG4 |
334 | tristate "Support for DiskOnChip G4 (EXPERIMENTAL)" | 333 | tristate "Support for DiskOnChip G4" |
335 | depends on EXPERIMENTAL && HAS_IOMEM | 334 | depends on HAS_IOMEM |
336 | select BCH | 335 | select BCH |
337 | select BITREVERSE | 336 | select BITREVERSE |
338 | help | 337 | help |
diff --git a/drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c b/drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c index 37d5b8956694..b2ab373c9eef 100644 --- a/drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c +++ b/drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c | |||
@@ -17,8 +17,8 @@ | |||
17 | #include <linux/bcma/bcma.h> | 17 | #include <linux/bcma/bcma.h> |
18 | 18 | ||
19 | /* Broadcom uses 1'000'000 but it seems to be too many. Tests on WNDR4500 has | 19 | /* Broadcom uses 1'000'000 but it seems to be too many. Tests on WNDR4500 has |
20 | * shown 164 retries as maxiumum. */ | 20 | * shown ~1000 retries as maxiumum. */ |
21 | #define NFLASH_READY_RETRIES 1000 | 21 | #define NFLASH_READY_RETRIES 10000 |
22 | 22 | ||
23 | #define NFLASH_SECTOR_SIZE 512 | 23 | #define NFLASH_SECTOR_SIZE 512 |
24 | 24 | ||
diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c index 67e62d3d495c..05ba3f0c2d19 100644 --- a/drivers/mtd/nand/fsmc_nand.c +++ b/drivers/mtd/nand/fsmc_nand.c | |||
@@ -573,23 +573,22 @@ static int dma_xfer(struct fsmc_nand_data *host, void *buffer, int len, | |||
573 | dma_dev = chan->device; | 573 | dma_dev = chan->device; |
574 | dma_addr = dma_map_single(dma_dev->dev, buffer, len, direction); | 574 | dma_addr = dma_map_single(dma_dev->dev, buffer, len, direction); |
575 | 575 | ||
576 | flags |= DMA_COMPL_SKIP_SRC_UNMAP | DMA_COMPL_SKIP_DEST_UNMAP; | ||
577 | |||
576 | if (direction == DMA_TO_DEVICE) { | 578 | if (direction == DMA_TO_DEVICE) { |
577 | dma_src = dma_addr; | 579 | dma_src = dma_addr; |
578 | dma_dst = host->data_pa; | 580 | dma_dst = host->data_pa; |
579 | flags |= DMA_COMPL_SRC_UNMAP_SINGLE | DMA_COMPL_SKIP_DEST_UNMAP; | ||
580 | } else { | 581 | } else { |
581 | dma_src = host->data_pa; | 582 | dma_src = host->data_pa; |
582 | dma_dst = dma_addr; | 583 | dma_dst = dma_addr; |
583 | flags |= DMA_COMPL_DEST_UNMAP_SINGLE | DMA_COMPL_SKIP_SRC_UNMAP; | ||
584 | } | 584 | } |
585 | 585 | ||
586 | tx = dma_dev->device_prep_dma_memcpy(chan, dma_dst, dma_src, | 586 | tx = dma_dev->device_prep_dma_memcpy(chan, dma_dst, dma_src, |
587 | len, flags); | 587 | len, flags); |
588 | |||
589 | if (!tx) { | 588 | if (!tx) { |
590 | dev_err(host->dev, "device_prep_dma_memcpy error\n"); | 589 | dev_err(host->dev, "device_prep_dma_memcpy error\n"); |
591 | dma_unmap_single(dma_dev->dev, dma_addr, len, direction); | 590 | ret = -EIO; |
592 | return -EIO; | 591 | goto unmap_dma; |
593 | } | 592 | } |
594 | 593 | ||
595 | tx->callback = dma_complete; | 594 | tx->callback = dma_complete; |
@@ -599,7 +598,7 @@ static int dma_xfer(struct fsmc_nand_data *host, void *buffer, int len, | |||
599 | ret = dma_submit_error(cookie); | 598 | ret = dma_submit_error(cookie); |
600 | if (ret) { | 599 | if (ret) { |
601 | dev_err(host->dev, "dma_submit_error %d\n", cookie); | 600 | dev_err(host->dev, "dma_submit_error %d\n", cookie); |
602 | return ret; | 601 | goto unmap_dma; |
603 | } | 602 | } |
604 | 603 | ||
605 | dma_async_issue_pending(chan); | 604 | dma_async_issue_pending(chan); |
@@ -610,10 +609,17 @@ static int dma_xfer(struct fsmc_nand_data *host, void *buffer, int len, | |||
610 | if (ret <= 0) { | 609 | if (ret <= 0) { |
611 | chan->device->device_control(chan, DMA_TERMINATE_ALL, 0); | 610 | chan->device->device_control(chan, DMA_TERMINATE_ALL, 0); |
612 | dev_err(host->dev, "wait_for_completion_timeout\n"); | 611 | dev_err(host->dev, "wait_for_completion_timeout\n"); |
613 | return ret ? ret : -ETIMEDOUT; | 612 | if (!ret) |
613 | ret = -ETIMEDOUT; | ||
614 | goto unmap_dma; | ||
614 | } | 615 | } |
615 | 616 | ||
616 | return 0; | 617 | ret = 0; |
618 | |||
619 | unmap_dma: | ||
620 | dma_unmap_single(dma_dev->dev, dma_addr, len, direction); | ||
621 | |||
622 | return ret; | ||
617 | } | 623 | } |
618 | 624 | ||
619 | /* | 625 | /* |
@@ -937,42 +943,35 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) | |||
937 | if (!res) | 943 | if (!res) |
938 | return -EINVAL; | 944 | return -EINVAL; |
939 | 945 | ||
940 | host->data_va = devm_request_and_ioremap(&pdev->dev, res); | 946 | host->data_va = devm_ioremap_resource(&pdev->dev, res); |
941 | if (!host->data_va) { | 947 | if (IS_ERR(host->data_va)) |
942 | dev_err(&pdev->dev, "data ioremap failed\n"); | 948 | return PTR_ERR(host->data_va); |
943 | return -ENOMEM; | 949 | |
944 | } | ||
945 | host->data_pa = (dma_addr_t)res->start; | 950 | host->data_pa = (dma_addr_t)res->start; |
946 | 951 | ||
947 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_addr"); | 952 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_addr"); |
948 | if (!res) | 953 | if (!res) |
949 | return -EINVAL; | 954 | return -EINVAL; |
950 | 955 | ||
951 | host->addr_va = devm_request_and_ioremap(&pdev->dev, res); | 956 | host->addr_va = devm_ioremap_resource(&pdev->dev, res); |
952 | if (!host->addr_va) { | 957 | if (IS_ERR(host->addr_va)) |
953 | dev_err(&pdev->dev, "ale ioremap failed\n"); | 958 | return PTR_ERR(host->addr_va); |
954 | return -ENOMEM; | ||
955 | } | ||
956 | 959 | ||
957 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_cmd"); | 960 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_cmd"); |
958 | if (!res) | 961 | if (!res) |
959 | return -EINVAL; | 962 | return -EINVAL; |
960 | 963 | ||
961 | host->cmd_va = devm_request_and_ioremap(&pdev->dev, res); | 964 | host->cmd_va = devm_ioremap_resource(&pdev->dev, res); |
962 | if (!host->cmd_va) { | 965 | if (IS_ERR(host->cmd_va)) |
963 | dev_err(&pdev->dev, "ale ioremap failed\n"); | 966 | return PTR_ERR(host->cmd_va); |
964 | return -ENOMEM; | ||
965 | } | ||
966 | 967 | ||
967 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fsmc_regs"); | 968 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fsmc_regs"); |
968 | if (!res) | 969 | if (!res) |
969 | return -EINVAL; | 970 | return -EINVAL; |
970 | 971 | ||
971 | host->regs_va = devm_request_and_ioremap(&pdev->dev, res); | 972 | host->regs_va = devm_ioremap_resource(&pdev->dev, res); |
972 | if (!host->regs_va) { | 973 | if (IS_ERR(host->regs_va)) |
973 | dev_err(&pdev->dev, "regs ioremap failed\n"); | 974 | return PTR_ERR(host->regs_va); |
974 | return -ENOMEM; | ||
975 | } | ||
976 | 975 | ||
977 | host->clk = clk_get(&pdev->dev, NULL); | 976 | host->clk = clk_get(&pdev->dev, NULL); |
978 | if (IS_ERR(host->clk)) { | 977 | if (IS_ERR(host->clk)) { |
@@ -1218,6 +1217,7 @@ static SIMPLE_DEV_PM_OPS(fsmc_nand_pm_ops, fsmc_nand_suspend, fsmc_nand_resume); | |||
1218 | #ifdef CONFIG_OF | 1217 | #ifdef CONFIG_OF |
1219 | static const struct of_device_id fsmc_nand_id_table[] = { | 1218 | static const struct of_device_id fsmc_nand_id_table[] = { |
1220 | { .compatible = "st,spear600-fsmc-nand" }, | 1219 | { .compatible = "st,spear600-fsmc-nand" }, |
1220 | { .compatible = "stericsson,fsmc-nand" }, | ||
1221 | {} | 1221 | {} |
1222 | }; | 1222 | }; |
1223 | MODULE_DEVICE_TABLE(of, fsmc_nand_id_table); | 1223 | MODULE_DEVICE_TABLE(of, fsmc_nand_id_table); |
diff --git a/drivers/mtd/nand/lpc32xx_mlc.c b/drivers/mtd/nand/lpc32xx_mlc.c index f182befa7360..0ca22ae9135c 100644 --- a/drivers/mtd/nand/lpc32xx_mlc.c +++ b/drivers/mtd/nand/lpc32xx_mlc.c | |||
@@ -677,11 +677,10 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) | |||
677 | return -ENXIO; | 677 | return -ENXIO; |
678 | } | 678 | } |
679 | 679 | ||
680 | host->io_base = devm_request_and_ioremap(&pdev->dev, rc); | 680 | host->io_base = devm_ioremap_resource(&pdev->dev, rc); |
681 | if (host->io_base == NULL) { | 681 | if (IS_ERR(host->io_base)) |
682 | dev_err(&pdev->dev, "ioremap failed\n"); | 682 | return PTR_ERR(host->io_base); |
683 | return -EIO; | 683 | |
684 | } | ||
685 | host->io_base_phy = rc->start; | 684 | host->io_base_phy = rc->start; |
686 | 685 | ||
687 | mtd = &host->mtd; | 686 | mtd = &host->mtd; |
diff --git a/drivers/mtd/nand/lpc32xx_slc.c b/drivers/mtd/nand/lpc32xx_slc.c index 030b78c62895..be94ed5abefb 100644 --- a/drivers/mtd/nand/lpc32xx_slc.c +++ b/drivers/mtd/nand/lpc32xx_slc.c | |||
@@ -778,11 +778,9 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) | |||
778 | } | 778 | } |
779 | host->io_base_dma = rc->start; | 779 | host->io_base_dma = rc->start; |
780 | 780 | ||
781 | host->io_base = devm_request_and_ioremap(&pdev->dev, rc); | 781 | host->io_base = devm_ioremap_resource(&pdev->dev, rc); |
782 | if (host->io_base == NULL) { | 782 | if (IS_ERR(host->io_base)) |
783 | dev_err(&pdev->dev, "ioremap failed\n"); | 783 | return PTR_ERR(host->io_base); |
784 | return -ENOMEM; | ||
785 | } | ||
786 | 784 | ||
787 | if (pdev->dev.of_node) | 785 | if (pdev->dev.of_node) |
788 | host->ncfg = lpc32xx_parse_dt(&pdev->dev); | 786 | host->ncfg = lpc32xx_parse_dt(&pdev->dev); |
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index 20e1241bd099..07e5784e5cd3 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
@@ -1448,9 +1448,9 @@ static int mxcnd_probe(struct platform_device *pdev) | |||
1448 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1448 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1449 | if (!res) | 1449 | if (!res) |
1450 | return -ENODEV; | 1450 | return -ENODEV; |
1451 | host->regs_ip = devm_request_and_ioremap(&pdev->dev, res); | 1451 | host->regs_ip = devm_ioremap_resource(&pdev->dev, res); |
1452 | if (!host->regs_ip) | 1452 | if (IS_ERR(host->regs_ip)) |
1453 | return -ENOMEM; | 1453 | return PTR_ERR(host->regs_ip); |
1454 | 1454 | ||
1455 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 1455 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
1456 | } else { | 1456 | } else { |
@@ -1460,9 +1460,9 @@ static int mxcnd_probe(struct platform_device *pdev) | |||
1460 | if (!res) | 1460 | if (!res) |
1461 | return -ENODEV; | 1461 | return -ENODEV; |
1462 | 1462 | ||
1463 | host->base = devm_request_and_ioremap(&pdev->dev, res); | 1463 | host->base = devm_ioremap_resource(&pdev->dev, res); |
1464 | if (!host->base) | 1464 | if (IS_ERR(host->base)) |
1465 | return -ENOMEM; | 1465 | return PTR_ERR(host->base); |
1466 | 1466 | ||
1467 | host->main_area0 = host->base; | 1467 | host->main_area0 = host->base; |
1468 | 1468 | ||
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index a8c1fb475fa6..43214151b882 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -2853,8 +2853,11 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip, | |||
2853 | int i; | 2853 | int i; |
2854 | int val; | 2854 | int val; |
2855 | 2855 | ||
2856 | /* ONFI need to be probed in 8 bits mode */ | 2856 | /* ONFI need to be probed in 8 bits mode, and 16 bits should be selected with NAND_BUSWIDTH_AUTO */ |
2857 | WARN_ON(chip->options & NAND_BUSWIDTH_16); | 2857 | if (chip->options & NAND_BUSWIDTH_16) { |
2858 | pr_err("Trying ONFI probe in 16 bits mode, aborting !\n"); | ||
2859 | return 0; | ||
2860 | } | ||
2858 | /* Try ONFI for unknown chip or LP */ | 2861 | /* Try ONFI for unknown chip or LP */ |
2859 | chip->cmdfunc(mtd, NAND_CMD_READID, 0x20, -1); | 2862 | chip->cmdfunc(mtd, NAND_CMD_READID, 0x20, -1); |
2860 | if (chip->read_byte(mtd) != 'O' || chip->read_byte(mtd) != 'N' || | 2863 | if (chip->read_byte(mtd) != 'O' || chip->read_byte(mtd) != 'N' || |
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index 4c317982fce5..891c52a30e6a 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
@@ -1408,40 +1408,32 @@ static void clear_memalloc(int memalloc) | |||
1408 | current->flags &= ~PF_MEMALLOC; | 1408 | current->flags &= ~PF_MEMALLOC; |
1409 | } | 1409 | } |
1410 | 1410 | ||
1411 | static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t *pos) | 1411 | static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t pos) |
1412 | { | 1412 | { |
1413 | mm_segment_t old_fs; | ||
1414 | ssize_t tx; | 1413 | ssize_t tx; |
1415 | int err, memalloc; | 1414 | int err, memalloc; |
1416 | 1415 | ||
1417 | err = get_pages(ns, file, count, *pos); | 1416 | err = get_pages(ns, file, count, pos); |
1418 | if (err) | 1417 | if (err) |
1419 | return err; | 1418 | return err; |
1420 | old_fs = get_fs(); | ||
1421 | set_fs(get_ds()); | ||
1422 | memalloc = set_memalloc(); | 1419 | memalloc = set_memalloc(); |
1423 | tx = vfs_read(file, (char __user *)buf, count, pos); | 1420 | tx = kernel_read(file, pos, buf, count); |
1424 | clear_memalloc(memalloc); | 1421 | clear_memalloc(memalloc); |
1425 | set_fs(old_fs); | ||
1426 | put_pages(ns); | 1422 | put_pages(ns); |
1427 | return tx; | 1423 | return tx; |
1428 | } | 1424 | } |
1429 | 1425 | ||
1430 | static ssize_t write_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t *pos) | 1426 | static ssize_t write_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t pos) |
1431 | { | 1427 | { |
1432 | mm_segment_t old_fs; | ||
1433 | ssize_t tx; | 1428 | ssize_t tx; |
1434 | int err, memalloc; | 1429 | int err, memalloc; |
1435 | 1430 | ||
1436 | err = get_pages(ns, file, count, *pos); | 1431 | err = get_pages(ns, file, count, pos); |
1437 | if (err) | 1432 | if (err) |
1438 | return err; | 1433 | return err; |
1439 | old_fs = get_fs(); | ||
1440 | set_fs(get_ds()); | ||
1441 | memalloc = set_memalloc(); | 1434 | memalloc = set_memalloc(); |
1442 | tx = vfs_write(file, (char __user *)buf, count, pos); | 1435 | tx = kernel_write(file, buf, count, pos); |
1443 | clear_memalloc(memalloc); | 1436 | clear_memalloc(memalloc); |
1444 | set_fs(old_fs); | ||
1445 | put_pages(ns); | 1437 | put_pages(ns); |
1446 | return tx; | 1438 | return tx; |
1447 | } | 1439 | } |
@@ -1511,7 +1503,7 @@ static void read_page(struct nandsim *ns, int num) | |||
1511 | if (do_read_error(ns, num)) | 1503 | if (do_read_error(ns, num)) |
1512 | return; | 1504 | return; |
1513 | pos = (loff_t)ns->regs.row * ns->geom.pgszoob + ns->regs.column + ns->regs.off; | 1505 | pos = (loff_t)ns->regs.row * ns->geom.pgszoob + ns->regs.column + ns->regs.off; |
1514 | tx = read_file(ns, ns->cfile, ns->buf.byte, num, &pos); | 1506 | tx = read_file(ns, ns->cfile, ns->buf.byte, num, pos); |
1515 | if (tx != num) { | 1507 | if (tx != num) { |
1516 | NS_ERR("read_page: read error for page %d ret %ld\n", ns->regs.row, (long)tx); | 1508 | NS_ERR("read_page: read error for page %d ret %ld\n", ns->regs.row, (long)tx); |
1517 | return; | 1509 | return; |
@@ -1573,7 +1565,7 @@ static int prog_page(struct nandsim *ns, int num) | |||
1573 | u_char *pg_off; | 1565 | u_char *pg_off; |
1574 | 1566 | ||
1575 | if (ns->cfile) { | 1567 | if (ns->cfile) { |
1576 | loff_t off, pos; | 1568 | loff_t off; |
1577 | ssize_t tx; | 1569 | ssize_t tx; |
1578 | int all; | 1570 | int all; |
1579 | 1571 | ||
@@ -1585,8 +1577,7 @@ static int prog_page(struct nandsim *ns, int num) | |||
1585 | memset(ns->file_buf, 0xff, ns->geom.pgszoob); | 1577 | memset(ns->file_buf, 0xff, ns->geom.pgszoob); |
1586 | } else { | 1578 | } else { |
1587 | all = 0; | 1579 | all = 0; |
1588 | pos = off; | 1580 | tx = read_file(ns, ns->cfile, pg_off, num, off); |
1589 | tx = read_file(ns, ns->cfile, pg_off, num, &pos); | ||
1590 | if (tx != num) { | 1581 | if (tx != num) { |
1591 | NS_ERR("prog_page: read error for page %d ret %ld\n", ns->regs.row, (long)tx); | 1582 | NS_ERR("prog_page: read error for page %d ret %ld\n", ns->regs.row, (long)tx); |
1592 | return -1; | 1583 | return -1; |
@@ -1595,16 +1586,15 @@ static int prog_page(struct nandsim *ns, int num) | |||
1595 | for (i = 0; i < num; i++) | 1586 | for (i = 0; i < num; i++) |
1596 | pg_off[i] &= ns->buf.byte[i]; | 1587 | pg_off[i] &= ns->buf.byte[i]; |
1597 | if (all) { | 1588 | if (all) { |
1598 | pos = (loff_t)ns->regs.row * ns->geom.pgszoob; | 1589 | loff_t pos = (loff_t)ns->regs.row * ns->geom.pgszoob; |
1599 | tx = write_file(ns, ns->cfile, ns->file_buf, ns->geom.pgszoob, &pos); | 1590 | tx = write_file(ns, ns->cfile, ns->file_buf, ns->geom.pgszoob, pos); |
1600 | if (tx != ns->geom.pgszoob) { | 1591 | if (tx != ns->geom.pgszoob) { |
1601 | NS_ERR("prog_page: write error for page %d ret %ld\n", ns->regs.row, (long)tx); | 1592 | NS_ERR("prog_page: write error for page %d ret %ld\n", ns->regs.row, (long)tx); |
1602 | return -1; | 1593 | return -1; |
1603 | } | 1594 | } |
1604 | ns->pages_written[ns->regs.row] = 1; | 1595 | ns->pages_written[ns->regs.row] = 1; |
1605 | } else { | 1596 | } else { |
1606 | pos = off; | 1597 | tx = write_file(ns, ns->cfile, pg_off, num, off); |
1607 | tx = write_file(ns, ns->cfile, pg_off, num, &pos); | ||
1608 | if (tx != num) { | 1598 | if (tx != num) { |
1609 | NS_ERR("prog_page: write error for page %d ret %ld\n", ns->regs.row, (long)tx); | 1599 | NS_ERR("prog_page: write error for page %d ret %ld\n", ns->regs.row, (long)tx); |
1610 | return -1; | 1600 | return -1; |
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index 1a88bd062ac1..8e820ddf4e08 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c | |||
@@ -1828,6 +1828,7 @@ static int omap_nand_probe(struct platform_device *pdev) | |||
1828 | dma_cap_mask_t mask; | 1828 | dma_cap_mask_t mask; |
1829 | unsigned sig; | 1829 | unsigned sig; |
1830 | struct resource *res; | 1830 | struct resource *res; |
1831 | struct mtd_part_parser_data ppdata = {}; | ||
1831 | 1832 | ||
1832 | pdata = pdev->dev.platform_data; | 1833 | pdata = pdev->dev.platform_data; |
1833 | if (pdata == NULL) { | 1834 | if (pdata == NULL) { |
@@ -2056,7 +2057,8 @@ static int omap_nand_probe(struct platform_device *pdev) | |||
2056 | goto out_release_mem_region; | 2057 | goto out_release_mem_region; |
2057 | } | 2058 | } |
2058 | 2059 | ||
2059 | mtd_device_parse_register(&info->mtd, NULL, NULL, pdata->parts, | 2060 | ppdata.of_node = pdata->of_node; |
2061 | mtd_device_parse_register(&info->mtd, NULL, &ppdata, pdata->parts, | ||
2060 | pdata->nr_parts); | 2062 | pdata->nr_parts); |
2061 | 2063 | ||
2062 | platform_set_drvdata(pdev, &info->mtd); | 2064 | platform_set_drvdata(pdev, &info->mtd); |
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index df954b4dcba2..d65afd23e171 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c | |||
@@ -952,10 +952,9 @@ static int s3c24xx_nand_probe(struct platform_device *pdev) | |||
952 | info->platform = plat; | 952 | info->platform = plat; |
953 | info->cpu_type = cpu_type; | 953 | info->cpu_type = cpu_type; |
954 | 954 | ||
955 | info->regs = devm_request_and_ioremap(&pdev->dev, res); | 955 | info->regs = devm_ioremap_resource(&pdev->dev, res); |
956 | if (info->regs == NULL) { | 956 | if (IS_ERR(info->regs)) { |
957 | dev_err(&pdev->dev, "cannot reserve register region\n"); | 957 | err = PTR_ERR(info->regs); |
958 | err = -EIO; | ||
959 | goto exit_error; | 958 | goto exit_error; |
960 | } | 959 | } |
961 | 960 | ||
diff --git a/drivers/mtd/nand/txx9ndfmc.c b/drivers/mtd/nand/txx9ndfmc.c index e3d7266e256f..e1e8748aa47b 100644 --- a/drivers/mtd/nand/txx9ndfmc.c +++ b/drivers/mtd/nand/txx9ndfmc.c | |||
@@ -9,6 +9,7 @@ | |||
9 | * (C) Copyright TOSHIBA CORPORATION 2004-2007 | 9 | * (C) Copyright TOSHIBA CORPORATION 2004-2007 |
10 | * All Rights Reserved. | 10 | * All Rights Reserved. |
11 | */ | 11 | */ |
12 | #include <linux/err.h> | ||
12 | #include <linux/init.h> | 13 | #include <linux/init.h> |
13 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
@@ -286,9 +287,9 @@ static int __init txx9ndfmc_probe(struct platform_device *dev) | |||
286 | drvdata = devm_kzalloc(&dev->dev, sizeof(*drvdata), GFP_KERNEL); | 287 | drvdata = devm_kzalloc(&dev->dev, sizeof(*drvdata), GFP_KERNEL); |
287 | if (!drvdata) | 288 | if (!drvdata) |
288 | return -ENOMEM; | 289 | return -ENOMEM; |
289 | drvdata->base = devm_request_and_ioremap(&dev->dev, res); | 290 | drvdata->base = devm_ioremap_resource(&dev->dev, res); |
290 | if (!drvdata->base) | 291 | if (IS_ERR(drvdata->base)) |
291 | return -EBUSY; | 292 | return PTR_ERR(drvdata->base); |
292 | 293 | ||
293 | hold = plat->hold ?: 20; /* tDH */ | 294 | hold = plat->hold ?: 20; /* tDH */ |
294 | spw = plat->spw ?: 90; /* max(tREADID, tWP, tRP) */ | 295 | spw = plat->spw ?: 90; /* max(tREADID, tWP, tRP) */ |
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c index 065f3fe02a2f..eec2aedb4ab8 100644 --- a/drivers/mtd/onenand/omap2.c +++ b/drivers/mtd/onenand/omap2.c | |||
@@ -637,6 +637,7 @@ static int omap2_onenand_probe(struct platform_device *pdev) | |||
637 | struct onenand_chip *this; | 637 | struct onenand_chip *this; |
638 | int r; | 638 | int r; |
639 | struct resource *res; | 639 | struct resource *res; |
640 | struct mtd_part_parser_data ppdata = {}; | ||
640 | 641 | ||
641 | pdata = pdev->dev.platform_data; | 642 | pdata = pdev->dev.platform_data; |
642 | if (pdata == NULL) { | 643 | if (pdata == NULL) { |
@@ -767,7 +768,8 @@ static int omap2_onenand_probe(struct platform_device *pdev) | |||
767 | if ((r = onenand_scan(&c->mtd, 1)) < 0) | 768 | if ((r = onenand_scan(&c->mtd, 1)) < 0) |
768 | goto err_release_regulator; | 769 | goto err_release_regulator; |
769 | 770 | ||
770 | r = mtd_device_parse_register(&c->mtd, NULL, NULL, | 771 | ppdata.of_node = pdata->of_node; |
772 | r = mtd_device_parse_register(&c->mtd, NULL, &ppdata, | ||
771 | pdata ? pdata->parts : NULL, | 773 | pdata ? pdata->parts : NULL, |
772 | pdata ? pdata->nr_parts : 0); | 774 | pdata ? pdata->nr_parts : 0); |
773 | if (r) | 775 | if (r) |
diff --git a/drivers/mtd/tests/mtd_nandecctest.c b/drivers/mtd/tests/mtd_nandecctest.c index 5015d10591d9..70106607c247 100644 --- a/drivers/mtd/tests/mtd_nandecctest.c +++ b/drivers/mtd/tests/mtd_nandecctest.c | |||
@@ -256,7 +256,7 @@ static int nand_ecc_test_run(const size_t size) | |||
256 | goto error; | 256 | goto error; |
257 | } | 257 | } |
258 | 258 | ||
259 | get_random_bytes(correct_data, size); | 259 | prandom_bytes(correct_data, size); |
260 | __nand_calculate_ecc(correct_data, size, correct_ecc); | 260 | __nand_calculate_ecc(correct_data, size, correct_ecc); |
261 | 261 | ||
262 | for (i = 0; i < ARRAY_SIZE(nand_ecc_test); i++) { | 262 | for (i = 0; i < ARRAY_SIZE(nand_ecc_test); i++) { |
diff --git a/drivers/mtd/tests/mtd_oobtest.c b/drivers/mtd/tests/mtd_oobtest.c index e827fa8cd844..3e24b379ffa4 100644 --- a/drivers/mtd/tests/mtd_oobtest.c +++ b/drivers/mtd/tests/mtd_oobtest.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/mtd/mtd.h> | 29 | #include <linux/mtd/mtd.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/sched.h> | 31 | #include <linux/sched.h> |
32 | #include <linux/random.h> | ||
32 | 33 | ||
33 | static int dev = -EINVAL; | 34 | static int dev = -EINVAL; |
34 | module_param(dev, int, S_IRUGO); | 35 | module_param(dev, int, S_IRUGO); |
@@ -46,26 +47,7 @@ static int use_offset; | |||
46 | static int use_len; | 47 | static int use_len; |
47 | static int use_len_max; | 48 | static int use_len_max; |
48 | static int vary_offset; | 49 | static int vary_offset; |
49 | static unsigned long next = 1; | 50 | static struct rnd_state rnd_state; |
50 | |||
51 | static inline unsigned int simple_rand(void) | ||
52 | { | ||
53 | next = next * 1103515245 + 12345; | ||
54 | return (unsigned int)((next / 65536) % 32768); | ||
55 | } | ||
56 | |||
57 | static inline void simple_srand(unsigned long seed) | ||
58 | { | ||
59 | next = seed; | ||
60 | } | ||
61 | |||
62 | static void set_random_data(unsigned char *buf, size_t len) | ||
63 | { | ||
64 | size_t i; | ||
65 | |||
66 | for (i = 0; i < len; ++i) | ||
67 | buf[i] = simple_rand(); | ||
68 | } | ||
69 | 51 | ||
70 | static int erase_eraseblock(int ebnum) | 52 | static int erase_eraseblock(int ebnum) |
71 | { | 53 | { |
@@ -129,7 +111,7 @@ static int write_eraseblock(int ebnum) | |||
129 | loff_t addr = ebnum * mtd->erasesize; | 111 | loff_t addr = ebnum * mtd->erasesize; |
130 | 112 | ||
131 | for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { | 113 | for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { |
132 | set_random_data(writebuf, use_len); | 114 | prandom_bytes_state(&rnd_state, writebuf, use_len); |
133 | ops.mode = MTD_OPS_AUTO_OOB; | 115 | ops.mode = MTD_OPS_AUTO_OOB; |
134 | ops.len = 0; | 116 | ops.len = 0; |
135 | ops.retlen = 0; | 117 | ops.retlen = 0; |
@@ -182,7 +164,7 @@ static int verify_eraseblock(int ebnum) | |||
182 | loff_t addr = ebnum * mtd->erasesize; | 164 | loff_t addr = ebnum * mtd->erasesize; |
183 | 165 | ||
184 | for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { | 166 | for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { |
185 | set_random_data(writebuf, use_len); | 167 | prandom_bytes_state(&rnd_state, writebuf, use_len); |
186 | ops.mode = MTD_OPS_AUTO_OOB; | 168 | ops.mode = MTD_OPS_AUTO_OOB; |
187 | ops.len = 0; | 169 | ops.len = 0; |
188 | ops.retlen = 0; | 170 | ops.retlen = 0; |
@@ -273,7 +255,7 @@ static int verify_eraseblock_in_one_go(int ebnum) | |||
273 | loff_t addr = ebnum * mtd->erasesize; | 255 | loff_t addr = ebnum * mtd->erasesize; |
274 | size_t len = mtd->ecclayout->oobavail * pgcnt; | 256 | size_t len = mtd->ecclayout->oobavail * pgcnt; |
275 | 257 | ||
276 | set_random_data(writebuf, len); | 258 | prandom_bytes_state(&rnd_state, writebuf, len); |
277 | ops.mode = MTD_OPS_AUTO_OOB; | 259 | ops.mode = MTD_OPS_AUTO_OOB; |
278 | ops.len = 0; | 260 | ops.len = 0; |
279 | ops.retlen = 0; | 261 | ops.retlen = 0; |
@@ -424,12 +406,12 @@ static int __init mtd_oobtest_init(void) | |||
424 | if (err) | 406 | if (err) |
425 | goto out; | 407 | goto out; |
426 | 408 | ||
427 | simple_srand(1); | 409 | prandom_seed_state(&rnd_state, 1); |
428 | err = write_whole_device(); | 410 | err = write_whole_device(); |
429 | if (err) | 411 | if (err) |
430 | goto out; | 412 | goto out; |
431 | 413 | ||
432 | simple_srand(1); | 414 | prandom_seed_state(&rnd_state, 1); |
433 | err = verify_all_eraseblocks(); | 415 | err = verify_all_eraseblocks(); |
434 | if (err) | 416 | if (err) |
435 | goto out; | 417 | goto out; |
@@ -444,13 +426,13 @@ static int __init mtd_oobtest_init(void) | |||
444 | if (err) | 426 | if (err) |
445 | goto out; | 427 | goto out; |
446 | 428 | ||
447 | simple_srand(3); | 429 | prandom_seed_state(&rnd_state, 3); |
448 | err = write_whole_device(); | 430 | err = write_whole_device(); |
449 | if (err) | 431 | if (err) |
450 | goto out; | 432 | goto out; |
451 | 433 | ||
452 | /* Check all eraseblocks */ | 434 | /* Check all eraseblocks */ |
453 | simple_srand(3); | 435 | prandom_seed_state(&rnd_state, 3); |
454 | pr_info("verifying all eraseblocks\n"); | 436 | pr_info("verifying all eraseblocks\n"); |
455 | for (i = 0; i < ebcnt; ++i) { | 437 | for (i = 0; i < ebcnt; ++i) { |
456 | if (bbt[i]) | 438 | if (bbt[i]) |
@@ -479,7 +461,7 @@ static int __init mtd_oobtest_init(void) | |||
479 | use_len = mtd->ecclayout->oobavail; | 461 | use_len = mtd->ecclayout->oobavail; |
480 | use_len_max = mtd->ecclayout->oobavail; | 462 | use_len_max = mtd->ecclayout->oobavail; |
481 | vary_offset = 1; | 463 | vary_offset = 1; |
482 | simple_srand(5); | 464 | prandom_seed_state(&rnd_state, 5); |
483 | 465 | ||
484 | err = write_whole_device(); | 466 | err = write_whole_device(); |
485 | if (err) | 467 | if (err) |
@@ -490,7 +472,7 @@ static int __init mtd_oobtest_init(void) | |||
490 | use_len = mtd->ecclayout->oobavail; | 472 | use_len = mtd->ecclayout->oobavail; |
491 | use_len_max = mtd->ecclayout->oobavail; | 473 | use_len_max = mtd->ecclayout->oobavail; |
492 | vary_offset = 1; | 474 | vary_offset = 1; |
493 | simple_srand(5); | 475 | prandom_seed_state(&rnd_state, 5); |
494 | err = verify_all_eraseblocks(); | 476 | err = verify_all_eraseblocks(); |
495 | if (err) | 477 | if (err) |
496 | goto out; | 478 | goto out; |
@@ -649,7 +631,7 @@ static int __init mtd_oobtest_init(void) | |||
649 | goto out; | 631 | goto out; |
650 | 632 | ||
651 | /* Write all eraseblocks */ | 633 | /* Write all eraseblocks */ |
652 | simple_srand(11); | 634 | prandom_seed_state(&rnd_state, 11); |
653 | pr_info("writing OOBs of whole device\n"); | 635 | pr_info("writing OOBs of whole device\n"); |
654 | for (i = 0; i < ebcnt - 1; ++i) { | 636 | for (i = 0; i < ebcnt - 1; ++i) { |
655 | int cnt = 2; | 637 | int cnt = 2; |
@@ -659,7 +641,7 @@ static int __init mtd_oobtest_init(void) | |||
659 | continue; | 641 | continue; |
660 | addr = (i + 1) * mtd->erasesize - mtd->writesize; | 642 | addr = (i + 1) * mtd->erasesize - mtd->writesize; |
661 | for (pg = 0; pg < cnt; ++pg) { | 643 | for (pg = 0; pg < cnt; ++pg) { |
662 | set_random_data(writebuf, sz); | 644 | prandom_bytes_state(&rnd_state, writebuf, sz); |
663 | ops.mode = MTD_OPS_AUTO_OOB; | 645 | ops.mode = MTD_OPS_AUTO_OOB; |
664 | ops.len = 0; | 646 | ops.len = 0; |
665 | ops.retlen = 0; | 647 | ops.retlen = 0; |
@@ -680,12 +662,13 @@ static int __init mtd_oobtest_init(void) | |||
680 | pr_info("written %u eraseblocks\n", i); | 662 | pr_info("written %u eraseblocks\n", i); |
681 | 663 | ||
682 | /* Check all eraseblocks */ | 664 | /* Check all eraseblocks */ |
683 | simple_srand(11); | 665 | prandom_seed_state(&rnd_state, 11); |
684 | pr_info("verifying all eraseblocks\n"); | 666 | pr_info("verifying all eraseblocks\n"); |
685 | for (i = 0; i < ebcnt - 1; ++i) { | 667 | for (i = 0; i < ebcnt - 1; ++i) { |
686 | if (bbt[i] || bbt[i + 1]) | 668 | if (bbt[i] || bbt[i + 1]) |
687 | continue; | 669 | continue; |
688 | set_random_data(writebuf, mtd->ecclayout->oobavail * 2); | 670 | prandom_bytes_state(&rnd_state, writebuf, |
671 | mtd->ecclayout->oobavail * 2); | ||
689 | addr = (i + 1) * mtd->erasesize - mtd->writesize; | 672 | addr = (i + 1) * mtd->erasesize - mtd->writesize; |
690 | ops.mode = MTD_OPS_AUTO_OOB; | 673 | ops.mode = MTD_OPS_AUTO_OOB; |
691 | ops.len = 0; | 674 | ops.len = 0; |
diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c index f93a76f88113..0c1140b6c286 100644 --- a/drivers/mtd/tests/mtd_pagetest.c +++ b/drivers/mtd/tests/mtd_pagetest.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/mtd/mtd.h> | 29 | #include <linux/mtd/mtd.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/sched.h> | 31 | #include <linux/sched.h> |
32 | #include <linux/random.h> | ||
32 | 33 | ||
33 | static int dev = -EINVAL; | 34 | static int dev = -EINVAL; |
34 | module_param(dev, int, S_IRUGO); | 35 | module_param(dev, int, S_IRUGO); |
@@ -45,26 +46,7 @@ static int bufsize; | |||
45 | static int ebcnt; | 46 | static int ebcnt; |
46 | static int pgcnt; | 47 | static int pgcnt; |
47 | static int errcnt; | 48 | static int errcnt; |
48 | static unsigned long next = 1; | 49 | static struct rnd_state rnd_state; |
49 | |||
50 | static inline unsigned int simple_rand(void) | ||
51 | { | ||
52 | next = next * 1103515245 + 12345; | ||
53 | return (unsigned int)((next / 65536) % 32768); | ||
54 | } | ||
55 | |||
56 | static inline void simple_srand(unsigned long seed) | ||
57 | { | ||
58 | next = seed; | ||
59 | } | ||
60 | |||
61 | static void set_random_data(unsigned char *buf, size_t len) | ||
62 | { | ||
63 | size_t i; | ||
64 | |||
65 | for (i = 0; i < len; ++i) | ||
66 | buf[i] = simple_rand(); | ||
67 | } | ||
68 | 50 | ||
69 | static int erase_eraseblock(int ebnum) | 51 | static int erase_eraseblock(int ebnum) |
70 | { | 52 | { |
@@ -98,7 +80,7 @@ static int write_eraseblock(int ebnum) | |||
98 | size_t written; | 80 | size_t written; |
99 | loff_t addr = ebnum * mtd->erasesize; | 81 | loff_t addr = ebnum * mtd->erasesize; |
100 | 82 | ||
101 | set_random_data(writebuf, mtd->erasesize); | 83 | prandom_bytes_state(&rnd_state, writebuf, mtd->erasesize); |
102 | cond_resched(); | 84 | cond_resched(); |
103 | err = mtd_write(mtd, addr, mtd->erasesize, &written, writebuf); | 85 | err = mtd_write(mtd, addr, mtd->erasesize, &written, writebuf); |
104 | if (err || written != mtd->erasesize) | 86 | if (err || written != mtd->erasesize) |
@@ -124,7 +106,7 @@ static int verify_eraseblock(int ebnum) | |||
124 | for (i = 0; i < ebcnt && bbt[ebcnt - i - 1]; ++i) | 106 | for (i = 0; i < ebcnt && bbt[ebcnt - i - 1]; ++i) |
125 | addrn -= mtd->erasesize; | 107 | addrn -= mtd->erasesize; |
126 | 108 | ||
127 | set_random_data(writebuf, mtd->erasesize); | 109 | prandom_bytes_state(&rnd_state, writebuf, mtd->erasesize); |
128 | for (j = 0; j < pgcnt - 1; ++j, addr += pgsize) { | 110 | for (j = 0; j < pgcnt - 1; ++j, addr += pgsize) { |
129 | /* Do a read to set the internal dataRAMs to different data */ | 111 | /* Do a read to set the internal dataRAMs to different data */ |
130 | err = mtd_read(mtd, addr0, bufsize, &read, twopages); | 112 | err = mtd_read(mtd, addr0, bufsize, &read, twopages); |
@@ -160,7 +142,8 @@ static int verify_eraseblock(int ebnum) | |||
160 | } | 142 | } |
161 | /* Check boundary between eraseblocks */ | 143 | /* Check boundary between eraseblocks */ |
162 | if (addr <= addrn - pgsize - pgsize && !bbt[ebnum + 1]) { | 144 | if (addr <= addrn - pgsize - pgsize && !bbt[ebnum + 1]) { |
163 | unsigned long oldnext = next; | 145 | struct rnd_state old_state = rnd_state; |
146 | |||
164 | /* Do a read to set the internal dataRAMs to different data */ | 147 | /* Do a read to set the internal dataRAMs to different data */ |
165 | err = mtd_read(mtd, addr0, bufsize, &read, twopages); | 148 | err = mtd_read(mtd, addr0, bufsize, &read, twopages); |
166 | if (mtd_is_bitflip(err)) | 149 | if (mtd_is_bitflip(err)) |
@@ -188,13 +171,13 @@ static int verify_eraseblock(int ebnum) | |||
188 | return err; | 171 | return err; |
189 | } | 172 | } |
190 | memcpy(boundary, writebuf + mtd->erasesize - pgsize, pgsize); | 173 | memcpy(boundary, writebuf + mtd->erasesize - pgsize, pgsize); |
191 | set_random_data(boundary + pgsize, pgsize); | 174 | prandom_bytes_state(&rnd_state, boundary + pgsize, pgsize); |
192 | if (memcmp(twopages, boundary, bufsize)) { | 175 | if (memcmp(twopages, boundary, bufsize)) { |
193 | pr_err("error: verify failed at %#llx\n", | 176 | pr_err("error: verify failed at %#llx\n", |
194 | (long long)addr); | 177 | (long long)addr); |
195 | errcnt += 1; | 178 | errcnt += 1; |
196 | } | 179 | } |
197 | next = oldnext; | 180 | rnd_state = old_state; |
198 | } | 181 | } |
199 | return err; | 182 | return err; |
200 | } | 183 | } |
@@ -326,7 +309,7 @@ static int erasecrosstest(void) | |||
326 | return err; | 309 | return err; |
327 | 310 | ||
328 | pr_info("writing 1st page of block %d\n", ebnum); | 311 | pr_info("writing 1st page of block %d\n", ebnum); |
329 | set_random_data(writebuf, pgsize); | 312 | prandom_bytes_state(&rnd_state, writebuf, pgsize); |
330 | strcpy(writebuf, "There is no data like this!"); | 313 | strcpy(writebuf, "There is no data like this!"); |
331 | err = mtd_write(mtd, addr0, pgsize, &written, writebuf); | 314 | err = mtd_write(mtd, addr0, pgsize, &written, writebuf); |
332 | if (err || written != pgsize) { | 315 | if (err || written != pgsize) { |
@@ -359,7 +342,7 @@ static int erasecrosstest(void) | |||
359 | return err; | 342 | return err; |
360 | 343 | ||
361 | pr_info("writing 1st page of block %d\n", ebnum); | 344 | pr_info("writing 1st page of block %d\n", ebnum); |
362 | set_random_data(writebuf, pgsize); | 345 | prandom_bytes_state(&rnd_state, writebuf, pgsize); |
363 | strcpy(writebuf, "There is no data like this!"); | 346 | strcpy(writebuf, "There is no data like this!"); |
364 | err = mtd_write(mtd, addr0, pgsize, &written, writebuf); | 347 | err = mtd_write(mtd, addr0, pgsize, &written, writebuf); |
365 | if (err || written != pgsize) { | 348 | if (err || written != pgsize) { |
@@ -417,7 +400,7 @@ static int erasetest(void) | |||
417 | return err; | 400 | return err; |
418 | 401 | ||
419 | pr_info("writing 1st page of block %d\n", ebnum); | 402 | pr_info("writing 1st page of block %d\n", ebnum); |
420 | set_random_data(writebuf, pgsize); | 403 | prandom_bytes_state(&rnd_state, writebuf, pgsize); |
421 | err = mtd_write(mtd, addr0, pgsize, &written, writebuf); | 404 | err = mtd_write(mtd, addr0, pgsize, &written, writebuf); |
422 | if (err || written != pgsize) { | 405 | if (err || written != pgsize) { |
423 | pr_err("error: write failed at %#llx\n", | 406 | pr_err("error: write failed at %#llx\n", |
@@ -565,7 +548,7 @@ static int __init mtd_pagetest_init(void) | |||
565 | pr_info("erased %u eraseblocks\n", i); | 548 | pr_info("erased %u eraseblocks\n", i); |
566 | 549 | ||
567 | /* Write all eraseblocks */ | 550 | /* Write all eraseblocks */ |
568 | simple_srand(1); | 551 | prandom_seed_state(&rnd_state, 1); |
569 | pr_info("writing whole device\n"); | 552 | pr_info("writing whole device\n"); |
570 | for (i = 0; i < ebcnt; ++i) { | 553 | for (i = 0; i < ebcnt; ++i) { |
571 | if (bbt[i]) | 554 | if (bbt[i]) |
@@ -580,7 +563,7 @@ static int __init mtd_pagetest_init(void) | |||
580 | pr_info("written %u eraseblocks\n", i); | 563 | pr_info("written %u eraseblocks\n", i); |
581 | 564 | ||
582 | /* Check all eraseblocks */ | 565 | /* Check all eraseblocks */ |
583 | simple_srand(1); | 566 | prandom_seed_state(&rnd_state, 1); |
584 | pr_info("verifying all eraseblocks\n"); | 567 | pr_info("verifying all eraseblocks\n"); |
585 | for (i = 0; i < ebcnt; ++i) { | 568 | for (i = 0; i < ebcnt; ++i) { |
586 | if (bbt[i]) | 569 | if (bbt[i]) |
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c index 596cbea8df4c..a6ce9c1fa6c5 100644 --- a/drivers/mtd/tests/mtd_speedtest.c +++ b/drivers/mtd/tests/mtd_speedtest.c | |||
@@ -49,13 +49,6 @@ static int pgcnt; | |||
49 | static int goodebcnt; | 49 | static int goodebcnt; |
50 | static struct timeval start, finish; | 50 | static struct timeval start, finish; |
51 | 51 | ||
52 | static void set_random_data(unsigned char *buf, size_t len) | ||
53 | { | ||
54 | size_t i; | ||
55 | |||
56 | for (i = 0; i < len; ++i) | ||
57 | buf[i] = random32(); | ||
58 | } | ||
59 | 52 | ||
60 | static int erase_eraseblock(int ebnum) | 53 | static int erase_eraseblock(int ebnum) |
61 | { | 54 | { |
@@ -396,7 +389,7 @@ static int __init mtd_speedtest_init(void) | |||
396 | goto out; | 389 | goto out; |
397 | } | 390 | } |
398 | 391 | ||
399 | set_random_data(iobuf, mtd->erasesize); | 392 | prandom_bytes(iobuf, mtd->erasesize); |
400 | 393 | ||
401 | err = scan_for_bad_eraseblocks(); | 394 | err = scan_for_bad_eraseblocks(); |
402 | if (err) | 395 | if (err) |
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c index 1d29739db916..787f539d16ca 100644 --- a/drivers/mtd/tests/mtd_stresstest.c +++ b/drivers/mtd/tests/mtd_stresstest.c | |||
@@ -282,8 +282,7 @@ static int __init mtd_stresstest_init(void) | |||
282 | } | 282 | } |
283 | for (i = 0; i < ebcnt; i++) | 283 | for (i = 0; i < ebcnt; i++) |
284 | offsets[i] = mtd->erasesize; | 284 | offsets[i] = mtd->erasesize; |
285 | for (i = 0; i < bufsize; i++) | 285 | prandom_bytes(writebuf, bufsize); |
286 | writebuf[i] = random32(); | ||
287 | 286 | ||
288 | err = scan_for_bad_eraseblocks(); | 287 | err = scan_for_bad_eraseblocks(); |
289 | if (err) | 288 | if (err) |
diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c index c880c2229c59..aade56f27945 100644 --- a/drivers/mtd/tests/mtd_subpagetest.c +++ b/drivers/mtd/tests/mtd_subpagetest.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/mtd/mtd.h> | 28 | #include <linux/mtd/mtd.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/sched.h> | 30 | #include <linux/sched.h> |
31 | #include <linux/random.h> | ||
31 | 32 | ||
32 | static int dev = -EINVAL; | 33 | static int dev = -EINVAL; |
33 | module_param(dev, int, S_IRUGO); | 34 | module_param(dev, int, S_IRUGO); |
@@ -43,26 +44,7 @@ static int bufsize; | |||
43 | static int ebcnt; | 44 | static int ebcnt; |
44 | static int pgcnt; | 45 | static int pgcnt; |
45 | static int errcnt; | 46 | static int errcnt; |
46 | static unsigned long next = 1; | 47 | static struct rnd_state rnd_state; |
47 | |||
48 | static inline unsigned int simple_rand(void) | ||
49 | { | ||
50 | next = next * 1103515245 + 12345; | ||
51 | return (unsigned int)((next / 65536) % 32768); | ||
52 | } | ||
53 | |||
54 | static inline void simple_srand(unsigned long seed) | ||
55 | { | ||
56 | next = seed; | ||
57 | } | ||
58 | |||
59 | static void set_random_data(unsigned char *buf, size_t len) | ||
60 | { | ||
61 | size_t i; | ||
62 | |||
63 | for (i = 0; i < len; ++i) | ||
64 | buf[i] = simple_rand(); | ||
65 | } | ||
66 | 48 | ||
67 | static inline void clear_data(unsigned char *buf, size_t len) | 49 | static inline void clear_data(unsigned char *buf, size_t len) |
68 | { | 50 | { |
@@ -119,7 +101,7 @@ static int write_eraseblock(int ebnum) | |||
119 | int err = 0; | 101 | int err = 0; |
120 | loff_t addr = ebnum * mtd->erasesize; | 102 | loff_t addr = ebnum * mtd->erasesize; |
121 | 103 | ||
122 | set_random_data(writebuf, subpgsize); | 104 | prandom_bytes_state(&rnd_state, writebuf, subpgsize); |
123 | err = mtd_write(mtd, addr, subpgsize, &written, writebuf); | 105 | err = mtd_write(mtd, addr, subpgsize, &written, writebuf); |
124 | if (unlikely(err || written != subpgsize)) { | 106 | if (unlikely(err || written != subpgsize)) { |
125 | pr_err("error: write failed at %#llx\n", | 107 | pr_err("error: write failed at %#llx\n", |
@@ -133,7 +115,7 @@ static int write_eraseblock(int ebnum) | |||
133 | 115 | ||
134 | addr += subpgsize; | 116 | addr += subpgsize; |
135 | 117 | ||
136 | set_random_data(writebuf, subpgsize); | 118 | prandom_bytes_state(&rnd_state, writebuf, subpgsize); |
137 | err = mtd_write(mtd, addr, subpgsize, &written, writebuf); | 119 | err = mtd_write(mtd, addr, subpgsize, &written, writebuf); |
138 | if (unlikely(err || written != subpgsize)) { | 120 | if (unlikely(err || written != subpgsize)) { |
139 | pr_err("error: write failed at %#llx\n", | 121 | pr_err("error: write failed at %#llx\n", |
@@ -157,7 +139,7 @@ static int write_eraseblock2(int ebnum) | |||
157 | for (k = 1; k < 33; ++k) { | 139 | for (k = 1; k < 33; ++k) { |
158 | if (addr + (subpgsize * k) > (ebnum + 1) * mtd->erasesize) | 140 | if (addr + (subpgsize * k) > (ebnum + 1) * mtd->erasesize) |
159 | break; | 141 | break; |
160 | set_random_data(writebuf, subpgsize * k); | 142 | prandom_bytes_state(&rnd_state, writebuf, subpgsize * k); |
161 | err = mtd_write(mtd, addr, subpgsize * k, &written, writebuf); | 143 | err = mtd_write(mtd, addr, subpgsize * k, &written, writebuf); |
162 | if (unlikely(err || written != subpgsize * k)) { | 144 | if (unlikely(err || written != subpgsize * k)) { |
163 | pr_err("error: write failed at %#llx\n", | 145 | pr_err("error: write failed at %#llx\n", |
@@ -193,7 +175,7 @@ static int verify_eraseblock(int ebnum) | |||
193 | int err = 0; | 175 | int err = 0; |
194 | loff_t addr = ebnum * mtd->erasesize; | 176 | loff_t addr = ebnum * mtd->erasesize; |
195 | 177 | ||
196 | set_random_data(writebuf, subpgsize); | 178 | prandom_bytes_state(&rnd_state, writebuf, subpgsize); |
197 | clear_data(readbuf, subpgsize); | 179 | clear_data(readbuf, subpgsize); |
198 | err = mtd_read(mtd, addr, subpgsize, &read, readbuf); | 180 | err = mtd_read(mtd, addr, subpgsize, &read, readbuf); |
199 | if (unlikely(err || read != subpgsize)) { | 181 | if (unlikely(err || read != subpgsize)) { |
@@ -220,7 +202,7 @@ static int verify_eraseblock(int ebnum) | |||
220 | 202 | ||
221 | addr += subpgsize; | 203 | addr += subpgsize; |
222 | 204 | ||
223 | set_random_data(writebuf, subpgsize); | 205 | prandom_bytes_state(&rnd_state, writebuf, subpgsize); |
224 | clear_data(readbuf, subpgsize); | 206 | clear_data(readbuf, subpgsize); |
225 | err = mtd_read(mtd, addr, subpgsize, &read, readbuf); | 207 | err = mtd_read(mtd, addr, subpgsize, &read, readbuf); |
226 | if (unlikely(err || read != subpgsize)) { | 208 | if (unlikely(err || read != subpgsize)) { |
@@ -257,7 +239,7 @@ static int verify_eraseblock2(int ebnum) | |||
257 | for (k = 1; k < 33; ++k) { | 239 | for (k = 1; k < 33; ++k) { |
258 | if (addr + (subpgsize * k) > (ebnum + 1) * mtd->erasesize) | 240 | if (addr + (subpgsize * k) > (ebnum + 1) * mtd->erasesize) |
259 | break; | 241 | break; |
260 | set_random_data(writebuf, subpgsize * k); | 242 | prandom_bytes_state(&rnd_state, writebuf, subpgsize * k); |
261 | clear_data(readbuf, subpgsize * k); | 243 | clear_data(readbuf, subpgsize * k); |
262 | err = mtd_read(mtd, addr, subpgsize * k, &read, readbuf); | 244 | err = mtd_read(mtd, addr, subpgsize * k, &read, readbuf); |
263 | if (unlikely(err || read != subpgsize * k)) { | 245 | if (unlikely(err || read != subpgsize * k)) { |
@@ -430,7 +412,7 @@ static int __init mtd_subpagetest_init(void) | |||
430 | goto out; | 412 | goto out; |
431 | 413 | ||
432 | pr_info("writing whole device\n"); | 414 | pr_info("writing whole device\n"); |
433 | simple_srand(1); | 415 | prandom_seed_state(&rnd_state, 1); |
434 | for (i = 0; i < ebcnt; ++i) { | 416 | for (i = 0; i < ebcnt; ++i) { |
435 | if (bbt[i]) | 417 | if (bbt[i]) |
436 | continue; | 418 | continue; |
@@ -443,7 +425,7 @@ static int __init mtd_subpagetest_init(void) | |||
443 | } | 425 | } |
444 | pr_info("written %u eraseblocks\n", i); | 426 | pr_info("written %u eraseblocks\n", i); |
445 | 427 | ||
446 | simple_srand(1); | 428 | prandom_seed_state(&rnd_state, 1); |
447 | pr_info("verifying all eraseblocks\n"); | 429 | pr_info("verifying all eraseblocks\n"); |
448 | for (i = 0; i < ebcnt; ++i) { | 430 | for (i = 0; i < ebcnt; ++i) { |
449 | if (bbt[i]) | 431 | if (bbt[i]) |
@@ -466,7 +448,7 @@ static int __init mtd_subpagetest_init(void) | |||
466 | goto out; | 448 | goto out; |
467 | 449 | ||
468 | /* Write all eraseblocks */ | 450 | /* Write all eraseblocks */ |
469 | simple_srand(3); | 451 | prandom_seed_state(&rnd_state, 3); |
470 | pr_info("writing whole device\n"); | 452 | pr_info("writing whole device\n"); |
471 | for (i = 0; i < ebcnt; ++i) { | 453 | for (i = 0; i < ebcnt; ++i) { |
472 | if (bbt[i]) | 454 | if (bbt[i]) |
@@ -481,7 +463,7 @@ static int __init mtd_subpagetest_init(void) | |||
481 | pr_info("written %u eraseblocks\n", i); | 463 | pr_info("written %u eraseblocks\n", i); |
482 | 464 | ||
483 | /* Check all eraseblocks */ | 465 | /* Check all eraseblocks */ |
484 | simple_srand(3); | 466 | prandom_seed_state(&rnd_state, 3); |
485 | pr_info("verifying all eraseblocks\n"); | 467 | pr_info("verifying all eraseblocks\n"); |
486 | for (i = 0; i < ebcnt; ++i) { | 468 | for (i = 0; i < ebcnt; ++i) { |
487 | if (bbt[i]) | 469 | if (bbt[i]) |
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index dfcc65b33e99..4f02848bb2bc 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c | |||
@@ -194,7 +194,7 @@ static int vol_cdev_fsync(struct file *file, loff_t start, loff_t end, | |||
194 | { | 194 | { |
195 | struct ubi_volume_desc *desc = file->private_data; | 195 | struct ubi_volume_desc *desc = file->private_data; |
196 | struct ubi_device *ubi = desc->vol->ubi; | 196 | struct ubi_device *ubi = desc->vol->ubi; |
197 | struct inode *inode = file->f_path.dentry->d_inode; | 197 | struct inode *inode = file_inode(file); |
198 | int err; | 198 | int err; |
199 | mutex_lock(&inode->i_mutex); | 199 | mutex_lock(&inode->i_mutex); |
200 | err = ubi_sync(ubi->ubi_num); | 200 | err = ubi_sync(ubi->ubi_num); |