platform/kernel/linux-rpi.git
4 years agomtd: rawnand: Add an invalid ECC mode to discriminate with valid ones
Miquel Raynal [Tue, 26 May 2020 19:56:18 +0000 (21:56 +0200)]
mtd: rawnand: Add an invalid ECC mode to discriminate with valid ones

NAND ECC modes (or providers) have their own enumeration but, unlike
their algorithms counterpart, there is no invalid or uninitialized
value to discriminate between an error and having chosen a no-ECC
situation. Add an "invalid" entry for this purpose.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200526195633.11543-7-miquel.raynal@bootlin.com
4 years agomtd: rawnand: Return an enum from of_get_nand_ecc_algo()
Miquel Raynal [Tue, 26 May 2020 19:56:17 +0000 (21:56 +0200)]
mtd: rawnand: Return an enum from of_get_nand_ecc_algo()

There is an enumeration to list ECC algorithm, let's use it instead of
returning an int.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200526195633.11543-6-miquel.raynal@bootlin.com
4 years agomtd: rawnand: Drop OOB_FIRST placement scheme
Miquel Raynal [Tue, 26 May 2020 19:56:15 +0000 (21:56 +0200)]
mtd: rawnand: Drop OOB_FIRST placement scheme

This scheme has been introduced for the Davinci controller and means
that the OOB area must be read *before* the rest of the data. This has
nothing to do with the ECC in OOB placement as it could be understood
and most importantly, there is no point in having this function out of
the Davinci NAND controller driver. A DT property for this scheme has
been added but never used, even by the Davinci driver which only uses
this scheme to change the default nand_read_page().

Move the main read_page() helper into the Davinci driver and remove
the remaining boilerplate.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200526195633.11543-4-miquel.raynal@bootlin.com
4 years agomtd: rawnand: Avoid a typedef
Miquel Raynal [Tue, 26 May 2020 19:56:14 +0000 (21:56 +0200)]
mtd: rawnand: Avoid a typedef

In new code, the use of typedef is discouraged. Turn this one in the
raw NAND core into a regular enumeration.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200526195633.11543-3-miquel.raynal@bootlin.com
4 years agomtd: Fix typo in mtd_ooblayout_set_databytes() description
Miquel Raynal [Tue, 26 May 2020 19:56:13 +0000 (21:56 +0200)]
mtd: Fix typo in mtd_ooblayout_set_databytes() description

