summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/io.c
Commit message (Collapse)AuthorAgeFilesLines
* ubi: Fix repeated words in commentsJilin Yuan2022-09-211-1/+1
| | | | | | | | Delete the redundant word 'a'. Delete the redundant word 'the'. Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com> Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: remove dead code in validate_vid_hdr()Jubin Zhong2021-02-121-6/+1
| | | | | | | | data_size is already checked against zero when vol_type matches UBI_VID_STATIC. Remove the following dead code. Signed-off-by: Jubin Zhong <zhongjubin@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Do not zero out EC and VID on ECC-ed NOR flashesPratyush Yadav2020-12-131-1/+8
| | | | | | | | | | | | | | | | | | For NOR flashes EC and VID are zeroed out before an erase is issued to make sure UBI does not mistakenly treat the PEB as used and associate it with an LEB. But on some flashes, like the Cypress Semper S28 SPI NOR flash family, multi-pass page programming is not allowed on the default ECC scheme. This means zeroing out these magic numbers will result in the flash throwing a page programming error. Do not zero out EC and VID for such flashes. A writesize > 1 is an indication of an ECC-ed flash. Signed-off-by: Pratyush Yadav <p.yadav@ti.com> Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com> Signed-off-by: Richard Weinberger <richard@nod.at>
* mm: remove the pgprot argument to __vmallocChristoph Hellwig2020-06-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The pgprot argument to __vmalloc is always PAGE_KERNEL now, so remove it. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Michael Kelley <mikelley@microsoft.com> [hyperv] Acked-by: Gao Xiang <xiang@kernel.org> [erofs] Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Wei Liu <wei.liu@kernel.org> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: Christophe Leroy <christophe.leroy@c-s.fr> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: David Airlie <airlied@linux.ie> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Haiyang Zhang <haiyangz@microsoft.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: "K. Y. Srinivasan" <kys@microsoft.com> Cc: Laura Abbott <labbott@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Nitin Gupta <ngupta@vflare.org> Cc: Robin Murphy <robin.murphy@arm.com> Cc: Sakari Ailus <sakari.ailus@linux.intel.com> Cc: Stephen Hemminger <sthemmin@microsoft.com> Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Paul Mackerras <paulus@ozlabs.org> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Will Deacon <will@kernel.org> Link: http://lkml.kernel.org/r/20200414131348.444715-22-hch@lst.de Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156Thomas Gleixner2019-05-301-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 59 temple place suite 330 boston ma 02111 1307 usa extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 1334 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Richard Fontana <rfontana@redhat.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mtd: Unconditionally update ->fail_addr and ->addr in part_erase()Boris Brezillon2018-03-151-1/+0
| | | | | | | | | | | | | | | | | ->fail_addr and ->addr can be updated no matter the result of parent->_erase(), we just need to remove the code doing the same thing in mtd_erase_callback() to avoid adjusting those fields twice. Note that this can be done because all MTD users have been converted to not pass an erase_info->callback() and are thus only taking the ->addr_fail and ->addr fields into account after part_erase() has returned. While we're at it, get rid of the erase_info->mtd field which was only needed to let mtd_erase_callback() get the partition device back. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Richard Weinberger <richard@nod.at>
* mtd: Stop assuming mtd_erase() is asynchronousBoris Brezillon2018-03-151-35/+0
| | | | | | | | | | None of the mtd->_erase() implementations work in an asynchronous manner, so let's simplify MTD users that call mtd_erase(). All they need to do is check the value returned by mtd_erase() and assume that != 0 means failure. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Richard Weinberger <richard@nod.at>
* UBI: Fix typosAndrew F. Davis2017-03-241-1/+1
| | | | | Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* UBI: introduce the VID buffer conceptBoris Brezillon2016-10-021-17/+22
| | | | | | | | | | | | | | | | | | | | Currently, all VID headers are allocated and freed using the ubi_zalloc_vid_hdr() and ubi_free_vid_hdr() function. These functions make sure to align allocation on ubi->vid_hdr_alsize and adjust the vid_hdr pointer to match the ubi->vid_hdr_shift requirements. This works fine, but is a bit convoluted. Moreover, the future introduction of LEB consolidation (needed to support MLC/TLC NANDs) will allows a VID buffer to contain more than one VID header. Hence the creation of a ubi_vid_io_buf struct to attach extra information to the VID header. We currently only store the actual pointer of the underlying buffer, but will soon add the number of VID headers contained in the buffer. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Only read necessary size when reading the VID headerSascha Hauer2016-07-291-1/+1
| | | | | | | | | | | | | | When reading the vid hdr from the device UBI always reads a whole page. Instead, read only the data we actually need and speed up attachment of UBI devices by potentially making use of reading subpages if the NAND driver supports it. Since the VID header may be at offset vid_hdr_shift in the page and we can only read from the beginning of a page we have to add that offset to the read size. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
* UBI: fix use of "VID" vs. "EC" in header self-checkBrian Norris2015-12-161-1/+1
| | | | | | | | | | | | | | | | | Looks like a typo, using UBI_EC_HDR_SIZE_CRC (note the "EC") to compute the CRC for the VID header. This shouldn't cause any functional change, as both structures are 64 bytes. Verified with: BUILD_BUG_ON(UBI_VID_HDR_SIZE_CRC != UBI_EC_HDR_SIZE_CRC); Reported here: http://lists.infradead.org/pipermail/linux-mtd/2013-September/048570.html Reported by: Bill Pringlemeir <bpringlemeir@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Richard Weinberger <richard@nod.at>
* UBI: Validate data_sizeRichard Weinberger2015-09-291-0/+5
| | | | | | | | | | Make sure that data_size is less than LEB size. Otherwise a handcrafted UBI image is able to trigger an out of bounds memory access in ubi_compare_lebs(). Cc: stable@vger.kernel.org Signed-off-by: Richard Weinberger <richard@nod.at> Reviewed-by: David Gstir <david@sigma-star.at>
* UBI: power cut emulation for testingdavid.oberhollenzer@sigma-star.at2015-04-131-0/+6
| | | | | | | | | | | | Emulate random power cuts by switching device to ro after a number of writes to allow simple power cut testing with nand-sim. Maximum and minimum number of successful writes before power cut and what kind of writes (EC header, VID header or none) to interrupt configurable via debugfs. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
* UBI: extend UBI layer debug/messaging capabilities - cosmeticsTanya Brokhman2015-01-281-2/+1
| | | | | | | | Some cosmetic fixes to the patch "UBI: Extend UBI layer debug/messaging capabilities". Signed-off-by: Tanya Brokhman <tlinder@codeaurora.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: Extend UBI layer debug/messaging capabilitiesTanya Brokhman2014-11-071-73/+77
| | | | | | | | | | | | | | If there is more then one UBI device mounted, there is no way to distinguish between messages from different UBI devices. Add device number to all ubi layer message types. The R/O block driver messages were replaced by pr_* since ubi_device structure is not used by it. Amended a bit by Artem. Signed-off-by: Tanya Brokhman <tlinder@codeaurora.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: avoid program operation on NOR flash after erasure interruptedQi Wang 王起 (qiwang)2014-01-091-32/+22
| | | | | | | | | | | | | | | | | | nor_erase_prepare() will be called before erase a NOR flash, it will program '0' into a block to mark this block. But program data into a erasure interrupted block can cause program timtout(several minutes at most) error, could impact other operation on NOR flash. So UBIFS can read this block first to avoid unneeded program operation. This patch try to put read operation at head of write operation in nor_erase_prepare(), read out the data. If the data is already corrupt, then no need to program any data into this block, just go to erase this block. This patch is validated on Micron NOR flash, part number is:JS28F512M29EWHA Signed-off-by: Qi Wang <qiwang@micron.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: introduce helpers dbg_chk_{io, gen}Ezequiel Garcia2012-12-101-7/+7
| | | | | | | | | | With this patch code is a bit more readable and there's no generated code or functionality impact. Furthermore, this abstracts implementation details and will allow to change ubi_debug_info in a less invasive way. Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: print lessArtem Bityutskiy2012-09-041-1/+1
| | | | | | | | | | | UBI currently prints a lot of information when it mounts a volume, which bothers some people. Make it less chatty - print only important information by default. Get rid of 'dbg_msg()' macro completely. Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: comply with coding styleArtem Bityutskiy2012-09-041-40/+38
| | | | | | Join all the split printk lines in order to stop checkpatch complaining. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: amend comments after all the renamingsArtem Bityutskiy2012-05-201-2/+1
| | | | | | | | | | This patch amends commentaries in scan.[ch] to match the new logic. Reminder - we did the restructuring to prepare the code for adding the fastmap. This patch also renames a couple of functions - it was too difficult to separate out that change and I decided that it is not too bad to have it in the same patch with commentaries changes. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: rename few functions for consistencyArtem Bityutskiy2012-05-201-9/+11
| | | | Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: get rid of dbg_errArtem Bityutskiy2012-05-201-18/+18
| | | | | | | | This patch removes the 'dbg_err()' macro and we now use 'ubi_err' instead. The idea of 'dbg_err()' was to compile out some error message to make the binary a bit smaller - but I think it was a bad idea. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: clean-up terminology for self-checks in io.cArtem Bityutskiy2012-05-201-39/+37
| | | | | | | | | | | We have the "sefl-check" feature in UBI, but for historical reasons many corresponding functions and commentaries in the code use term "paranoid check" instead. Let's clean this up and use "self-check" everywhere. This patch renames functions, amends comments and messages. It touches only the io.c file. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: remove Kconfig debugging optionArtem Bityutskiy2012-05-201-12/+0
| | | | | | | | | This patch kills the UBI debugging Kconfig option completely and makes all the debugging stuff to be always compiled-in. It was pain in the neck to maintain this useless option because all users I am aware of have debugging enabled anyway - how else will you diagnose errors otherwise? Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: always warn if case of I/O errorsArtem Bityutskiy2012-05-201-6/+6
| | | | | | | | Currently UBI silently retries I/O operation in case of errors. This patch makes it emit a warning before retrying. This should allow users notice issues earlier. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: always dump VID and EC headers in case of errorsArtem Bityutskiy2012-05-201-10/+10
| | | | | | | | | | | UBI (and UBIFS) are a bit over-engineered WRT debugging. The idea was to link as few as possible when debugging is disabled, but the downside is that most people produce bug reports which are difficult to understand. Always dump the VID and EC headers' contents in case of errors when it is helpful. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* UBI: always dump flash contents in case of errorsArtem Bityutskiy2012-05-201-2/+2
| | | | | | | | | | | UBI (and UBIFS) are a bit over-engineered WRT debugging. The idea was to link as few as possible when debugging is disabled, but the downside is that most people produce bug reports which are difficult to understand. Always dump the flash contents in case of errors, not only when debugging is enabled. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
* UBI: always dump the stack on errorArtem Bityutskiy2012-05-201-14/+14
| | | | | | | | | | | | UBI (and UBIFS) are a bit over-engineered WRT debugging. The idea was to link as few as possible when debugging is disabled, but the downside is that most people produce bug reports which are difficult to understand. This patch weeds out the 'ubi_dbg_dump_stack()' function and turns it into 'dump_stack()' - it is always useful to have stack dump in case of an error. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
* UBI: rename peb_buf1 to peb_bufArtem Bityutskiy2012-03-091-7/+7
| | | | | | Now we have only one buffer so let's rename it to just 'peb_buf1'. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* mtd: introduce mtd_block_markbad interfaceArtem Bityutskiy2012-01-091-1/+1
| | | | | Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
* mtd: introduce mtd_block_isbad interfaceArtem Bityutskiy2012-01-091-1/+1
| | | | | Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
* mtd: introduce mtd_write interfaceArtem Bityutskiy2012-01-091-4/+3
| | | | | Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
* mtd: introduce mtd_read interfaceArtem Bityutskiy2012-01-091-3/+3
| | | | | Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
* mtd: introduce mtd_erase interfaceArtem Bityutskiy2012-01-091-1/+1
| | | | | | | | | | | | | | | | | | | This patch is part of a patch-set which changes the MTD interface from 'mtd->func()' form to 'mtd_func()' form. We need this because we want to add common code to to all drivers in the mtd core level, which is impossible with the current interface when MTD clients call driver functions like 'read()' or 'write()' directly. At this point we just introduce a new inline wrapper function, but later some of them are expected to gain more code. E.g., the input parameters check should be moved to the wrappers rather than be duplicated at many drivers. This particular patch introduced the 'mtd_erase()' interface. The following patches add all the other interfaces one by one. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
* mtd: utilize `mtd_is_*()' functionsBrian Norris2011-09-211-12/+12
| | | | | Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
* UBI: prepare debugging stuff to further debugfs conversionArtem Bityutskiy2011-06-011-3/+3
| | | | | | | | We'll need the 'struct ubi_device *ubi' pointer in every debugging function (to access the ->dbg field), so add this pointer to all the functions implementing UBI debugging test modes like 'ubi_dbg_is_bitflip()' etc. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: use debugfs for the extra checks knobsArtem Bityutskiy2011-06-011-7/+7
| | | | | | | | | | This patch introduces debugfs support to UBI. All the UBI stuff is kept in the "ubi" debugfs directory, which contains per-UBI device "ubi/ubiX" sub-directories, containing debugging files. This file also creates "ubi/ubiX/chk_gen" and "ubi/ubiX/chk_io" knobs for switching general and I/O extra checks on and off. And it removes the 'debug_chks' UBI module parameters. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix typo in a messageArtem Bityutskiy2011-04-141-1/+1
| | | | | | | | When a PEB passes the torture test, UBI prints "do not mark it a bad", but should print "do not mark it as bad". This patch corrects the typo. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix minor stylistic issuesArtem Bityutskiy2011-04-141-2/+2
| | | | | | | | | | Fix checkpatch.pl errors and warnings: * space before tab * line over 80 characters * include linux/ioctl.h instead of asm/ioctl.h Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: check if we are in RO mode in the erase routineArtem Bityutskiy2011-04-051-1/+7
| | | | | | | | | | 'do_sync_erase()' has to check whether we are in R/O mode before erasing the PEB. This patch adds the check and while on it, adds an assertion which validates the 'pnum' argument, as well as removes a check which is always true because it has already been done few lines before. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: use GFP_NOFS properlyArtem Bityutskiy2011-03-241-2/+2
| | | | | | | | | This patch fixes a brown-paperbag bug which was introduced by me: I used incorrect "GFP_KERNEL | GFP_NOFS" allocation flags to make sure my allocations do not cause write-back. But the correct form is "GFP_NOFS". Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: make self-checks dynamicArtem Bityutskiy2011-03-161-3/+24
| | | | | | | | | | | | | | This patch adds a possibility to dynamically switch UBI self-checks on and off, instead of toggling them compile-time from the configuration menu. This is much more flexible, and consistent with UBIFS, and this also simplifies UBI Kconfig menu and the code. This patch introduces two levels of self-checks - general, which includes all self-checks which are relatively fast, and I/O, which includes write-verify checks and erase-verify checks, which are relatively slow and involve flash I/O. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: remove UBI_IO_DEBUG macroArtem Bityutskiy2011-03-161-18/+16
| | | | | | | | | This additional little macro is used to print a bit more messages while scanning the media. However, we have the 'dbg_bld()' macro for this, so we better us 'dbg_bld()' and kill UBI_IO_DEBUG. This simplifies the code a tiny bit. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: allocate erase checking buffer on demandArtem Bityutskiy2011-03-161-7/+12
| | | | | | | | | | | | | | | | Instead of using pre-allocated 'ubi->dbg_peb_buf' buffer in 'ubi_dbg_check_all_ff()', dynamically allocate it when needed. The intend is to get rid of the pre-allocated 'ubi->dbg_peb_buf' buffer completely. And the need for this arises because we want to change to dynamic debugging control instead of compile-time control, i.e., we are going to kill the CONFIG_MTD_UBI_DEBUG_PARANOID Kconfig option, which would mean that 'ubi->dbg_peb_buf' is always allocated, which would be wasteful. Thus, we are getting rid of 'ubi->dbg_peb_buf', and this is a preparation for that. signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: allocate write checking buffer on demandArtem Bityutskiy2011-03-161-9/+15
| | | | | | | | | | | | | | | | Instead of using pre-allocated 'ubi->dbg_peb_buf' buffer in 'ubi_dbg_check_write()', dynamically allocate it when needed. The intend is to get rid of the pre-allocated 'ubi->dbg_peb_buf' buffer completely. And the need for this arises because we want to change to dynamic debugging control instead of compile-time control, i.e., we are going to kill the CONFIG_MTD_UBI_DEBUG_PARANOID Kconfig option, which would mean that 'ubi->dbg_peb_buf' is always allocated, which would be wasteful. Thus, we are getting rid of 'ubi->dbg_peb_buf', and this is a preparation for that. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: always re-read in case of read failuresArtem Bityutskiy2011-02-061-1/+1
| | | | | | | | | | | | | When the read operation fails, UBI tries to re-read several times in a hope that one of the subsequent reads may succeed. However, currently UBI re-reads only if MTD failed to read all data, but does not re-reads if all the data were read, but with an integrity error (-EBADMSB). This patch makes UBI to always re-try reading. This should be useful for reading NAND pages with unstable bits - re-reading may help to get correct data. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: use raw mtd read function in debugging codeArtem Bityutskiy2011-02-061-2/+4
| | | | | | | | This change affects only the debugging code. Namely, use mtd->read() function instead of ubi_io_read() to avoid bit-flips injection (ubi_dbg_is_bitflip()) which we do not want on the debugging path. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: try to reveal buggy MTD driversArtem Bityutskiy2011-02-061-0/+22
| | | | | | | | | | | | | | | | | | | | | When reading data from the flash, corrupt the buffer we are about to read to. The idea is to fix the following possible situation: 1. The buffer contains data from previous operation, e.g., read from another PEB previously. The data looks like expected, e.g., if we just do not read anything and return - the caller would not notice this. E.g., if we are reading a VID header, the buffer may contain a valid VID header from another PEB. 2. The driver is buggy and returns use success or -EBADMSG or -EUCLEAN, but it does not actually put any data to the buffer. This may confuse UBI or upper layers - they may think the buffer contains valid data while in fact it is just old data. Thus, try to reveal such buggy MTD drivers with simple debugging code which fills the read buffer with 0x12 constant. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: add a commentary about allocating VID header buffer on stackArtem Bityutskiy2011-01-261-0/+7
| | | | Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix NOR erase preparation quirkHolger Brunck2011-01-261-2/+4
| | | | | | | | | | In 'nor_erase_prepare()' we want to make sure the UBI headers are corrupted. But it is possible that one of the headers just contains all 0xFFs, which is also OK, because UBI will erase it in case of a power cut. Signed-off-by: Holger Brunck <holger.brunck@keymile.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>