[PATCH] drm/i915/gmch: fix not used warning in intel_alloc_mchbar_resource

zhangshida starzhangzsd at gmail.com
Tue Jul 11 03:29:40 UTC 2023


From: Shida Zhang <zhangshida at kylinos.cn>

Quiet down this gcc warning generated by
gcc (Debian 10.2.1-6) 10.2.1 20210110:

../drivers/gpu/drm/i915/soc/intel_gmch.c: In function ‘intel_alloc_mchbar_resource’:
../drivers/gpu/drm/i915/soc/intel_gmch.c:41:6: error: variable ‘mchbar_addr’ set but not used [-Werror=unused-but-set-variable]
   41 |  u64 mchbar_addr;
      |      ^~~~~~~~~~~

Reported-by: k2ci <kernel-bot at kylinos.cn>
Signed-off-by: Shida Zhang <zhangshida at kylinos.cn>
---
 drivers/gpu/drm/i915/soc/intel_gmch.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/soc/intel_gmch.c b/drivers/gpu/drm/i915/soc/intel_gmch.c
index 6d0204942f7a..f7db6cb3f828 100644
--- a/drivers/gpu/drm/i915/soc/intel_gmch.c
+++ b/drivers/gpu/drm/i915/soc/intel_gmch.c
@@ -38,16 +38,18 @@ intel_alloc_mchbar_resource(struct drm_i915_private *i915)
 {
 	int reg = GRAPHICS_VER(i915) >= 4 ? MCHBAR_I965 : MCHBAR_I915;
 	u32 temp_lo, temp_hi = 0;
+#ifdef CONFIG_PNP
 	u64 mchbar_addr;
+#endif
 	int ret;
 
 	if (GRAPHICS_VER(i915) >= 4)
 		pci_read_config_dword(i915->gmch.pdev, reg + 4, &temp_hi);
 	pci_read_config_dword(i915->gmch.pdev, reg, &temp_lo);
-	mchbar_addr = ((u64)temp_hi << 32) | temp_lo;
 
 	/* If ACPI doesn't have it, assume we need to allocate it ourselves */
 #ifdef CONFIG_PNP
+	mchbar_addr = ((u64)temp_hi << 32) | temp_lo;
 	if (mchbar_addr &&
 	    pnp_range_reserved(mchbar_addr, mchbar_addr + MCHBAR_SIZE))
 		return 0;
-- 
2.27.0



More information about the dri-devel mailing list