[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <35e498b6-3b2c-d154-db00-d755af339b60@linaro.org>
Date: Fri, 5 Mar 2021 10:33:35 +0000
From: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
To: Rafał Miłecki <rafal@...ecki.pl>,
Rafał Miłecki <zajec5@...il.com>,
Rob Herring <robh+dt@...nel.org>
Cc: devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mips@...r.kernel.org,
Florian Fainelli <f.fainelli@...il.com>,
Vivek Unune <npcomplete13@...il.com>,
bcm-kernel-feedback-list@...adcom.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] nvmem: iomap: new driver exposing NVMEM accessible
using I/O mapping
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
Powered by blists - more mailing lists