GitHub/LineageOS/android_kernel_motorola_exynos9610.git
13 years agomtd: define `mtd_is_*()' functions
Brian Norris [Wed, 21 Sep 2011 01:30:51 +0000 (18:30 -0700)]
mtd: define `mtd_is_*()' functions

These functions can be used instead of referencing -EUCLEAN and -EBADMSG
all over the place. They should help make code a little bit more
readable.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: nand: remove gotos in `check_create()'
Brian Norris [Wed, 7 Sep 2011 20:13:35 +0000 (13:13 -0700)]
mtd: nand: remove gotos in `check_create()'

This is a second step in restructuring `check_create()'. When we don't
rely on goto statements for our main functionality, the code will become
a little easier to manipulate.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: nand: begin restructuring check_create
Brian Norris [Wed, 7 Sep 2011 20:13:34 +0000 (13:13 -0700)]
mtd: nand: begin restructuring check_create

We will begin restructuring the code for check_create so that we can
make some important changes. For now, we should just begin to get rid of
some goto statements to make things cleaner. This is the first step of a
few, which are separated to make them easier to follow.

This step should just be a code refactor.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: nand: fix style
Brian Norris [Wed, 7 Sep 2011 20:13:33 +0000 (13:13 -0700)]
mtd: nand: fix style

Remove some extra spaces
Consistently use '0x' prefix for bitfield-like constants
Spelling: "aplies" -> "applies"

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: nand: remove unnecessary variable
Brian Norris [Wed, 7 Sep 2011 20:13:32 +0000 (13:13 -0700)]
mtd: nand: remove unnecessary variable

`writeops' is unnecessary in the function `nand_update_bbt()'

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: nand: do not ignore all ECC errors
Brian Norris [Wed, 7 Sep 2011 20:13:29 +0000 (13:13 -0700)]
mtd: nand: do not ignore all ECC errors

There are a few reasons not to ignore ECC errors here.

First, mtd->read_oob is being called in raw mode, so there should be no
error correction in the first place.

Second, if we change this such that there *is* error correction in this
function, then we will want to pass the error message upward.

In fact, the code I introduced to "ignore ECC errors" would have been
better if it had just placed this test down in `scan_block_full()' in
the first place. We would like to ignore ECC errors when we are simply
checking for bad block markers (e.g., factory marked), but we may not
want to ignore ECC errors when scanning OOB for a flash-based BBT
pattern (in `scan_read_raw()'; note that the return codes from
`scan_read_raw()' are not actually handled yet).

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: nand: refactor scanning code
Brian Norris [Wed, 7 Sep 2011 20:13:28 +0000 (13:13 -0700)]
mtd: nand: refactor scanning code

A few pieces of code are unnecessarily duplicated. For easier
maintenance, we should fix this.

This should have no functional effect.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: drop Integrator flash map Kconfig
Linus Walleij [Wed, 7 Sep 2011 07:50:29 +0000 (09:50 +0200)]
mtd: drop Integrator flash map Kconfig

The integrator flash has been deleted, even from the Makefile.
Drop the Kconfig entry as well.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: kill old field for `struct mtd_info_user'
Brian Norris [Wed, 31 Aug 2011 01:45:46 +0000 (18:45 -0700)]
mtd: kill old field for `struct mtd_info_user'

The ecctype and eccsize fields have been obsolete for a while. Since they
don't have any users, we can kill them and leave padding in their place
for now.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: nand: kill member `ops' of `struct nand_chip'
Brian Norris [Wed, 31 Aug 2011 01:45:45 +0000 (18:45 -0700)]
mtd: nand: kill member `ops' of `struct nand_chip'

The nand_chip.ops field is a struct that is passed around globally with
no particular reason. Every time it is used, it could just as easily be
replaced with a local struct that is updated on each operation. So make
it local.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: document ABI
Brian Norris [Wed, 31 Aug 2011 01:45:44 +0000 (18:45 -0700)]
mtd: document ABI

We're missing a lot of important documentation in include/mtd/mtd-abi.h:

* add a simple description of each ioctl (feel free to expand!)
* give full explanations of recently added and modified operations
* explain the usage of "RAW" that appear in different modes and types of
  operations
* fix some comment style along the way

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: add MEMWRITE ioctl
Brian Norris [Fri, 9 Sep 2011 16:59:03 +0000 (09:59 -0700)]
mtd: add MEMWRITE ioctl

Implement a new ioctl for writing both page data and OOB to flash at the
same time. This ioctl is intended to be a generic interface that can
replace other ioctls (MEMWRITEOOB and MEMWRITEOOB64) and cover the
functionality of several other old ones, e.g., MEMWRITE can:

* write autoplaced OOB instead of using ECCGETLAYOUT (deprecated) and
  working around the reserved areas
* write raw (no ECC) OOB instead of using MTDFILEMODE to set the
  per-file-descriptor MTD_FILE_MODE_RAW
* write raw (no ECC) data instead of using MTDFILEMODE
  (MTD_FILE_MODE_RAW) and using standard character device "write"

This ioctl is especially useful for MLC NAND, which cannot be written
twice (i.e., we cannot successfully write the page data and OOB in two
separate operations). Instead, MEMWRITE can write both in a single
operation.

Note that this ioctl is not affected by the MTD file mode (i.e.,
MTD_FILE_MODE_RAW vs. MTD_FILE_MODE_NORMAL), since it receives its write
mode as an input parameter.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: rename MTD_MODE_* to MTD_FILE_MODE_*
Brian Norris [Wed, 31 Aug 2011 01:45:41 +0000 (18:45 -0700)]
mtd: rename MTD_MODE_* to MTD_FILE_MODE_*

These modes hold their state only for the life of their file descriptor,
and they overlap functionality with the MTD_OPS_* modes. Particularly,
MTD_MODE_RAW and MTD_OPS_RAW cover the same function: to provide raw
(i.e., without ECC) access to the flash. In fact, although it may not be
clear, MTD_MODE_RAW implied that operations should enable the
MTD_OPS_RAW mode.

Thus, we should be specific on what each mode means. This is a start,
where MTD_FILE_MODE_* actually represents a "file mode," not necessarily
a true global MTD mode.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: rename MTD_OOB_* to MTD_OPS_*
Brian Norris [Wed, 31 Aug 2011 01:45:40 +0000 (18:45 -0700)]
mtd: rename MTD_OOB_* to MTD_OPS_*

These modes are not necessarily for OOB only. Particularly, MTD_OOB_RAW
affected operations on in-band page data as well. To clarify these
options and to emphasize that their effect is applied per-operation, we
change the primary prefix to MTD_OPS_.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: move mtd_oob_mode_t to shared kernel/user space
Brian Norris [Wed, 31 Aug 2011 01:45:39 +0000 (18:45 -0700)]
mtd: move mtd_oob_mode_t to shared kernel/user space

We will want to use the MTD_OOB_{PLACE,AUTO,RAW} modes in user-space
applications through the introduction of new ioctls, so we should make
this enum a shared type.

This enum is now anonymous.

Artem: tweaked the patch.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: support reading OOB without ECC
Brian Norris [Wed, 31 Aug 2011 01:45:38 +0000 (18:45 -0700)]
mtd: support reading OOB without ECC

This fixes issues with `nanddump -n' and the MEMREADOOB[64] ioctls on
hardware that performs error correction when reading only OOB data. A
driver for such hardware needs to know when we're doing a RAW vs. a
normal write, but mtd_do_read_oob does not pass such information to the
lower layers (e.g., NAND). We should pass MTD_OOB_RAW or MTD_OOB_PLACE
based on the MTD file mode.

For now, most drivers can get away with just setting:

  chip->ecc.read_oob_raw = chip->ecc.read_oob

This is done by default; but for systems that behave as described above,
you must supply your own replacement function.

This was tested with nandsim as well as on actual SLC NAND.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Jim Quinlan <jim2101024@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: nand: document nand_chip.oob_poi
Brian Norris [Wed, 31 Aug 2011 01:45:43 +0000 (18:45 -0700)]
mtd: nand: document nand_chip.oob_poi

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: support writing OOB without ECC
Brian Norris [Wed, 31 Aug 2011 01:45:37 +0000 (18:45 -0700)]
mtd: support writing OOB without ECC

This fixes issues with `nandwrite -n -o' and the MEMWRITEOOB[64] ioctls
on hardware that writes ECC when writing OOB. The problem arises as
follows: `nandwrite -n' can write page data to flash without applying
ECC, but when used with the `-o' option, ECC is applied (incorrectly),
contrary to the `--noecc' option.

I found that this is the case because my hardware computes and writes
ECC data to flash upon either OOB write or page write. Thus, to support
a proper "no ECC" write, my driver must know when we're performing a raw
OOB write vs. a normal ECC OOB write. However, MTD does not pass any raw
mode information to the write_oob functions.  This patch addresses the
problems by:

1) Passing MTD_OOB_RAW down to lower layers, instead of just defaulting
   to MTD_OOB_PLACE
2) Handling MTD_OOB_RAW within the NAND layer's `nand_do_write_oob'
3) Adding a new (replaceable) function pointer in struct ecc_ctrl; this
   function should support writing OOB without ECC data. Current
   hardware often can use the same OOB write function when writing
   either with or without ECC

