platform/kernel/linux-starfive.git
8 years agomtd: nand: jz4780: Update ecc correction error codes
Harvey Hunt [Fri, 8 Jan 2016 16:45:17 +0000 (16:45 +0000)]
mtd: nand: jz4780: Update ecc correction error codes

Update jz4780_bch_ecc_correct's return codes with appropriate values,
as specified in /include/linux/mtd/nand.h.

Signed-off-by: Harvey Hunt <harvey.hunt@imgtec.com>
Cc: Alex Smith <alex@alex-smith.me.uk>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nandsim: use nand_get_controller_data()
Brian Norris [Thu, 7 Jan 2016 19:06:46 +0000 (11:06 -0800)]
mtd: nandsim: use nand_get_controller_data()

Commit d699ed250c07 ("mtd: nand: make use of
nand_set/get_controller_data() helpers") overlooked some uses of
nand_chip::priv.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
8 years agomtd: jz4780_nand: remove useless mtd->priv = chip assignment
Brian Norris [Thu, 7 Jan 2016 18:02:59 +0000 (10:02 -0800)]
mtd: jz4780_nand: remove useless mtd->priv = chip assignment

As of commit 2d3b77bac34b ("mtd: nand: update mtd_to_nand()"), this
assignment isn't necessary, since struct mtd_info is embedded in struct
nand_chip.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Harvey Hunt <harvey.hunt@imgtec.com>
Cc: Alex Smith <alex@alex-smith.me.uk>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
8 years agostaging: mt29f_spinand: make use of nand_set/get_controller_data() helpers
Boris BREZILLON [Thu, 10 Dec 2015 08:00:42 +0000 (09:00 +0100)]
staging: mt29f_spinand: make use of nand_set/get_controller_data() helpers

New helpers have been added to avoid directly accessing chip->field. Use
them where appropriate.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: make use of nand_set/get_controller_data() helpers
Boris BREZILLON [Thu, 10 Dec 2015 08:00:41 +0000 (09:00 +0100)]
mtd: nand: make use of nand_set/get_controller_data() helpers

New helpers have been added to avoid directly accessing chip->field. Use
them where appropriate.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Brian: fixed a few rebase conflicts]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoARM: make use of nand_set/get_controller_data() helpers
Boris BREZILLON [Thu, 10 Dec 2015 08:00:40 +0000 (09:00 +0100)]
ARM: make use of nand_set/get_controller_data() helpers

New helpers have been added to avoid directly accessing chip->field. Use
them where appropriate.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: add helpers to access ->priv
Boris BREZILLON [Thu, 10 Dec 2015 08:00:39 +0000 (09:00 +0100)]
mtd: nand: add helpers to access ->priv

Add two helpers to access the field reserved for private controller data.
This makes it clearer what this field is reserved for and ease future
refactoring.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: jz4780: driver for NAND devices on JZ4780 SoCs
Alex Smith [Mon, 4 Jan 2016 12:34:43 +0000 (12:34 +0000)]
mtd: nand: jz4780: driver for NAND devices on JZ4780 SoCs

Add a driver for NAND devices connected to the NEMC on JZ4780 SoCs, as
well as the hardware BCH controller. DMA is not currently implemented.

While older 47xx SoCs also have a BCH controller, they are incompatible
with the one in the 4780 due to differing register/bit positions, which
would make implementing a common driver for them quite messy.

Signed-off-by: Alex Smith <alex.smith@imgtec.com>
Cc: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Harvey Hunt <harvey.hunt@imgtec.com>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Brian: fixed a few small mistakes]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: jz4740: remove custom 'erased check' implementation
Boris BREZILLON [Wed, 30 Dec 2015 19:41:29 +0000 (20:41 +0100)]
mtd: nand: jz4740: remove custom 'erased check' implementation

The jz4740 driver is manually checking for 'erased pages' while
correcting ECC bytes.
This logic can now done by the core infrastructure, and can thus be removed
from this driver.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: diskonchip: remove custom 'erased check' implementation
Boris BREZILLON [Wed, 30 Dec 2015 19:39:52 +0000 (20:39 +0100)]
mtd: nand: diskonchip: remove custom 'erased check' implementation

The diskonchip driver is manually checking for 'erased pages' while
correcting ECC bytes.
This logic can now done by the core infrastructure, and can thus be removed
from this driver.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: davinci: remove custom 'erased check' implementation
Boris BREZILLON [Wed, 30 Dec 2015 19:32:05 +0000 (20:32 +0100)]
mtd: nand: davinci: remove custom 'erased check' implementation

