All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 05/11] ARM: tegra: pinctrl: remove duplication
Date: Thu, 20 Mar 2014 22:07:46 -0600	[thread overview]
Message-ID: <532BBB12.9090501@wwwdotorg.org> (raw)
In-Reply-To: <CAPnjgZ1Ay3Qpwp4h5tMY0ACvO5Y0FL=AYSWO28tkftyt2jhvfA@mail.gmail.com>

On 03/20/2014 07:25 PM, Simon Glass wrote:
> Hi Stephen,
> 
> On 20 March 2014 12:57, Stephen Warren <swarren@wwwdotorg.org> wrote:
>>
>> On 03/14/2014 01:37 PM, Simon Glass wrote:
>>> Hi Stephen,
>>>
>>> On 13 March 2014 11:42, Stephen Warren <swarren@wwwdotorg.org> wrote:
>>>> From: Stephen Warren <swarren@nvidia.com>
>>>>
>>>> Much of arch/arm/cpu/tegra*-common/pinmux.c is identical. Remove the
>>>> duplication by creating pinmux-common.c for all the identical code.
>>>>
>>>> This leaves:
>>>> * arch/arm/include/asm/arch-tegra*/pinmux.h defining only the names of
>>>>   the various pins/pin groups, drive groups, and mux functions.
>>>> * arch/arm/cpu/tegra*-common/pinmux.c containing only the lookup table
>>>>   stating which pin groups support which mux functions.
>>>>
>>>> The code in pinmux-common.c is semantically identical to that in the
>>>> various original pinmux.c, but had some consistency and cleanup fixes
>>>> applied during migration.

>>>> diff --git a/arch/arm/cpu/tegra-common/pinmux-common.c b/arch/arm/cpu/tegra-common/pinmux-common.c
>>
>>>> +/* return 1 if a pin_pupd_is in range */
>>>> +#define pmux_pin_pupd_isvalid(pupd) \
>>>> +       (((pupd) >= PMUX_PULL_NORMAL) && ((pupd) <= PMUX_PULL_UP))
>>>> +
>>>> +/* return 1 if a pin_tristate_is in range */
>>>> +#define pmux_pin_tristate_isvalid(tristate) \
>>>> +       (((tristate) >= PMUX_TRI_NORMAL) && ((tristate) <= PMUX_TRI_TRISTATE))
>>>> +
>>>> +#ifdef TEGRA_PMX_HAS_PIN_IO_BIT_ETC
>>>
>>> Do we need this #Ifdef?
>>>
>>>> +/* return 1 if a pin_io_is in range */
>>>> +#define pmux_pin_io_isvalid(io) \
>>>> +       (((io) >= PMUX_PIN_OUTPUT) && ((io) <= PMUX_PIN_INPUT))
>>
>> We certainly need not to compile this code, since e.g. PMUX_PIN_INPUT
>> doesn't exist on Tegra20 due to equivalent #ifdefs in pinmux.h.
>>
>> I do explicitly want to keep the ifdefs in pinmux.h, so that APIs are
>> not prototyped, and values not defined, for features that don't exist on
>> the SoC that U-Boot is being built for. This validates at compile time
>> that code isn't using invalid APIs. While pinmux.h could be split up
>> into a few separate header files to avoid the ifdefs, I think that would
>> make the header situation far more complex than it needs to be.
> 
> Arguably you have created this problem by having #ifdefs in the C file
> - if there was a separate file for each SoC then it would be much
> harder to mess this up.

Well, then you get a link error rather than a compiler error for an
unprototyped function or undefined enum/#define. I think the compile
error is a bit more obvious myself, but granted either would work.

...
>> So in summary, I'd like to keep the ifdefs. I think they're pretty
>> simple and not a maintenance burden. Do you object?
> 
> No. I can't possibly object given that you have completed such a great clean-up.

Great, thanks. I'll post V2 tomorrow.

  reply	other threads:[~2014-03-21  4:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-13 17:41 [U-Boot] [PATCH 00/11] ARM: tegra: pinmux driver cleanup Stephen Warren
2014-03-13 17:41 ` [U-Boot] [PATCH 01/11] ARM: tegra: pinctrl: remove func_safe Stephen Warren
2014-03-14 18:22   ` Simon Glass
2014-03-14 18:45     ` Stephen Warren
2014-03-13 17:41 ` [U-Boot] [PATCH 02/11] ARM: tegra: pinctrl: remove vddio Stephen Warren
2014-03-14 18:23   ` Simon Glass
2014-03-13 17:41 ` [U-Boot] [PATCH 03/11] ARM: tegra: pinctrl: make pmux_func values consistent on Tegra20 Stephen Warren
2014-03-14 18:25   ` Simon Glass
2014-03-13 17:42 ` [U-Boot] [PATCH 04/11] ARM: tegra: prototype pinmux_init() in board.h Stephen Warren
2014-03-14 18:26   ` Simon Glass
2014-03-13 17:42 ` [U-Boot] [PATCH 05/11] ARM: tegra: pinctrl: remove duplication Stephen Warren
2014-03-14 19:37   ` Simon Glass
2014-03-20 19:57     ` Stephen Warren
2014-03-21  1:25       ` Simon Glass
2014-03-21  4:07         ` Stephen Warren [this message]
2014-03-13 17:42 ` [U-Boot] [PATCH 06/11] ARM: tegra: reduce public pinmux API Stephen Warren
2014-03-14 19:39   ` Simon Glass
2014-03-13 17:42 ` [U-Boot] [PATCH 07/11] ARM: tegra: pinmux naming consistency fixes Stephen Warren
2014-03-14 20:15   ` Simon Glass
2014-03-14 23:43     ` Stephen Warren
2014-03-20 19:08     ` Stephen Warren
2014-03-13 17:42 ` [U-Boot] [PATCH 08/11] ARM: tegra: Tegra20 pinmux cleanup Stephen Warren
2014-03-13 17:42 ` [U-Boot] [PATCH 09/11] ARM: tegra: Tegra30 " Stephen Warren
2014-03-13 17:42 ` [U-Boot] [PATCH 10/11] ARM: tegra: Tegra114 " Stephen Warren
2014-03-13 17:42 ` [U-Boot] [PATCH 11/11] ARM: tegra: Tegra124 " Stephen Warren

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=532BBB12.9090501@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=u-boot@lists.denx.de \
    /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.