Re: [PATCH] memory: renesas-rpc-if: Avoid unaligned bus access for HyperFlash

From: Wolfram Sang
Date: Sat Sep 25 2021 - 05:55:10 EST

Hi Andrew,

thanks for this patch!

> + const int maxw = (IS_ENABLED(CONFIG_64BIT)) ? 8 : 4;
> + u8 buf[2];

I could imagine the code becomes more readable if we make use of
something like:

unsigned long from_ul = from;

and then use it throughout the function?

> +#ifdef CONFIG_64BIT
> + *(u64 *)to = __raw_readq(from);
> +#else
> + *(u32 *)to = __raw_readl(from);
> +#endif

To keep the ifdeffery minimal:

if (maxw == 8)
*(u64 *)to = __raw_readq(from);
*(u32 *)to = __raw_readl(from);

and let the compiler do its job.

I wondered if this could be a helper function somewhere instead of open
coded in this driver. However, I did not find any similar code in the
kernel yet, so it might be too early to make this a helper. Have you
looked for similar code? I might have just missed it.

Happy hacking,


Attachment: signature.asc
Description: PGP signature