All of lore.kernel.org
 help / color / mirror / Atom feed
From: Barry Song <21cnbao@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Stephen Warren <swarren@nvidia.com>,
	linus.walleij@stericsson.com, linux-kernel@vger.kernel.org,
	workgroup.linux@csr.com, Rongjun Ying <rongjun.ying@csr.com>
Subject: Re: [PATCH v2] pinmux: add a driver for the CSR SiRFprimaII pinmux
Date: Sun, 9 Oct 2011 13:39:01 +0800	[thread overview]
Message-ID: <CAGsJ_4z=ME6krkhmcYnrNdJqpifJxoNvDCsFpKqVt_-EdKhWiw@mail.gmail.com> (raw)
In-Reply-To: <3712698.4MAZQPafzW@wuerfel>

2011/10/8 Arnd Bergmann <arnd@arndb.de>:
> On Saturday 08 October 2011 19:58:23 Barry Song wrote:
>> > You can probably simplify this and other things with
>> > preprocessor macros if you want to, like:
>> >
>> > #define SIRF_FUNC_ENTRY(a) \
>> > { .name = "##a##", .pins = ##a##_pins, .num_pins =
>> > ARRAY_SIZE(##a##_pins), .padmux = &##a##_padmux }
>> >
>> > Then just:
>> >
>> > static const struct sirfsoc_pinmux_func sirfsoc_pinmux_funcs[] = {
>> >     SIRF_FUNC_ENTRY(lcd_16bits),
>> >
>> >
>> > The macro syntax is probably wrong, the preprocessor always
>> > craze me out, but you get the idea.
>>
>>  :-)  .name = "##a##"  should be changed to .name = #a
>>
>> #name will convert name into a string "name"
>>
>
> Better don't use string concatenation at all if you can avoid it.
>
> A generic macro like
>
> #define SIRF_PINMUX(_name, _pins, _padmux) \
>        { .name = (_name), .pins = (_pins), \
>          .num_pins = ARRAY_SIZE(_pins), padmux = (_padmux), }
>
> is both very easy to understand for someone reading it casually and
> lets you actually grep for where the identifiers are being used.
>
>> static const struct sirfsoc_pinmux_func sirfsoc_pinmux_funcs[] = {
>>     SIRF_FUNC_ENTRY(lcd_16bits),
>
> for the first time, you have no clue what that does, but
>
> static const struct sirfsoc_pinmux_func sirfsoc_pinmux_funcs[] = {
>        SIRF_PINMUX("lcd_16bits", lcd_16bits_pins, &lcd_16bits_padmux),
>        ...
> };
>
> Makes it very clear what you are referencing here and needs no extra lines.

well. thanks! i'll send prima2 pinmux v3 rebased on Linus W's v9 and
with this change too.

>
>        Arnd
>
-barry

WARNING: multiple messages have this Message-ID (diff)
From: 21cnbao@gmail.com (Barry Song)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] pinmux: add a driver for the CSR SiRFprimaII pinmux
Date: Sun, 9 Oct 2011 13:39:01 +0800	[thread overview]
Message-ID: <CAGsJ_4z=ME6krkhmcYnrNdJqpifJxoNvDCsFpKqVt_-EdKhWiw@mail.gmail.com> (raw)
In-Reply-To: <3712698.4MAZQPafzW@wuerfel>

2011/10/8 Arnd Bergmann <arnd@arndb.de>:
> On Saturday 08 October 2011 19:58:23 Barry Song wrote:
>> > You can probably simplify this and other things with
>> > preprocessor macros if you want to, like:
>> >
>> > #define SIRF_FUNC_ENTRY(a) \
>> > { .name = "##a##", .pins = ##a##_pins, .num_pins =
>> > ARRAY_SIZE(##a##_pins), .padmux = &##a##_padmux }
>> >
>> > Then just:
>> >
>> > static const struct sirfsoc_pinmux_func sirfsoc_pinmux_funcs[] = {
>> > ? ? SIRF_FUNC_ENTRY(lcd_16bits),
>> >
>> >
>> > The macro syntax is probably wrong, the preprocessor always
>> > craze me out, but you get the idea.
>>
>> ?:-) ?.name = "##a##" ?should be changed to .name = #a
>>
>> #name will convert name into a string "name"
>>
>
> Better don't use string concatenation at all if you can avoid it.
>
> A generic macro like
>
> #define SIRF_PINMUX(_name, _pins, _padmux) \
> ? ? ? ?{ .name = (_name), .pins = (_pins), \
> ? ? ? ? ?.num_pins = ARRAY_SIZE(_pins), padmux = (_padmux), }
>
> is both very easy to understand for someone reading it casually and
> lets you actually grep for where the identifiers are being used.
>
>> static const struct sirfsoc_pinmux_func sirfsoc_pinmux_funcs[] = {
>> ? ? SIRF_FUNC_ENTRY(lcd_16bits),
>
> for the first time, you have no clue what that does, but
>
> static const struct sirfsoc_pinmux_func sirfsoc_pinmux_funcs[] = {
> ? ? ? ?SIRF_PINMUX("lcd_16bits", lcd_16bits_pins, &lcd_16bits_padmux),
> ? ? ? ?...
> };
>
> Makes it very clear what you are referencing here and needs no extra lines.

well. thanks! i'll send prima2 pinmux v3 rebased on Linus W's v9 and
with this change too.

>
> ? ? ? ?Arnd
>
-barry

  reply	other threads:[~2011-10-09  5:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-01  2:22 [PATCH v2] pinmux: add a driver for the CSR SiRFprimaII pinmux Barry Song
2011-09-01  2:22 ` Barry Song
2011-09-01 11:12 ` Linus Walleij
2011-09-01 11:12   ` Linus Walleij
2011-09-01 11:35   ` Barry Song
2011-09-01 11:35     ` Barry Song
2011-10-08 11:58   ` Barry Song
2011-10-08 11:58     ` Barry Song
2011-10-08 13:08     ` Arnd Bergmann
2011-10-08 13:08       ` Arnd Bergmann
2011-10-09  5:39       ` Barry Song [this message]
2011-10-09  5:39         ` Barry Song

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='CAGsJ_4z=ME6krkhmcYnrNdJqpifJxoNvDCsFpKqVt_-EdKhWiw@mail.gmail.com' \
    --to=21cnbao@gmail.com \
    --cc=arnd@arndb.de \
    --cc=linus.walleij@linaro.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rongjun.ying@csr.com \
    --cc=swarren@nvidia.com \
    --cc=workgroup.linux@csr.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.