summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
Commit message (Collapse)AuthorAgeFilesLines
* mtd: ubi: Max out wear-leveling thresholdStefan Riedmueller2019-10-144-26/+12
| | | | | | | | | | | | | | | | | | | Due to the recursive ubi_thread implementation in the barebox, a large amount of wear-leveling can lead to a stack overflow. This was observed during extensive ubi stress tests with the linux kernel and periodic power cycles. We found that if the wear-leveling threshold is exceeded and a large amount of erase blocks need wear-leveling the stack can overflow. The hardware used to observe this was a phyCORE-i.MX 6 with 1GB NAND flash. As the kernel is perfectly capable of handling wear-leveling we can disable wear-leveling in the barebox by maxing out the threshold and removing its Kconfig option. Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: nand_omap_gpmc: Fix mtd_info usageTeresa Remmet2019-09-301-8/+8
| | | | | | | | | | | The mtd_info has not been set correctly in the omap gpmc probe. Remove the mtd_info in the private struct like it has been done in other nand drivers. And update the driver accordingly. Fixes: 76b6f74c5397 ("mtd: nand: Embed struct mtd_info into struct nand_chip") Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/omap'Sascha Hauer2019-09-125-8/+833
|\
| * mtd: peb: Add function to write fileSascha Hauer2019-08-281-0/+84
| | | | | | | | | | | | | | | | | | This adds a function to the mtd peb API to write a file spanning multiple blocks to a mtd device. Bad blocks are automatically skipped and before anything is done we check if the image will fit into the remaining space (honouring bad blocks). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: gpmc: Add BCH16 supportSascha Hauer2019-08-281-8/+325
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for BCH16 ECC encoding. The support is mostly taken from Linux-5.3-rc6. One major change is the different wrap mode used. The Kernel uses wrapmode 1, which means "pass all data through the BCH engine". Still the Kernel has to skip the OOB marker which is done by reading all user data, then use NAND_CMD_RNDOUT to position right behind the OOB marker and then read the ECC data. Instead of doing this we use wrap mode 4 which allows us to bypass the OOB marker from the BCH engine automatically. This explains bch_wrapmode = 1, eccsize0 = 0, eccsize1 = 52 vs. bch_wrapmode = 4, eccsize0 = 4, eccsize1 = 52 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: gpmc: Add support for ELMSascha Hauer2019-08-283-0/+424
| | | | | | | | | | | | | | | | This adds support for the ELM (Error Location Module) found on not-too-old OMAP SoCs. The driver has been taken from Linux-5.3-rc6 with interrupt support removed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/mtd'Sascha Hauer2019-09-1215-219/+215
|\ \
| * | mtd: spi-nor: Import missing Micron devicesAndrey Smirnov2019-09-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | Import entries for n25q00a, mt25qu02g, mt25ql02g, supported by latest Linux kernel. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: spi-nor: Add support for s25fl128s0 s25fl128s1 flashes from LinuxDU HUANPENG2019-09-021-0/+4
| | | | | | | | | | | | | | | | | | | | | These definitions are taken from Linux's spi-nor driver as of v5.2-rc4 Signed-off-by: DU HUANPENG <u74147@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: nand: Embed struct mtd_info into struct nand_chipSascha Hauer2019-08-2610-52/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to what is done in the Kernel. In the Kernel we have a struct nand_device embedded into struct nand_chip and the nand_device has an mtd_info embedded into it. Until we have struct nand_device we embed mtd_info directly into the nand_chip. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: nand: denali: Add variables for mtd_info and nand_chipSascha Hauer2019-08-261-51/+52
| | | | | | | | | | | | | | | | | | | | | | | | Accessing the mtd_info from the nand_chip will change in the next patch, so instead of accessing it each time when used create a variable for mtd_info to keep the next patch smaller. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: nand: Add and use static inline wrapper for getting nand_chip from mtdSascha Hauer2019-08-2612-118/+118
| |/ | | | | | | | | | | | | | | | | All drivers in tree use mtd->priv for the nand_chip. Add and use a static inline wrapper mtd_to_nand() which we already have in the kernel for getting the nand_chip from the mtd_info struct. Next step would be to embed a struct mtd_info into struct nand_chip. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: spi-nor: add support for sst26vf seriesOleksij Rempel2019-08-211-0/+25
| | | | | | | | | | | | | | | | Ported from linux-4.19-at91 linux4sam_6.1 and needed for SAMA5D27 SOM1 EK. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: spi-nor: add UNLOCK_GLOBAL_BLOCK supportOleksij Rempel2019-08-211-1/+24
|/ | | | | | | | Ported from linux-4.19-at91 linux4sam_6.1 and needed for SAMA5D27 SOM1 EK. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd-gpmi-nand'Sascha Hauer2019-08-152-118/+182
|\
| * mtd: nand-mxs: Make ecc strength configurable via device treeSascha Hauer2019-08-061-4/+21
| | | | | | | | | | | | | | | | | | | | | | According to the binding doc the mxs NAND driver supports the "nand-ecc-strength" and "nand-ecc-step-size" options. This adds support for these options to the driver. The "nand-ecc-step-size" is not really configurable, the only accepted value is 512 so this is merely to sanity check that there's nothing specified that we can't yet support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: Add function to parse device tree propertiesSascha Hauer2019-08-061-0/+27
| | | | | | | | | | | | | | This adds nand_of_parse_node() which can be used to parse generic NAND device properties. Not very complete yet, but it's a start. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand-mxs: inline only once used functionSascha Hauer2019-08-061-6/+1
| | | | | | | | | | | | | | mxs_nand_ecc_size_in_bits() is used only once and is simple enough to be inlined. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand-mxs: pass mtd_info to mxs_nand_get_mark_offset()Sascha Hauer2019-08-061-6/+5
| | | | | | | | | | | | | | struct mtd_info * contains everything mxs_nand_get_mark_offset() needs, so pass this pointer rather than several integer arguments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand-mxs: change API between NAND driver and fcb codeSascha Hauer2019-08-061-29/+33
| | | | | | | | | | | | | | | | | | | | | | | | The imx-bbu-nand-fcb update handler code calls into the NAND driver to get the ecc strength and bad block marker position. Change the API so that only a single function is necessary and not three functions. Also in future the ecc strength will be configurable via device tree. This means static parameters like page size / oob size are no longer enough to calculate the ecc strength and so we store a pointer to our mtd_info struct in a static global variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand-mxs: Make locally used variable staticSascha Hauer2019-08-061-3/+1
| | | | | | | | | | | | | | fake_ecc_layout is only used in the mxs nand driver, so make it static. Also it's not necessary to zero the structure. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand-mxs: calculate ecc_strength only onceSascha Hauer2019-08-061-12/+36
| | | | | | | | | | | | | | | | | | | | Instead of calculating the ecc strength multiple times with each page read just do it once and store the result in chip->ecc.strength. While at it also store the correct value in chip->ecc.bytes instead of writing a bogus value into it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand-mxs: consistently rename struct nand_chip * to "chip"Sascha Hauer2019-08-061-74/+74
| | | | | | | | | | | | | | The struct nand_chip * is sometimes named "nand" and sometimes "chip". For consistency name it "chip" throughout the driver. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: spi-nor: fix page offset/remains calculation in spi_nor_writeBastian Krause2019-08-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | nor->write() simply adds the number of written bytes to the pointer given. Thus retval is incremented in each loop cycle for each spi_nor_write() call without ever resetting it. This leads to wrong page offset/remains calculations and an incorrect number of bytes written to retlen. This becomes apparant only if the calling function actually compares len and retlen (e.g. mtd_peb_write() ). Otherwise wrong data is written: $ memcpy -s /dev/prng -d prng_data 0 0 10k $ erase /dev/mtd0.mypart $ cp prng_data /dev/mtd0.mypart $ memcmp -s prng_data -d /dev/mtd0.mypart 0 0 memcmp returned "files differ" before, with this patch it returns "OK". Fixes: c8516869c4 ("spi: Extend the core to ease integration of SPI memory controllers") Signed-off-by: Bastian Krause <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: nand: Add ecc parameters as device parametersSascha Hauer2019-07-181-0/+4
| | | | | | | | | | | | | | The ecc strength/bytes/size values are useful informations sometimes, add them as device parameters. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | UBI: silence erroneous GCC warning about uninitialized readAhmad Fatoum2019-07-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC reports following use of an uninitialized variable: ./drivers/mtd/ubi/eba.c: In function 'try_write_vid_and_data': ./drivers/mtd/ubi/eba.c:904:9: warning: 'opnum' may be used uninitialized in this function [-Wmaybe-uninitialized] err = ubi_wl_put_peb(ubi, vol_id, lnum, opnum, 0); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is incorrect, because it's only called when err == 0 and opnum is always initialized if err == 0. Silence the warning by initializing a variable. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: peb: Do not mark as bad in mtd_peb_torture()Sascha Hauer2019-07-161-6/+3
| | | | | | | | | | | | | | | | | | | | | | Both the Kernel and mtd-utils have peb torture functions and both do not mark the block as bad automatically. Instead, the caller must mark the block as bad when -EIO is returned from the torture function. Do the same in barebox. This is necessary as the UBI code otherwise may mark a block as bad twice: Once indirectly in mtd_peb_torture() and then directly afterwards. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: ubi: mark PEBs as bad on erase failureSascha Hauer2019-07-153-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | 70542a9c65 converted UBI to use mtd_peb_torture(). It was assumed that a block was marked as bad when it didn't pass the torture test. However, not all possibly bad blocks went through the torture test, so it could happen that a block that could not be erased was still kept as good block. This patch fixes this and explicitly calls ubi_io_mark_bad() when a block cannot be erased. Fixes: 70542a9c65 ("mtd: ubi: Use mtd_peb_torture") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: spi-nor: Add support for ISSI flashes from LinuxUwe Kleine-König2019-06-171-0/+21
|/ | | | | | | The definitions are taken from Linux's spi-nor driver as of v5.2-rc4. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2019-06-111-1/+1
|\
| * treewide: replace '---help---' with 'help' in Kconfig filesMasahiro Yamada2019-05-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Linux, '---help---' was deprecated in favor of 'help', and this is checked by the recent checkpatch.pl See Linux commit 84af7a6194e493fae312a2b7fa5a3b51f76d9282 The number of '---help---' is gradually decreasing in Linux, but there are still lots. However, '---help---' will be completely killed when the time comes. Fortunately, there are only some in Barebox. Replacing them is not hard. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nand: nand_mxs: Do not zero out DMA coherent memoryAndrey Smirnov2019-05-281-3/+0
|/ | | | | | | | Memory returned by dma_alloc_coherent() should already be zeroed out, so there's no need to do this explicitly. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/qspi'Sascha Hauer2019-05-104-365/+725
|\
| * mtd: spi-nor: Add support for more Macronix devicesSascha Hauer2019-05-081-0/+3
| | | | | | | | | | | | Add support for the Macronix mx66u51235f, mx66l1g45g and mx66l1g55g. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: devices: m25p80: use the spi_mem_xx() APISteffen Trumtrar2019-05-082-82/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the barebox adoption of the linux v4.16 patch 4120f8d158ef904fb305b27e4a4524649faf3096 Author: Boris Brezillon <bbrezillon@kernel.org> AuthorDate: Thu Apr 26 18:18:19 2018 +0200 Commit: Mark Brown <broonie@kernel.org> CommitDate: Fri May 11 11:33:51 2018 +0900 mtd: spi-nor: Use the spi_mem_xx() API The spi_mem_xxx() API has been introduced to replace the spi_flash_read() one. Make use of it so we can get rid of spi_flash_read(). Note that using spi_mem_xx() also simplifies the code because this API takes care of using the regular spi_sync() interface when the optimized ->mem_ops interface is not implemented by the controller. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Frieder Schrempf <frieder.schrempf@exceet.de> Tested-by: Frieder Schrempf <frieder.schrempf@exceet.de> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: spi-nor: provide default erase_sector implementationSteffen Trumtrar2019-05-081-4/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on the Linux v4.4 patch commit c67cbb839da9cc2757eabfa128556db6a2baf160 Author: Brian Norris <computersforpeace@gmail.com> AuthorDate: Tue Nov 10 12:15:27 2015 -0800 Commit: Brian Norris <computersforpeace@gmail.com> CommitDate: Thu Nov 19 13:34:44 2015 -0800 mtd: spi-nor: provide default erase_sector implementation Some spi-nor drivers perform sector erase by duplicating their write_reg() command. Let's not require that the driver fill this out, and provide a default instead. Tested on m25p80.c and Medatek's MT8173 SPI NOR flash driver. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: spi-nor: introduce SPI 1-2-2 and SPI 1-4-4 protocolsSteffen Trumtrar2019-05-083-204/+511
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sync the driver with Linux v4.12 and apply the patch commit cfc5604c488ccd17936b69008af0c9ae050f4a08 Author: Cyrille Pitchen <cyrille.pitchen@atmel.com> AuthorDate: Tue Apr 25 22:08:46 2017 +0200 Commit: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr> CommitDate: Mon May 15 21:56:17 2017 +0200 mtd: spi-nor: introduce SPI 1-2-2 and SPI 1-4-4 protocols This patch changes the prototype of spi_nor_scan(): its 3rd parameter is replaced by a 'struct spi_nor_hwcaps' pointer, which tells the spi-nor framework about the actual hardware capabilities supported by the SPI controller and its driver. Besides, this patch also introduces a new 'struct spi_nor_flash_parameter' telling the spi-nor framework about the hardware capabilities supported by the SPI flash memory and the associated settings required to use those hardware caps. Then, to improve the readability of spi_nor_scan(), the discovery of the memory settings and the memory initialization are now split into two dedicated functions. 1 - spi_nor_init_params() The spi_nor_init_params() function is responsible for initializing the 'struct spi_nor_flash_parameter'. Currently this structure is filled with legacy values but further patches will allow to override some parameter values dynamically, for instance by reading the JESD216 Serial Flash Discoverable Parameter (SFDP) tables from the SPI memory. The spi_nor_init_params() function only deals with the hardware capabilities of the SPI flash memory: especially it doesn't care about the hardware capabilities supported by the SPI controller. 2 - spi_nor_setup() The second function is called once the 'struct spi_nor_flash_parameter' has been initialized by spi_nor_init_params(). With both 'struct spi_nor_flash_parameter' and 'struct spi_nor_hwcaps', the new argument of spi_nor_scan(), spi_nor_setup() computes the best match between hardware caps supported by both the (Q)SPI memory and controller hence selecting the relevant settings for (Fast) Read and Page Program operations. Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com> Reviewed-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: spi-nor: remove unused write_enable from write_regSteffen Trumtrar2019-05-083-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on the Linux v4.2 commit: commit f9f3ce835ddce3c669eee869253105f88819888b Author: Jagan Teki <jteki@openedev.com> AuthorDate: Wed Aug 19 15:26:44 2015 +0530 Commit: Brian Norris <computersforpeace@gmail.com> CommitDate: Fri Sep 11 16:04:55 2015 -0700 mtd: spi-nor: Zap unneeded write_enable from write_reg The 'write_enable' argument is unused and unneeded, so remove it from the API. Signed-off-by: Jagan Teki <jteki@openedev.com> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Han Xu <han.xu@freescale.com> [Brian: fixed for nxp-spifi.c] Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * spi: Extend the core to ease integration of SPI memory controllersSteffen Trumtrar2019-05-081-23/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sync with Linux v5.1-rc1. This is the barebox adoption of the commit commit c36ff266dc82f4ae797a6f3513c6ffa344f7f1c7 Author: Boris Brezillon <boris.brezillon@bootlin.com> Date: Thu Apr 26 18:18:14 2018 +0200 spi: Extend the core to ease integration of SPI memory controllers Some controllers are exposing high-level interfaces to access various kind of SPI memories. Unfortunately they do not fit in the current spi_controller model and usually have drivers placed in drivers/mtd/spi-nor which are only supporting SPI NORs and not SPI memories in general. This is an attempt at defining a SPI memory interface which works for all kinds of SPI memories (NORs, NANDs, SRAMs). Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Frieder Schrempf <frieder.schrempf@exceet.de> Tested-by: Frieder Schrempf <frieder.schrempf@exceet.de> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: spi-nor: cadence: add cqspi_set_protocolSteffen Trumtrar2019-05-081-63/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | Sync up the driver with the original linux v4.7 driver version. As only Quad-SPI mode is/was supported, the function was not ported in the initial move to barebox. To make future synchronizations with the kernel driver easier, add this function and reorder the functions in the driver accordingly. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2019-05-101-1/+0
|\ \
| * | UBI: remove Kconfig entry from includeJan Remmet2019-05-061-1/+0
| |/ | | | | | | | | | | | | | | CONFIG_MTD_UBI_WL_THRESHOLD can be set via Kconfig. default there is also 4096. So remove the leftover here. Signed-off-by: Jan Remmet <j.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / mtd: spi-nor: add Winbond W25Q40BWAlexander Kurz2019-04-231-0/+1
|/ | | | | | | This 4MBit SPI chip can be found in Kindle Voyage devices Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2019-02-132-1/+29
|\
| * mtd: peb: Add function to skip bad blocksSascha Hauer2019-01-281-0/+27
| | | | | | | | | | | | | | | | This adds a function that given a pointer to a PEB number increases the number until the corresponding PEB is good. It also checks for the PEB number being inside the mtd device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ubi: prevent null pointer referenceRoland Hieber2019-01-221-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After flashing a bogus UBI image, e.g. when the UBI is bigger than the available flash size, it can happen that barebox hangs itself with a stacktrace when the board code or the environment does a ubi_attach() on boot: ERROR: ubi0 error: init_volumes: not enough PEBs, required 7478, available 4024 unable to handle NULL pointer dereference at address 0x00000204 pc : [<1fd1eaf2>] lr : [<1fd15aad>] sp : 1feefd30 ip : 0000000a fp : 1fd5d1d7 r10: 00001d34 r9 : 00000000 r8 : 1fd5d540 r7 : 14983148 r6 : 00000006 r5 : ffffffe4 r4 : 14983004 r3 : 1fd82bfc r2 : 021f0000 r1 : 0000000a r0 : 00000000 Flags: nzcv IRQs off FIQs off Mode SVC_32 [<1fd1eaf2>] (ubi_fastmap_destroy_checkmap+0x8/0xa) from [<1fd15aad>] (ubi_read_volume_table+0x4d9/0x71c) [<1fd15aad>] (ubi_read_volume_table+0x4d9/0x71c) from [<1fd1cbf7>] (ubi_attach+0x157/0x1f8) [<1fd1cbf7>] (ubi_attach+0x157/0x1f8) from [<1fd16ec3>] (ubi_attach_mtd_dev+0x4a3/0x954) [...] After this change, barebox at least boots to a prompt where the faulty flash can be repaired: ERROR: ubi0 error: init_volumes: not enough PEBs, required 7478, available 4024 ERROR: ubi0 error: ubi_attach_mtd_dev: failed to attach mtd0, error -28 [...] running /env/bin/init... barebox@boardname:/ Signed-off-by: Roland Hieber <rhi@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: devfs: Change .lseek callbacks to return 'int'Andrey Smirnov2019-02-042-6/+5
| | | | | | | | | | | | | | | | | | | | | | Returning requested offset from .lseek() callback doesn't really give us any new information while bringing unnecessary complications. Change all .lseek() types (both in struct struct cdev_operations and in struct fs_driver_d) to return 'int' and adjust the rest of the codebase accordingly. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | devfs: Drop dev_lseek_default()Andrey Smirnov2019-01-293-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only the following cdevs do not declare an .lseek() operation: - Console devices in common/console.c - Firmware framework in common/firmware.c - JTAG driver in drivers/misc/jtag.c - UBI in drivers/mtd/ubi/barebox.c Of those four, first two are marked DEVFS_IS_CHARACTER_DEV and implement only .write() operation and the last two don't implement anything but .ioctl(). While there's probably no meaningful way to use lseek() against any of those devices, there doesn't seem to be any harm in allowing it either. Change devfs_lseek() to ignore absense of .lseek() callback and drop dev_lseek_default() and all references to it in the codebase. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Revert "mtd: nand: Kill the chip->scan_bbt() hook"Sascha Hauer2019-01-214-16/+29
|/ | | | This reverts commit 95ce69795506293eae28d6e64055d2c7ae27f164.
* Merge branch 'for-next/mtd'Sascha Hauer2019-01-157-315/+418
|\