mtd: dc21285: fix bytewise memcpy()
PATCH 1/1 mtd: dc21285: fix bytewise memcpy()
From: Arnd Bergmann <[email protected]>
The commit that split up the 8/16/32-bit operations in 2004 seems to have broken the 8-bit case, as clang-21 now points out:
drivers/mtd/maps/dc21285.c:129:97: error: parameter 'len' set but not used [-Werror,-Wunused-but-set-parameter]
129 | static void dc21285_copy_to_8(struct map_info *map, unsigned long to, const void *from, ssize_t len)
Put back the loop that was in linux-2.6.8 and earlier for this case.
--- drivers/mtd/maps/dc21285.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/mtd/maps/dc21285.c +8 -6
@@ -128,12 +128,14 @@ static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const voistatic void dc21285_copy_to_8 (struct map_info *map,unsigned long to,const void *from,ssize_t len) { -map_word d; - d.x[0 ] = *((uint8_t *)from); -dc21285_write8 (map, d, to); - from++; - to++; - len--; +while (len >0 ) { +map_word d; + d.x[0 ] = *((uint8_t *)from); +dc21285_write8 (map, d, to); + from++; + to++; + len--; + } }static struct map_info dc21285_map = {
Signature · 1 line
2.39.5
Miquel Raynal
maintainerHello Arnd,
Quoted 5 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The commit that split up the 8/16/32-bit operations in 2004 seems to have broken the 8-bit case, as clang-21 now points out:
Quoted 8 lines
drivers/mtd/maps/dc21285.c:129:97: error: parameter 'len' set but not used [-Werror,-Wunused-but-set-parameter]
129 | static voiddc21285_copy_to_8(struct map_info *map, unsigned long to, const void *from, ssize_t len)Put back the loop that was in linux-2.6.8 and earlier for this case.
Fixes 67d4878e4e61 ("NOR flash drivers update")Cc David Woodhouse <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>
Thanks for the patch, I'll take it, but that probably means few to no people still use it, if broken for more than 20 years...
Cheers,
Miquèl
Quoted 11 lines · Miquel Raynal
Quoted 8 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The commit that split up the 8/16/32-bit operations in 2004 seems to have broken the 8-bit case, as clang-21 now points out:
drivers/mtd/maps/dc21285.c:129:97: error: parameter 'len' set but not used [-Werror,-Wunused-but-set-parameter]
129 | static voiddc21285_copy_to_8(struct map_info *map, unsigned long to, const void *from, ssize_t len)
Quoted 8 lines
Quoted 5 lines
Put back the loop that was in linux-2.6.8 and earlier for this case.
Fixes 67d4878e4e61 ("NOR flash drivers update")Cc David Woodhouse <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>Thanks for the patch, I'll take it, but that probably means few to no people still use it, if broken for more than 20 years...
Yes, certainly. I also have a patch to mark the mach-footbridge platform as deprecated and schedule it for removal, I need to resend that patch.
What I suspect happened here is that the bug was harmless because the few boards that use this driver all have 16-bit or 32-bit flashes, while the 8-bit codepath was indeed unused.
Arnd