The davinci driver is manually checking for 'erased pages' while
correcting ECC bytes.
This logic can now done by the core infrastructure, and can thus be removed
from this driver.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Tested-by: Franklin S Cooper Jr. <fcooper@ti.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: use nand_check_erased_ecc_chunk in default ECC read functions
Boris BREZILLON [Wed, 30 Dec 2015 19:32:04 +0000 (20:32 +0100)]
mtd: nand: use nand_check_erased_ecc_chunk in default ECC read functions

The default NAND read functions are relying on the underlying controller
driver to correct bitflips, but some of those controllers cannot properly
fix bitflips in erased pages.
Check for bitflips in erased pages in default core functions if the driver
delegated the this check by setting the NAND_ECC_GENERIC_ERASED_CHECK flag.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Tested-by: Franklin S Cooper Jr. <fcooper@ti.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: return consistent error codes in ecc.correct() implementations
Boris BREZILLON [Wed, 30 Dec 2015 19:32:03 +0000 (20:32 +0100)]
mtd: nand: return consistent error codes in ecc.correct() implementations

The error code returned by the ecc.correct() are not consistent over the
all implementations.

Document the expected behavior in include/linux/mtd/nand.h and fix
offending implementations.

[Brian: this looks like a bugfix for the ECC reporting in the bf5xx_nand
driver, but we haven't seen any testing results for it]

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Tested-by: Franklin S Cooper Jr. <fcooper@ti.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agodoc: dt: mtd: new binding for jz4780-{nand,bch}
Alex Smith [Mon, 4 Jan 2016 12:34:42 +0000 (12:34 +0000)]
doc: dt: mtd: new binding for jz4780-{nand,bch}

Add DT bindings for NAND devices connected to the NEMC on JZ4780 SoCs,
as well as the hardware BCH controller, used by the jz4780_{nand,bch}
drivers.

Signed-off-by: Alex Smith <alex.smith@imgtec.com>
Cc: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Harvey Hunt <harvey.hunt@imgtec.com>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: cfi_cmdset_0001: fixing memory leak and handling failed kmalloc
Insu Yun [Tue, 29 Dec 2015 18:45:09 +0000 (13:45 -0500)]
mtd: cfi_cmdset_0001: fixing memory leak and handling failed kmalloc

kmalloc needs to be handled when failing in memory pressure.
Also, it has memory leak in error routine.

Signed-off-by: Insu Yun <wuninsu@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: spi-nor: wait until lock/unlock operations are ready
Ezequiel García [Mon, 28 Dec 2015 20:54:51 +0000 (17:54 -0300)]
mtd: spi-nor: wait until lock/unlock operations are ready

On Micron and Numonyx devices, the status register write command
(WRSR), raises a work-in-progress bit (WIP) on the status register.
The datasheets for these devices specify that while the status
register write is in progress, the status register WIP bit can still
be read to check the end of the operation.

This commit adds a wait_till_ready call on lock/unlock operations,
which is required for Micron and Numonyx but should be harmless for
others. This is needed to prevent applications from issuing erase or
program operations before the unlock operation is completed.

Reported-by: Stas Sergeev <stsp@list.ru>
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: tests: consolidate kmalloc/memset 0 call to kzalloc
Nicholas Mc Guire [Thu, 31 Dec 2015 15:21:22 +0000 (16:21 +0100)]
mtd: tests: consolidate kmalloc/memset 0 call to kzalloc

This is an API consolidation only. The use of kmalloc + memset to 0
is equivalent to kzalloc.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agojffs2: use to_delayed_work
Geliang Tang [Fri, 1 Jan 2016 14:06:27 +0000 (22:06 +0800)]
jffs2: use to_delayed_work

Use to_delayed_work() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: assign reasonable default name for NAND drivers
Brian Norris [Tue, 5 Jan 2016 18:39:45 +0000 (10:39 -0800)]
mtd: nand: assign reasonable default name for NAND drivers

Commits such as commit 853f1c58c4b2 ("mtd: nand: omap2: show parent
device structure in sysfs") attempt to rely on the core MTD code to set
the MTD name based on the parent device. However, nand_base tries to set
a different default name according to the flash name (e.g., extracted
from the ONFI parameter page), which means NAND drivers will never make
use of the MTD defaults. This is not the intention of commit
853f1c58c4b2.

This results in problems when trying to use the cmdline partition
parser, since the MTD name is different than expected. Let's fix this by
providing a default NAND name, where possible.

Note that this is not really a great default name in the long run, since
this means that if there are multiple MTDs attached to the same
controller device, they will have the same name. But that is an existing
issue and requires future work on a better controller vs. flash chip
abstraction to fix properly.

Fixes: 853f1c58c4b2 ("mtd: nand: omap2: show parent device structure in sysfs")
Reported-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Tested-by: Heiko Schocher <hs@denx.de>
Cc: Heiko Schocher <hs@denx.de>
Cc: Frans Klaver <fransklaver@gmail.com>
Cc: <stable@vger.kernel.org>
8 years agomtd: merge MTD development from v4.4 into for-v4.5 development
Brian Norris [Wed, 6 Jan 2016 00:04:40 +0000 (16:04 -0800)]
mtd: merge MTD development from v4.4 into for-v4.5 development

Small conflict between some bugfixes for 4.4 and some refactoring for
4.5.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: spi-nor: fix stm_is_locked_sr() parameters
Brian Norris [Tue, 15 Dec 2015 18:48:21 +0000 (10:48 -0800)]
mtd: spi-nor: fix stm_is_locked_sr() parameters

stm_is_locked_sr() takes the status register (SR) value as the last
parameter, not the second.

Reported-by: Bayi Cheng <bayi.cheng@mediatek.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Bayi Cheng <bayi.cheng@mediatek.com>
8 years agomtd: spi-nor: fix Spansion regressions (aliased with Winbond)
Brian Norris [Tue, 15 Dec 2015 18:48:20 +0000 (10:48 -0800)]
mtd: spi-nor: fix Spansion regressions (aliased with Winbond)

Spansion and Winbond have occasionally used the same manufacturer ID,
and they don't support the same features. Particularly, writing SR=0
seems to break read access for Spansion's s25fl064k. Unfortunately, we
don't currently have a way to differentiate these Spansion and Winbond
parts, so rather than regressing support for these Spansion flash, let's
drop the new Winbond lock/unlock support for now. We can try to address
Winbond support during the next release cycle.

Original discussion:

http://patchwork.ozlabs.org/patch/549173/
http://patchwork.ozlabs.org/patch/553683/

Fixes: 357ca38d4751 ("mtd: spi-nor: support lock/unlock/is_locked for Winbond")
Fixes: c6fc2171b249 ("mtd: spi-nor: disable protection for Winbond flash at startup")
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reported-by: Felix Fietkau <nbd@openwrt.org>
Cc: Felix Fietkau <nbd@openwrt.org>
8 years agomtd: nand: fix for drop unnecessary partition parser data
Stephen Rothwell [Mon, 4 Jan 2016 18:32:54 +0000 (10:32 -0800)]
mtd: nand: fix for drop unnecessary partition parser data

From Stephen:

    Hi Brian,

    After merging the l2-mtd tree, today's linux-next build (powerpc
    ppc44x_defconfig) failed like this:

    drivers/mtd/nand/ndfc.c: In function 'ndfc_chip_init':
    drivers/mtd/nand/ndfc.c:177:2: error: 'ppdata' undeclared (first use in this function)
      ppdata.of_node = flash_np;
      ^

    Caused by commit

      a61ae81a1907 ("mtd: nand: drop unnecessary partition parser data")

The flash node is already correctly assigned using the new helper
(nand_set_flash_node()) so the correct fix is indeed to simply drop this
line.

Fixes: a61ae81a1907 ("mtd: nand: drop unnecessary partition parser data")
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: fix cmdlinepart parser, early naming for auto-filled MTD
Brian Norris [Fri, 11 Dec 2015 23:58:01 +0000 (15:58 -0800)]
mtd: fix cmdlinepart parser, early naming for auto-filled MTD

Commit 807f16d4db95 ("mtd: core: set some defaults when dev.parent is
set") attempted to provide some default settings for MTDs that
 (a) assign the parent device and
 (b) don't provide their own name or owner

However, this isn't a perfect drop-in replacement for the boilerplate
found in some drivers, because the MTD name is used by partition
parsers like cmdlinepart, but the name isn't set until add_mtd_device(),
after the parsing is completed. This means cmdlinepart sees a NULL name
and therefore will not work properly.

Fix this by moving the default name and owner assignment to be first in
the MTD registration process.

[Note: this does not fix all reported issues, particularly with NAND
drivers. Will require an additional fix for drivers/mtd/nand/]

Fixes: 807f16d4db95 ("mtd: core: set some defaults when dev.parent is set")
Reported-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Heiko Schocher <hs@denx.de>
Cc: Frans Klaver <fransklaver@gmail.com>
8 years agomtd: sh_flctl: pass FIFO as physical address
Arnd Bergmann [Tue, 8 Dec 2015 15:38:12 +0000 (16:38 +0100)]
mtd: sh_flctl: pass FIFO as physical address

By convention, the FIFO address we pass using dmaengine_slave_config
is a physical address in the form that is understood by the DMA
engine, as a dma_addr_t, phys_addr_t or resource_size_t.

The sh_flctl driver however passes a virtual __iomem address that
gets cast to dma_addr_t in the slave driver. This happens to work
on shmobile because that platform sets up an identity mapping for
its MMIO regions, but such code is not portable to other platforms,
and prevents us from ever changing the platform mapping or reusing
the driver on other architectures like ARM64 that might not have the
mapping.

We also get a warning about a type mismatch for the case that
dma_addr_t is wider than a pointer, i.e. when CONFIG_LPAE is set:

drivers/mtd/nand/sh_flctl.c: In function 'flctl_setup_dma':
drivers/mtd/nand/sh_flctl.c:163:17: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  cfg.dst_addr = (dma_addr_t)FLDTFIFO(flctl);

This changes the driver to instead pass the physical address of
the FIFO that is extracted from the MMIO resource, making the
code more portable and avoiding the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: denali: make MTD_NAND_DENALI_DT dependent on OF
Masahiro Yamada [Wed, 16 Dec 2015 05:00:09 +0000 (14:00 +0900)]
mtd: denali: make MTD_NAND_DENALI_DT dependent on OF

The build passes even if CONFIG_OF is undefined, but it makes sense
to let it depend on OF.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: Disable subpage writes for drivers without ecc->hwctl
Helmut Schaa [Wed, 9 Apr 2014 09:13:24 +0000 (11:13 +0200)]
mtd: nand: Disable subpage writes for drivers without ecc->hwctl

nand_write_subpage_hwecc causes a crash if the driver did not register
ecc->hwctl or ecc->calculate. Fix this by disabling subpage writes if
ecc->hwctl or ecc->calculate is not provided by the driver.

This behavior was introduced in commit 837a6ba4f3b6d23026674e6af6b6849a4634fff9
"mtd: nand: subpage write support for hardware based ECC schemes".

This fixes a crash with fsl_elbc_nand and maybe others:

Unable to handle kernel paging request for instruction fetch
Faulting instruction address: 0x00000000
Oops: Kernel access of bad area, sig: 11 [#1]
SMP NR_CPUS=2 P1020 RDB
Modules linked in: ath9k ath9k_common pppoe ppp_async option iptable_nat ath9k_hw ath usb_wwan pppox ppp_generic nf_nat_ipv4 nf_conntrack_ipv4 mac80211 ipt_MASQUERADE cfg80211 xt_time xt_tcpudp xt_state xt_quota xt_policy xt_pkttype xt_owner xt_nat xt_multiport xt_mh
CPU: 1 PID: 2161 Comm: ubiformat Not tainted 3.10.26 #6
task: efbc2700 ti: c7950000 task.ti: c7950000
NIP: 00000000 LR: c01a495c CTR: 00000000
REGS: c7951cb0 TRAP: 0400   Not tainted  (3.10.26)
MSR: 00029000 <CE,EE,ME>  CR: 24002028  XER: 00000000

GPR00: c01a4b6c c7951d60 efbc2700 ef84b000 00000001 00000000 000001ff c7800500
GPR08: 00000000 00000000 efae5e40 c01a4ae4 24002022 10023418 c7951e5c c7800500
GPR16: c017b6a8 00000000 0000003f c053404c 00000000 00000004 00000000 00000003
GPR24: 00000010 00000200 ef84b000 c7800d00 c7800000 c7800500 ef84b1c8 00000000
NIP [00000000]   (null)
LR [c01a495c] nand_write_subpage_hwecc+0x74/0x174
Call Trace:
[c7951d60] [c7951d64] 0xc7951d64 (unreliable)
[c7951da0] [c01a4b6c] nand_write_page+0x88/0x198
[c7951dd0] [c01a5f7c] nand_do_write_ops+0x2f4/0x39c
[c7951e40] [c01a61e0] nand_write+0x58/0x84
[c7951e80] [c019e29c] mtdchar_write+0x1dc/0x28c
[c7951ef0] [c00aba84] vfs_write+0xcc/0x1ac
[c7951f10] [c00ac04c] SyS_write+0x4c/0x90
[c7951f40] [c000cd84] ret_from_syscall+0x0/0x3c
 --- Exception: c01 at 0x48050ed8
     LR = 0x100071b8
 Instruction dump:
 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
 ---[ end trace 161d3c65a2a15cb8 ]---

Kernel panic - not syncing: Fatal exception

[Brian: editorial note - we've applied a previous fix for the driver in
question (fsl_elbc_nand) long ago:
commit f034d87def51 ("mtd: eLBC NAND: fix subpage write support")
but this still makes sense, and it could solve issues on some other
unforseen driver.]

Cc: Pekon Gupta <pekon.gupta@gmail.com>
Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Cc: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: ftl: use swap() in copy_erase_unit()
Fabian Frederick [Wed, 10 Jun 2015 16:31:06 +0000 (18:31 +0200)]
mtd: ftl: use swap() in copy_erase_unit()

Use kernel.h macro definition.

Thanks to Julia Lawall for Coccinelle scripting support.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: cfi_cmdset_0002: use swap() in cfi_cmdset_0002()
Fabian Frederick [Wed, 10 Jun 2015 16:31:32 +0000 (18:31 +0200)]
mtd: cfi_cmdset_0002: use swap() in cfi_cmdset_0002()

Use kernel.h macro definition.

Thanks to Julia Lawall for Coccinelle scripting support.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: mtk-nor: adjust sequence of trigger function and assignment function
Bayi Cheng [Fri, 18 Dec 2015 03:02:40 +0000 (11:02 +0800)]
mtd: mtk-nor: adjust sequence of trigger function and assignment function

Move write data register before excute command to avoid
missing first byte write to nor flash

Signed-off-by: Bayi Cheng <bayi.cheng@mediatek.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: remove unused and buggy get_platform_nandchip() helper function
Boris BREZILLON [Mon, 14 Dec 2015 15:13:31 +0000 (16:13 +0100)]
mtd: nand: remove unused and buggy get_platform_nandchip() helper function

Nobody uses the get_platform_nandchip() helper function which is supposed
to return a pointer to a platform_nand_chip struct from an mtd_info
pointer.
Moreover, this function is buggy since the introduction of the plat_nand
layer (chip->priv is now storing a pointer to an intermediate
plat_nand_data structure allocated in plat_nand_probe(), and we have no
way to retrieve a pointer to the provided platform_nand_chip struct from
this plat_nand_data pointer).

While we are at it, remove the useless (and buggy, since it's pointing to
something stored on the stack) data->chip.priv assignment.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Fixes: 711fdf627ce1 ("[MTD] [NAND] platform NAND driver: add driver")
Cc: Vitaly Wool <vitalywool@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: kill the chip->flash_node field
Boris BREZILLON [Thu, 10 Dec 2015 08:00:38 +0000 (09:00 +0100)]
mtd: nand: kill the chip->flash_node field

Now that the nand_chip struct directly embeds an mtd_info struct we can
get rid of the ->flash_node field and forward set/get_flash_node requests
to the MTD layer.

As a side effect, we no longer need the mtd_set_of_node() call done in
nand_dt_init().

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: simplify nand_dt_init() usage
Boris BREZILLON [Thu, 10 Dec 2015 08:00:37 +0000 (09:00 +0100)]
mtd: nand: simplify nand_dt_init() usage

nand_dt_init() function requires 3 arguments where it actually needs one
(dn and mtd can both be retrieved from chip). Drop these parameters.

Testing for dn != NULL inside nand_dt_init() also helps simplifying the
caller code.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agostaging: mt29f_spinand: remove useless mtd->priv = chip assignment
Boris BREZILLON [Thu, 10 Dec 2015 08:00:36 +0000 (09:00 +0100)]
staging: mt29f_spinand: remove useless mtd->priv = chip assignment

mtd_to_nand() now uses the container_of() approach to transform an
mtd_info pointer into a nand_chip one. Drop useless mtd->priv
assignments from NAND controller drivers.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agocris: nand: remove useless mtd->priv = chip assignments
Boris BREZILLON [Thu, 10 Dec 2015 08:00:35 +0000 (09:00 +0100)]
cris: nand: remove useless mtd->priv = chip assignments

mtd_to_nand() now uses the container_of() approach to transform an
mtd_info pointer into a nand_chip one. Drop useless mtd->priv
assignments from NAND controller drivers.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: remove useless mtd->priv = chip assignments
Boris BREZILLON [Thu, 10 Dec 2015 08:00:34 +0000 (09:00 +0100)]
mtd: nand: remove useless mtd->priv = chip assignments

mtd_to_nand() now uses the container_of() approach to transform an
mtd_info pointer into a nand_chip one. Drop useless mtd->priv
assignments from NAND controller drivers.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: update mtd_to_nand()
Boris BREZILLON [Thu, 10 Dec 2015 08:00:33 +0000 (09:00 +0100)]
mtd: nand: update mtd_to_nand()

Now that all drivers are using the mtd instance embedded in the nand_chip
struct we can safely update the mtd_to_nand() implementation to use
the container_of macro instead of returning the content of mtd->priv.
This will allow us to remove mtd->priv = chip assignments done in all
NAND controller drivers.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: denali: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Fri, 11 Dec 2015 14:06:00 +0000 (15:06 +0100)]
mtd: nand: denali: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: socrates: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Fri, 11 Dec 2015 14:04:06 +0000 (15:04 +0100)]
mtd: nand: socrates: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: bcm47xx: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 07:59:52 +0000 (08:59 +0100)]
mtd: nand: bcm47xx: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agocris: nand: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:32 +0000 (09:00 +0100)]
cris: nand: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Patch all drivers to make use
of this mtd instance instead of using the instance embedded in their
private struct or dynamically allocated.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agostaging: mt29f_spinand: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:31 +0000 (09:00 +0100)]
staging: mt29f_spinand: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device, use it instead of allocating
a new one.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: docg4: simplify error case
Brian Norris [Fri, 18 Dec 2015 19:39:53 +0000 (11:39 -0800)]
mtd: nand: docg4: simplify error case

