From: Marek Vasut <marex@denx.de>
To: linux-arm-kernel@lists.infradead.org
Cc: kernel@dh-electronics.com, Marek Vasut <marex@denx.de>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Arnd Bergmann <arnd@arndb.de>, Fabio Estevam <festevam@gmail.com>,
Jeff Johnson <quic_jjohnson@quicinc.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Saravana Kannan <saravanak@google.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Shawn Guo <shawnguo@kernel.org>,
imx@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH v4 2/3] soc: imx8m: Remove global soc_uid
Date: Sun, 29 Sep 2024 20:49:17 +0200 [thread overview]
Message-ID: <20240929184930.73049-2-marex@denx.de> (raw)
In-Reply-To: <20240929184930.73049-1-marex@denx.de>
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.
Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Jeff Johnson <quic_jjohnson@quicinc.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Saravana Kannan <saravanak@google.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: imx@lists.linux.dev
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
V3: New patch
V4: No change
---
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;
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
next prev parent reply other threads:[~2024-09-29 18:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-29 18:49 [PATCH v4 1/3] soc: imx8m: Probe the SoC driver as platform driver Marek Vasut
2024-09-29 18:49 ` Marek Vasut [this message]
2024-09-29 18:49 ` [PATCH v4 3/3] soc: imx8m: Use devm_* to simplify probe failure handling Marek Vasut
2024-10-18 3:14 ` [PATCH v4 1/3] soc: imx8m: Probe the SoC driver as platform driver Shawn Guo
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=20240929184930.73049-2-marex@denx.de \
--to=marex@denx.de \
--cc=angelogioacchino.delregno@collabora.com \
--cc=arnd@arndb.de \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@dh-electronics.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=quic_jjohnson@quicinc.com \
--cc=s.hauer@pengutronix.de \
--cc=saravanak@google.com \
--cc=shawnguo@kernel.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