Skip to contentSkip to conversation

soc/tegra: fuse: Add fuse clock check in tegra_fuse_readl

PATCH Applied Nagarjuna Kristam 2 participants 3 messages Sep 3, 2019 – Oct 1, 2019 Tegra architecture support

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 soc/tegra: fuse: Add fuse clock check in tegra_fuse_readl

tegra_fuse_readl() can be called from drivers at any time. If this API is called before tegra_fuse_probe(), we end up enabling clock before it is registered. Add check for fuse clock in tegra_fuse_readl() and return corresponding error if any.

---
V2:
- Added Null and other error checks for fuse->clk.

---
 drivers/soc/tegra/fuse/fuse-tegra.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/soc/tegra/fuse/fuse-tegra.c +4 -1
index 3eb44e6..58996c6 100644
@@ -186,9 +186,12 @@ u32 __init tegra_fuse_read_early(unsigned int offset)
 
 int tegra_fuse_readl(unsigned long offset, u32 *value)
 {
-	if (!fuse->read)
+	if (!fuse->read || !fuse->clk)
 		return -EPROBE_DEFER;
 
+	if (IS_ERR(fuse->clk))
+		return PTR_ERR(fuse->clk);
+
 	*value = fuse->read(fuse, offset);
 
 	return 0;
Signature · 1 line
2.7.4
Acked-by on v2 1/1
#1 lore raw
Quoted 5 lines · Nagarjuna Kristam

tegra_fuse_readl() can be called from drivers at any time. If this API is called before tegra_fuse_probe(), we end up enabling clock before it is registered. Add check for fuse clock in tegra_fuse_readl() and return corresponding error if any.

Quoted 7 lines

---
V2:
- Added Null and other error checks for fuse->clk.

---
 drivers/soc/tegra/fuse/fuse-tegra.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Hi ARM-SoC maintainers,

can you pick this up as a bugfix for v5.4-rc1? Would you prefer to pick it up directly or do you want a pull request for this?

The patchwork link is:

	http://patchwork.ozlabs.org/patch/1156928/

And in that case:

Thanks,
Thierry

Quoted 21 lines
drivers/soc/tegra/fuse/fuse-tegra.c +4 -1
index 3eb44e6..58996c6 100644
@@ -186,9 +186,12 @@ u32 __init tegra_fuse_read_early(unsigned int offset)
 
 int tegra_fuse_readl(unsigned long offset, u32 *value)
 {
-	if (!fuse->read)
+	if (!fuse->read || !fuse->clk)
 		return -EPROBE_DEFER;
 
+	if (IS_ERR(fuse->clk))
+		return PTR_ERR(fuse->clk);
+
 	*value = fuse->read(fuse, offset);
 
 	return 0;
Signature · 1 line
2.7.4
#2 lore raw
In reply to Nagarjuna Kristam
Quoted 5 lines · Nagarjuna Kristam

tegra_fuse_readl() can be called from drivers at any time. If this API is called before tegra_fuse_probe(), we end up enabling clock before it is registered. Add check for fuse clock in tegra_fuse_readl() and return corresponding error if any.

Quoted 7 lines

---
V2:
- Added Null and other error checks for fuse->clk.

---
 drivers/soc/tegra/fuse/fuse-tegra.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Applied to for-5.5/soc, thanks.

Thierry