Other refactorings have left the 'fail' label much simpler, so it
shouldn't have to handle the failed allocation case.

This also fixes a -Wshadow warning.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
8 years agomtd: nand: s3c2410: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:22 +0000 (09:00 +0100)]
mtd: nand: s3c2410: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: update the documentation to reflect framework changes
Boris BREZILLON [Thu, 10 Dec 2015 08:00:30 +0000 (09:00 +0100)]
mtd: nand: update the documentation to reflect framework changes

The MTD device is now directly embedded in the nand_chip struct. Update the
mtdnand documentation to mention this aspect and fix the different
examples.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: vf610: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:29 +0000 (09:00 +0100)]
mtd: nand: vf610: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: txx9ndfmc: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:28 +0000 (09:00 +0100)]
mtd: nand: txx9ndfmc: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: tmio: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:27 +0000 (09:00 +0100)]
mtd: nand: tmio: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: sunxi: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:26 +0000 (09:00 +0100)]
mtd: nand: sunxi: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: sharpsl: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:24 +0000 (09:00 +0100)]
mtd: nand: sharpsl: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: sh_flctl: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:23 +0000 (09:00 +0100)]
mtd: nand: sh_flctl: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: r852: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:21 +0000 (09:00 +0100)]
mtd: nand: r852: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: pxa3xx: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:20 +0000 (09:00 +0100)]
mtd: nand: pxa3xx: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: plat: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:19 +0000 (09:00 +0100)]
mtd: nand: plat: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: pasemi: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:18 +0000 (09:00 +0100)]
mtd: nand: pasemi: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: orion: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:17 +0000 (09:00 +0100)]
mtd: nand: orion: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: omap2: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:16 +0000 (09:00 +0100)]
mtd: nand: omap2: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: nuc900: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:15 +0000 (09:00 +0100)]
mtd: nand: nuc900: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: ndfc: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:14 +0000 (09:00 +0100)]
mtd: nand: ndfc: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: nandsim: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:13 +0000 (09:00 +0100)]
mtd: nand: nandsim: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: mxc: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:12 +0000 (09:00 +0100)]
mtd: nand: mxc: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: mpc5121: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:11 +0000 (09:00 +0100)]
mtd: nand: mpc5121: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: lpc32xx: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:10 +0000 (09:00 +0100)]
mtd: nand: lpc32xx: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: jz4740: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:09 +0000 (09:00 +0100)]
mtd: nand: jz4740: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: hisi504: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:08 +0000 (09:00 +0100)]
mtd: nand: hisi504: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: gpmi: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:07 +0000 (09:00 +0100)]
mtd: nand: gpmi: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: gpio: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:06 +0000 (09:00 +0100)]
mtd: nand: gpio: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: fsmc: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:05 +0000 (09:00 +0100)]
mtd: nand: fsmc: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: fsl_upm: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:04 +0000 (09:00 +0100)]
mtd: nand: fsl_upm: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: fsl_ifc: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:03 +0000 (09:00 +0100)]
mtd: nand: fsl_ifc: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: fsl_elbc: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:02 +0000 (09:00 +0100)]
mtd: nand: fsl_elbc: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: docg4: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:01 +0000 (09:00 +0100)]
mtd: nand: docg4: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: diskonchip: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 08:00:00 +0000 (09:00 +0100)]
mtd: nand: diskonchip: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: davinci: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 07:59:58 +0000 (08:59 +0100)]
mtd: nand: davinci: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: cmx270: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 07:59:56 +0000 (08:59 +0100)]
mtd: nand: cmx270: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Brian: dropped a defunct comment]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: cs553x: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 07:59:57 +0000 (08:59 +0100)]
mtd: nand: cs553x: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: cafe: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 07:59:55 +0000 (08:59 +0100)]
mtd: nand: cafe: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: brcm: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 07:59:54 +0000 (08:59 +0100)]
mtd: nand: brcm: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: bf5xx: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 07:59:53 +0000 (08:59 +0100)]
mtd: nand: bf5xx: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: au1550nd: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 07:59:51 +0000 (08:59 +0100)]
mtd: nand: au1550nd: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: atmel: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 07:59:50 +0000 (08:59 +0100)]
mtd: nand: atmel: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: ams-delta: use the mtd instance embedded in struct nand_chip
Boris BREZILLON [Thu, 10 Dec 2015 07:59:49 +0000 (08:59 +0100)]
mtd: nand: ams-delta: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance
instead of allocating our own.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: omap2: create and use mtd_to_omap()
Boris BREZILLON [Thu, 10 Dec 2015 07:59:48 +0000 (08:59 +0100)]
mtd: nand: omap2: create and use mtd_to_omap()

