Skip to contentSkip to conversation

soc/tegra: fuse: Explicitly cast to/from __iomem

PATCH In review Thierry Reding 2 participants 2 messages Feb 24, 2022 Tegra architecture support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc/tegra: fuse: Explicitly cast to/from __iomem

From: Thierry Reding <[email protected]>

sparse is picky about casts between different address spaces. A cast to plain void * needs to be accompanied by a __force modifier and casting back to void __iomem * needs to be explicit to avoid warnings.

Fixes 88724b78a84c ("soc/tegra: fuse: Use resource-managed helpers")
---
 drivers/soc/tegra/fuse/fuse-tegra.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/tegra/fuse/fuse-tegra.c +2 -2
index 10d2ae99babd..aa94fda282f4 100644
@@ -202,8 +202,8 @@ static const struct nvmem_cell_info tegra_fuse_cells[] = {
 
 static void tegra_fuse_restore(void *base)
 {
+	fuse->base = (void __iomem *)base;
 	fuse->clk = NULL;
-	fuse->base = base;
 }
 
 static int tegra_fuse_probe(struct platform_device *pdev)
@@ -213,7 +213,7 @@ static int tegra_fuse_probe(struct platform_device *pdev)
 	struct resource *res;
 	int err;
 
-	err = devm_add_action(&pdev->dev, tegra_fuse_restore, base);
+	err = devm_add_action(&pdev->dev, tegra_fuse_restore, (void __force *)base);
 	if (err)
 		return err;
 
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Thierry Reding

From: Thierry Reding <[email protected]>

sparse is picky about casts between different address spaces. A cast to plain void * needs to be accompanied by a __force modifier and casting back to void __iomem * needs to be explicit to avoid warnings.

Fixes 88724b78a84c ("soc/tegra: fuse: Use resource-managed helpers")
---
 drivers/soc/tegra/fuse/fuse-tegra.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/tegra/fuse/fuse-tegra.c +1 -1
index 10d2ae99babd..aa94fda282f4 100644
@@ -202,8 +202,8 @@ static const struct nvmem_cell_info tegra_fuse_cells[] = {
 
 static void tegra_fuse_restore(void *base)
 {
+	fuse->base = (void __iomem *)base;
 	fuse->clk = NULL;
-	fuse->base = base;
 }
 
 static int tegra_fuse_probe(struct platform_device *pdev)

drivers/soc/tegra/fuse/fuse-tegra.c static int tegra_fuse_probe(struct platform_device *pdev) · line 219

Quoted 8 lines
drivers/soc/tegra/fuse/fuse-tegra.c +1 -1
@@ -213,7 +213,7 @@ static int tegra_fuse_probe(struct platform_device *pdev)
 	struct resource *res;
 	int err;
 
-	err = devm_add_action(&pdev->dev, tegra_fuse_restore, base);
+	err = devm_add_action(&pdev->dev, tegra_fuse_restore, (void __force *)base);
 	if (err)
 		return err;
 

Thank you, I had the same change on my mind.