Fix a probable copy/paste error: the function works like
mtd_ooblayout_set_bytes(), not *_get_bytes().

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200526195633.11543-2-miquel.raynal@bootlin.com
4 years agomtd: rawnand: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:35 +0000 (15:00 +0200)]
mtd: rawnand: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Now that all drivers have been converted to do not use nand_release()
anymore, let's remove this helper.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-63-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Reorganize ns_cleanup_module()
Miquel Raynal [Mon, 25 May 2020 08:58:51 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Reorganize ns_cleanup_module()

Reorganize ns_cleanup_module() to fit the reworked exit path of
ns_init_module().

There is no need for a ns_free_lists() function anymore, so drop it.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-18-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Rename a label in ns_init_module()
Miquel Raynal [Mon, 25 May 2020 08:58:50 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Rename a label in ns_init_module()

Rename the "error" label to gave it a meaning.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-17-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Manage lists on error in ns_init_module()
Miquel Raynal [Mon, 25 May 2020 08:58:49 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Manage lists on error in ns_init_module()

Lists are filled with calls to ns_parse_weakblocks(),
ns_parse_weakpages() and ns_parse_gravepages(). Handle them in the
error path, all at the same time.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-16-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Fix the label pointing on nand_cleanup()
Miquel Raynal [Mon, 25 May 2020 08:58:48 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Fix the label pointing on nand_cleanup()

Drop the generic err_exit.

The remaining operation to do from this goto statement is to cleanup
the NAND allocations, so rename it.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-15-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Free erase_block_wear on error
Miquel Raynal [Mon, 25 May 2020 08:58:47 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Free erase_block_wear on error

Free erase_block_wear on error, which is allocated by
ns_setup_wear_reporting().

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-14-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Use an additional label when freeing the nandsim object
Miquel Raynal [Mon, 25 May 2020 08:58:46 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Use an additional label when freeing the nandsim object

Cosmetic change to give a meaning to all labels in this complicated
error path.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-13-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Stop using nand_release()
Miquel Raynal [Mon, 25 May 2020 08:58:45 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Stop using nand_release()

nand_release() basically calls mtd_device_unregister() and
nand_cleanup(). Both helpers should be called after MTD device
registration and NAND scan, respectively. Drop nand_release() and use
the two helpers directly so that they fit the error path and the
labels there.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-12-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Free the partition names in ns_free()
Miquel Raynal [Mon, 25 May 2020 08:58:44 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Free the partition names in ns_free()

ns_free() is the helper that is called symmetrically to ns_init() and
so should free the same objects, including the partition names.

Now, callers of ns_free() do not need to free this partition names
themselves.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-11-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Free the allocated device on error in ns_init()
Miquel Raynal [Mon, 25 May 2020 08:58:43 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Free the allocated device on error in ns_init()

The nandsim device is allocated and initialized inside ns_init() by a
call to ns_alloc_device(), free it on error.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-10-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Free partition names on error in ns_init()
Miquel Raynal [Mon, 25 May 2020 08:58:42 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Free partition names on error in ns_init()

The ns_init() function shall free the partition names allocated by
ns_get_partition_name() on error.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-9-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Fix the two ns_alloc_device() error paths
Miquel Raynal [Mon, 25 May 2020 08:58:41 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Fix the two ns_alloc_device() error paths

The ns_alloc_device() helper has actually two distinct path. Handle
errors in both of them.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-8-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Remove debugfs entries at unload time
Miquel Raynal [Mon, 25 May 2020 08:58:40 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Remove debugfs entries at unload time

Create a ns_debugfs_remove() helper for that and call it in
ns_cleanup_module().

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-7-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Keep track of the created debugfs entries
Miquel Raynal [Mon, 25 May 2020 08:58:39 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Keep track of the created debugfs entries

Debugfs entries should be removed in the error path, so first, keep
track of them.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-6-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Clean error handling
Miquel Raynal [Mon, 25 May 2020 08:58:38 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Clean error handling

Many function calls are done this way:

        if ((retval = func()) != 0)
        return retval;

while we expect in the kernel function calls like:

        retval = func();
if (retval)
        return retval;

Apply this change where possible and also use "ret" instead of
"retval" in ns_init_module for consistency, as it is only used in this
function.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-5-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Use a consistent ns_ prefix for all functions
Miquel Raynal [Mon, 25 May 2020 08:58:37 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Use a consistent ns_ prefix for all functions

Some functions are prefixed "nandsim_", others "ns_" and many are
simply not prefixed at all. Make this file consistent by prefixing all
functions by "ns_".

This is a mechanical change. Sometimes the line is a bit reworked as
well to fit the kernel coding style. For instance, there are several
places where displayed strings are cut. When one of this line is
changed because of the naming update, the two parts of the strings
gets concatenated.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-4-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Use octal permissions
Miquel Raynal [Mon, 25 May 2020 08:58:36 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Use octal permissions

Symbolic permissions 'S_IRUSR' are not preferred. Checkpatch.pl
advises to use octal permissions '0400'.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-3-miquel.raynal@bootlin.com
4 years agomtd: rawnand: nandsim: Consistent use of 'ns' instead of 'dev'
Miquel Raynal [Mon, 25 May 2020 08:58:35 +0000 (10:58 +0200)]
mtd: rawnand: nandsim: Consistent use of 'ns' instead of 'dev'

The nandsim object is called 'ns' almost everywhere, keep it that way
everywhere for consistency.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-2-miquel.raynal@bootlin.com
4 years agomtd: rawnand: brcmnand: support v2.1-v2.2 controllers
Álvaro Fernández Rojas [Fri, 22 May 2020 12:15:24 +0000 (14:15 +0200)]
mtd: rawnand: brcmnand: support v2.1-v2.2 controllers

v2.1: tested on Netgear DGND3700v1 (BCM6368)
v2.2: tested on Netgear DGND3700v2 (BCM6362)

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-6-noltari@gmail.com
4 years agodt-bindings: mtd: brcmnand: add v2.1 and v2.2 support
Álvaro Fernández Rojas [Fri, 22 May 2020 12:15:23 +0000 (14:15 +0200)]
dt-bindings: mtd: brcmnand: add v2.1 and v2.2 support

Add brcm,brcmnand-v2.1 and brcm,brcmnand-v2.2 as possible compatible
strings to support brcmnand controllers v2.1 and v2.2.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-5-noltari@gmail.com
4 years agomtd: rawnand: brcmnand: rename page sizes
Álvaro Fernández Rojas [Fri, 22 May 2020 12:15:22 +0000 (14:15 +0200)]
mtd: rawnand: brcmnand: rename page sizes

Current pages sizes apply to controllers after v3.4

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-4-noltari@gmail.com
4 years agomtd: rawnand: brcmnand: fix CS0 layout
Álvaro Fernández Rojas [Fri, 22 May 2020 12:15:21 +0000 (14:15 +0200)]
mtd: rawnand: brcmnand: fix CS0 layout

Only v3.3-v5.0 have a different CS0 layout.
Controllers before v3.3 use the same layout for every CS.

Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-3-noltari@gmail.com
4 years agomtd: rawnand: brcmnand: rename v4 registers
Álvaro Fernández Rojas [Fri, 22 May 2020 12:15:20 +0000 (14:15 +0200)]
mtd: rawnand: brcmnand: rename v4 registers

These registers are also used on v3.3.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-2-noltari@gmail.com
4 years agomtd: rawnand: gpmi: Use nand_extract_bits()
Miquel Raynal [Fri, 8 May 2020 17:18:05 +0000 (19:18 +0200)]
mtd: rawnand: gpmi: Use nand_extract_bits()

Drop the use of gpmi_copy_bits() in favor of the NAND helper
nand_extract_bits().

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200508171805.8627-1-miquel.raynal@bootlin.com
4 years agomtd: rawnand: omap_elm: Fix runtime PM imbalance on error
Dinghao Liu [Fri, 22 May 2020 10:40:06 +0000 (18:40 +0800)]
mtd: rawnand: omap_elm: Fix runtime PM imbalance on error

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200522104008.28340-1-dinghao.liu@zju.edu.cn
4 years agomtd: rawnand: gpmi: Fix runtime PM imbalance in gpmi_nand_probe
Dinghao Liu [Fri, 22 May 2020 10:17:13 +0000 (18:17 +0800)]
mtd: rawnand: gpmi: Fix runtime PM imbalance in gpmi_nand_probe

There is no reason that the failure of __gpmi_enable_clk()
could lead to PM usage counter decrement.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200522101713.24350-1-dinghao.liu@zju.edu.cn
4 years agomtd: rawnand: gpmi: Fix runtime PM imbalance on error
Dinghao Liu [Fri, 22 May 2020 09:51:39 +0000 (17:51 +0800)]
mtd: rawnand: gpmi: Fix runtime PM imbalance on error

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200522095139.19653-1-dinghao.liu@zju.edu.cn
4 years agomtd: rawnand: ingenic: Convert the driver to exec_op()
Boris Brezillon [Tue, 19 May 2020 23:24:54 +0000 (01:24 +0200)]
mtd: rawnand: ingenic: Convert the driver to exec_op()

Let's convert the driver to exec_op() to have one less driver relying
on the legacy interface.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Tested-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519232454.374081-4-boris.brezillon@collabora.com
4 years agomtd: rawnand: ingenic: Fix the RB gpio active-high property on qi, lb60
Boris Brezillon [Tue, 19 May 2020 23:24:53 +0000 (01:24 +0200)]
mtd: rawnand: ingenic: Fix the RB gpio active-high property on qi, lb60

The rb-gpios semantics was undocumented and qi,lb60 (along with the
ingenic driver) got it wrong. The active state encodes the NAND ready
state, which is high level. Since there's no signal inverter on this
board, it should be active-high. Let's fix that here for older DTs so
we can re-use the generic nand_gpio_waitrdy() helper, and be consistent
with what other drivers do.

Suggested-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519232454.374081-3-boris.brezillon@collabora.com
4 years agomtd: rawnand: xway: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:34 +0000 (15:00 +0200)]
mtd: rawnand: xway: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-62-miquel.raynal@bootlin.com
4 years agomtd: rawnand: xway: Fix the probe error path
Miquel Raynal [Tue, 19 May 2020 13:00:33 +0000 (15:00 +0200)]
mtd: rawnand: xway: Fix the probe error path

nand_release() is supposed be called after MTD device registration.
Here, only nand_scan() happened, so use nand_cleanup() instead.

There is no real Fixes tag applying here as the use of nand_release()
in this driver predates the introduction of nand_cleanup() in
commit d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
which makes this change possible. However, pointing this commit as the
culprit for backporting purposes makes sense even if this commit is not
introducing any bug.

Fixes: d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-61-miquel.raynal@bootlin.com
4 years agomtd: rawnand: vf610: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:32 +0000 (15:00 +0200)]
mtd: rawnand: vf610: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Stefan Agner <stefan@agner.ch>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-60-miquel.raynal@bootlin.com
4 years agomtd: rawnand: txx9ndfmc: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:31 +0000 (15:00 +0200)]
mtd: rawnand: txx9ndfmc: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-59-miquel.raynal@bootlin.com
4 years agomtd: rawnand: tmio: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:30 +0000 (15:00 +0200)]
mtd: rawnand: tmio: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-58-miquel.raynal@bootlin.com
4 years agomtd: rawnand: tmio: Fix the probe error path
Miquel Raynal [Tue, 19 May 2020 13:00:29 +0000 (15:00 +0200)]
mtd: rawnand: tmio: Fix the probe error path

nand_release() is supposed be called after MTD device registration.
Here, only nand_scan() happened, so use nand_cleanup() instead.

There is no real Fixes tag applying here as the use of nand_release()
in this driver predates by far the introduction of nand_cleanup() in
commit d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
which makes this change possible. However, pointing this commit as the
culprit for backporting purposes makes sense even if this commit is not
introducing any bug.

Fixes: d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-57-miquel.raynal@bootlin.com
4 years agomtd: rawnand: tango: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:28 +0000 (15:00 +0200)]
mtd: rawnand: tango: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-56-miquel.raynal@bootlin.com
4 years agomtd: rawnand: sunxi: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:27 +0000 (15:00 +0200)]
mtd: rawnand: sunxi: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-55-miquel.raynal@bootlin.com
4 years agomtd: rawnand: sunxi: Fix the probe error path
Miquel Raynal [Tue, 19 May 2020 13:00:26 +0000 (15:00 +0200)]
mtd: rawnand: sunxi: Fix the probe error path

nand_release() is supposed be called after MTD device registration.
Here, only nand_scan() happened, so use nand_cleanup() instead.

Fixes: 1fef62c1423b ("mtd: nand: add sunxi NAND flash controller support")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-54-miquel.raynal@bootlin.com
4 years agomtd: rawnand: stm32_fmc2: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:25 +0000 (15:00 +0200)]
mtd: rawnand: stm32_fmc2: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Christophe Kerello <christophe.kerello@st.com>
Reviewed-by: Christophe Kerello <christophe.kerello@st.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-53-miquel.raynal@bootlin.com
4 years agomtd: rawnand: socrates: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:24 +0000 (15:00 +0200)]
mtd: rawnand: socrates: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-52-miquel.raynal@bootlin.com
4 years agomtd: rawnand: socrates: Fix the probe error path
Miquel Raynal [Tue, 19 May 2020 13:00:23 +0000 (15:00 +0200)]
mtd: rawnand: socrates: Fix the probe error path

nand_release() is supposed be called after MTD device registration.
Here, only nand_scan() happened, so use nand_cleanup() instead.

There is no real Fixes tag applying here as the use of nand_release()
in this driver predates by far the introduction of nand_cleanup() in
commit d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
which makes this change possible. However, pointing this commit as the
culprit for backporting purposes makes sense even if this commit is not
introducing any bug.

Fixes: d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-51-miquel.raynal@bootlin.com
4 years agomtd: rawnand: sharpsl: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:22 +0000 (15:00 +0200)]
mtd: rawnand: sharpsl: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-50-miquel.raynal@bootlin.com
4 years agomtd: rawnand: sharpsl: Fix the probe error path
Miquel Raynal [Tue, 19 May 2020 13:00:21 +0000 (15:00 +0200)]
mtd: rawnand: sharpsl: Fix the probe error path

nand_release() is supposed be called after MTD device registration.
Here, only nand_scan() happened, so use nand_cleanup() instead.

There is no Fixes tag applying here as the use of nand_release()
in this driver predates by far the introduction of nand_cleanup() in
commit d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
which makes this change possible. However, pointing this commit as the
culprit for backporting purposes makes sense.

Fixes: d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-49-miquel.raynal@bootlin.com
4 years agomtd: rawnand: sh_flctl: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:20 +0000 (15:00 +0200)]
mtd: rawnand: sh_flctl: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-48-miquel.raynal@bootlin.com
4 years agomtd: rawnand: s3c2410: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:19 +0000 (15:00 +0200)]
mtd: rawnand: s3c2410: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-47-miquel.raynal@bootlin.com
4 years agomtd: rawnand: r852: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:18 +0000 (15:00 +0200)]
mtd: rawnand: r852: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-46-miquel.raynal@bootlin.com
4 years agomtd: rawnand: qcom: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:17 +0000 (15:00 +0200)]
mtd: rawnand: qcom: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-45-miquel.raynal@bootlin.com
4 years agomtd: rawnand: plat_nand: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:16 +0000 (15:00 +0200)]
mtd: rawnand: plat_nand: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-44-miquel.raynal@bootlin.com
4 years agomtd: rawnand: plat_nand: Fix the probe error path
Miquel Raynal [Tue, 19 May 2020 13:00:15 +0000 (15:00 +0200)]
mtd: rawnand: plat_nand: Fix the probe error path

nand_release() is supposed be called after MTD device registration.
Here, only nand_scan() happened, so use nand_cleanup() instead.

There is no real Fixes tag applying here as the use of nand_release()
in this driver predates by far the introduction of nand_cleanup() in
commit d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
which makes this change possible, hence pointing it as the commit to
fix for backporting purposes, even if this commit is not introducing
any bug.

Fixes: d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-43-miquel.raynal@bootlin.com
4 years agomtd: rawnand: pasemi: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:14 +0000 (15:00 +0200)]
mtd: rawnand: pasemi: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-42-miquel.raynal@bootlin.com
4 years agomtd: rawnand: pasemi: Fix the probe error path
Miquel Raynal [Tue, 19 May 2020 13:00:13 +0000 (15:00 +0200)]
mtd: rawnand: pasemi: Fix the probe error path

nand_cleanup() is supposed to be called on error after a successful
call to nand_scan() to free all NAND resources.

There is no real Fixes tag applying here as the use of nand_release()
in this driver predates by far the introduction of nand_cleanup() in
commit d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
which makes this change possible, hence pointing it as the commit to
fix for backporting purposes, even if this commit is not introducing
any bug.

Fixes: d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-41-miquel.raynal@bootlin.com
4 years agomtd: rawnand: oxnas: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:12 +0000 (15:00 +0200)]
mtd: rawnand: oxnas: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-40-miquel.raynal@bootlin.com
4 years agomtd: rawnand: oxnas: Release all devices in the _remove() path
Miquel Raynal [Tue, 19 May 2020 13:00:11 +0000 (15:00 +0200)]
mtd: rawnand: oxnas: Release all devices in the _remove() path

