aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdpart.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-06-23mtd: partitions: fixup some allocate_partition() whitespaceBrian Norris1-3/+3
Some recent patches caused churn around this area, and checkpatch noticed the existing issues. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2017-06-22mtd: partitions: add support for partition parsersRafał Miłecki1-0/+31
Some devices have partitions that are kind of containers with extra subpartitions / volumes instead of e.g. a simple filesystem data. To support such cases we need to first create normal flash device partitions and then take care of these special ones. It's very common case for home routers. Depending on the vendor there are formats like TRX, Seama, TP-Link, WRGG & more. All of them are used to embed few partitions into a single one / single firmware file. Ideally all vendors would use some well documented / standardized format like UBI (and some probably start doing so), but there are still countless devices on the market using these poor vendor specific formats. This patch extends MTD subsystem by allowing to specify list of parsers that should be tried for a given partition. Supporting such poor formats is highly unlikely to be the top priority so these changes try to minimize maintenance cost to the minimum. It reuses existing code for these new parsers and just adds a one property and one new function. This implementation requires setting partition parsers in a flash parser. A proper change of bcm47xxpart will follow and in the future we will hopefully also find a solution for doing it with ofpart ("fixed-partitions"). Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2017-06-22mtd: partitions: add support for subpartitionsRafał Miłecki1-7/+16
Some flash device partitions can be containers with extra subpartitions (volumes). All callbacks are already capable of this additional level of indirection. This patch makes sure we always display subpartitions using a tree structure and takes care of deleting subpartitions when parent gets removed. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2017-06-22mtd: partitions: rename "master" to the "parent" where appropriateRafał Miłecki1-99/+105
This prepares mtd subsystem for the new feature: subpartitions. In some cases flash device partition can be a container with extra subpartitions (volumes). So far there was a flat structure implemented. One master (flash device) could be partitioned into few partitions. Every partition got its master and it was enough to get things running. To support subpartitions we need to store pointer to the parent for each partition. This is required to implement more natural tree structure and handle all recursion and offsets calculation. To make code consistent this patch renamed "master" to the "parent" in places where we can be dealing with subpartitions. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2017-06-22mtd: partitions: remove sysfs files when deleting all master's partitionsRafał Miłecki1-2/+2
When support for sysfs "offset" file was added it missed to update the del_mtd_partitions function. It deletes partitions just like mtd_del_partition does so both should also take care of removing sysfs files. This change moves sysfs_remove_files call to the shared function to fix this issue. Fixes: a62c24d755291 ("mtd: part: Add sysfs variable for offset of partition") Cc: Dan Ehrenberg <dehrenberg@chromium.org> Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2017-06-22mtd: partitions: add helper for deleting partitionRafał Miłecki1-32/+43
There are two similar functions handling deletion. One handles single partition and another the whole MTD flash device. They share (duplicate) some code so it makes sense to add a small helper for that part. Function del_mtd_partitions has been moved a bit to keep all deleting stuff together. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2017-06-20mtd: partitions: factor out code calling parserBrian Norris1-9/+24
This code is going to be reused for parsers matched using OF so let's factor it out to make this easier. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Acked-by: Brian Norris <computersforpeace@gmail.com>
2017-06-13mtd: handle partitioning on devices with 0 erasesizeChris Packham1-9/+17
erasesize is meaningful for flash devices but for SRAM there is no concept of an erase block so erasesize is set to 0. When partitioning these devices instead of ensuring partitions fall on erasesize boundaries we ensure they fall on writesize boundaries. Helped-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2017-02-09mtd: Add partition device node to mtd partition devicesSascha Hauer1-0/+1
The user visible change here is that mtd partitions get an of_node link in sysfs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2017-02-08mtd: introduce function max_bad_blocksJeff Westfahl1-0/+10
If implemented, 'max_bad_blocks' returns the maximum number of bad blocks to reserve for a MTD. An implementation for NAND is coming soon. Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com> Signed-off-by: Zach Brown <zach.brown@ni.com> Acked-by: Boris Brezillon <boris.brezillon@free-electron.com> Acked-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2016-10-11treewide: remove redundant #include <linux/kconfig.h>Masahiro Yamada1-1/+0
Kernel source files need not include <linux/kconfig.h> explicitly because the top Makefile forces to include it with: -include $(srctree)/include/linux/kconfig.h This commit removes explicit includes except the following: * arch/s390/include/asm/facilities_src.h * tools/testing/radix-tree/linux/kernel.h These two are used for host programs. Link: http://lkml.kernel.org/r/1473656164-11929-1-git-send-email-yamada.masahiro@socionext.com Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-10-08Merge tag '4.9/mtd-pairing-scheme' of github.com:linux-nand/linuxBrian Norris1-0/+1
Introduction of the MTD pairing scheme concept.
2016-09-28mtdpart: Propagate _get/put_device()Richard Weinberger1-0/+18
If the master device has callbacks for _get/put_device() and this MTD has slaves a get_mtd_device() call on paritions will never issue the registered callbacks. Fix this by propagating _get/put_device() down. Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2016-09-15mtd: introduce the mtd_pairing_scheme conceptBoris Brezillon1-0/+1
MLC and TLC NAND devices are using NAND cells exposing more than one bit, but instead of attaching all the bits in a given cell to a single NAND page, each bit is usually attached to a different page. This concept is called 'page pairing', and has significant impacts on the flash storage usage. The main problem showed by these devices is that interrupting a page program operation may not only corrupt the page we are programming but also the page it is paired with, hence the need to expose to MTD users the pairing scheme information. The pairing APIs allows one to query pairing information attached to a given page (here called wunit), or the other way around (the wunit pointed by pairing information). It also provides several helpers to help the conversion between absolute offsets and wunits, and query the number of pairing groups. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Reviewed-by: Brian Norris <computersforpeace@gmail.com>
2016-04-19mtd: create an mtd_ooblayout_ops struct to ease ECC layout definitionBoris Brezillon1-1/+22
ECC layout definitions are currently exposed using the nand_ecclayout struct which embeds oobfree and eccpos arrays with predefined size. This approach was acceptable when NAND chips were providing relatively small OOB regions, but MLC and TLC now provide OOB regions of several hundreds of bytes, which implies a non negligible overhead for everybody even those who only need to support legacy NANDs. Create an mtd_ooblayout_ops interface providing the same functionality (expose the ECC and oobfree layout) without the need for this huge structure. The mtd->ecclayout is now deprecated and should be replaced by the equivalent mtd_ooblayout_ops. In the meantime we provide a wrapper around the ->ecclayout field to ease migration to this new model. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2016-04-19mtd: use mtd_set_ecclayout() where appropriateBoris Brezillon1-1/+1
Use the mtd_set_ecclayout() helper instead of directly assigning the mtd->ecclayout field. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2016-03-07mtd: create an mtd_oobavail() helper and make use of itBoris BREZILLON1-4/+1
Currently, all MTD drivers/sublayers exposing an OOB area are doing the same kind of test to extract the available OOB size based on the mtd_info and mtd_oob_ops structures. Move this common logic into an inline function and make use of it. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Suggested-by: Priit Laes <plaes@plaes.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-12-09mtd: partitions: support a cleanup callback for parsersBrian Norris1-2/+33
If partition parsers need to clean up their resources, we shouldn't assume that all memory will fit in a single kmalloc() that the caller can kfree(). We should allow the parser to provide a proper cleanup routine. Note that this means we need to keep a hold on the parser's module for a bit longer, and release it later with mtd_part_parser_put(). Alongside this, define a default callback that we'll automatically use if the parser doesn't provide one, so we can still retain the old behavior. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2015-12-09mtd: partitions: pass around 'mtd_partitions' wrapper structBrian Norris1-7/+8
For some of the core partitioning code, it helps to keep info about the parsed partition (and who parsed them) together in one place. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-12-09mtd: partitions: remove kmemdup()Brian Norris1-1/+1
The use of kmemdup() complicates the error handling a bit. We don't actually need to allocate new memory, since this reference is treated as const, and it is copied into new memory by the partition registration code anyway. So remove it. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2015-12-09mtd: partitions: rename MTD parser get/putBrian Norris1-5/+8
We're going to reuse put_partition_parser(), so let's fix up the prefix naming a bit, to hopefully be more consistent. Also make convert to a true C function instead of a macro. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2015-12-04mtd: partitions: turn PART() macro into inline functionBrian Norris1-30/+33
We can guard against reorganization of struct mtd_part by using container_of(). We can also make sure we're using the right pointer types by making this a static inline function instead of a macro. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-19mtd: partitions: add module_mtd_part_parser() helperBrian Norris1-2/+6
This can help eliminate some boilerplate by generating the module_init() and module_exit() functions, and by automatically assigning the module owner. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-12mtd: zero out mtd_partition struct before using itBrian Norris1-2/+1
It's easier to guarantee we've cleared out all unused fields with memset() than by manually initializing each field. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2015-10-26mtd: mtdpart: Do not fail mtd probe when parsing partitions failsBrian Norris1-4/+10
Due to wrong assumption in ofpart ofpart fails on Exynos on SPI chips with no partitions because the subnode containing controller data confuses the ofpart parser. Thus compiling in ofpart support automatically fails probing any SPI NOR flash without partitions on Exynos. Compiling in a partitioning scheme should not cause probe of otherwise valid device to fail. Instead, let's do the following: * try parsers until one succeeds * if no parser succeeds, report the first error we saw * even in the failure case, allow MTD to probe, with fallback partitions or no partitions at all -- the master device will still be registered Issue report and comments initially by Michal Suchanek. Reported-by: Michal Suchanek <hramrach@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-10-11mtd: mtdpart: add debug prints to partition parser.Michal Suchanek1-0/+5
The probe of a mtd device can fail when a partition parser returns error. The failure due to partition parsing can be quite mysterious when multiple partitioning schemes are compiled in and any of them can fail the probe. Add debug prints which show what parsers were tried and what they returned. Signed-off-by: Michal Suchanek <hramrach@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-09-30mtd: mtdpart: fix add_mtd_partitions error pathBoris BREZILLON1-1/+3
If we fail to allocate a partition structure in the middle of the partition creation process, the already allocated partitions are never removed, which means they are still present in the partition list and their resources are never freed. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Cc: stable@vger.kernel.org Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-04-05mtd: part: Remove partition overlap checksDan Ehrenberg1-20/+1
This patch makes MTD dynamic partitioning more flexible by removing overlap checks for dynamic partitions. I don't see any particular reason why overlapping dynamic partitions should be prohibited while static partitions are allowed to overlap freely. The checks previously had an off-by-one error, where 'end' should be one less than what it is currently set at, and adding partitions out of increasing order will fail. Disabling the checks resolves this issue. Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-04-05mtd: part: Add sysfs variable for offset of partitionDan Ehrenberg1-0/+29
This patch makes a sysfs variable called 'offset' on each partition which contains the offset in bytes from the beginning of the master device that the partition starts. Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-04-05mtd: part: Create the master device node when partitionedDan Ehrenberg1-5/+13
For many use cases, it helps to have a device node for the entire MTD device as well as device nodes for the individual partitions. For example, this allows querying the entire device's properties. A common idiom is to create an additional partition which spans over the whole device. This patch makes a config option, CONFIG_MTD_PARTITIONED_MASTER, which makes the master partition present even when the device is partitioned. This isn't turned on by default since it presents a backwards-incompatible device numbering. The patch also makes the parent of a partition device be the master, if the config flag is set, now that the master is a full device. Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-01-20fs: introduce f_op->mmap_capabilities for nommu mmap supportChristoph Hellwig1-1/+0
Since "BDI: Provide backing device capability information [try #3]" the backing_dev_info structure also provides flags for the kind of mmap operation available in a nommu environment, which is entirely unrelated to it's original purpose. Introduce a new nommu-only file operation to provide this information to the nommu mmap code instead. Splitting this from the backing_dev_info structure allows to remove lots of backing_dev_info instance that aren't otherwise needed, and entirely gets rid of the concept of providing a backing_dev_info for a character device. It also removes the need for the mtd_inodefs filesystem. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Tejun Heo <tj@kernel.org> Acked-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Jens Axboe <axboe@fb.com>
2014-07-08mtd: Account for BBT blocks when a partition is being allocatedEzequiel Garcia1-1/+3
With the introduction of mtd_block_isreserved(), it's now possible to fix the bad and reserved block distribution exposed by ecc_stats, instead of accounting all the bad or reserved blocks as 'bad'. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Tested-by: Pekon Gupta <pekon@ti.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-07-08mtd: Introduce mtd_block_isreserved()Ezequiel Garcia1-0/+9
In addition to mtd_block_isbad(), which checks if a block is bad or reserved, it's needed to check if a block is reserved only (but not bad). This commit adds an MTD interface for it, in a similar fashion to mtd_block_isbad(). While here, fix mtd_block_isbad() so the out-of-bounds checking is done before the callback check. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Tested-by: Pekon Gupta <pekon@ti.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-03-10mtd: Add a retlen parameter to _get_{fact,user}_prot_infoChristian Riesch1-6/+8
Signed-off-by: Christian Riesch <christian.riesch@omicron.at> Cc: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-01-03mtd: make register_mtd_parser return voidAxel Lin1-3/+1
register_mtd_parser never fails; hence make it return void. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-01-03mtd: make deregister_mtd_parser return voidAxel Lin1-2/+1
deregister_mtd_parser never fails; hence make it return void. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-01-03mtd: make mtd_partition.name constGeert Uytterhoeven1-1/+1
This allows to drop a few casts. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2013-08-30mtd: set the ecc step size for master/slave mtd_infoHuang Shijie1-0/+1
Set the ecc step size for master/slave mtd_info{}. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2013-04-05mtd: mtdcore: use const qualifierArtem Bityutskiy1-1/+1
Be a bit stricter and add few more 'const' qualifiers. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2013-04-05mtd: add 'const' qualifier to a couple of register functionsArtem Bityutskiy1-1/+1
'mtd_device_parse_register()' and 'parse_mtd_partitions()' functions accept a an array of character pointers. These functions modify neither the pointers nor the characters they point to. The characters are actually names of the MTD parsers. At the moment, the argument type is 'const char **', which means that only the names of the parsers are constant. Let's turn the argument type into 'const char * const *', which means that both names and the pointers which point to them are constant. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2012-10-09Merge tag 'disintegrate-mtd-20121009' of git://git.infradead.org/users/dhowells/linux-headersDavid Woodhouse1-1/+11
UAPI Disintegration 2012-10-09 Conflicts: MAINTAINERS arch/arm/configs/bcmring_defconfig arch/arm/mach-imx/clk-imx51-imx53.c drivers/mtd/nand/Kconfig drivers/mtd/nand/bcm_umi_nand.c drivers/mtd/nand/nand_bcm_umi.h drivers/mtd/nand/orion_nand.c
2012-09-29mtd: mtdpart: break it as soon as we parse out the partitionsHuang Shijie1-1/+4
We may cause a memory leak when the @types has more then one parser. Take the `default_mtd_part_types` for example. The default_mtd_part_types has two parsers now: `cmdlinepart` and `ofpart`. Assume the following case: The kernel command line sets the partitions like: #gpmi-nand:20m(boot),20m(kernel),1g(rootfs),-(user) But the devicetree file(such as arch/arm/boot/dts/imx28-evk.dts) also sets the same partitions as the kernel command line does. In the current code, the partitions parsed out by the `ofpart` will overwrite the @pparts which has already set by the `cmdlinepart` parser, and the the partitions parsed out by the `cmdlinepart` is missed. A memory leak occurs. So we should break the code as soon as we parse out the partitions, In actually, this patch makes a priority order between the parsers. If one parser has already parsed out the partitions successfully, it's no need to use another parser anymore. Signed-off-by: Huang Shijie <shijie8@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2012-09-04mtd: mtdparts: introduce mtd_get_device_sizeRichard Genoud1-0/+10
'mtd_get_device_size()' returns the size of the whole MTD device, that is the mtd_info master size. This will be used by UBI to calculate the maximum number of bad blocks (MBB) on a MTD device. Artem: amended the patch a bit. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-09-04mtd: mark mtd_is_partition argument as constantRichard Genoud1-1/+1
'struct mtd_info' is not modified by 'mtd_is_partition()' so it can be marked as "const". Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-05-13mtd: driver _read() returns max_bitflips; mtd_read() returns -EUCLEANMike Dunn1-6/+6
The drivers' _read() method, absent an error, returns a non-negative integer indicating the maximum number of bit errors that were corrected in any one region comprising an ecc step. MTD returns -EUCLEAN if this is >= bitflip_threshold, 0 otherwise. If bitflip_threshold is zero, the comparison is not made since these devices lack ECC and always return zero in the non-error case (thanks Brian)¹. Note that this is a subtle change to the driver interface. This and the preceding patches in this set were tested with ubi on top of the nandsim and docg4 devices, running the ubi test io_basic from mtd-utils. ¹ http://lists.infradead.org/pipermail/linux-mtd/2012-March/040468.html Signed-off-by: Mike Dunn <mikedunn@newsguy.com> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr> Acked-by: Brian Norris <computersforpeace@gmail.com> Ivan Djelic <ivan.djelic@parrot.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2012-05-13mtd: bitflip_threshold added to mtd_info and sysfsMike Dunn1-0/+2
An element 'bitflip_threshold' is added to struct mtd_info, and also exposed as a read/write variable in sysfs. This will be used to determine whether or not mtd_read() returns -EUCLEAN or 0 (absent a hard error). If the driver leaves it as zero, mtd will set it to a default value of ecc_strength. This v2 adds the line that propagates bitflip_threshold from the master to the partitions - thanks Ivan¹. ¹ http://lists.infradead.org/pipermail/linux-mtd/2012-April/040900.html Signed-off-by: Mike Dunn <mikedunn@newsguy.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2012-03-27mtd: flash drivers set ecc strengthMike Dunn1-0/+1
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 <mikedunn@newsguy.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
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 <mikedunn@newsguy.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2012-03-27mtd: remove R/O checking duplicationArtem Bityutskiy1-13/+1
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 <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2012-03-27mtd: do not duplicate length and offset checks in driversArtem Bityutskiy1-29/+1
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 <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>