Hi, Daniel > -----Original Message----- > From: Daniel Baluta <daniel.bal...@gmail.com> > Sent: Wednesday, June 26, 2019 8:42 PM > To: Anson Huang <anson.hu...@nxp.com> > Cc: Shawn Guo <shawn...@kernel.org>; Sascha Hauer > <s.ha...@pengutronix.de>; Pengutronix Kernel Team > <ker...@pengutronix.de>; Fabio Estevam <feste...@gmail.com>; Aisheng > Dong <aisheng.d...@nxp.com>; Abel Vesa <abel.v...@nxp.com>; linux- > arm-kernel <linux-arm-ker...@lists.infradead.org>; Linux Kernel Mailing List > <linux-kernel@vger.kernel.org>; dl-linux-imx <linux-...@nxp.com>; Daniel > Baluta <daniel.bal...@nxp.com> > Subject: Re: [PATCH] soc: imx-scu: Add SoC UID(unique identifier) support > > On Wed, Jun 26, 2019 at 10:06 AM <anson.hu...@nxp.com> wrote: > > > > From: Anson Huang <anson.hu...@nxp.com> > > > > Add i.MX SCU SoC's UID(unique identifier) support, user can read it > > from sysfs: > > > > root@imx8qxpmek:~# cat /sys/devices/soc0/soc_uid > > 7B64280B57AC1898 > > > > Signed-off-by: Anson Huang <anson.hu...@nxp.com> > > --- > > drivers/soc/imx/soc-imx-scu.c | 35 > > +++++++++++++++++++++++++++++++++++ > > 1 file changed, 35 insertions(+) > > > > diff --git a/drivers/soc/imx/soc-imx-scu.c > > b/drivers/soc/imx/soc-imx-scu.c index 676f612..8d322a1 100644 > > --- a/drivers/soc/imx/soc-imx-scu.c > > +++ b/drivers/soc/imx/soc-imx-scu.c > > @@ -27,6 +27,36 @@ struct imx_sc_msg_misc_get_soc_id { > > } data; > > } __packed; > > > > +struct imx_sc_msg_misc_get_soc_uid { > > + struct imx_sc_rpc_msg hdr; > > + u32 uid_low; > > + u32 uid_high; > > +} __packed; > > + > > +static ssize_t soc_uid_show(struct device *dev, > > + struct device_attribute *attr, char *buf) > > +{ > > + struct imx_sc_msg_misc_get_soc_uid msg; > > + struct imx_sc_rpc_msg *hdr = &msg.hdr; > > + u64 soc_uid; > > + > > + hdr->ver = IMX_SC_RPC_VERSION; > > + hdr->svc = IMX_SC_RPC_SVC_MISC; > > + hdr->func = IMX_SC_MISC_FUNC_UNIQUE_ID; > > + hdr->size = 1; > > + > > + /* the return value of SCU FW is in correct, skip return value > > + check */ > > Why do you mean by "in correct"?
I made a mistake, it should be "incorrect", the existing SCFW of this API returns an error value even this API is successfully called, to make it work with current SCFW, I have to skip the return value check for this API for now. Will send V2 patch to fix this typo. > > + imx_scu_call_rpc(soc_ipc_handle, &msg, true); > > + > > + soc_uid = msg.uid_high; > > + soc_uid <<= 32; > > + soc_uid |= msg.uid_low; > > + > > + return sprintf(buf, "%016llX\n", soc_uid); > > snprintf? The snprintf is to avoid buffer overflow, which in this case, I don't know the size of "buf", and the value(u64) to be printed is with fixed length of 64, so I think sprint is just OK. Anson. > > > +} > > + > > +static DEVICE_ATTR_RO(soc_uid); > > + > > static int imx_scu_soc_id(void) > > { > > struct imx_sc_msg_misc_get_soc_id msg; @@ -102,6 +132,11 @@ > > static int imx_scu_soc_probe(struct platform_device *pdev) > > goto free_revision; > > } > > > > + ret = device_create_file(soc_device_to_device(soc_dev), > > + &dev_attr_soc_uid); > > + if (ret) > > + goto free_revision; > > + > > return 0; > > > > free_revision: > > -- > > 2.7.4 > >