Skip to content
  • Arnd Bergmann's avatar
    mtd: mtk: avoid warning in mtk_ecc_encode · 8ff0513b
    Arnd Bergmann authored
    
    
    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: default avatarArnd Bergmann <arnd@arndb.de>
    Tested-by: default avatarRogerCC Lin <rogercc.lin@mediatek.com>
    Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
    8ff0513b