oxnans_nand_remove() should release all MTD devices and clean all NAND
devices, not only the first one registered.

Fixes: 668592492409 ("mtd: nand: Add OX820 NAND Support")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-39-miquel.raynal@bootlin.com
4 years agomtd: rawnand: oxnas: Unregister all devices on error
Miquel Raynal [Tue, 19 May 2020 13:00:10 +0000 (15:00 +0200)]
mtd: rawnand: oxnas: Unregister all devices on error

On error, the oxnas probe path just frees the device which failed and
aborts the probe, leaving unreleased resources.

Fix this situation by calling mtd_device_unregister()/nand_cleanup()
on these.

Fixes: 668592492409 ("mtd: nand: Add OX820 NAND Support")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-38-miquel.raynal@bootlin.com
4 years agomtd: rawnand: oxnas: Fix the probe error path
Miquel Raynal [Tue, 19 May 2020 13:00:09 +0000 (15:00 +0200)]
mtd: rawnand: oxnas: Fix the probe error path

nand_release() is supposed be called after MTD device registration.
Here, only nand_scan() happened, so use nand_cleanup() instead.

While at it, be consistent and move the function call in the error
path thanks to a goto statement.

Fixes: 668592492409 ("mtd: nand: Add OX820 NAND Support")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-37-miquel.raynal@bootlin.com
4 years agomtd: rawnand: oxnas: Keep track of registered devices
Miquel Raynal [Tue, 19 May 2020 13:00:08 +0000 (15:00 +0200)]
mtd: rawnand: oxnas: Keep track of registered devices

