From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
To: Boris Brezillon
<boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: Richard Weinberger <richard-/L3Ra7n9ekc@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Matthias Brugger
<matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Brian Norris
<computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH] mtd: mtk: avoid warning in mtk_ecc_encode
Date: Fri, 30 Sep 2016 19:25:17 +0200 [thread overview]
Message-ID: <201609301925.17577.arnd@arndb.de> (raw)
In-Reply-To: <20160930185139.15c8be66@bbrezillon>
On Friday 30 September 2016, Boris Brezillon wrote:
> > + /* copy into possibly unaligned OOB region with actual length */
> > + memcpy(data + bytes, eccdata, len);
>
> Is it better than
>
> for (i = 0; i < len; i += 4) {
> u32 val = __raw_readl(ecc->regs + ECC_ENCPAR(i / 4));
>
> memcpy(data + bytes + i, &val, min(len, 4));
> }
>
> I'm probably missing something, but what's the point of creating a
> temporary buffer of 112 bytes on the stack since you'll have to copy
> this data to the oob buffer at some point?
I tried something like that first, but wasn't too happy with it for
a number of small reasons:
- __raw_readl in a driver is not usually the right API, __memcpy32_from_io
uses it internally, but it's better for a driver not to rely on that,
in case we need some barriers (which we may in factt need for other drivers).
- the min(len,4) expression is incorrect, fixing that makes it more complicated
again
- I didn't like to call memcpy() multiple times, as that might get turned
into an external function call (the compiler is free to optimize small
memcpy calls or not).
I agree that he 112 byte buffer isn't ideal either, it just seemed to
be the lesser annoyance.
Arnd
next prev parent reply other threads:[~2016-09-30 17:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-30 16:33 [PATCH] mtd: mtk: avoid warning in mtk_ecc_encode Arnd Bergmann
2016-09-30 16:51 ` Boris Brezillon
2016-09-30 17:25 ` Arnd Bergmann [this message]
2016-10-01 9:25 ` Boris Brezillon
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=201609301925.17577.arnd@arndb.de \
--to=arnd-r2ngtmty4d4@public.gmane.org \
--cc=boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=richard-/L3Ra7n9ekc@public.gmane.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox