aboutsummaryrefslogtreecommitdiff
path: root/drivers
AgeCommit message (Collapse)AuthorFilesLines
2012-03-27mtd: nand/fsmc: Pass partition information through platform dataVipin Kumar1-6/+7
This patch reimplements the passing of partition information through platform data. This was unintentionally deleted in commit 0d04eda1430e9a796214bee644b7e05d99cfe613 "mtd: fsmc_nand.c: use mtd_device_parse_register" Artem: fix gcc warning about passin 0 instead of NULL. Signed-off-by: Vipin Kumar <[email protected]> Acked-by: Stefan Roese <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Cc: [email protected] [3.2+] Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: phram: dot not crash when built-in and passing boot paramHervé Fache1-3/+30
This patch is based on Ville Herva's similar patch to block2mtd. Trying to pass a parameter through the kernel command line when built-in would crash the kernel, as phram_setup() was called so early that kmalloc() was not functional yet. This patch only saves the parameter string at the early boot stage, and parses it later when init_phram() is called. The same happens in both module and built-in cases. With this patch, I can boot with a statically-compiled phram, and mount a ext2 root fs from physical RAM, without the need for a initrd. This has been tested in built-in and module cases, with and without a parameter string. Artem: amended comments a bit Signed-off-by: Hervé Fache <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: gpmi: fix the wrong DMA command.Huang Shijie1-1/+2
The last DMA command of ECC read page is used to disable the BCH module. But the original code missed to set the pio[2] which is used to set the GPMI_HW_GPMI_ECCCTRL register. fix it now. Signed-off-by: Huang Shijie <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: flash drivers set ecc strengthMike Dunn31-1/+63
Flash device drivers initialize 'ecc_strength' in struct mtd_info, which is the maximum number of bit errors that can be corrected in one writesize region. Drivers using the nand interface intitialize 'strength' in struct nand_ecc_ctrl, which is the maximum number of bit errors that can be corrected in one ecc step. Nand infrastructure code translates this to 'ecc_strength'. Also for nand drivers, the nand infrastructure code sets ecc.strength for ecc modes NAND_ECC_SOFT, NAND_ECC_SOFT_BCH, and NAND_ECC_NONE. It is set in the driver for all other modes. Signed-off-by: Mike Dunn <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: docg3 reduce read alignment burdenRobert Jarzmik1-8/+13
The read function was so far requiring the reads to be aligned on page boundaries, and be page length multiples in size. Relieve these constraints to ease the userspace ubifs programs runs, which read ubifs headers of 64 bytes. Artem: squashed a later fix from Robert Jarzmik into this patch. Signed-off-by: Robert Jarzmik <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: sh_flctl: Add power management with QoS requestBastian Hecht1-9/+42
Adds power management code with fine granularity. Every flash control command is enclosed by runtime_put()/get()s. To make sure that no overhead is generated by too frequent power state switches, a quality of service request is issued. Signed-off-by: Bastian Hecht <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: do not use plain 0 as NULLArtem Bityutskiy40-84/+88
The first 3 arguments of 'mtd_device_parse_register()' are pointers, but many callers pass '0' instead of 'NULL'. Fix this globally. Thanks to coccinelle for making it easy to do with the following semantic patch: @@ expression mtd, types, parser_data, parts, nr_parts; @@ ( -mtd_device_parse_register(mtd, 0, parser_data, parts, nr_parts) +mtd_device_parse_register(mtd, NULL, parser_data, parts, nr_parts) | -mtd_device_parse_register(mtd, types, 0, parts, nr_parts) +mtd_device_parse_register(mtd, types, NULL, parts, nr_parts) | -mtd_device_parse_register(mtd, types, parser_data, 0, nr_parts) +mtd_device_parse_register(mtd, types, parser_data, NULL, nr_parts) ) Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: maps: sa1100-flash: Add reference counter to set_vpp()Paul Parsons1-1/+13
This patch is part of a set which fixes unnecessary flash erase and write errors resulting from the MTD CFI driver turning off vpp while an erase is in progress. This patch allows sa1100_set_vpp() calls to be nested by adding a reference counter. Signed-off-by: Paul Parsons <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: maps: pcmciamtd: Add reference counter to set_vpp()Paul Parsons1-1/+12
This patch is part of a set which fixes unnecessary flash erase and write errors resulting from the MTD CFI driver turning off vpp while an erase is in progress. This patch allows pcmciamtd_set_vpp() calls to be nested by adding a reference counter. Signed-off-by: Paul Parsons <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: maps: l440gx: Add reference counter to set_vpp()Paul Parsons1-5/+9
This patch is part of a set which fixes unnecessary flash erase and write errors resulting from the MTD CFI driver turning off vpp while an erase is in progress. This patch allows l440gx_set_vpp() calls to be nested by adding a reference counter. Signed-off-by: Paul Parsons <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: maps: physmap: Add reference counter to set_vpp()Paul Parsons1-2/+20
This patch is part of a set which fixes unnecessary flash erase and write errors resulting from the MTD CFI driver turning off vpp while an erase is in progress. This patch allows physmap_set_vpp() calls to be nested by adding a reference counter. omap1_set_vpp() already used a reference counter. Since it is called from physmap_set_vpp(), omap1_set_vpp() can now be simplified. simtec_nor_vpp() already disabled hard interrupts. Since it is called from physmap_set_vpp(), simtec_nor_vpp() can now be simplified. Signed-off-by: Paul Parsons <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: chips: cfi_cmdset_0002: Match ENABLE_VPP()/DISABLE_VPP() callsPaul Parsons1-2/+4
This patch is part of a set which fixes unnecessary flash erase and write errors resulting from the MTD CFI driver turning off vpp while an erase is in progress. This patch ensures that only those flash operations which call ENABLE_VPP() can then call DISABLE_VPP(). Other operations should never call DISABLE_VPP(). Signed-off-by: Paul Parsons <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: chips: cfi_cmdset_0001: Match ENABLE_VPP()/DISABLE_VPP() callsPaul Parsons1-6/+9
This patch is part of a set which fixes unnecessary flash erase and write errors resulting from the MTD CFI driver turning off vpp while an erase is in progress. This patch ensures that only those flash operations which call ENABLE_VPP() can then call DISABLE_VPP(). Other operations should never call DISABLE_VPP(). Signed-off-by: Paul Parsons <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: fsmc: Support of 224-bytes OOB area lengthArmando Visconti1-0/+40
The current patch is required to support EVALSPEAR1340CPU Revision 2 where a new (ONFI compliant) MT29F16G08 NAND flash from Micron is present. This NAND flash device defines a OOB area which is 224 bytes long (oobsize). Signed-off-by: Armando Visconti <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: fsmc: Improve the fsmc_correct_data() routineArmando Visconti1-21/+17
This patch improves the error correction routine for bch8 - Loop only up to number of errors detected - Improve the error index calculation procedure Additionally, it also renames the "correct" routine to indicate that it is bch8 specific Signed-off-by: Armando Visconti <[email protected]> Signed-off-by: Vipin Kumar <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: fsmc: fixed data abort inside change_bit()Armando Visconti1-1/+1
Since change_bit() requires a (unsigned int *) as second arg, the correct definition of err_idx[] array declared as local variable of fsmc_correct_data() is the following: u32 err_idx[8]; Signed-off-by: Armando Visconti <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: fsmc: use ALE and CLE offsets from platform dataShiraz Hashim1-4/+5
ALE and CLE offsets can be different on different devices. Let devices pass these offsets to the fsmc driver through platform data. Signed-off-by: Shiraz Hashim <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: fsmc_nand: ECC1 & ECC4 layout separated for different page sizesBhavna Yadav1-17/+159
ECC1 & ECC4 layout for NAND of different pages sizes for e.g. 512bytes, 2KiB, 4KiB and 8KiB are separated. Previously there existed one ECC4 layout for 2KiB & 4KiB page size due to which oob test module available in drivers/mtd/nand/test was failing. Signed-off-by: Bhavna Yadav <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: fsmc: Newly erased page read algorithm implementedVipin Kumar1-4/+52
A newly erased page contains ff in data as well as spare area. While reading an erased page, the read out ecc from spare area does not match the ecc generated by fsmc ecc hardware accelerator. This is because ecc of data ff ff is not ff ff. This leads to errors when file system erases and reads back the pages to ensure consistency. This patch adds a software workaround to ensure that the ecc check is not performed for erased pages. This problem is solved by checking the number of bits (in 512 byte data + 13 byte ecc) which are 0. If these number of bits are less than 8, the page is considered erased and correction algorithm is not tried on that page Signed-off-by: Vipin Kumar <[email protected]> Acked-by: Linus Walleij <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: fix partition wrapper functionsMike Dunn1-27/+33
This patch reverts a change that may have been mistakenly included with the set of patches that introduced the new mtd api entry functions. Or perhaps I am mistaken :) The problem is in the partition wrapper functions, where the calls to the driver methods were replaced with calls to the new mtd api functions. This causes the api function to be called a second time, further down the call stack. This is not only unnecessary and redundant - because the sanity checking code and (more restrictive) bounds checks for the partition were done in the first call - but is potentially problematic and confusing. For example, the call stack for a call to mtd_read() on a partitioned device currently looks like this: mtd_read() gets struct mtd_info for the partition | +-> part_read() via the pointer assigned when the partition was created | +->mtd_read() this time gets struct mtd_info for the master | +->xyz_driver_read() via the pointer asigned by the driver It seems that this can cause a variety of problems. For example, if you want to add code to the api function that tests a value in mtd_info that is relevant only to the partition. Or (in my case) you want the driver to return a value that may be different from that returned by the mtd api function. This patch eliminates the second call to the mtd api function. It was tested on the docg4 nand driver with a subset of the api functions, but I inspected the rest and don't see any problems. Signed-off-by: Mike Dunn <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: docg3 trivial renamingRobert Jarzmik1-1/+1
Change the name of the mtd so that it is simpler, and is easier to cope with by mtdparts. Signed-off-by: Robert Jarzmik <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: sh_flctl: Add FLHOLDCR registerBastian Hecht1-0/+3
Add a register used in new FLCTL hardware and a feature flag for it. Signed-off-by: Bastian Hecht <[email protected]> Acked-by: Laurent Pinchart <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: sh_flctl: Use cached register value for FLCMNCRBastian Hecht1-15/+7
Instead of reading out the register, use a cached value. This will make way for a proper runtime power management implementation. Signed-off-by: Bastian Hecht <[email protected]> Acked-by: Laurent Pinchart <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: sh_flctl: Implement NAND_CMD_RNDOUT commandBastian Hecht1-0/+16
Implements the command to seek and read in pages. Signed-off-by: Bastian Hecht <[email protected]> Acked-by: Laurent Pinchart <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: sh_flctl: Expand the READID command to 8 bytesBastian Hecht1-3/+9
The nand base code wants to read out 8 bytes in the READID command. Reflect this in the driver code. Signed-off-by: Bastian Hecht <[email protected]> Acked-by: Laurent Pinchart <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: sh_flctl: Reorder empty_fifo() callsBastian Hecht1-3/+2
Reorders the calls to make it a bit shorter and match the calling procedure displayed in the datasheet. Signed-off-by: Bastian Hecht <[email protected]> Acked-by: Laurent Pinchart <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: mips: lantiq: reintroduce support for cmdline partitionsDaniel Schwierzeck1-1/+2
Since commit ca97dec2ab5c87e9fbdf7e882e1820004a3966fa the command line parsing of MTD partitions does not work anymore. Signed-off-by: Daniel Schwierzeck <[email protected]> Signed-off-by: John Crispin <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Cc: [email protected] [3.2+] Acked-by: John Crispin <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: change the location of the ONFI detected logHuang Shijie1-1/+1
Some strange nand chip(such as Hynix H27UBG8T2A) can pass the `ONFI` signature check. So the log can be printed out even it is not an ONFI nand indeed. Change this log to the end of the function. Print out the log only when we really detect an ONFI nand. Signed-off-by: Huang Shijie <[email protected]> Acked-by: Florian Fainelli <[email protected]> Acked-by: Brian Norris <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mxs-dma : rewrite the last parameter of mxs_dma_prep_slave_sg()Huang Shijie3-15/+46
[1] Background : The GPMI does ECC read page operation with a DMA chain consist of three DMA Command Structures. The middle one of the chain is used to enable the BCH, and read out the NAND page. The WAIT4END(wait for command end) is a comunication signal between the GPMI and MXS-DMA. [2] The current DMA code sets the WAIT4END bit at the last one, such as: +-----+ +-----+ +-----+ | cmd | ------------> | cmd | ------------------> | cmd | +-----+ +-----+ +-----+ ^ | | set WAIT4END here This chain works fine in the mx23/mx28. [3] But in the new GPMI version (used in MX50/MX60), the WAIT4END bit should be set not only at the last DMA Command Structure, but also at the middle one, such as: +-----+ +-----+ +-----+ | cmd | ------------> | cmd | ------------------> | cmd | +-----+ +-----+ +-----+ ^ ^ | | | | set WAIT4END here too set WAIT4END here If we do not set WAIT4END, the BCH maybe stalls in "ECC reading page" state. In the next ECC write page operation, a DMA-timeout occurs. This has been catched in the MX6Q board. [4] In order to fix the bug, rewrite the last parameter of mxs_dma_prep_slave_sg(), and use the dma_ctrl_flags: --------------------------------------------------------- DMA_PREP_INTERRUPT : append a new DMA Command Structrue. DMA_CTRL_ACK : set the WAIT4END bit for this DMA Command Structure. --------------------------------------------------------- [5] changes to the relative drivers: <1> For mxs-mmc driver, just use the new flags, do not change any logic. <2> For gpmi-nand driver, and use the new flags to set the DMA chain, especially for ecc read page. Acked-by: Shawn Guo <[email protected]> Signed-off-by: Huang Shijie <[email protected]> Acked-by: Vinod Koul <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mxs-dma : move the mxs dma.h to a more common placeHuang Shijie3-3/+3
Move the header to a more common place. The mxs dma engine is not only used in mx23/mx28, but also used in mx50/mx6q. It will also be used in the future chips. Rename it to mxs-dma.h, and create a new folder include/linux/fsl/ to store the Freescale's header files. change mxs-dma driver, mxs-mmc driver, gpmi-nand driver, mxs-saif driver to the new header file. Acked-by: Shawn Guo <[email protected]> Acked-by: Mark Brown <[email protected]> Signed-off-by: Huang Shijie <[email protected]> Acked-by: Vinod Koul <[email protected]> Acked-by: Chris Ball <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: fix 'Flash device refused suspend due to active operation' messageRussell King1-1/+1
While debugging on SA11x0, the following message was observed: "Flash device refused suspend due to active operation (state 20)" Signed-off-by: Russell King <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: gpmi: fix compiler warningHuang Shijie1-1/+0
The gpmi driver selects the MTD_CMDLINE_PARTS directly. But we should not select a visible symbol. Just remove the select. Signed-off-by: Huang Shijie <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: simplify return logic in do_map_probe()Uwe Kleine-König1-4/+1
Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27sfc: mtd: Use MTD_FAIL_ADDR_UNKNOWN instead of 0xffffffffShmulik Ladkani1-1/+1
As of bb0eb217, MTD_FAIL_ADDR_UNKNOWN should be used to indicate mtd erase failure not specific to any particular block. Use MTD_FAIL_ADDR_UNKNOWN instead of 0xffffffff when setting 'erase->fail_addr' in 'efx_mtd_erase()'. Signed-off-by: Shmulik Ladkani <[email protected]> Acked-by: Ben Hutchings <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: ixp4xx: oops in ixp4xx_flash_probeMarc Kleine-Budde1-1/+4
In commit "c797533 mtd: abstract last MTD partition parser argument" the third argument of "mtd_device_parse_register()" changed from start address of the MTD device to a pointer to a struct. The "ixp4xx_flash_probe()" function was not converted properly, causing an oops during boot. This patch fixes the problem by filling the needed information into a "struct mtd_part_parser_data" and passing it to "mtd_device_parse_register()". Signed-off-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Cc: [email protected] [3.2+] Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: check for zero length in OTP functionsArtem Bityutskiy1-0/+73
This patch changes all the OTP functions like 'mtd_get_fact_prot_info()' and makes them return zero immediately if the input 'len' parameter is 0. This is not really needed currently, but most of the other functions do this, and it is just consistent to do the same in the OTP functions. This patch also moves the OTP functions from the header file to mtdcore.c because they become a bit too big for being inlined. Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: move zero length verification to MTD API functionsArtem Bityutskiy13-76/+21
In many places in drivers we verify for the zero length, but this is very inconsistent across drivers. This is obviously the right thing to do, though. This patch moves the check to the MTD API functions instead and removes a lot of duplication. Signed-off-by: Artem Bityutskiy <[email protected]> Reviewed-by: Shmulik Ladkani <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: harmonize mtd_point interface implementationArtem Bityutskiy5-14/+3
Some MTD drivers return -EINVAL if the 'phys' parameter is not NULL, trying to convey that they cannot return the physical address. However, this is not very logical because they still can return the virtual address ('virt'). But some drivers (lpddr) just ignore the 'phys' parameter instead, which is a more logical thing to do. Let's harmonize this and: 1. Always initialize 'virt' and 'phys' to 'NULL' in 'mtd_point()'. 2. Do not return an error if the physical address cannot be found. So as a result, all drivers will set 'phys' to 'NULL' if it is not supported. None of the 'mtd_point()' users use 'phys' anyway, so this should not break anything. I guess we could also just delete this parameter later. Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: remove junk pmc551.hArtem Bityutskiy1-2/+38
This header is tiny and contains only pmc551-private stuff, so it should not live in 'include/linux' - let's just merge it with pmc551.c. Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: remove retlen zeroing duplicationArtem Bityutskiy18-73/+1
The MTD API function now zero the 'retlen' parameter before calling the driver's method — do not do this again in drivers. This removes duplicated '*retlen = 0' assignent from the following methods: 'mtd_point()' 'mtd_read()' 'mtd_write()' 'mtd_writev()' 'mtd_panic_write()' Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: remove R/O checking duplicationArtem Bityutskiy7-54/+15
Many drivers check whether the partition is R/O and return -EROFS if yes. Let's stop having duplicated checks and move them to the API functions instead. And again a bit of noise - deleted few too sparse newlines, sorry. Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: do not duplicate length and offset checks in driversArtem Bityutskiy23-321/+3
We already verify that offset and length are within the MTD device size in the MTD API functions. Let's remove the duplicated checks in drivers. This patch only affects the following API's: 'mtd_erase()' 'mtd_point()' 'mtd_unpoint()' 'mtd_get_unmapped_area()' 'mtd_read()' 'mtd_write()' 'mtd_panic_write()' 'mtd_lock()' 'mtd_unlock()' 'mtd_is_locked()' 'mtd_block_isbad()' 'mtd_block_markbad()' This patch adds a bit of noise by removing too sparse empty lines, but this is not too bad. Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: add offset and length checks to the API functionArtem Bityutskiy1-0/+148
Add verification of the offset and length to MTD API functions and verify that MTD device offset and length are within MTD device size. The modified API functions are: 'mtd_erase()' 'mtd_point()' 'mtd_unpoint()' 'mtd_get_unmapped_area()' 'mtd_read()' 'mtd_write()' 'mtd_panic_write()' 'mtd_lock()' 'mtd_unlock()' 'mtd_is_locked()' 'mtd_block_isbad()' 'mtd_block_markbad()' This patch also uninlines these functions and exports in mtdcore.c because they are not performance-critical and do not have to be inlined. Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: return error code from mtd_unpointArtem Bityutskiy7-17/+29
The 'mtd_unpoint()' API function should be able to return an error code because it may fail if you specify incorrect offset. This patch changes this MTD API function and amends all the drivers correspondingly. Also return '-EOPNOTSUPP' from 'mtd_unpoint()' when the '->unpoint()' method is undefined. We do not really need this currently, but this just makes sense to be consistent with 'mtd_point()'. Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: nand: write BBM to OOB even with flash-based BBTBrian Norris1-15/+31
Currently, the flash-based BBT implementation writes bad block data only to its flash-based table and not to the OOB marker area. Then, as new bad blocks are marked over time, the OOB markers become incomplete and the flash-based table becomes the only source of current bad block information. This becomes an obvious problem when, for example: * bootloader cannot read the flash-based BBT format * BBT is corrupted and the flash must be rescanned for bad blocks; we want to remember bad blocks that were marked from Linux So to keep the bad block markers in sync with the flash-based BBT, this patch changes the default so that we write bad block markers to the proper OOB area on each block in addition to flash-based BBT. Comments are updated, expanded, and/or relocated as necessary. The new flash-based BBT procedure for marking bad blocks: (1) erase the affected block, to allow OOB marker to be written cleanly (2) update in-memory BBT (3) write bad block marker to OOB area of affected block (4) update flash-based BBT Note that we retain the first error encountered in (3) or (4), finish the procedures, and dump the error in the end. This should handle power cuts gracefully enough. (1) and (2) are mostly harmless (note that (1) will not erase an already-recognized bad block). The OOB and BBT may be "out of sync" if we experience power loss bewteen (3) and (4), but we can reasonably expect that on next boot, subsequent I/O operations will discover that the block should be marked bad again, thus re-syncing the OOB and BBT. Note that this is a change from the previous default flash-based BBT behavior. If your system cannot support writing bad block markers to OOB, use the new NAND_BBT_NO_OOB_BBM option (in combination with NAND_BBT_USE_FLASH and NAND_BBT_NO_OOB). Signed-off-by: Brian Norris <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: redboot: remove useless codeArtem Bityutskiy1-4/+2
We do not need to invoke 'mtd_can_have_bb()' before invoking 'mtd_block_isbad()' because the latter already handles the case when the MTD device does not support bad blocks. Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: nftlcore: remove out-of-date and now irrelevant piece of codeArtem Bityutskiy1-7/+0
Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtdoops: clean-up new MTD API usageArtem Bityutskiy1-5/+4
Let's remove useless 'mtd_can_have_bb()' function invocations. Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: mtdconcat: return -EOPNOTSUPP if block_markbad is undefinedArtem Bityutskiy1-3/+0
The main 'mtd_block_markbad()' function returns -EOPNOTSUPP if the '->block_markbad' method is undefined, and mtdconcat should do the same. Fix this by simply removing the 'mtd_can_have_bb()' because it is not really necessary. It could be treated as an optimization, but this function is expected to be used so rarely that it does not matter. Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
2012-03-27mtd: sst25l: initialize writebufsizeArtem Bityutskiy1-0/+1
The writebufsize concept was introduce by commit "0e4ca7e mtd: add writebufsize field to mtd_info struct" and it represents the maximum amount of data the device writes to the media at a time. This is an important parameter for UBIFS which is used during recovery and which basically defines how big a corruption caused by a power cut can be. Set writebufsize to the flash page size because it is the maximum amount of data it writes at a time. Signed-off-by: Artem Bityutskiy <[email protected]> Cc: [email protected] [2.6.38+] Signed-off-by: David Woodhouse <[email protected]>