mtd: mtk: avoid warning in mtk_ecc_encode
authorArnd Bergmann <arnd@arndb.de>
Mon, 17 Oct 2016 22:05:31 +0000 (00:05 +0200)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Fri, 28 Oct 2016 08:21:23 +0000 (10:21 +0200)
commit8ff0513bdcdd71e84aa561cce216675d43fb41b8
tree5a78c67a0d77953159dbad5e57f52f95a4e9b001
parent73f907fd5fa56b0066d199bdd7126bbd04f6cd7b
mtd: mtk: avoid warning in mtk_ecc_encode

When building with -Wmaybe-uninitialized, gcc produces a silly false positive
warning for the mtk_ecc_encode function:

drivers/mtd/nand/mtk_ecc.c: In function 'mtk_ecc_encode':
drivers/mtd/nand/mtk_ecc.c:402:15: error: 'val' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The function for some reason contains a double byte swap on big-endian
builds to get the OOB data into the correct order again, and is written
in a slightly confusing way.

Using a simple memcpy32_fromio() to read the data simplifies it a lot
so it becomes more readable and produces no warning. However, the
output might not have 32-bit alignment, so we have to use another
memcpy to avoid taking alignment faults or writing beyond the end
of the array.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: RogerCC Lin <rogercc.lin@mediatek.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
drivers/mtd/nand/mtk_ecc.c