All initialized and registered devices should be listed somewhere so
that we can unregister/free them in the _remove() path.

This patch is not a fix per-se but is needed to apply three other
fixes coming right after, explaining the Fixes/Cc: stable tags.

Fixes: 668592492409 ("mtd: nand: Add OX820 NAND Support")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-36-miquel.raynal@bootlin.com
4 years agomtd: rawnand: orion: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:07 +0000 (15:00 +0200)]
mtd: rawnand: orion: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-35-miquel.raynal@bootlin.com
4 years agomtd: rawnand: orion: Fix the probe error path
Miquel Raynal [Tue, 19 May 2020 13:00:06 +0000 (15:00 +0200)]
mtd: rawnand: orion: Fix the probe error path

nand_release() is supposed be called after MTD device registration.
Here, only nand_scan() happened, so use nand_cleanup() instead.

There is no real Fixes tag applying here as the use of nand_release()
in this driver predates by far the introduction of nand_cleanup() in
commit d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
which makes this change possible. However, pointing this commit as the
culprit for backporting purposes makes sense even if this commit is not
introducing any bug.

Fixes: d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-34-miquel.raynal@bootlin.com
4 years agomtd: rawnand: omap2: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:05 +0000 (15:00 +0200)]
mtd: rawnand: omap2: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-33-miquel.raynal@bootlin.com
4 years agomtd: rawnand: ndfc: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:04 +0000 (15:00 +0200)]
mtd: rawnand: ndfc: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-32-miquel.raynal@bootlin.com
4 years agomtd: rawnand: mxic: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:03 +0000 (15:00 +0200)]
mtd: rawnand: mxic: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-31-miquel.raynal@bootlin.com
4 years agomtd: rawnand: mxc: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:02 +0000 (15:00 +0200)]
mtd: rawnand: mxc: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-30-miquel.raynal@bootlin.com
4 years agomtd: rawnand: mtk: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 13:00:01 +0000 (15:00 +0200)]
mtd: rawnand: mtk: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-29-miquel.raynal@bootlin.com
4 years agomtd: rawnand: mtk: Fix the probe error path
Miquel Raynal [Tue, 19 May 2020 13:00:00 +0000 (15:00 +0200)]
mtd: rawnand: mtk: Fix the probe error path

