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

Wolfram Sang
2021-09-25T09:55:04Z

[-- Attachment #1: Type: text/plain, Size: 834 bytes --]

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);
else
*(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,

Wolfram

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]