All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben-linux@fluff.org>
To: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Kukjin Kim <kgene.kim@samsung.com>,
	Thomas Abraham <thomas.ab@samsung.com>,
	linux-samsung-soc@vger.kernel.org, ben-linux@fluff.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 11/11] ARM: S5P6440: Remove redundant defines
Date: Thu, 13 May 2010 03:02:36 +0100	[thread overview]
Message-ID: <20100513020236.GS6684@trinity.fluff.org> (raw)
In-Reply-To: <AANLkTimTm_Vxvb2xvJnVxTxUaYguFgGeaWGypzA1yjwM@mail.gmail.com>

On Thu, May 13, 2010 at 10:49:29AM +0900, Jassi Brar wrote:
> On Thu, May 13, 2010 at 9:28 AM, Kukjin Kim <kgene.kim@samsung.com> wrote:
> > From: Thomas Abraham <thomas.ab@samsung.com>
> > --- a/arch/arm/mach-s5p6440/clock.c
> > +++ b/arch/arm/mach-s5p6440/clock.c
> > @@ -357,121 +357,121 @@ static struct clk init_clocks_disable[] = {
> >                .id             = -1,
> >                .parent         = &clk_hclk.clk,
> >                .enable         = s5p6440_mem_ctrl,
> > -               .ctrlbit        = S5P_CLKCON_MEM0_HCLK_NFCON,
> > +               .ctrlbit        = (1 << 2),
> Peculiar. I have never seen defines dropped in favor of magic numbers.

I know it seems a little odd at first, but people seem to be clinging
on to writing it down in a header file and then using it once as some
form of high law of programming. Whilst talking with Kukjin and others
last year and looking at this, we came to the following conclusions
about single-use defines:

1) It takes two lines of code, where one is sufficient.

2) You only have to look in the relevant .c file to find out the
   value instead of tracking down a header. This makes it easier
   to verify the value against the manual and easier to compare
   against simialr code.

Thus ends today's public service broadcast.

-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.

WARNING: multiple messages have this Message-ID (diff)
From: ben-linux@fluff.org (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 11/11] ARM: S5P6440: Remove redundant defines
Date: Thu, 13 May 2010 03:02:36 +0100	[thread overview]
Message-ID: <20100513020236.GS6684@trinity.fluff.org> (raw)
In-Reply-To: <AANLkTimTm_Vxvb2xvJnVxTxUaYguFgGeaWGypzA1yjwM@mail.gmail.com>

On Thu, May 13, 2010 at 10:49:29AM +0900, Jassi Brar wrote:
> On Thu, May 13, 2010 at 9:28 AM, Kukjin Kim <kgene.kim@samsung.com> wrote:
> > From: Thomas Abraham <thomas.ab@samsung.com>
> > --- a/arch/arm/mach-s5p6440/clock.c
> > +++ b/arch/arm/mach-s5p6440/clock.c
> > @@ -357,121 +357,121 @@ static struct clk init_clocks_disable[] = {
> > ? ? ? ? ? ? ? ?.id ? ? ? ? ? ? = -1,
> > ? ? ? ? ? ? ? ?.parent ? ? ? ? = &clk_hclk.clk,
> > ? ? ? ? ? ? ? ?.enable ? ? ? ? = s5p6440_mem_ctrl,
> > - ? ? ? ? ? ? ? .ctrlbit ? ? ? ?= S5P_CLKCON_MEM0_HCLK_NFCON,
> > + ? ? ? ? ? ? ? .ctrlbit ? ? ? ?= (1 << 2),
> Peculiar. I have never seen defines dropped in favor of magic numbers.

I know it seems a little odd at first, but people seem to be clinging
on to writing it down in a header file and then using it once as some
form of high law of programming. Whilst talking with Kukjin and others
last year and looking at this, we came to the following conclusions
about single-use defines:

1) It takes two lines of code, where one is sufficient.

2) You only have to look in the relevant .c file to find out the
   value instead of tracking down a header. This makes it easier
   to verify the value against the manual and easier to compare
   against simialr code.

Thus ends today's public service broadcast.

-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.

  reply	other threads:[~2010-05-13  2:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-13  0:28 [PATCH 11/11] ARM: S5P6440: Remove redundant defines Kukjin Kim
2010-05-13  0:28 ` Kukjin Kim
2010-05-13  1:49 ` Jassi Brar
2010-05-13  1:49   ` Jassi Brar
2010-05-13  2:02   ` Ben Dooks [this message]
2010-05-13  2:02     ` Ben Dooks
2010-05-13  4:54     ` Kyungmin Park
2010-05-13  4:54       ` Kyungmin Park
2010-05-13  9:06       ` Russell King - ARM Linux
2010-05-13  9:06         ` Russell King - ARM Linux
2010-05-14  2:12         ` Ben Dooks
2010-05-14  2:12           ` Ben Dooks
2010-05-14  5:35         ` Ben Dooks
2010-05-14  5:35           ` Ben Dooks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100513020236.GS6684@trinity.fluff.org \
    --to=ben-linux@fluff.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=kgene.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=thomas.ab@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.