nand_release() is supposed be called after MTD device registration.
Here, only nand_scan() happened, so use nand_cleanup() instead.

There is no real Fixes tag applying here as the use of nand_release()
in this driver predates the introduction of nand_cleanup() in
commit d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
which makes this change possible. However, pointing this commit as the
culprit for backporting purposes makes sense even if this commit is not
introducing any bug.

Fixes: d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-28-miquel.raynal@bootlin.com
4 years agomtd: rawnand: mpc5121: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:59 +0000 (14:59 +0200)]
mtd: rawnand: mpc5121: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-27-miquel.raynal@bootlin.com
4 years agomtd: rawnand: marvell: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:58 +0000 (14:59 +0200)]
mtd: rawnand: marvell: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-26-miquel.raynal@bootlin.com
4 years agomtd: rawnand: lpc32xx_slc: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:57 +0000 (14:59 +0200)]
mtd: rawnand: lpc32xx_slc: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-25-miquel.raynal@bootlin.com
4 years agomtd: rawnand: lpc32xx_mlc: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:56 +0000 (14:59 +0200)]
mtd: rawnand: lpc32xx_mlc: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-24-miquel.raynal@bootlin.com
4 years agomtd: rawnand: ingenic: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:55 +0000 (14:59 +0200)]
mtd: rawnand: ingenic: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Harvey Hunt <harveyhuntnexus@gmail.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-23-miquel.raynal@bootlin.com
4 years agomtd: rawnand: ingenic: Fix the probe error path
Miquel Raynal [Tue, 19 May 2020 12:59:54 +0000 (14:59 +0200)]
mtd: rawnand: ingenic: Fix the probe error path