This was tested with nandsim as well as on actual SLC NAND.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Jim Quinlan <jim2101024@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: add the common code for GPMI-NAND controller driver
Huang Shijie [Thu, 8 Sep 2011 02:47:09 +0000 (10:47 +0800)]
mtd: add the common code for GPMI-NAND controller driver

These files contain the common code for the GPMI-NAND driver.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Acked-by: Marek Vasut <marek.vasut@gmail.com>
Tested-by: Koen Beel <koen.beel@barco.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: add GPMI-NAND driver in the config and Makefile
Huang Shijie [Thu, 8 Sep 2011 02:47:11 +0000 (10:47 +0800)]
mtd: add GPMI-NAND driver in the config and Makefile

add the GPMI-NAND driver in the relevant Kconfig and Makefile in the MTD.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Acked-by: Marek Vasut <marek.vasut@gmail.com>
Tested-by: Koen Beel <koen.beel@barco.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: add helper functions library and header files for GPMI NAND driver
Huang Shijie [Thu, 8 Sep 2011 02:47:10 +0000 (10:47 +0800)]
mtd: add helper functions library and header files for GPMI NAND driver

bch-regs.h : registers file for BCH module
gpmi-regs.h: registers file for GPMI module
gpmi-lib.c: helper functions library.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Acked-by: Marek Vasut <marek.vasut@gmail.com>
Tested-by: Koen Beel <koen.beel@barco.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: check parts pointer before using it
Jason Liu [Wed, 24 Aug 2011 11:26:28 +0000 (19:26 +0800)]
mtd: check parts pointer before using it

The code has the check for parts but it called after kmemdup,
kmemdup(parts, sizeof(*parts) * nr_parts,...)
if (!parts)
return -ENOMEM

In fact, we need check parts before safely using it.
and we also need check the real_parts to make sure kmemdup
allocation sucessfully.

Signed-off-by: Jason Liu <jason.hui@linaro.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: style fixups in multi-line comment, indentation
Brian Norris [Wed, 24 Aug 2011 00:17:36 +0000 (17:17 -0700)]
mtd: style fixups in multi-line comment, indentation

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: nand: fix spelling error (date => data)
Brian Norris [Wed, 24 Aug 2011 00:17:35 +0000 (17:17 -0700)]
mtd: nand: fix spelling error (date => data)

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: remove MEMSETOOBSEL macro definition
Brian Norris [Wed, 24 Aug 2011 00:17:34 +0000 (17:17 -0700)]
mtd: remove MEMSETOOBSEL macro definition

MEMSETOOBSEL is completely unused and useless. Remove the definition.

Note: it's probably best not to use this ioctl number in the future for
MTD, since that may cause conflicts between old kernels and new user
software (or new kernels and old user software).

Artem: leave a comment about MEMSETOOBSEL.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: doc: remove mention of MEMSETOOBSEL
Brian Norris [Wed, 24 Aug 2011 00:17:33 +0000 (17:17 -0700)]
mtd: doc: remove mention of MEMSETOOBSEL

It's been gone for a while.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: do not assume oobsize is power of 2
Brian Norris [Wed, 24 Aug 2011 00:17:32 +0000 (17:17 -0700)]
mtd: do not assume oobsize is power of 2

Previous generations of MTDs all used OOB sizes that were powers of 2,
(e.g., 64, 128). However, newer generations of flash, especially NAND,
use irregular OOB sizes that are not powers of 2 (e.g., 218, 224, 448).
This means we cannot use masks like "mtd->oobsize - 1" to assume that we
will get a proper bitmask for OOB operations.

These masks are really only intended to hide the "page" portion of the
offset, leaving any OOB offset intact, so a masking with the writesize
(which *is* always a power of 2) is valid and makes more sense.

This has been tested for read/write of NAND devices (nanddump/nandwrite)
using nandsim and actual NAND flash.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: mxc_nand: add mx53 NFC driver support
Jason Liu [Mon, 22 Aug 2011 06:13:17 +0000 (14:13 +0800)]
mtd: mxc_nand: add mx53 NFC driver support

This has already been tested with Samsung NAND: K9LAG08U0M
on MX53EVK board, ubi/ubifs has already been tested OK too.

Signed-off-by: Jason Liu <jason.hui@linaro.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: bcm_umi_nand: clean up error handling code
Julia Lawall [Wed, 10 Aug 2011 08:14:14 +0000 (10:14 +0200)]
mtd: bcm_umi_nand: clean up error handling code

Convert error handling code to use gotos.  At the same time, this adds
calls to kfree and iounmap in a few cases where they were overlooked.

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Jiandong Zheng <jdzheng@broadcom.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: eLBC NAND: update ecc_stats.corrected when lteccr available
Michael Hench [Tue, 26 Jul 2011 20:07:42 +0000 (15:07 -0500)]
mtd: eLBC NAND: update ecc_stats.corrected when lteccr available

