Skip to contentSkip to conversation

drm/amd/powerplay: use ARRAY_SIZE() to calculate array size.

PATCH Applied Muhammad Falak R Wani 4 participants 5 messages May 13, 2016 – May 17, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amd/powerplay: use ARRAY_SIZE() to calculate array size.

It is preferred to use ARRAY_SIZE() for size calculation, instead using sizeof(array)/sizeof(*array). It makes the code more readable.

---
 drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c +1 -1
index da18f44..87c023e 100644
@@ -639,7 +639,7 @@ static int cz_smu_populate_firmware_entries(struct pp_smumgr *smumgr)
 
 	cz_smu->driver_buffer_length = 0;
 
-	for (i = 0; i < sizeof(firmware_list)/sizeof(*firmware_list); i++) {
+	for (i = 0; i < ARRAY_SIZE(firmware_list); i++) {
 
 		firmware_type = cz_translate_firmware_enum_to_arg(smumgr,
 					firmware_list[i]);
Signature · 1 line
1.9.1
maintainer Reviewed-by on v2 1/1
#1 lore raw

Am 13.05.2016 um 19:36 schrieb Muhammad Falak R Wani:

Quoted 4 lines

It is preferred to use ARRAY_SIZE() for size calculation, instead using sizeof(array)/sizeof(*array). It makes the code more readable.

Thanks for the cleanup,
Christian.

Quoted 9 lines
---
  drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c +0 -0
index da18f44..87c023e 100644

drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c static int cz_smu_populate_firmware_entries(struct pp_smumgr *smumgr) · line 645

Quoted 8 lines
drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c +1 -1
@@ -639,7 +639,7 @@ static int cz_smu_populate_firmware_entries(struct pp_smumgr *smumgr)
 
  	cz_smu->driver_buffer_length = 0;
 
-	for (i = 0; i < sizeof(firmware_list)/sizeof(*firmware_list); i++) {
+	for (i = 0; i < ARRAY_SIZE(firmware_list); i++) {
 
  		firmware_type = cz_translate_firmware_enum_to_arg(smumgr,
  					firmware_list[i]);

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

Reviewed-by on v2 1/1
#2 lore raw
In reply to Muhammad Falak R Wani
Quoted 4 lines · Muhammad Falak R Wani

It is preferred to use ARRAY_SIZE() for size calculation, instead using sizeof(array)/sizeof(*array). It makes the code more readable.

Thanks, and sorry about before, if I made you feel like you made a "childish mistake". As Dan said, this is mostly a question of
style: your code was right, it just had an unnecessary bit.

I hope I didn't give you a bad impression of the community, most people around here have better manners than I :P

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

#3 lore raw
Quoted 8 lines · Eric Engestrom
Quoted 4 lines · Muhammad Falak R Wani

It is preferred to use ARRAY_SIZE() for size calculation, instead using sizeof(array)/sizeof(*array). It makes the code more readable.

Quoted 8 lines

Thanks, and sorry about before, if I made you feel like you made a "childish mistake". As Dan said, this is mostly a question of
style: your code was right, it just had an unnecessary bit.

I hope I didn't give you a bad impression of the community, most people around here have better manners than I :P

Cheers

Thank you for such a nice gesture. No, I didn't get any bad impression. Infact people learn like this.

Thank you guys :)

Applied
#4 lore raw
In reply to Muhammad Falak R Wani
Quoted 4 lines · Muhammad Falak R Wani

It is preferred to use ARRAY_SIZE() for size calculation, instead using sizeof(array)/sizeof(*array). It makes the code more readable.

Applied. thanks!

Alex

Quoted 20 lines
---
 drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c +1 -2
index da18f44..87c023e 100644
@@ -639,7 +639,7 @@ static int cz_smu_populate_firmware_entries(struct pp_smumgr *smumgr)
 
        cz_smu->driver_buffer_length = 0;
 
-       for (i = 0; i < sizeof(firmware_list)/sizeof(*firmware_list); i++) {
+       for (i = 0; i < ARRAY_SIZE(firmware_list); i++) {
 
                firmware_type = cz_translate_firmware_enum_to_arg(smumgr,
                                        firmware_list[i]);
--

1.9.1

Quoted 4 lines

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

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