public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 2/2] ARM: SAMSUNG: Cleanup resources by using macro
Date: Mon, 03 Oct 2011 17:01:11 +0200	[thread overview]
Message-ID: <1957187.UuLfeIqa6D@wuerfel> (raw)
In-Reply-To: <005901cc817e$51a56d00$f4f04700$%kim@samsung.com>

On Monday 03 October 2011 12:41:22 Kukjin Kim wrote:
> This patch adds macro SAMSUNG_RES_MEM, SAMSUNG_RES_IRQ
> and so on to cleanup regarding 'struct resource' by using
> defined helpers at <linux/ioport.h>.
> 
> Cc: Ben Dooks <ben-linux@fluff.org>
> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>

When we introduced those macros, it was specifically so that platforms
would be migrated to use them instead of providing their own.

> index 8f19241..a506831 100644
> --- a/arch/arm/plat-samsung/include/plat/devs.h
> +++ b/arch/arm/plat-samsung/include/plat/devs.h
> @@ -18,6 +18,17 @@
>  
>  #include <linux/platform_device.h>
>  
> +#define SAMSUNG_RES_MEM(soc, ip, sz)   DEFINE_RES_MEM(soc##_PA_##ip, sz)
> +#define SAMSUNG_RES_IRQ(ip)            DEFINE_RES_IRQ(IRQ_##ip)
> +
> +#define SAMSUNG_RES_MEM_NAMED(soc, ip, sz, name)       \
> +                               DEFINE_RES_MEM_NAMED(soc##_PA_##ip, sz, name)
> +#define SAMSUNG_RES_IRQ_NAMED(ip, name)                        \
> +                               DEFINE_RES_IRQ_NAMED(IRQ_##ip, name)
> +#define SAMSUNG_RES_DMA_NAMED(ch, name)                        \
> +                               DEFINE_RES_DMA_NAMED(DMACH_##ch, name)

I think the string concatenation really just obfuscates the code, and
it does not actually save much at all. When you replace

+       [0] = SAMSUNG_RES_MEM(S3C, WDT, SZ_1K),
+       [1] = SAMSUNG_RES_IRQ(WDT),

with

+       [0] = DEFINE_RES_MEM(S3C_PA_WDT, SZ_1K),
+       [1] = DEFINE_RES_IRQ(IRQ_WDT),

you need practically no extra space, but you gain the advantages that

* Someone using grep for DEFINE_RES_MEM finds all memory resources without
  having to look up what your macros do an where they are used.
* Someone using grep to look for S3C_PA_WDT finds the place where it is used.
* Someone reading the resource definition immediately knows what the
  macro does if familiar with other platforms using that macro.

	Arnd

  parent reply	other threads:[~2011-10-03 15:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-03  3:41 [PATCH V2 2/2] ARM: SAMSUNG: Cleanup resources by using macro Kukjin Kim
2011-10-03  3:53 ` Kyungmin Park
2011-10-03 13:13   ` Kukjin Kim
2011-10-03 14:20     ` Sylwester Nawrocki
2011-10-04 12:45       ` Kukjin Kim
2011-10-03 15:01 ` Arnd Bergmann [this message]
2011-10-04 12:45   ` Kukjin Kim
2011-10-04 15:26     ` Arnd Bergmann
2011-10-04 23:27       ` Kyungmin Park
2011-10-05  1:17         ` Kukjin Kim
2011-10-05  1:17       ` Kukjin Kim

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=1957187.UuLfeIqa6D@wuerfel \
    --to=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox