linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size.
@ 2016-05-13 17:36 Muhammad Falak R Wani
  2016-05-14 20:00 ` Christian König
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Muhammad Falak R Wani @ 2016-05-13 17:36 UTC (permalink / raw)
  To: David Airlie
  Cc: Alex Deucher, Christian König, Rex Zhu,
	Nils Wallménius, Jammy Zhou, Dan Carpenter, dri-devel,
	linux-kernel

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size.
  2016-05-13 17:36 [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size Muhammad Falak R Wani
@ 2016-05-14 20:00 ` Christian König
  2016-05-16 15:53 ` Eric Engestrom
  2016-05-16 16:18 ` Alex Deucher
  2 siblings, 0 replies; 5+ messages in thread
From: Christian König @ 2016-05-14 20:00 UTC (permalink / raw)
  To: Muhammad Falak R Wani, David Airlie
  Cc: Nils Wallménius, Jammy Zhou, linux-kernel, dri-devel,
	Alex Deucher, Rex Zhu, Christian König, Dan Carpenter

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]);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size.
  2016-05-13 17:36 [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size Muhammad Falak R Wani
  2016-05-14 20:00 ` Christian König
@ 2016-05-16 15:53 ` Eric Engestrom
  2016-05-17  6:28   ` Muhammad Falak R Wani
  2016-05-16 16:18 ` Alex Deucher
  2 siblings, 1 reply; 5+ messages in thread
From: Eric Engestrom @ 2016-05-16 15:53 UTC (permalink / raw)
  To: Muhammad Falak R Wani
  Cc: David Airlie, Nils Wallménius, Jammy Zhou, linux-kernel,
	dri-devel, Alex Deucher, Rex Zhu, Christian König,
	Dan Carpenter

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size.
  2016-05-13 17:36 [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size Muhammad Falak R Wani
  2016-05-14 20:00 ` Christian König
  2016-05-16 15:53 ` Eric Engestrom
@ 2016-05-16 16:18 ` Alex Deucher
  2 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2016-05-16 16:18 UTC (permalink / raw)
  To: Muhammad Falak R Wani
  Cc: David Airlie, Nils Wallménius, Jammy Zhou, LKML,
	Maling list - DRI developers, Alex Deucher, Rex Zhu,
	Christian König, Dan Carpenter

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size.
  2016-05-16 15:53 ` Eric Engestrom
@ 2016-05-17  6:28   ` Muhammad Falak R Wani
  0 siblings, 0 replies; 5+ messages in thread
From: Muhammad Falak R Wani @ 2016-05-17  6:28 UTC (permalink / raw)
  To: Eric Engestrom
  Cc: David Airlie, Nils Wallménius, Jammy Zhou, linux-kernel,
	dri-devel, Alex Deucher, Rex Zhu, Christian König,
	Dan Carpenter

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 :)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-05-17  6:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-13 17:36 [PATCH v2] drm/amd/powerplay: use ARRAY_SIZE() to calculate array size Muhammad Falak R Wani
2016-05-14 20:00 ` Christian König
2016-05-16 15:53 ` Eric Engestrom
2016-05-17  6:28   ` Muhammad Falak R Wani
2016-05-16 16:18 ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).