Skip to contentSkip to conversation

drm/amdgpu: Use ARRAY_SIZE to get array length

PATCH In review yipechai 2 participants 3 messages Jan 13, 2022

Subsystems (2)
lore
Share & tools
lore

yipechai

author
#0 lore raw

PATCH v2 1/2 drm/amdgpu: Use ARRAY_SIZE to get array length

Use ARRAY_SIZE to get array length.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -1
index 23f4290b2fde..394a18e3c6af 100644
@@ -89,7 +89,8 @@ const char *get_ras_block_str(struct ras_common_if *ras_block)
 	return ras_block_string[ras_block->block];
 }
 
-#define ras_block_str(_BLOCK_)  (((_BLOCK_) < (sizeof(*ras_block_string)/sizeof(const char*))) ? ras_block_string[_BLOCK_] : "Out Of Range")
+#define ras_block_str(_BLOCK_) \
+	(((_BLOCK_) < ARRAY_SIZE(ras_block_string)) ? ras_block_string[_BLOCK_] : "Out Of Range")
 
 #define ras_err_str(i) (ras_error_string[ffs(i)])
 
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v2 2/2 drm/amdgpu: To eliminate the warning of no previous prototype for 'amdgpu_ras_block_match_default'

To eliminate the warning of no previous prototype
for 'amdgpu_ras_block_match_default'.

Fix compile warnings.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -1
index 394a18e3c6af..7afeec4255bd 100644
@@ -869,7 +869,8 @@ static int amdgpu_ras_enable_all_features(struct amdgpu_device *adev,
 }
 /* feature ctl end */
 
-int amdgpu_ras_block_match_default(struct amdgpu_ras_block_object* block_obj, enum amdgpu_ras_block block)
+static int amdgpu_ras_block_match_default(struct amdgpu_ras_block_object *block_obj,
+		enum amdgpu_ras_block block)
 {
 	if(!block_obj)
 		return -EINVAL;
Signature · 1 line
2.25.1
Reviewed-by on v2 2/2
#2 lore raw

RE: [PATCH V2 2/2] drm/amdgpu: To eliminate the warning of no previous prototype for 'amdgpu_ras_block_match_default'

[AMD Official Use Only]

The subject can be simplified as "fix compile warning for ras_block_match_default", with that fixed the series is:

Quoted 39 lines

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Thursday, January 13, 2022 6:32 PM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Clements, John <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH V2 2/2] drm/amdgpu: To eliminate the warning of no previous prototype for 'amdgpu_ras_block_match_default'

To eliminate the warning of no previous prototype for 'amdgpu_ras_block_match_default'.

Fix compile warnings.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -1
index 394a18e3c6af..7afeec4255bd 100644
@@ -869,7 +869,8 @@ static int amdgpu_ras_enable_all_features(struct
 amdgpu_device *adev,  }
 /* feature ctl end */
 
-int amdgpu_ras_block_match_default(struct amdgpu_ras_block_object*
 block_obj, enum amdgpu_ras_block block)
+static int amdgpu_ras_block_match_default(struct amdgpu_ras_block_object
 *block_obj,
+		enum amdgpu_ras_block block)
 {
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
 	if(!block_obj)
 		return -EINVAL;
--

2.25.1