Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1400940
| From | "Deucher, Alexander" <Alexander.Deucher@amd.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | RE: [PATCH] drm/amd/powerplay: use ARRAY_SIZE() for size of array |
| Date | 2016-05-13 21:00 +0200 |
| Message-ID | <ryqtA-Q9-9@gated-at.bofh.it> (permalink) |
| References | <rxGqK-4tl-11@gated-at.bofh.it> <rxVzu-30G-19@gated-at.bofh.it> <ryoUO-7ZA-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
> -----Original Message-----
> From: Muhammad Falak R Wani [mailto:falakreyaz@gmail.com]
> Sent: Friday, May 13, 2016 1:17 PM
> To: Jani Nikula
> Cc: Koenig, Christian; Nils Wallménius; Zhou, Jammy; linux-
> kernel@vger.kernel.org; dri-devel@lists.freedesktop.org; Deucher,
> Alexander; Zhu, Rex; Dan Carpenter
> Subject: Re: [PATCH] drm/amd/powerplay: use ARRAY_SIZE() for size of
> array
>
> On Thu, May 12, 2016 at 12:53:48PM +0300, Jani Nikula wrote:
> > On Wed, 11 May 2016, Muhammad Falak R Wani <falakreyaz@gmail.com>
> wrote:
> > > Use ARRAY_SIZE() for the size calculation of the array. Also move the
> > > condition evaulation function out of the for loop.
> > > Although, any respectable c-compiler would optimize this and evaluate
> > > the function only once outside the loop, but the optimzation engine
> > > of gcc is bit brain-dead, and at times needs some hand holding.
> >
> > This just caught my eye. ARRAY_SIZE is a macro that expands to a compile
> > time constant. Arguably adding the the local variable here gives GCC
> > more chances to go wrong than keeping the ARRAY_SIZE in the loop
> > condition.
> >
> > BR,
> > Jani.
> >
> > >
> > > Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
> > > ---
> > > drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | 3 ++-
> > > 1 file changed, 2 insertions(+), 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..718a551 100644
> > > --- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> > > +++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> > > @@ -636,10 +636,11 @@ static int
> cz_smu_populate_firmware_entries(struct pp_smumgr *smumgr)
> > > int ret;
> > > enum cgs_ucode_id ucode_id;
> > > struct cgs_firmware_info info = {0};
> > > + int n = ARRAY_SIZE(firmware_list);
> > >
> > > cz_smu->driver_buffer_length = 0;
> > >
> > > - for (i = 0; i < sizeof(firmware_list)/sizeof(*firmware_list); i++) {
> > > + for (i = 0; i < n; i++) {
> > >
> > > firmware_type =
> cz_translate_firmware_enum_to_arg(smumgr,
> > > firmware_list[i]);
> >
> > --
> > Jani Nikula, Intel Open Source Technology Center
> Should i send a new patch, with these modifications. Sorry for my
> childish mistake, i got a little too carried away.
Yes, please send an updated patch.
Thanks,
Alex
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH] drm/amd/powerplay: use ARRAY_SIZE() for size of array Muhammad Falak R Wani <falakreyaz@gmail.com> - 2016-05-13 19:20 +0200 RE: [PATCH] drm/amd/powerplay: use ARRAY_SIZE() for size of array "Deucher, Alexander" <Alexander.Deucher@amd.com> - 2016-05-13 21:00 +0200 Re: [PATCH] drm/amd/powerplay: use ARRAY_SIZE() for size of array Dan Carpenter <dan.carpenter@oracle.com> - 2016-05-13 22:30 +0200
csiph-web