lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZvbkL97Ba3CNPjEk@lizhi-Precision-Tower-5810>
Date: Fri, 27 Sep 2024 12:58:23 -0400
From: Frank Li <Frank.li@....com>
To: Marek Vasut <marex@...x.de>
Cc: linux-arm-kernel@...ts.infradead.org, kernel@...electronics.com,
	AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
	Arnd Bergmann <arnd@...db.de>, Fabio Estevam <festevam@...il.com>,
	Jeff Johnson <quic_jjohnson@...cinc.com>,
	Neil Armstrong <neil.armstrong@...aro.org>,
	Pengutronix Kernel Team <kernel@...gutronix.de>,
	Saravana Kannan <saravanak@...gle.com>,
	Sascha Hauer <s.hauer@...gutronix.de>,
	Shawn Guo <shawnguo@...nel.org>, imx@...ts.linux.dev,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/2] soc: imx8m: Remove global soc_uid

On Thu, Sep 26, 2024 at 11:36:52PM +0200, Marek Vasut wrote:
> The static global soc_uid is only ever used as kasprintf() parameter in
> imx8m_soc_probe(). Pass pointer to local u64 variable to .soc_revision()
> callback instead and let the .soc_revision() callback fill in the content.
> Remove the unnecessary static global variable.

Can you simple said:

Remove the unnecessary static global variable 'soc_uid', which only used
in imx8m_soc_probe().

>
> Signed-off-by: Marek Vasut <marex@...x.de>
> ---
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
> Cc: Arnd Bergmann <arnd@...db.de>
> Cc: Fabio Estevam <festevam@...il.com>
> Cc: Jeff Johnson <quic_jjohnson@...cinc.com>
> Cc: Neil Armstrong <neil.armstrong@...aro.org>
> Cc: Pengutronix Kernel Team <kernel@...gutronix.de>
> Cc: Saravana Kannan <saravanak@...gle.com>
> Cc: Sascha Hauer <s.hauer@...gutronix.de>
> Cc: Shawn Guo <shawnguo@...nel.org>
> Cc: imx@...ts.linux.dev
> Cc: linux-arm-kernel@...ts.infradead.org
> Cc: linux-kernel@...r.kernel.org
> ---
> V3: New patch
> ---
>  drivers/soc/imx/soc-imx8m.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
> index 5ea8887828c06..966593320e28d 100644
> --- a/drivers/soc/imx/soc-imx8m.c
> +++ b/drivers/soc/imx/soc-imx8m.c
> @@ -30,11 +30,9 @@
>
>  struct imx8_soc_data {
>  	char *name;
> -	int (*soc_revision)(u32 *socrev);
> +	int (*soc_revision)(u32 *socrev, u64 *socuid);
>  };
>
> -static u64 soc_uid;
> -
>  #ifdef CONFIG_HAVE_ARM_SMCCC
>  static u32 imx8mq_soc_revision_from_atf(void)
>  {
> @@ -51,7 +49,7 @@ static u32 imx8mq_soc_revision_from_atf(void)
>  static inline u32 imx8mq_soc_revision_from_atf(void) { return 0; };
>  #endif
>
> -static int imx8mq_soc_revision(u32 *socrev)
> +static int imx8mq_soc_revision(u32 *socrev, u64 *socuid)
>  {
>  	struct device_node *np;
>  	void __iomem *ocotp_base;
> @@ -89,9 +87,9 @@ static int imx8mq_soc_revision(u32 *socrev)
>  			rev = REV_B1;
>  	}
>
> -	soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH);
> -	soc_uid <<= 32;
> -	soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW);
> +	*socuid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH);
> +	*socuid <<= 32;
> +	*socuid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW);
>
>  	*socrev = rev;
>
> @@ -109,7 +107,7 @@ static int imx8mq_soc_revision(u32 *socrev)
>  	return ret;
>  }
>
> -static int imx8mm_soc_uid(void)
> +static int imx8mm_soc_uid(u64 *socuid)
>  {
>  	void __iomem *ocotp_base;
>  	struct device_node *np;
> @@ -136,9 +134,9 @@ static int imx8mm_soc_uid(void)
>
>  	clk_prepare_enable(clk);
>
> -	soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH + offset);
> -	soc_uid <<= 32;
> -	soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + offset);
> +	*socuid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH + offset);
> +	*socuid <<= 32;
> +	*socuid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + offset);
>
>  	clk_disable_unprepare(clk);
>  	clk_put(clk);
> @@ -151,7 +149,7 @@ static int imx8mm_soc_uid(void)
>  	return ret;
>  }
>
> -static int imx8mm_soc_revision(u32 *socrev)
> +static int imx8mm_soc_revision(u32 *socrev, u64 *socuid)
>  {
>  	struct device_node *np;
>  	void __iomem *anatop_base;
> @@ -172,7 +170,7 @@ static int imx8mm_soc_revision(u32 *socrev)
>  	iounmap(anatop_base);
>  	of_node_put(np);
>
> -	return imx8mm_soc_uid();
> +	return imx8mm_soc_uid(socuid);
>
>  err_iomap:
>  	of_node_put(np);
> @@ -215,10 +213,11 @@ static __maybe_unused const struct of_device_id imx8_soc_match[] = {
>  static int imx8m_soc_probe(struct platform_device *pdev)
>  {
>  	struct soc_device_attribute *soc_dev_attr;
> -	struct soc_device *soc_dev;
> +	const struct imx8_soc_data *data;
>  	const struct of_device_id *id;
> +	struct soc_device *soc_dev;
>  	u32 soc_rev = 0;
> -	const struct imx8_soc_data *data;
> +	u64 soc_uid = 0;

unnecessary this these orders in this patch.

>  	int ret;
>
>  	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
> @@ -241,7 +240,7 @@ static int imx8m_soc_probe(struct platform_device *pdev)
>  	if (data) {
>  		soc_dev_attr->soc_id = data->name;
>  		if (data->soc_revision) {
> -			ret = data->soc_revision(&soc_rev);
> +			ret = data->soc_revision(&soc_rev, &soc_uid);
>  			if (ret)
>  				goto free_soc;
>  		}
> --
> 2.45.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