diff mbox

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

Message ID 1463161029-7490-1-git-send-email-falakreyaz@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Muhammad Falak R Wani May 13, 2016, 5:36 p.m. UTC
It is preferred to use ARRAY_SIZE() for size calculation, instead
using sizeof(array)/sizeof(*array). It makes the code more readable.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
---
 drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian König May 14, 2016, 8 p.m. UTC | #1
Am 13.05.2016 um 19:36 schrieb 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.
>
> Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

Thanks for the cleanup,
Christian.

> ---
>   drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> index da18f44..87c023e 100644
> --- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> @@ -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]);
Eric Engestrom May 16, 2016, 3:53 p.m. UTC | #2
On Fri, May 13, 2016 at 11:06:40PM +0530, Muhammad Falak R Wani wrote:
> It is preferred to use ARRAY_SIZE() for size calculation, instead
> using sizeof(array)/sizeof(*array). It makes the code more readable.
> 
> Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>

Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>

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
Alex Deucher May 16, 2016, 4:18 p.m. UTC | #3
On Fri, May 13, 2016 at 1:36 PM, Muhammad Falak R Wani
<falakreyaz@gmail.com> wrote:
> It is preferred to use ARRAY_SIZE() for size calculation, instead
> using sizeof(array)/sizeof(*array). It makes the code more readable.
>
> Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>

Applied.  thanks!

Alex

> ---
>  drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> index da18f44..87c023e 100644
> --- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> @@ -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
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Muhammad Falak R Wani May 17, 2016, 6:28 a.m. UTC | #4
On Mon, May 16, 2016 at 04:53:50PM +0100, Eric Engestrom wrote:
> On Fri, May 13, 2016 at 11:06:40PM +0530, Muhammad Falak R Wani wrote:
> > It is preferred to use ARRAY_SIZE() for size calculation, instead
> > using sizeof(array)/sizeof(*array). It makes the code more readable.
> > 
> > Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
> 
> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
> 
> 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 :)
diff mbox

Patch

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
index da18f44..87c023e 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
@@ -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]);