Signed-off-by: Michael Hench <MichaelHench@gmail.com>
Acked-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: s3c2410 nand: Remove uncessary null check
Jonghwan Choi [Thu, 21 Jul 2011 06:33:58 +0000 (15:33 +0900)]
mtd: s3c2410 nand: Remove uncessary null check

clk_get() return a pointer to the struct clk or an ERR_PTR().

Signed-off-by: Jonghwan Choi <jhbird.choi@samsung.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: spelling fixes
Brian Norris [Wed, 20 Jul 2011 16:53:42 +0000 (09:53 -0700)]
mtd: spelling fixes

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: use MTD_NAND_OMAP2 for OMAP4
Jan Weitzel [Wed, 20 Jul 2011 07:28:04 +0000 (09:28 +0200)]
mtd: use MTD_NAND_OMAP2 for OMAP4

use MTD_NAND_OMAP2 also for OMAP4 arch.
testes with omap4430

Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: Kbuild: remove reference to MTD_PARTITIONS
Brian Norris [Tue, 19 Jul 2011 17:06:16 +0000 (10:06 -0700)]
mtd: Kbuild: remove reference to MTD_PARTITIONS

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: cleanup last uses of MTD_DEBUG config macros
Brian Norris [Tue, 19 Jul 2011 17:06:13 +0000 (10:06 -0700)]
mtd: cleanup last uses of MTD_DEBUG config macros

Some messages that were tied to CONFIG_MTD_DEBUG_VERBOSE can now simply
be enabled using dynamic debugging features, if necessary. There's no
need for special debugging functions here.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: remove CONFIG_MTD_DEBUG
Brian Norris [Tue, 19 Jul 2011 17:06:12 +0000 (10:06 -0700)]
mtd: remove CONFIG_MTD_DEBUG

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: pcmciamtd: remove custom DEBUG() function
Brian Norris [Tue, 19 Jul 2011 17:06:11 +0000 (10:06 -0700)]
mtd: pcmciamtd: remove custom DEBUG() function

We don't need a custom DEBUG() macro here. Just use the built-in kernel
code with dynamic debugging features.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: cleanup style on pr_debug messages
Brian Norris [Tue, 19 Jul 2011 17:06:10 +0000 (10:06 -0700)]
mtd: cleanup style on pr_debug messages

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: replace DEBUG() with pr_debug()
Brian Norris [Tue, 19 Jul 2011 17:06:09 +0000 (10:06 -0700)]
mtd: replace DEBUG() with pr_debug()

Start moving away from the MTD_DEBUG_LEVEL messages. The dynamic
debugging feature is a generic kernel feature that provides more
flexibility.

(See Documentation/dynamic-debug-howto.txt)

Also fix some punctuation, indentation, and capitalization that went
along with the affected lines.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: nand: style fixups in pr_* messages
Brian Norris [Tue, 19 Jul 2011 17:06:08 +0000 (10:06 -0700)]
mtd: nand: style fixups in pr_* messages

This is a cleanup of some punctuation, indentation, and capitalization
on the lines affected affected by the last patch.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: nand: convert printk() to pr_*()
Brian Norris [Tue, 19 Jul 2011 17:06:07 +0000 (10:06 -0700)]
mtd: nand: convert printk() to pr_*()

Instead of directly calling printk, it's simpler to use the built-in
pr_* functions. This shortens code and allows easy customization through
the definition of a pr_fmt() macro (not used currently). Ideally, we
could implement much of this with dev_* functions, but the MTD subsystem
does not necessarily register all its master `mtd_info.dev` device, so
we cannot use dev_* consistently. See:
http://lists.infradead.org/pipermail/linux-mtd/2011-July/036950.html

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: nand: change KERN_DEBUG to KERN_INFO
Brian Norris [Tue, 19 Jul 2011 17:06:06 +0000 (10:06 -0700)]
mtd: nand: change KERN_DEBUG to KERN_INFO

Soon we will change many printk statements into pr_* statements, i.e.,
'printk(KERN_INFO, ...)' becomes 'pr_info(...)'. However, this means that
KERN_DEBUG messages will become pr_debug() statements and therefore will
not be activated by default - they must be enabled using dynamic debug.
So, for important DEBUG messages, we will simply upgrade these to INFO
so that they appear by default.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: dataflash: add device tree probe support
Shawn Guo [Fri, 15 Jul 2011 08:38:56 +0000 (16:38 +0800)]
mtd: dataflash: add device tree probe support

