LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Matheus Castello <matheus@castello.eng.br>
Cc: kbuild-all@01.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] pinctrl: generic: add API to solve generic sub-node property name
Date: Wed, 2 May 2018 14:56:44 +0200	[thread overview]
Message-ID: <CACRpkdZRVEsDkYRHeR5X8pvKsuvAUktLdzmHvjF+cbMiRuyYDQ@mail.gmail.com> (raw)
In-Reply-To: <1525201801-25682-2-git-send-email-matheus@castello.eng.br>

On Tue, May 1, 2018 at 9:10 PM, Matheus Castello
<matheus@castello.eng.br> wrote:

> Set dt_params with the definitions of the generic sub-node properties
> global in pinconf-generic.h and add a function to pinconf-generic API
> to decode a packed param returning the string name from sub-node
> property.
>
> This can be useful in debug from pinctrl-vendor driver or even for
> debug in pinconf driver.
>
> Signed-off-by: Matheus Castello <matheus@castello.eng.br>

(...)

> +const char *pinconf_generic_get_param_property_name(struct pinctrl_dev *pctldev,
> +       unsigned int num_configs, unsigned long *param)
> +{
> +       struct pinctrl_desc *desc = pctldev->desc;
> +       unsigned int num_params = ARRAY_SIZE(pinconf_dt_params),
> +               num_custom_params = desc->num_custom_params,
> +               i, j;
> +
> +       for (i = 0; i < num_configs; i++) {
> +               enum pin_config_param pin_param =
> +               pinconf_to_config_param(param[i]);
> +
> +               /* first search on default properties */
> +               for (j = 0; j < num_params; j++) {
> +                       if (pin_param == pinconf_dt_params[j].param)
> +                               return pinconf_dt_params[j].property;
> +               }

If this is only for OF, we should rename the function to something including
*of* as well.

I would like it if you manage to break the dependency to OF though.

> +++ b/include/linux/pinctrl/pinconf-generic.h
>
> +static const struct pinconf_generic_params pinconf_dt_params[] = {
> +       { "bias-bus-hold", PIN_CONFIG_BIAS_BUS_HOLD, 0 },
> +       { "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 },
> +       { "bias-high-impedance", PIN_CONFIG_BIAS_HIGH_IMPEDANCE, 0 },
(...)

Is it really advisible to put big static constant arrays into header
files like this?

This will end up with a copy in each file where it is included and it is not a
small thing that gets replicated all over the place either.

What about just add it as extern and exporting the symbol if you
need it elsewhere?

Yours,
Linus Walleij

  reply	other threads:[~2018-05-02 12:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-01  7:40 [PATCH v1 0/2] pinctrl: generic: improve apply_setting error verbosity Matheus Castello
2018-05-01  7:40 ` [PATCH v1 1/2] pinctrl: generic: add API to solve generic sub-node property name Matheus Castello
2018-05-01  7:40 ` [PATCH v1 2/2] pinctrl: generic: improve apply_setting error verbosity Matheus Castello
2018-05-01  8:34   ` kbuild test robot
2018-05-01 10:05   ` kbuild test robot
2018-05-01 19:09     ` [PATCH v2 0/2] " Matheus Castello
2018-05-01 19:10       ` [PATCH v2 1/2] pinctrl: generic: add API to solve generic sub-node property name Matheus Castello
2018-05-02 12:56         ` Linus Walleij [this message]
2018-05-01 19:10       ` [PATCH v2 2/2] pinctrl: generic: improve apply_setting error verbosity Matheus Castello
2018-05-02 12:51         ` Linus Walleij
2018-05-08  5:27           ` Matheus Castello

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=CACRpkdZRVEsDkYRHeR5X8pvKsuvAUktLdzmHvjF+cbMiRuyYDQ@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=kbuild-all@01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matheus@castello.eng.br \
    --subject='Re: [PATCH v2 1/2] pinctrl: generic: add API to solve generic sub-node property name' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).