All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@kernel.org>
To: Andrew Gabbasov <andrew_gabbasov@mentor.com>
Cc: linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Sergei Shtylyov <sergei.shtylyov@gmail.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>
Subject: Re: [PATCH] memory: renesas-rpc-if: Avoid unaligned bus access for HyperFlash
Date: Sat, 25 Sep 2021 11:54:57 +0200	[thread overview]
Message-ID: <YU7x8cabSsQiUJuE@kunai> (raw)
In-Reply-To: <20210922184830.29147-1-andrew_gabbasov@mentor.com>

[-- 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 --]

  parent reply	other threads:[~2021-09-25  9:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22 18:48 [PATCH] memory: renesas-rpc-if: Avoid unaligned bus access for HyperFlash Andrew Gabbasov
2021-09-24 11:12 ` Krzysztof Kozlowski
2021-09-24 12:34   ` Andrew Gabbasov
2021-09-24 12:37     ` Wolfram Sang
2021-09-25  9:54 ` Wolfram Sang [this message]
2021-09-25 10:49   ` Andrew Gabbasov
2021-09-27  9:25     ` 'Wolfram Sang'
2021-09-28 10:35 ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YU7x8cabSsQiUJuE@kunai \
    --to=wsa@kernel.org \
    --cc=andrew_gabbasov@mentor.com \
    --cc=geert+renesas@glider.be \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=sergei.shtylyov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.