Skip to contentSkip to conversation

drm: msm: adreno: use IS_ERR() instead of null pointer check

PATCH In review Wang Qing 2 participants 3 messages Nov 7, 2020 – Oct 2, 2021

Subsystems (4)
lore
Share & tools
lore

Wang Qing

author
#0 lore raw

PATCH v2 1/1 drm: msm: adreno: use IS_ERR() instead of null pointer check

a6xx_gmu_get_mmio() never return null in case of error, but ERR_PTR(), so we should use IS_ERR() instead of null pointer check and IS_ERR_OR_NULL().

---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +3 -3
index 491fee4..82420f7
@@ -492,7 +492,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
 	void __iomem *seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq");
 	uint32_t pdc_address_offset;
 
-	if (!pdcptr || !seqptr)
+	if (IS_ERR(pdcptr) || IS_ERR(seqptr))
 		goto err;
 
 	if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
@@ -580,9 +580,9 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
 	wmb();
 
 err:
-	if (!IS_ERR_OR_NULL(pdcptr))
+	if (!IS_ERR(pdcptr))
 		iounmap(pdcptr);
-	if (!IS_ERR_OR_NULL(seqptr))
+	if (!IS_ERR(seqptr))
 		iounmap(seqptr);
 }
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 2 lines · Wang Qing

a6xx_gmu_get_mmio() never return null in case of error, but ERR_PTR(), so we should use IS_ERR() instead of null pointer check and IS_ERR_OR_NULL().

Not quite. a6xx_gmu_get_mmio() can return NULL, as it uses ioremap() internally. And ioremap returns NULL in case of error. So the proper check should be IS_ERR_OR_NULL().

Quoted 32 lines
---
  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +3 -3
index 491fee4..82420f7
@@ -492,7 +492,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
  	void __iomem *seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq");
  	uint32_t pdc_address_offset;
 
-	if (!pdcptr || !seqptr)
+	if (IS_ERR(pdcptr) || IS_ERR(seqptr))
  		goto err;
 
  	if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
@@ -580,9 +580,9 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
  	wmb();
 
  err:
-	if (!IS_ERR_OR_NULL(pdcptr))
+	if (!IS_ERR(pdcptr))
  		iounmap(pdcptr);
-	if (!IS_ERR_OR_NULL(seqptr))
+	if (!IS_ERR(seqptr))
  		iounmap(seqptr);
  }
 
Signature · 2 lines
With best wishes
Dmitry
#2 lore raw
In reply to Wang Qing
Quoted 4 lines · Wang Qing

a6xx_gmu_get_mmio() never return null in case of error, but ERR_PTR(), so we should use IS_ERR() instead of null pointer check and IS_ERR_OR_NULL().

As a second thought, ioremap's NULL is converted to ERR_PTR(-EINVAL), so the patch is correct.

Quoted 30 lines
---
  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +3 -3
index 491fee4..82420f7
@@ -492,7 +492,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
  	void __iomem *seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq");
  	uint32_t pdc_address_offset;
 
-	if (!pdcptr || !seqptr)
+	if (IS_ERR(pdcptr) || IS_ERR(seqptr))
  		goto err;
 
  	if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
@@ -580,9 +580,9 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
  	wmb();
 
  err:
-	if (!IS_ERR_OR_NULL(pdcptr))
+	if (!IS_ERR(pdcptr))
  		iounmap(pdcptr);
-	if (!IS_ERR_OR_NULL(seqptr))
+	if (!IS_ERR(seqptr))
  		iounmap(seqptr);
  }
 
Signature · 2 lines
With best wishes
Dmitry