Skip to contentSkip to conversation

drm: Use IS_ERR() instead of null pointer check

PATCH Superseded Wang Qing 2 participants 2 messages Nov 6, 2020

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wang Qing

author
#0 lore raw

PATCH 1/1 drm: 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

---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +1 -1
index 491fee4..8c81a89
@@ -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))
Signature · 1 line
2.7.4
#1 lore raw

Hi Wang.

Thanks for the fix.

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

In the future please put "drm/<driver-dir>:" in the subject. See git log . in said directory for normal practice - this let the readers see this is an msm related patch.

Quoted 9 lines
---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +0 -0
index 491fee4..8c81a89

drivers/gpu/drm/msm/adreno/a6xx_gmu.c static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu) · line 496

Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +1 -1
@@ -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;

When the pointer is checked after the err: label the function IS_ERR_OR_NULL() is used. Please update both places so they match.

Sam

Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +0 -0
 	if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel