Hi Aisheng,

> Subject: RE: [PATCH 2/4] nvmem: imx: add i.MX8 nvmem driver
> 
> > From: Peng Fan
> > Sent: Sunday, May 5, 2019 9:28 PM
> > Subject: [PATCH 2/4] nvmem: imx: add i.MX8 nvmem driver
> >
> > This patch adds i.MX8 nvmem ocotp driver to access fuse via RPC to
> > i.MX8 system controller.
> >
> > Signed-off-by: Peng Fan <peng....@nxp.com>
> 
> Only a few minor comments.
> Otherwise, this patch looks good to me.
> 
> First, the patch title probably better to be:
> nvmem: imx: add i.MX8 SCU based ocotp driver support

Fix in V2.

> 
> > Cc: Srinivas Kandagatla <srinivas.kandaga...@linaro.org>
> > Cc: Shawn Guo <shawn...@kernel.org>
> > Cc: Sascha Hauer <s.ha...@pengutronix.de>
> > Cc: Pengutronix Kernel Team <ker...@pengutronix.de>
> > Cc: Fabio Estevam <feste...@gmail.com>
> > Cc: NXP Linux Team <linux-...@nxp.com>
> > Cc: linux-arm-ker...@lists.infradead.org
> > ---
> >  drivers/nvmem/Kconfig         |   7 +++
> >  drivers/nvmem/Makefile        |   2 +
> >  drivers/nvmem/imx-ocotp-scu.c | 135
> > ++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 144 insertions(+)
> >  create mode 100644 drivers/nvmem/imx-ocotp-scu.c
> >
> > diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index
> > 530d570724c9..0e705c04bd8c 100644
> > --- a/drivers/nvmem/Kconfig
> > +++ b/drivers/nvmem/Kconfig
> > @@ -36,6 +36,13 @@ config NVMEM_IMX_OCOTP
> >       This driver can also be built as a module. If so, the module
> >       will be called nvmem-imx-ocotp.
> >
> > +config NVMEM_IMX_OCOTP_SCU
> > +   tristate "i.MX8 On-Chip OTP Controller support"
> 
> i.MX8 SCU On-Chip OTP Controller support
Fix in V2
> 
> > +   depends on IMX_SCU
> > +   help
> > +     This is a driver for the On-Chip OTP Controller (OCOTP)
> 
> SCU On-Chip OTP
Fix in V2.
> 
> > +     available on i.MX8 SoCs.
> > +
[.....]

> > +
> > +static int imx_scu_ocotp_read(void *context, unsigned int offset,
> > +                         void *val, size_t bytes)
> > +{
> > +   struct ocotp_priv *priv = context;
> > +   u32 count, index, num_bytes;
> > +   u8 *buf, *p;
> 
> It seems buf has never been used as u8.
> So probably a better way is:
> U32 *buf;
> Void *p.
> Then we can save all the explicit conversion of u32.

Fix in V2.

> 
> > +   int i, ret;
> > +
> > +   index = offset >> 2;
> > +   num_bytes = round_up((offset % 4) + bytes, 4);
> > +   count = num_bytes >> 2;
> > +
> > +   if (count > (priv->data->nregs - index))
> > +           count = priv->data->nregs - index;
> > +
> > +   p = kzalloc(num_bytes, GFP_KERNEL);
> > +   if (!p)
> > +           return -ENOMEM;
> > +
> > +   buf = p;
> > +
> > +   for (i = index; i < (index + count); i++) {
> > +           if (priv->data->devtype == IMX8QXP) {
> > +                   if ((i > 271) && (i < 544)) {
> > +                           *(u32 *)buf = 0;
> > +                           buf += 4;
> > +                           continue;
> > +                   }
> > +           }
> > +
> > +           ret = imx_sc_misc_otp_fuse_read(priv->nvmem_ipc, i,
> > +                                           (u32 *)buf);
> 
> Is this API already in kernel?

Ah. I forgot to post out that API in this patchset. Will add that in V2.

[....]
> > +
> > +MODULE_AUTHOR("Peng Fan <peng....@nxp.com>");
> > +MODULE_DESCRIPTION("i.MX8QM OCOTP fuse box driver");
> 
> i.MX8 SCU OCOTP fuse box driver

Fix in V2.

Thanks,
Peng.

> 
> Regards
> Dong Aisheng
> 
> > +MODULE_LICENSE("GPL v2");
> > --
> > 2.16.4

Reply via email to