Define and use mtd_to_omap() instead of container_of();

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: nuc900: create and use mtd_to_nuc900()
Boris BREZILLON [Thu, 10 Dec 2015 07:59:47 +0000 (08:59 +0100)]
mtd: nand: nuc900: create and use mtd_to_nuc900()

Create and use mtd_to_nuc900() instead of direct container_of() calls.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: fsmc: create and use mtd_to_fsmc()
Boris BREZILLON [Thu, 10 Dec 2015 07:59:46 +0000 (08:59 +0100)]
mtd: nand: fsmc: create and use mtd_to_fsmc()

Create and use mtd_to_fsmc() to avoid duplication of
container_of(mtd, struct fsmc_nand_data, mtd) calls.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: omap_elm: print interrupt resource using %pr
Arnd Bergmann [Fri, 18 Dec 2015 13:15:17 +0000 (14:15 +0100)]
mtd: omap_elm: print interrupt resource using %pr

When CONFIG_LPAE is set on ARM, resource_size_t is 64-bit wide
and we get a warning about an incorrect format string for printing
the interrupt number in elm_probe:

drivers/mtd/nand/omap_elm.c: In function 'elm_probe':
drivers/mtd/nand/omap_elm.c:417:23: warning: format '%i' expects argument of type 'int', but argument 3 has type 'resource_size_t {aka long long unsigned int}' [-Wformat=]

