* [PATCH] mtd: dc21285: fix bytewise memcpy()
@ 2025-08-07 7:20 Arnd Bergmann
2025-08-07 7:54 ` Miquel Raynal
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2025-08-07 7:20 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
Nathan Chancellor
Cc: Arnd Bergmann, David Woodhouse, Nick Desaulniers, Bill Wendling,
Justin Stitt, linux-mtd, linux-kernel, llvm
From: Arnd Bergmann <arnd@arndb.de>
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.
Fixes: 67d4878e4e61 ("NOR flash drivers update")
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/mtd/maps/dc21285.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/maps/dc21285.c b/drivers/mtd/maps/dc21285.c
index 70a3db3ab856..1d70bf62e91f 100644
--- a/drivers/mtd/maps/dc21285.c
+++ b/drivers/mtd/maps/dc21285.c
@@ -128,12 +128,14 @@ static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const voi
static 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 = {
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: dc21285: fix bytewise memcpy()
2025-08-07 7:20 [PATCH] mtd: dc21285: fix bytewise memcpy() Arnd Bergmann
@ 2025-08-07 7:54 ` Miquel Raynal
2025-08-07 11:55 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Miquel Raynal @ 2025-08-07 7:54 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Richard Weinberger, Vignesh Raghavendra, Nathan Chancellor,
Arnd Bergmann, David Woodhouse, Nick Desaulniers, Bill Wendling,
Justin Stitt, linux-mtd, linux-kernel, llvm
Hello Arnd,
On 07/08/2025 at 09:20:34 +02, Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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.
>
> Fixes: 67d4878e4e61 ("NOR flash drivers update")
> Cc: David Woodhouse <dwmw2@infradead.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: dc21285: fix bytewise memcpy()
2025-08-07 7:54 ` Miquel Raynal
@ 2025-08-07 11:55 ` Arnd Bergmann
0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2025-08-07 11:55 UTC (permalink / raw)
To: Miquel Raynal, Arnd Bergmann
Cc: Richard Weinberger, Vignesh Raghavendra, Nathan Chancellor,
David Woodhouse, Nick Desaulniers, Bill Wendling, Justin Stitt,
linux-mtd, linux-kernel, llvm
On Thu, Aug 7, 2025, at 09:54, Miquel Raynal wrote:
>
> On 07/08/2025 at 09:20:34 +02, Arnd Bergmann <arnd@kernel.org> wrote:
>
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> 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.
>>
>> Fixes: 67d4878e4e61 ("NOR flash drivers update")
>> Cc: David Woodhouse <dwmw2@infradead.org>
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-07 11:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07 7:20 [PATCH] mtd: dc21285: fix bytewise memcpy() Arnd Bergmann
2025-08-07 7:54 ` Miquel Raynal
2025-08-07 11:55 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).