Re: [PATCH v2] pinmux: add a driver for the CSR SiRFprimaII pinmux

From: Barry Song
Date: Sun Oct 09 2011 - 01:40:32 EST


2011/10/8 Arnd Bergmann <arnd@xxxxxxxx>:
> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/