nand_release() is supposed be called after MTD device registration.
Here, only nand_scan() happened, so use nand_cleanup() instead.

There is no real Fixes tag applying here as the use of nand_release()
in this driver predates the introduction of nand_cleanup() in
commit d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
which makes this change possible. Hence, pointing it as the commit to
fix for backporting purposes, even if this commit is not introducing
any bug makes sense.

Fixes: d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: stable@vger.kernel.org
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Harvey Hunt <harveyhuntnexus@gmail.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-22-miquel.raynal@bootlin.com
4 years agomtd: rawnand: hisi504: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:53 +0000 (14:59 +0200)]
mtd: rawnand: hisi504: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-21-miquel.raynal@bootlin.com
4 years agomtd: rawnand: gpmi: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:52 +0000 (14:59 +0200)]
mtd: rawnand: gpmi: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Han Xu <han.xu@nxp.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-20-miquel.raynal@bootlin.com
4 years agomtd: rawnand: gpio: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:51 +0000 (14:59 +0200)]
mtd: rawnand: gpio: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-19-miquel.raynal@bootlin.com
4 years agomtd: rawnand: fsmc: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:50 +0000 (14:59 +0200)]
mtd: rawnand: fsmc: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-18-miquel.raynal@bootlin.com
4 years agomtd: rawnand: fsl_upm: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:49 +0000 (14:59 +0200)]
mtd: rawnand: fsl_upm: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-17-miquel.raynal@bootlin.com
4 years agomtd: rawnand: fsl_ifc: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:48 +0000 (14:59 +0200)]
mtd: rawnand: fsl_ifc: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-16-miquel.raynal@bootlin.com
4 years agomtd: rawnand: fsl_elbc: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:47 +0000 (14:59 +0200)]
mtd: rawnand: fsl_elbc: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-15-miquel.raynal@bootlin.com
4 years agomtd: rawnand: diskonchip: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:46 +0000 (14:59 +0200)]
mtd: rawnand: diskonchip: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-14-miquel.raynal@bootlin.com
4 years agomtd: rawnand: diskonchip: Fix the probe error path
Miquel Raynal [Tue, 19 May 2020 12:59:45 +0000 (14:59 +0200)]
mtd: rawnand: diskonchip: Fix the probe error path