It adds device tree probe support for mtd_dataflash driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: pxa3xx_nand: enable multiple chip select support
Lei Wen [Fri, 15 Jul 2011 03:44:33 +0000 (20:44 -0700)]
mtd: pxa3xx_nand: enable multiple chip select support

Current pxa3xx_nand controller has two chip select which
both be workable. This patch enable this feature.

Update platform driver to support this feature.

Another notice should be taken that:
When you want to use this feature, you should not enable the
keep configuration feature, for two chip select could be
attached with different nand chip. The different page size
and timing requirement make the keep configuration impossible.

Signed-off-by: Lei Wen <leiwen@marvell.com>
13 years agomtd: pxa3xx_nand: sperate each chip individual info
Lei Wen [Fri, 15 Jul 2011 03:44:32 +0000 (20:44 -0700)]
mtd: pxa3xx_nand: sperate each chip individual info

For support two chip select, we seperate chip specific info in this
patch.

Signed-off-by: Lei Wen <leiwen@marvell.com>
13 years agomtd: pxa3xx_nand: convert all printk into dev_*
Lei Wen [Fri, 15 Jul 2011 03:44:31 +0000 (20:44 -0700)]
mtd: pxa3xx_nand: convert all printk into dev_*

Also add missed warning message.

Signed-off-by: Lei Wen <leiwen@marvell.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
13 years agomtd: pxa3xx_nand: enhance suspend and resume routine
Lei Wen [Fri, 15 Jul 2011 03:44:30 +0000 (20:44 -0700)]
mtd: pxa3xx_nand: enhance suspend and resume routine

This patch add protection on the suspend&resume path to prevent
some unexpected behavior, like interrupt occur at the very second
of resume back and it don't follow normal command path, which lead
to bug.

Signed-off-by: Lei Wen <leiwen@marvell.com>
13 years agomtd: eLBC NAND: remove elbc_fcm_ctrl->oob_poi
Mike Hench [Tue, 5 Jul 2011 23:14:48 +0000 (19:14 -0400)]
mtd: eLBC NAND: remove elbc_fcm_ctrl->oob_poi

The eLBC NAND driver currently follows up each program/write operation with a
read-back of the page, in order to [ostensibly] fill in ECC data for the
caller. However, the page address used for this read is always -1, so the read
will never work correctly.  Remove this useless (and potentially problematic)
block of code.

Signed-off-by: Matthew L. Creech <mlcreech@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: atmel_nand: optimize read/write buffer functions
Nicolas Ferre [Mon, 4 Jul 2011 14:17:53 +0000 (16:17 +0200)]
mtd: atmel_nand: optimize read/write buffer functions

For PIO NAND access functions, we use the features of the SMC:
- no need to take into account the NAND bus width: SMC will deal with this
- use of an IO memcpy on the NAND chip-select space is able to generate
  proper SMC behavior.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: nand: don't free the global data too early
Liu Shuo [Tue, 28 Jun 2011 01:50:51 +0000 (09:50 +0800)]
mtd: nand: don't free the global data too early

The global data fsl_lbc_ctrl_dev->nand don't have to be freed in
fsl_elbc_chip_remove(). The right place to do that is in fsl_elbc_nand_remove()
if elbc_fcm_ctrl->counter is zero.

Signed-off-by: Liu Shuo <b35362@freescale.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: plat-nand: Fixup kerneldoc for struct platform_nand_chip
Tobias Klauser [Fri, 1 Jul 2011 11:51:15 +0000 (13:51 +0200)]
mtd: plat-nand: Fixup kerneldoc for struct platform_nand_chip

The set_parts and priv members of struct platform_nand_chip where
removed in commit c36a6ef3845262ade529afb9f458738b1f196f83 but the
kerneldoc wasn't updated.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: fsl_upm: fix a memory leak in fun_chip_init error path
Axel Lin [Thu, 30 Jun 2011 11:53:09 +0000 (19:53 +0800)]
mtd: fsl_upm: fix a memory leak in fun_chip_init error path

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: atmel_nand: fix wrong use of 0 as NULL
Nicolas Ferre [Wed, 29 Jun 2011 16:41:16 +0000 (18:41 +0200)]
mtd: atmel_nand: fix wrong use of 0 as NULL

Fixing this error:
atmel_nand.c:718:20: warning: Using plain integer as NULL pointer

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: nand_flash_detect_onfi propagate busw info
Matthieu CASTET [Sun, 26 Jun 2011 16:26:55 +0000 (18:26 +0200)]
mtd: nand_flash_detect_onfi propagate busw info

there is a bug in nand_flash_detect_onfi, busw need to be passed
by pointer to return it.

Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
Acked-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: edit NAND-related comment
Brian Norris [Tue, 28 Jun 2011 23:29:00 +0000 (16:29 -0700)]
mtd: edit NAND-related comment

