[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YU7x8cabSsQiUJuE@kunai>
Date: Sat, 25 Sep 2021 11:54:57 +0200
From: Wolfram Sang <wsa@...nel.org>
To: Andrew Gabbasov <andrew_gabbasov@...tor.com>
Cc: linux-renesas-soc@...r.kernel.org, linux-kernel@...r.kernel.org,
Krzysztof Kozlowski <krzk@...nel.org>,
Sergei Shtylyov <sergei.shtylyov@...il.com>,
Geert Uytterhoeven <geert+renesas@...der.be>
Subject: Re: [PATCH] memory: renesas-rpc-if: Avoid unaligned bus access for
HyperFlash
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
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists