Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1400919 > unrolled thread

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

Started byMuhammad Falak R Wani <falakreyaz@gmail.com>
First post2016-05-13 19:40 +0200
Last post2016-05-16 18:20 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size. Muhammad Falak R Wani <falakreyaz@gmail.com> - 2016-05-13 19:40 +0200
    Re: [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate  array size. Eric Engestrom <eric.engestrom@imgtec.com> - 2016-05-16 18:00 +0200
      Re: [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate  array size. Muhammad Falak R Wani <falakreyaz@gmail.com> - 2016-05-17 08:30 +0200
    Re: [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size. Alex Deucher <alexdeucher@gmail.com> - 2016-05-16 18:20 +0200

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

FromMuhammad Falak R Wani <falakreyaz@gmail.com>
Date2016-05-13 19:40 +0200
Subject[PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size.
Message-ID<rypea-8bu-23@gated-at.bofh.it>
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(-)

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

[toc] | [next] | [standalone]


#1401586 — Re: [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size.

FromEric Engestrom <eric.engestrom@imgtec.com>
Date2016-05-16 18:00 +0200
SubjectRe: [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size.
Message-ID<rzt61-rV-9@gated-at.bofh.it>
In reply to#1400919
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

[toc] | [prev] | [next] | [standalone]


#1402128 — Re: [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size.

FromMuhammad Falak R Wani <falakreyaz@gmail.com>
Date2016-05-17 08:30 +0200
SubjectRe: [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size.
Message-ID<rzGFX-XB-1@gated-at.bofh.it>
In reply to#1401586
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 :)

[toc] | [prev] | [next] | [standalone]


#1401598

FromAlex Deucher <alexdeucher@gmail.com>
Date2016-05-16 18:20 +0200
Message-ID<rztpo-Ox-9@gated-at.bofh.it>
In reply to#1400919
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web