Not sure nand_cleanup() is the right function to call here but in any
case it is not nand_release(). Indeed, even a comment says that
calling nand_release() is a bit of a hack as there is no MTD device to
unregister. So switch to nand_cleanup() for now and drop this
comment.

There is no Fixes tag applying here as the use of nand_release()
in this driver predates by far the introduction of nand_cleanup() in
commit d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
which makes this change possible. However, pointing this commit as the
culprit for backporting purposes makes sense even if it did not intruce
any bug.

Fixes: d44154f969a4 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-13-miquel.raynal@bootlin.com
4 years agomtd: rawnand: denali: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:44 +0000 (14:59 +0200)]
mtd: rawnand: denali: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-12-miquel.raynal@bootlin.com
4 years agomtd: rawnand: denali: Delete items from the list in the _remove() path
Miquel Raynal [Tue, 19 May 2020 12:59:43 +0000 (14:59 +0200)]
mtd: rawnand: denali: Delete items from the list in the _remove() path

Denali driver keeps track of devices with a list. Delete items of this
list as long as they are not in use anymore.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-11-miquel.raynal@bootlin.com
4 years agomtd: rawnand: davinci: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:42 +0000 (14:59 +0200)]
mtd: rawnand: davinci: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-10-miquel.raynal@bootlin.com
4 years agomtd: rawnand: cs553x: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:41 +0000 (14:59 +0200)]
mtd: rawnand: cs553x: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-9-miquel.raynal@bootlin.com
4 years agomtd: rawnand: cafe: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:39 +0000 (14:59 +0200)]
mtd: rawnand: cafe: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-7-miquel.raynal@bootlin.com
4 years agomtd: rawnand: cadence: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:38 +0000 (14:59 +0200)]
mtd: rawnand: cadence: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-6-miquel.raynal@bootlin.com
4 years agomtd: rawnand: brcmnand: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:37 +0000 (14:59 +0200)]
mtd: rawnand: brcmnand: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Kamal Dasu <kdasu.kdev@gmail.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-5-miquel.raynal@bootlin.com
4 years agomtd: rawnand: bcm47xx: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:36 +0000 (14:59 +0200)]
mtd: rawnand: bcm47xx: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-4-miquel.raynal@bootlin.com
4 years agomtd: rawnand: au1550nd: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:35 +0000 (14:59 +0200)]
mtd: rawnand: au1550nd: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-3-miquel.raynal@bootlin.com
4 years agomtd: rawnand: ams-delta: Stop using nand_release()
Miquel Raynal [Tue, 19 May 2020 12:59:34 +0000 (14:59 +0200)]
mtd: rawnand: ams-delta: Stop using nand_release()

