[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231011093412.7994-6-kkartik@nvidia.com>
Date: Wed, 11 Oct 2023 15:04:09 +0530
From: Kartik <kkartik@...dia.com>
To: <thierry.reding@...il.com>, <jonathanh@...dia.com>,
<keescook@...omium.org>, <andy@...nel.org>, <akpm@...ux-foundation.org>,
<arnd@...db.de>, <petlozup@...dia.com>, <pshete@...dia.com>,
<kkartik@...dia.com>, <ulf.hansson@...aro.org>, <frank.li@...o.com>,
<robh@...nel.org>, <stefank@...dia.com>, <pdeschrijver@...dia.com>,
<linux-tegra@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-hardening@...r.kernel.org>, <linux-mm@...ck.org>
Subject: [PATCH v4 5/8] soc/tegra: fuse: Add function to add lookups
Add helper function tegra_fuse_add_lookups() to register Tegra fuse
nvmem lookups. So, this can be shared between tegra_fuse_init() and
ACPI probe, which is to be introduced later.
Use kmemdup_array to duplicate fuse->soc->lookups.
Signed-off-by: Kartik <kkartik@...dia.com>
---
v3 -> v4:
* Use kmemdup_array to duplicate fuse->soc->lookups.
* Return err at the end of tegra_fuse_probe to remove
redundant code.
v1 -> v2:
* Use size_mul to calculate lookups array size.
---
drivers/soc/tegra/fuse/fuse-tegra.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
index 98805885158e..ddf25a1bb19d 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
@@ -113,6 +113,21 @@ static void tegra_fuse_restore(void *base)
fuse->clk = NULL;
}
+static int tegra_fuse_add_lookups(struct tegra_fuse *fuse)
+{
+ size_t size;
+ int ret;
+
+ ret = kmemdup_array((void *)&fuse->lookups, &size, fuse->soc->lookups,
+ sizeof(*fuse->lookups), fuse->soc->num_lookups, GFP_KERNEL);
+ if (ret)
+ return ret;
+
+ nvmem_add_cell_lookups(fuse->lookups, size);
+
+ return 0;
+}
+
static int tegra_fuse_probe(struct platform_device *pdev)
{
void __iomem *base = fuse->base;
@@ -398,6 +413,7 @@ static int __init tegra_init_fuse(void)
const struct of_device_id *match;
struct device_node *np;
struct resource regs;
+ int err;
tegra_init_apbmisc();
@@ -495,15 +511,11 @@ static int __init tegra_init_fuse(void)
pr_debug("Tegra CPU Speedo ID %d, SoC Speedo ID %d\n",
tegra_sku_info.cpu_speedo_id, tegra_sku_info.soc_speedo_id);
- if (fuse->soc->lookups) {
- size_t size = sizeof(*fuse->lookups) * fuse->soc->num_lookups;
+ err = tegra_fuse_add_lookups(fuse);
+ if (err)
+ pr_err("failed to add FUSE lookups\n");
- fuse->lookups = kmemdup(fuse->soc->lookups, size, GFP_KERNEL);
- if (fuse->lookups)
- nvmem_add_cell_lookups(fuse->lookups, fuse->soc->num_lookups);
- }
-
- return 0;
+ return err;
}
early_initcall(tegra_init_fuse);
--
2.34.1
Powered by blists - more mailing lists