linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Lothar Waßmann" <LW@KARO-electronics.de>
To: Andy Duan <fugang.duan@nxp.com>
Cc: "festevam@gmail.com" <festevam@gmail.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"srinivas.kandagatla@linaro.org" <srinivas.kandagatla@linaro.org>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [EXT] Re: [PATCH nvmem 1/1] nvmem: imx: correct the fuse word index
Date: Fri, 5 Jul 2019 09:12:35 +0200	[thread overview]
Message-ID: <20190705091235.365b93cb@karo-electronics.de> (raw)
In-Reply-To: <VI1PR0402MB360040318C9FB6656B46C566FFF50@VI1PR0402MB3600.eurprd04.prod.outlook.com>

Hi,

On Fri, 5 Jul 2019 02:46:32 +0000 Andy Duan wrote:
> From: Andy Duan Sent: Friday, July 5, 2019 12:08 AM
> > From: Lothar Waßmann <LW@KARO-electronics.de> Sent: Thursday, July 4,
> > 2019 11:46 PM  
> > > Hi,
> > >
> > > On Thu,  4 Jul 2019 22:20:15 +0800 fugang.duan@nxp.com wrote:  
> > > > From: Fugang Duan <fugang.duan@nxp.com>
> > > >
> > > > iMX8 fuse word index represent as one 4-bytes word, it should not be
> > > > divided by 4.
> > > >
> > > > Exp:
> > > > - MAC0 address layout in fuse:
> > > > offset 708: MAC[3] MAC[2] MAC[1] MAC[0]
> > > > offset 709: XX     xx     MAC[5] MAC[4]
> > > >
> > > > Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
> > > > ---
> > > >  drivers/nvmem/imx-ocotp-scu.c | 6 +++---
> > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/drivers/nvmem/imx-ocotp-scu.c
> > > > b/drivers/nvmem/imx-ocotp-scu.c index d9dc482..be2f5f0 100644
> > > > --- a/drivers/nvmem/imx-ocotp-scu.c
> > > > +++ b/drivers/nvmem/imx-ocotp-scu.c
> > > > @@ -71,8 +71,8 @@ static int imx_scu_ocotp_read(void *context,
> > > > unsigned  
> > > int offset,  
> > > >       void *p;
> > > >       int i, ret;
> > > >
> > > > -     index = offset >> 2;
> > > > -     num_bytes = round_up((offset % 4) + bytes, 4);
> > > > +     index = offset;
> > > > +     num_bytes = round_up(bytes, 4);
> > > >       count = num_bytes >> 2;
> > > >
> > > >       if (count > (priv->data->nregs - index)) @@ -100,7 +100,7 @@
> > > > static int imx_scu_ocotp_read(void *context, unsigned int offset,
> > > >               buf++;
> > > >       }
> > > >
> > > > -     memcpy(val, (u8 *)p + offset % 4, bytes);
> > > > +     memcpy(val, (u8 *)p, bytes);
> > > >
> > > >       kfree(p);
> > > >  
> > > With these changes you could use the 'val' pointer directly as the
> > > destination for ocotp_read() without need for an intermediate buffer.
> > >
> > >
> > > Lothar Waßmann  
> > 
> > You are right, in fact, we can remove "p" and "buf" pointer.
> > Thanks for your review, I will send out the V2.  
> 
> Hi Lothar,
> 
> It still need intermediate buffer to read out n words (n * 4 bytes) from eFuse.
> Because 'val' buffer size is real count parsed from DT, which is not an integer multiple of 4.
> 
> For example, cell->bytes is parsed from "reg" property and it is real count like 6.
>                         fec_mac0: mac@2c4 {
>                                 reg = <0x2c4 6>;
>                         }; 
> 
> So we have to use intermediate buffer here.
>
val is a u32 pointer, so legally it cannot point to any buffer whose
size is not divisible by four!


Lothar Waßmann

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-07-05 13:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-04 14:20 [PATCH nvmem 1/1] nvmem: imx: correct the fuse word index fugang.duan
2019-07-04 15:45 ` Lothar Waßmann
2019-07-04 16:07   ` [EXT] " Andy Duan
2019-07-05  2:46     ` Andy Duan
2019-07-05  7:12       ` Lothar Waßmann [this message]
2019-07-05  7:32         ` Andy Duan
2019-07-10  2:29           ` Andy Duan
2019-07-15  5:35 ` Andy Duan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190705091235.365b93cb@karo-electronics.de \
    --to=lw@karo-electronics.de \
    --cc=festevam@gmail.com \
    --cc=fugang.duan@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).