This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().

Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-2-miquel.raynal@bootlin.com
4 years agomtd: rawnand: arasan: Support the hardware BCH ECC engine
Miquel Raynal [Tue, 19 May 2020 07:45:49 +0000 (09:45 +0200)]
mtd: rawnand: arasan: Support the hardware BCH ECC engine

Add support for the hardware ECC BCH engine.

Please mind that this engine has an important limitation:
BCH implementation does not inform the user when an uncorrectable ECC
error occurs. To workaround this, we avoid using the hardware engine
in the read path and do the computation with the software BCH
implementation, which is faster than mixing hardware (for correction)
and software (for verification).

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200519074549.23673-9-miquel.raynal@bootlin.com
4 years agomtd: rawnand: arasan: Add new Arasan NAND controller
Miquel Raynal [Tue, 19 May 2020 07:45:48 +0000 (09:45 +0200)]
mtd: rawnand: arasan: Add new Arasan NAND controller

Add the Arasan NAND controller driver. This brings only NAND
controller support. The ECC engine being a bit subtle, hardware ECC
support will be added in a second time.

This work is based on contributions from Naga Sureshkumar Relli.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200519074549.23673-8-miquel.raynal@bootlin.com
4 years agodt-bindings: mtd: Document ARASAN NAND bindings
Miquel Raynal [Tue, 19 May 2020 07:45:47 +0000 (09:45 +0200)]
dt-bindings: mtd: Document ARASAN NAND bindings

Document the Arasan NAND controller bindings.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/linux-mtd/20200519074549.23673-7-miquel.raynal@bootlin.com
4 years agoMAINTAINERS: Add Arasan NAND controller and bindings
Miquel Raynal [Tue, 19 May 2020 07:45:46 +0000 (09:45 +0200)]
MAINTAINERS: Add Arasan NAND controller and bindings

Fill a new entry for the Arasan NAND controller.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200519074549.23673-6-miquel.raynal@bootlin.com
4 years agomtd: rawnand: Add nand_extract_bits()
Miquel Raynal [Tue, 19 May 2020 07:45:45 +0000 (09:45 +0200)]
mtd: rawnand: Add nand_extract_bits()

There are cases where ECC bytes are not byte-aligned. Indeed, BCH
implies using a number of ECC bits, which are not always a multiple of
8. We then need a helper like nand_extract_bits() to extract these
syndromes from a buffer.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200519074549.23673-5-miquel.raynal@bootlin.com
4 years agomtd: rawnand: Ensure the number of bitflips is consistent
Miquel Raynal [Tue, 19 May 2020 07:45:44 +0000 (09:45 +0200)]
mtd: rawnand: Ensure the number of bitflips is consistent

The main NAND read page function can loop over "page reads" many times
in if the reading reports uncorrectable error(s) and if the chip
supports the read_retry feature.

In this case, the number of bitflips is summarized between
attempts. Fix this by re-initializing the entire mtd_ecc_stats object
each time we retry.

Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200519074549.23673-4-miquel.raynal@bootlin.com