This patch avoids the type mismatch by printing the interrupt as
a resource using the %pr format string.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: bcm47xxnflash: really unregister NAND on device removal
Brian Norris [Wed, 9 Dec 2015 01:04:59 +0000 (17:04 -0800)]
mtd: bcm47xxnflash: really unregister NAND on device removal

The field bcma_nflash::mtd is never set to be non-zero anywhere, but we
test for it in the removal path. So the MTD is never unregistered.

Also, we should use nand_release(), not mtd_device_unregister().

Finally, we don't need to use the 'platdata' for stashing/retrieving our
*driver* data -- that's what *_{get,set}_drvdata() are for.

So, kill off bcm_nflash::mtd, and stash the struct bcm47xxnflash in
drvdata instead. Also move the forward declaration of mtd_info up a bit,
since struct bcma_sflash should be using it.

Caught while inspecting other changes being made to this driver. Compile
tested only.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: "Rafał Miłecki" <zajec5@gmail.com>
Cc: linux-wireless@vger.kernel.org
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
8 years agomtd: nand: denali: add missing nand_release() call in denali_remove()
Boris BREZILLON [Fri, 11 Dec 2015 14:02:34 +0000 (15:02 +0100)]
mtd: nand: denali: add missing nand_release() call in denali_remove()

Unregister the NAND device from the NAND subsystem when removing a denali
NAND controller, otherwise the MTD attached to the NAND device is still
exposed by the MTD layer, and accesses to this device will likely crash
the system.