This comment was unclear regarding which NAND functions do and do not
support ECC on the spare area. This update should reflect the current
status of the NAND system but can be updated if changes are made in
the standard functions.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: tests: ignore corrected bitflips in OOB on mtd_readtest
Brian Norris [Tue, 28 Jun 2011 23:28:59 +0000 (16:28 -0700)]
mtd: tests: ignore corrected bitflips in OOB on mtd_readtest

read_oob may now return ECC error codes. If the code is -EUCLEAN, then
we can safely ignore the error as a corrected bitflip.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: nand: ignore ECC errors for simple BBM scans
Brian Norris [Tue, 28 Jun 2011 23:28:58 +0000 (16:28 -0700)]
mtd: nand: ignore ECC errors for simple BBM scans

Now that nand_do_readoob() may return -EUCLEAN or -EBADMSG on ECC errors,
we need to handle the return value specially in some cases.

When scanning for simple bad block markers, reacting to an ECC error is
not very useful, as we assume that the relevant markers are still
non-0xFF for true bad blocks.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agojffs2: use mutex_is_locked() in __jffs2_flush_wbuf()
Alexey Khoroshilov [Mon, 27 Jun 2011 20:21:30 +0000 (00:21 +0400)]
jffs2: use mutex_is_locked() in __jffs2_flush_wbuf()

Use a helper to test if a mutex is held instead of a hack with
mutex_trylock().

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: ofpart: add ofoldpart alias
Dmitry Eremin-Solenikov [Mon, 27 Jun 2011 12:34:46 +0000 (16:34 +0400)]
mtd: ofpart: add ofoldpart alias

ofpart.ko also provides ofoldpart MTD parser. Add respective
MODULE_ALIAS("ofoldpart"); declaration.

Artem: improve the comment

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: nand: handle ECC errors in OOB
Brian Norris [Thu, 23 Jun 2011 23:45:24 +0000 (16:45 -0700)]
mtd: nand: handle ECC errors in OOB

While the standard NAND OOB functions do not do ECC on the spare area,
it is possible for a driver to supply its own OOB ECC functions (e.g., HW
ECC). nand_do_read_oob should act like nand_do_read_ops in checking the
ECC stats and returning -EBADMSG or -EUCLEAN on uncorrectable errors or
correctable bitflips, respectively. These error codes could be used in
flash-based BBT code or in YAFFS, for example.

Doing this, however, messes with the behavior of mtd_do_readoob. Now,
mtd_do_readoob should check whether we had -EUCLEAN or -EBADMSG errors
and discard those as "non-fatal" so that the ioctls can still succeed
with (possibly uncorrected) data.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: make ofpart buildable as a separate module
Dmitry Eremin-Solenikov [Sun, 26 Jun 2011 21:02:59 +0000 (01:02 +0400)]
mtd: make ofpart buildable as a separate module

As ofpart now uses a standard mtd partitions parser interface, make it
buildable as a separate module. Also provide MODULE_DESCRIPTION and
MODULE_AUTHOR for this module.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: spelling, capitalization, uniformity
Brian Norris [Thu, 23 Jun 2011 21:12:08 +0000 (14:12 -0700)]
mtd: spelling, capitalization, uniformity

Therefor -> Therefore
[Intern], [Internal] -> [INTERN]
[REPLACABLE] -> [REPLACEABLE]
syndrom, syndom -> syndrome
ecc -> ECC
buswith -> buswidth
endianess -> endianness
dont -> don't
occures -> occurs
independend -> independent
wihin -> within
erease -> erase
blockes -> blocks
...

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: drop mtd_device_register
Dmitry Eremin-Solenikov [Thu, 23 Jun 2011 11:33:15 +0000 (15:33 +0400)]
mtd: drop mtd_device_register

mtd_device_register() is a limited version of mtd_device_parse_register.
Replace it with macro calling mtd_device_parse_register().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: remove put_partition_parser() from public header
Dmitry Eremin-Solenikov [Thu, 23 Jun 2011 11:26:14 +0000 (15:26 +0400)]
mtd: remove put_partition_parser() from public header

There is no need to pollute public header with a definition private
to mtdpart.c. Move it from mtd/partitions.h to mtdpart.c

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: hide parse_mtd_partitions
Dmitry Eremin-Solenikov [Thu, 23 Jun 2011 11:23:08 +0000 (15:23 +0400)]
mtd: hide parse_mtd_partitions

