summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
Commit message (Collapse)AuthorAgeFilesLines
* string: Fix (v)asprintf prototypesSascha Hauer2016-04-156-12/+14
| | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: move crc specific stuff to crc.hSascha Hauer2016-04-152-1/+3
| | | | | | | We have a crc.h, so move our crc function prototypes there to further cleanup common.h. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ubifs'Sascha Hauer2016-04-083-3/+2
|\
| * Move GFP_NOFS to barebox-wrapperAlexander Stein2016-04-081-2/+0
| | | | | | | | | | | | | | This will also be used by upcoming UBIFS update. Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: ubi: Set max_write_size to actual value read from flashAlexander Stein2016-04-081-1/+1
| | | | | | | | | | | | | | | | | | Currently max_write_size is set to minimal I/O size. Set to buffer size read from flash. Required by UBIFS recovery which uses max_write_size for error detection. Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: cfi-flash: Set MTD's writebufsizeAlexander Stein2016-04-081-0/+1
| | | | | | | | | | | | | | writebufsize is zero initialized, set actual value during init. Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: doc3: Fix wrong format specifierSascha Hauer2016-04-081-1/+1
| | | | | | | | | | | | Fixes: 1e009bf mtd: Make erase_info structs 64bit where necessary Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/ubiformat'Sascha Hauer2016-04-083-1/+59
|\ \
| * | mtd: ubi: Add function to get ubi number from mtd deviceSascha Hauer2016-04-081-0/+20
| | | | | | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: ubi: umount mounted volumes before detaching a ubi deviceSascha Hauer2016-04-081-0/+17
| | | | | | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: ubi: make ubi_detach_mtd_dev ubi internalSascha Hauer2016-04-082-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We want to extend the functionality of the ubi detach function, but we don't want to change the original detach function to make UBI updates easier. This adds a barebox specific detach function which encapsulates the original UBI function. Also this makes the original ubi detach function internal to ubi. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: ubi: rename cdev.c to barebox.cSascha Hauer2016-04-082-1/+1
| |/ | | | | | | | | | | | | | | | | cdev.c exists in the kernel UBI code, but barebox has completely different content in this file. rename it to barebox.c to reduce the number of merge conflicts. Also with the name barebox.c we now have a place to put other barebox specific UBI code to. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/mtd-imx-nand'Sascha Hauer2016-04-081-102/+139
|\ \
| * | mtd: nand-imx: fix raw read/writeSascha Hauer2016-03-171-28/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | raw read/write was not possible because we enabled the ECC engine during driver initialization. To support raw mode we have to disable the ECC engine dynamically when needed. This has to be done before the send_page function is called. The places where we have to disable the ECC engine are not available in the driver, but are buried in the Nand layer. To make them available we have to implement driver specific write/read_page functions in which we configure the ECC mode. This also makes the driver better readable as it makes the detour around the driver internal data buffer when reading/writing pages unnecessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: nand-imx: remove/replace debug printSascha Hauer2016-03-171-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The relevant informations which command is sent for which page is already contained in the informations imx_nand_command() prints, so remove the debug prints in send_cmd and send_addr (which only exist for v1/v2 controllers, not for v3). Also use dev_dbg to print debug informations instead of MTD_DEBUG. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: nand-imx: remove dead codeSascha Hauer2016-03-171-45/+0
| | | | | | | | | | | | | | | | | | | | | Neither CONFIG_MXC_NAND_LOW_LEVEL_ERASE nor CONFIG_MTD_NAND_MXC_FORCE_CE are defined anywhere, remove the code inside the ifdefs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: nand-imx: Fix correct_data return value for v2/v3 controllersSascha Hauer2016-03-171-12/+6
| | | | | | | | | | | | | | | | | | | | | | | | The correct return value for a uncorrectable page is -EBADMSG, not -1 (which is -EPERM). Also the max_bitflips returned shall be the bitflips per ecc step, not per page. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: nand-imx: Fix v1 controller ECC codeSascha Hauer2016-03-171-12/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The driver returns wrong values for the ECC correction. For 2k pages the controller reads and corrects in chunks of 512 bytes. The ECC status register values are overwritten with each each new chunk read, so after reading for chunks the .correct callback wil only return the ECC errors for the last 512 byte chunk. ECC errors in the other three chunks remain undetected. Fix this by accumulating the ECC status while reading the chunks and return the accumulated value in the .correct callback. Also return -EBADMSG for a bad message and not -1. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/imx-bbu-nand-fcb'Sascha Hauer2016-04-0814-473/+895
|\ \ \
| * | | mtd: nand: export nand_check_erased_bufSascha Hauer2016-04-081-1/+1
| | |/ | |/| | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | commands: Create nand_bitflip commandSascha Hauer2016-04-061-0/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a command to flip bits in a Nand flash. This is useful for testing purposes to check if flipped bits are corrected and if the driver returns the correct number of bitflips. The command writes a configurable number of bitflips to a single Nand page. If the -r option is not given the results are reproducible, so calling the same command twice will revert the bitflips. The command uses the raw read/write Nand operations which are probably less tested than the regular read/write operations, so the command may produce surprising results. As of writing the command has been tested with the GPMI Nand driver and the imx-nand driver with fixes posted. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: ubi: Make debug options configurableSascha Hauer2016-04-062-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | This makes the UBI debug options configurable. This make the debug options actually available to the user and also allows the compiler to optimize away the debug code when the options are disabled. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: ubi: Use mtd_peb_eraseSascha Hauer2016-04-062-68/+1
| | | | | | | | | | | | | | | | | | mtd_peb_erase provides the same functionality as do_sync_erase. Use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: ubi: Use mtd_peb_writeSascha Hauer2016-04-062-126/+1
| | | | | | | | | | | | | | | | | | mtd_peb_write provides the same functionality as ubi_io_write. Use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: ubi: Use mtd_peb_readSascha Hauer2016-04-062-97/+5
| | | | | | | | | | | | | | | | | | | | | mtd_peb_read provides the same functionality as ubi_io_read. Use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: ubi: Use mtd_peb_tortureSascha Hauer2016-04-063-116/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | The mtd-peb API provides a torture test derived from the UBI torture test. Use it. Since the mtd-peb variant of the torture test will also mark a block as bad when the test fails this also makes a separate ubi_io_mark_bad unnecessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: ubi: Use mtd_peb_check_all_ffSascha Hauer2016-04-061-37/+2
| | | | | | | | | | | | | | | | | | Use mtd-peb function for checking for a all-ff buffer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: ubi: Use mtd_all_ff/mtd_check_patternSascha Hauer2016-04-064-26/+6
| | | | | | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: Introduce mtd-peb APISascha Hauer2016-04-063-1/+547
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code which properly wants to handle Nand flash has to work in a block based way since blocks are the entities that are erased or may become bad. The regular mtd API works based on offsets in the device which introduces unhandy 64bit arithmetics and the requirement to align buffers to blocks. This introduces the mtd peb API (PEB for physical Erase Block) which allows the users to work in a block oriented way. The API is heavily inspired by the UBI IO layer and in fact can replace parts thereof later. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: Introduce mtd_check_patternSascha Hauer2016-03-151-0/+19
| | | | | | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: rename mtd_all_ff -> mtd_buf_all_ffSascha Hauer2016-03-152-2/+10
| | | | | | | | | | | | | | | | | | | | | To make clear this function checks a given buffer and not data on a mtd device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: Introduce function to get mtd type stringSascha Hauer2016-03-151-0/+22
| | | | | | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: mtdpart: Add oob_read functionSascha Hauer2016-03-151-0/+22
| | | | | | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: Add support for marking blocks as goodSascha Hauer2016-03-154-0/+115
| |/ | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / mtd: doc3: Fix wrong format specifierSascha Hauer2016-03-301-1/+1
|/ | | | | | Fixes: 1e009bf mtd: Make erase_info structs 64bit where necessary Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd'Sascha Hauer2016-03-117-33/+73
|\
| * mtd: nand: default bitflip-reporting threshold to 75% of correction strengthSascha Hauer2016-03-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on Kernel commit 240181fd0ffa6 from Brian Norris: The MTD API reports -EUCLEAN only if the maximum number of bitflips found in any ECC block exceeds a certain threshold. This is done to avoid excessive -EUCLEAN reports to MTD users, which may induce additional scrubbing of data, even when the ECC algorithm in use is perfectly capable of handling the bitflips. This threshold can be controlled by user-space (via sysfs), to allow users to determine what they are willing to tolerate in their application. But it still helps to have sane defaults. In recent discussion [1], it was pointed out that our default threshold is equal to the correction strength. That means that we won't actually report any -EUCLEAN (i.e., "bitflips were corrected") errors until there are almost too many to handle. It was determined that 3/4 of the correction strength is probably a better default. [1] http://lists.infradead.org/pipermail/linux-mtd/2015-January/057259.html Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: mtd_[read|write|erase]: check for valid input dataSascha Hauer2016-03-041-0/+22
| | | | | | | | | | | | | | | | mtd_[read|write|erase] are input functions to the mtd subsystem, so check for valid input data here rather than relying on the drivers doing this. The checks are copied from the Kernel as of 4.5-rc5 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: core: check offset in mtd_block_markbadStefan Christ2016-02-231-0/+3
| | | | | | | | | | | | | | | | Check if the given offset is valid for the mtd device. Print an error message if not to inform the user in the command 'nand'. Signed-off-by: Stefan Christ <s.christ@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: spi-nor: Add support for s25fl116kSascha Hauer2016-02-111-0/+1
| | | | | | | | | | | | | | The Spansion s25fl116k is a 16MBit flash memory. Add the flash info entry for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: spi-nor: Match jedec,spi-norSascha Hauer2016-02-111-0/+2
| | | | | | | | | | | | | | | | It is recommended to use jedec,spi-nor instead of specifying the exact flash type (which is autodetected via Jedec ID anyway), so add the compatible entry to the driver. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: mtdoob device: change name to have the chip name firstSascha Hauer2016-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | Normally all device files assoctiated to a mtd device begin with the chip name itself. Only the mtdoob device is an exception: it begins with the chip name without the index end ends with the index. Change the name to be like the other names, i.e. change nand_oob0 to nand0.oob. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: Fix erasing of devices >4GiBSascha Hauer2016-02-093-5/+5
| | | | | | | | | | | | | | | | | | When a device >4GiB is erased, not only the offset can be bigger than 4GiB, but also the size. This happens with the simplest command to erase a device: erase /dev/nand0. Make the size argument a 64bit type to make this work. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: Fix mtd_op_erase for devices >4GiBSascha Hauer2016-02-091-2/+2
| | | | | | | | | | | | | | The mtd erase file operation has a unnecessary conversion to unsigned long in the offset. Remove it to make it work with chips >4GiB. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: Fix mtd_op_read for devices >4GiBSascha Hauer2016-02-091-3/+2
| | | | | | | | | | | | | | The mtd read file operation has a unnecessary conversion to unsigned long in the read offset. Remove it to make it work with chips >4GiB Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: Make erase_info structs 64bit where necessarySascha Hauer2016-02-091-1/+1
| | | | | | | | | | | | | | | | Make the userspace structs 64bit where necessary. Since we do not have separated kernel/userspace in barebox we can just modifiy the original structs instead of adding separate 64bit structs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: Fix mtdraw for Nand > 4GiBSascha Hauer2016-02-091-20/+33
| | | | | | | | | | | | | | | | The mtdraw code has some casts to avoid 64bit divisions. For Chips >4GiB using 64bit types become necessary, so use them and to the necessary 64bit math. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand-bb: Fix 8k page size nandsSascha Hauer2016-02-091-1/+1
| | | | | | | | | | | | | | As the comment states BB_WRITEBUF_SIZE must be a multiple of the largest NAND page size. Since this is 8192 and not 4096, change it accordingly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | driver: replace dev_request_mem_region with dev_request_mem_resourceSascha Hauer2016-03-0712-41/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // <smpl> @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | driver: Fix return check of dev_request_mem_regionSascha Hauer2016-02-233-9/+9
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region returns an ERR_PTR, fix places which check for a NULL pointer instead. This patch has been generated with this semantic patch, written by me and improved by Andrey Smirnov: // <smpl> @@ expression e; expression e1; @@ e = dev_request_mem_region(...); ... -if (!e) - return e1; +if (IS_ERR(e)) + return PTR_ERR(e); @ rule1 @ expression e; @@ e = dev_request_mem_region(...); @@ expression rule1.e; identifier ret, label; constant errno; @@ if (!e) { ... ( - ret = -errno; + ret = PTR_ERR(e); ... goto label; | - return -errno; + return PTR_ERR(e); ) } @depends on rule1@ expression rule1.e; @@ - if (e == NULL) + if (IS_ERR(e)) { ... } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>