On 05/03/2021 10:24, Rafał Miłecki wrote:
+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!
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!
P.S.
Please don't yell at me in every sentence :( Makes me a bit sad :(
Sorry!! I did not mean anything as such! :-)
--srini