lkml.org 
[lkml]   [2018]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH v2 1/2] pinctrl: generic: add API to solve generic sub-node property name
    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

    \
     
     \ /
      Last update: 2018-05-02 14:57    [W:3.656 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site