[PATCH 08/13] nvmem: add kvx otp non volatile regbank support
Jules Maselbas
jmaselbas at kalray.eu
Mon Jan 17 03:17:17 PST 2022
> > +static int kvx_otp_nv_read(void *context, unsigned int offset,
> > + void *_val, size_t bytes)
> > +{
> > + struct kvx_otp_nv_priv *priv = context;
> > + u8 *val = _val;
> > + u32 tmp, copy_size;
> > + u8 skip = offset & OTP_NV_ALIGN_MASK;
> > +
> > + offset &= ~OTP_NV_ALIGN_MASK;
> > +
> > + while (bytes) {
> > + tmp = readl(priv->base + offset);
> > + if (skip != 0)
> > + copy_size = min(OTP_NV_ALIGN - skip, (int) bytes);
> > + else
> > + copy_size = min(bytes, sizeof(tmp));
> > +
> > + memcpy(val, ((u8 *) &tmp) + skip, copy_size);
> > + if (skip != 0)
> > + skip = 0;
>
> The if() here is unnecessary.
Indeed, thanks.
More information about the barebox
mailing list