Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1494212
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] mtd: mtk: avoid warning in mtk_ecc_encode |
| Date | 2016-09-30 19:30 +0200 |
| Message-ID | <sn9Nf-4Ta-23@gated-at.bofh.it> (permalink) |
| References | <sn90R-4l6-9@gated-at.bofh.it> <sn9ke-4sR-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] mtd: mtk: avoid warning in mtk_ecc_encode Arnd Bergmann <arnd@arndb.de> - 2016-09-30 18:40 +0200
Re: [PATCH] mtd: mtk: avoid warning in mtk_ecc_encode Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-09-30 19:00 +0200
Re: [PATCH] mtd: mtk: avoid warning in mtk_ecc_encode Arnd Bergmann <arnd@arndb.de> - 2016-09-30 19:30 +0200
Re: [PATCH] mtd: mtk: avoid warning in mtk_ecc_encode Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-10-01 11:30 +0200
csiph-web