Fixes: 2a0a288ec258 ("mtd: denali: split the generic driver and PCI layer")
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: brcmnand: defer to devm_ioremap_resource() for error checking
Brian Norris [Thu, 10 Dec 2015 02:33:17 +0000 (18:33 -0800)]
mtd: brcmnand: defer to devm_ioremap_resource() for error checking

devm_ioremap_resource() does error checking on the 'res' argument, so
drop the error check in bcm6368_nand.c.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Tested-by: Simon Arlott <simon@fire.lp0.eu>
8 years agomtd: brcmnand: Add support for the BCM6368
Simon Arlott [Wed, 9 Dec 2015 20:43:54 +0000 (20:43 +0000)]
mtd: brcmnand: Add support for the BCM6368

The BCM6368 has a NAND interrupt register with combined status and enable
registers.

As the BCM6328, BCM6362 and BCM6368 all use v2.1 controllers, the first
variant that will work with this driver is the BCM63268 using a v4.0
controller.

Set up the device by disabling and acking all interrupts, then handle
the CTRL_READY interrupt.

Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: brcmnand: Request and enable the clock if present
Simon Arlott [Wed, 9 Dec 2015 20:42:25 +0000 (20:42 +0000)]
mtd: brcmnand: Request and enable the clock if present

Attempt to enable a clock named "nand" as some SoCs have a clock for the
controller that needs to be enabled.

Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agodoc: dt: mtd: brcmnand: Add brcm,bcm6368-nand device tree binding
Simon Arlott [Wed, 9 Dec 2015 20:40:58 +0000 (20:40 +0000)]
doc: dt: mtd: brcmnand: Add brcm,bcm6368-nand device tree binding

Add device tree binding for NAND on the BCM6368.

The BCM6368 has a NAND interrupt register with combined status and enable
registers. It also requires a clock, so add an optional clock to the
common brcmnand binding.

Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: nand: Confine MTD_NAND_SH_FLCTL to SUPERH
Geert Uytterhoeven [Tue, 8 Dec 2015 17:40:59 +0000 (18:40 +0100)]
mtd: nand: Confine MTD_NAND_SH_FLCTL to SUPERH

As of commit a521422ea4ae6128 ("ARM: shmobile: mackerel: Remove Legacy C
board code"), the Renesas SuperH FLCTL driver is no longer used on ARM
SH-Mobile SoCs. Restrict the dependencies, unless compile-testing.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: spi-nor: Check the return value from read_sr()
Fabio Estevam [Fri, 20 Nov 2015 18:26:11 +0000 (16:26 -0200)]
mtd: spi-nor: Check the return value from read_sr()

We should better check the return value from read_sr() and
propagate it in the case of error.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomtd: partitions: support a cleanup callback for parsers
Brian Norris [Wed, 9 Dec 2015 18:24:03 +0000 (10:24 -0800)]
mtd: partitions: support a cleanup callback for parsers

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>
8 years agomtd: partitions: pass around 'mtd_partitions' wrapper struct
Brian Norris [Fri, 4 Dec 2015 23:25:17 +0000 (15:25 -0800)]
mtd: partitions: pass around 'mtd_partitions' wrapper struct

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>
8 years agomtd: partitions: remove kmemdup()
Brian Norris [Fri, 4 Dec 2015 23:25:16 +0000 (15:25 -0800)]
mtd: partitions: remove kmemdup()

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>
8 years agomtd: partitions: rename MTD parser get/put
Brian Norris [Fri, 4 Dec 2015 23:25:15 +0000 (15:25 -0800)]
mtd: partitions: rename MTD parser get/put

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>
8 years agomtd: partitions: make parsers return 'const' partition arrays
Brian Norris [Fri, 4 Dec 2015 23:25:14 +0000 (15:25 -0800)]
mtd: partitions: make parsers return 'const' partition arrays

We only want to modify these arrays inside the parser "drivers", so the
drivers should construct them however they like, then return them as
immutable arrays.

This will make other refactorings easier.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
8 years agomtd: ofpart: assign return argument exactly once
Brian Norris [Fri, 4 Dec 2015 23:25:13 +0000 (15:25 -0800)]
mtd: ofpart: assign return argument exactly once

It's easier to refactor these parsers if the return value gets assigned
only once, just like every other MTD partition parser.

This prepares for making the second arg to the parse_fn() const. This is
OK if we construct the partitions completely first, and assign them to
the return pointer only after we're done modifying them.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>