Thread (6 messages) 6 messages, 3 authors, 2021-03-05

Re: [PATCH 2/2] nvmem: iomap: new driver exposing NVMEM accessible using I/O mapping

From: Rafał Miłecki <rafal@milecki.pl>
Date: 2021-03-05 10:59:32
Also in: linux-devicetree, linux-mips, lkml

On 05.03.2021 11:33, Srinivas Kandagatla wrote:
On 05/03/2021 10:24, Rafał Miłecki wrote:
quoted
quoted
quoted
+static int iomap_read(void *context, unsigned int offset, void *val,
+              size_t bytes)
+{
+    struct iomap *priv = context;
+    u8 *src = priv->base + offset;
+    u8 *dst = val;
+    size_t tmp;
+
+    tmp = offset % 4;
+    memcpy_fromio(dst, src, tmp);
+    dst += tmp;
+    src += tmp;
+    bytes -= tmp;
+
+    tmp = rounddown(bytes, 4);
+    __ioread32_copy(dst, src, tmp / 4);
+    dst += tmp;
+    src += tmp;
+    bytes -= tmp;
+
+    memcpy_fromio(dst, src, bytes);
+

You could just do this!

     while (bytes--)
         *val++ = readb(priv->base + offset + i++);
Do you mean that as replacement for "memcpy_fromio" or the whole
function code?
Yes please!
quoted
The reason for using __ioread32_copy() was to improve reading
performance (using aligned 32 bit access where possible). I'm not sure
if that really matters?
Just simple while loop is much readable than the previous code TBH!
quoted
quoted
P.S.
Please don't yell at me in every sentence :( Makes me a bit sad :(
Sorry!! I did not mean anything as such! :-)
All clear (I hope)! Thanks for your review!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help