There is no need to export parse_mtd_partitions() now , as it's fully handled
by registration functions. So move the definition to private header and
remove respective EXPORT_SYMBOL_GPL.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: nand: drop edb7312 support
Dmitry Eremin-Solenikov [Thu, 23 Jun 2011 08:33:52 +0000 (12:33 +0400)]
mtd: nand: drop edb7312 support

EDB7312 isn't supported by mainline kernel, so drop it now.
If the board support will ever be submitted to mainline,
one can revert this commit.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: maps: drop edb7312 support
Dmitry Eremin-Solenikov [Thu, 23 Jun 2011 08:33:52 +0000 (12:33 +0400)]
mtd: maps: drop edb7312 support

EDB7312 isn't supported by mainline kernel, this driver wasn't working
before recent fixes, the same functionality can be achieved via physmap,
so drop it now. If the board support will ever be submitted to mainline,
one either can revert this commit, or use physmap mtd map driver.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: OneNAND: Detect the correct NOP when 4KiB pagesize
Kyungmin Park [Wed, 22 Jun 2011 05:16:49 +0000 (14:16 +0900)]
mtd: OneNAND: Detect the correct NOP when 4KiB pagesize

There are two different 4KiB pagesize chips
KFM4G16Q4M series have NOP 4 with version ID 0x0131
But KFM4G16Q5M has NOP 1 with versoin ID 0x013e

Note that Q5M means that it has NOP 1.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: socrates_nand.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:01:07 +0000 (18:01 +0400)]
mtd: socrates_nand.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: ndfc.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:00:51 +0000 (18:00 +0400)]
mtd: ndfc.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: mpc5121_nfc.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:00:42 +0000 (18:00 +0400)]
mtd: mpc5121_nfc.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: fsl_upm.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:00:37 +0000 (18:00 +0400)]
mtd: fsl_upm.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: fsl_elbc_nand.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:00:36 +0000 (18:00 +0400)]
mtd: fsl_elbc_nand.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: m25p80.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 13:59:16 +0000 (17:59 +0400)]
mtd: m25p80.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: physmap_of.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 13:59:59 +0000 (17:59 +0400)]
mtd: physmap_of.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: physmap_of: move parse_obsolete_partitions to become separate parser
Dmitry Eremin-Solenikov [Sun, 29 May 2011 21:26:17 +0000 (01:26 +0400)]
mtd: physmap_of: move parse_obsolete_partitions to become separate parser

Move parse_obsolete_partitions() to ofpart.c and register it as an
ofoldpart partitions parser.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: drop of_mtd_parse_partitions()
Dmitry Eremin-Solenikov [Sun, 29 May 2011 21:05:33 +0000 (01:05 +0400)]
mtd: drop of_mtd_parse_partitions()

All users have been converted to call of_mtd_parse_partitions through
parse_mtd_partitions() multiplexer. Drop obsolete API.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: socrates_nand: use ofpart through generic parsing
Dmitry Eremin-Solenikov [Sun, 29 May 2011 21:02:26 +0000 (01:02 +0400)]
mtd: socrates_nand: use ofpart through generic parsing

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: ndfc: use ofpart through generic parsing
Dmitry Eremin-Solenikov [Sun, 29 May 2011 21:02:25 +0000 (01:02 +0400)]
mtd: ndfc: use ofpart through generic parsing

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: mpc5121_nfc: use ofpart through generic parsing
Dmitry Eremin-Solenikov [Sun, 29 May 2011 21:02:24 +0000 (01:02 +0400)]
mtd: mpc5121_nfc: use ofpart through generic parsing

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: fsl_upm: use ofpart through generic parsing
Dmitry Eremin-Solenikov [Sun, 29 May 2011 21:02:23 +0000 (01:02 +0400)]
mtd: fsl_upm: use ofpart through generic parsing

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: fsl_elbc_nand: use ofpart through generic parsing
Dmitry Eremin-Solenikov [Sun, 29 May 2011 21:02:22 +0000 (01:02 +0400)]
mtd: fsl_elbc_nand: use ofpart through generic parsing

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: m25p80: use ofpart through generic parsing
Dmitry Eremin-Solenikov [Sun, 29 May 2011 21:02:20 +0000 (01:02 +0400)]
mtd: m25p80: use ofpart through generic parsing

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: physmap_of: use ofpart through generic parsing
Dmitry Eremin-Solenikov [Sun, 29 May 2011 21:02:21 +0000 (01:02 +0400)]
mtd: physmap_of: use ofpart through generic parsing

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: prepare to convert of_mtd_parse_partitions to partition parser
Dmitry Eremin-Solenikov [Sun, 29 May 2011 17:32:33 +0000 (21:32 +0400)]
mtd: prepare to convert of_mtd_parse_partitions to partition parser

Prepare to convert of_mtd_parse_partitions() to usual partitions parser:
1) Register ofpart parser
2) Internally don't use passed device for error printing
3) Add device_node to mtd_part_parser_data struct
4) Move of_mtd_parse_partitions from __devinit to common text section
5) add ofpart to the default list of partition parsers

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: abstract last MTD partition parser argument
Dmitry Eremin-Solenikov [Fri, 10 Jun 2011 14:18:28 +0000 (18:18 +0400)]
mtd: abstract last MTD partition parser argument

Encapsulate last MTD partition parser argument into a separate
structure. Currently it holds only 'origin' field for RedBoot parser,
but will be extended in future to contain at least device_node for OF
devices.

Amended commentary to make kerneldoc happy

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: nand_base: always initialise oob_poi before writing OOB data
THOMSON, Adam (Adam) [Tue, 14 Jun 2011 14:52:38 +0000 (16:52 +0200)]
mtd: nand_base: always initialise oob_poi before writing OOB data

In nand_do_write_ops() code it is possible for a caller to provide
ops.oobbuf populated and ops.mode == MTD_OOB_AUTO, which currently
means that the chip->oob_poi buffer isn't initialised to all 0xFF.
The nand_fill_oob() method then carries out the task of copying
the provided OOB data to oob_poi, but with MTD_OOB_AUTO it skips
areas marked as unavailable by the layout struct, including the
bad block marker bytes.

An example of this causing issues is when the last OOB data read
was from the start of a bad block where the markers are not 0xFF,
and the caller wishes to write new OOB data at the beginning of
another block. In this scenario the caller would provide OOB data,
but nand_fill_oob() would skip the bad block marker bytes in
oob_poi before copying the OOB data provided by the caller.
This means that when the OOB data is written back to NAND,
the block is inadvertently marked as bad without the caller knowing.
This has been witnessed when using YAFFS2 where tags are stored
in the OOB.

To avoid this oob_poi is always initialised to 0xFF to make sure
no left over data is inadvertently written back to the OOB area.

Credits to Brian Norris <computersforpeace@gmail.com> for fixing this
patch.

Signed-off-by: Adam Thomson <adam.thomson@alcatel-lucent.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
Cc: stable@kernel.org [2.6.20+]
13 years agojffs2: Avoid unneeded 'if' before kfree
Jesper Juhl [Mon, 13 Jun 2011 20:16:44 +0000 (22:16 +0200)]
jffs2: Avoid unneeded 'if' before kfree

kfree() deals gracefully with NULL pointers, so it's pointless to test for
one prior to calling it.
This removes such a test from jffs2_scan_medium().

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: onenand: remove redundant mtd_device_unregister before onenand_release
Axel Lin [Fri, 17 Jun 2011 11:06:33 +0000 (19:06 +0800)]
mtd: onenand: remove redundant mtd_device_unregister before onenand_release

onenand_release() will call mtd_device_unregister(), thus remove the redundant
mtd_device_unregister() call before onenand_release().

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
13 years agomtd: edb7312: correctly pass MTD name to parsers
Dmitry Eremin-Solenikov [Thu, 9 Jun 2011 10:54:41 +0000 (14:54 +0400)]
mtd: edb7312: correctly pass MTD name to parsers

cmdline partitions parser expects MTD name at mtd->name, instead of
origin, while edb7312 passes MTDID as origin. Fix that.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: mtd_dataflash.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 13:59:18 +0000 (17:59 +0400)]
mtd: mtd_dataflash.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: onenand/samsung.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:01:16 +0000 (18:01 +0400)]
mtd: onenand/samsung.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Axel Lin <axel.lin@gmail.com>: fixed build error.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: onenand/omap2.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:01:11 +0000 (18:01 +0400)]
mtd: onenand/omap2.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Axel Lin <axel.lin@gmail.com>: fixed build breakage

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: onenand/generic.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:01:10 +0000 (18:01 +0400)]
mtd: onenand/generic.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: txx9ndfmc.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:01:09 +0000 (18:01 +0400)]
mtd: txx9ndfmc.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: tmio_nand.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:01:09 +0000 (18:01 +0400)]
mtd: tmio_nand.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: sharpsl.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:01:03 +0000 (18:01 +0400)]
mtd: sharpsl.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: s3c2410.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:01:02 +0000 (18:01 +0400)]
mtd: s3c2410.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: pxa3xx_nand.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:00:59 +0000 (18:00 +0400)]
mtd: pxa3xx_nand.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
13 years agomtd: ppchameleonevb.c: use mtd_device_parse_register
Dmitry Eremin-Solenikov [Thu, 2 Jun 2011 14:00:58 +0000 (18:00 +0400)]
mtd: ppchameleonevb.c: use mtd_device_parse_register

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>