lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 28 Oct 2014 16:38:27 +0100
From:	Linus Walleij <linus.walleij@...aro.org>
To:	Antoine Tenart <antoine.tenart@...e-electrons.com>
Cc:	Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/4] pinctrl: add helpers for group based drivers

On Mon, Oct 20, 2014 at 10:04 AM, Antoine Tenart
<antoine.tenart@...e-electrons.com> wrote:

> Since the group based drivers have their dt properties documented in the
> generic pinctrl documentation, add generic helpers to avoid duplicating
> code and to be sure new drivers won't use specific bindings for a known
> purpose.
>
> This patch add two functions to help group based drivers map their
> nodes:
> - of_pinctrl_utils_read_function(): reads the function name of a
>   specified node, and gets the number of groups it should be
>   applied to.
> - of_pinctrl_for_each_function_group(): navigates through the groups of
>   a specified node, reading at each iteration the name of the current
>   group.
>
> Signed-off-by: Antoine Tenart <antoine.tenart@...e-electrons.com>

GOOD IDEA!

Let's work from this and change a few drivers.

Some comments:

> +#ifdef CONFIG_OF
> +int of_pinctrl_utils_read_function(struct pinctrl_dev *pctldev,
> +               struct device_node *node, const char **function_name,
> +               int *ngroups)
> +{
> +       int ret;
> +
> +       ret = of_property_read_string(node, "function", function_name);
> +       if (ret) {
> +               dev_err(pctldev->dev, "missing function property in node %s\n",
> +                       node->name);
> +               return -EINVAL;
> +       }
> +
> +       *ngroups = of_property_count_strings(node, "groups");
> +       if (ngroups <= 0) {
> +               dev_err(pctldev->dev, "missing groups property in node %s\n",
> +                       node->name);
> +               return -EINVAL;
> +       }
> +
> +       return 0;
> +}
> +EXPORT_SYMBOL_GPL(of_pinctrl_utils_read_function);
> +#endif

Isn't it nasty to print dev_err() here if you maybe just want
to check if this node has a "function" element and proceed to
see if it's a pin config group in case it hasn't?

Or should we add of_pinctrl_utils_node_is_mux() and
of_pinctrl_utils_node_is_config() to check this?

> +#define of_pinctrl_for_each_function_group(node, prop, group_name)     \
> +               of_property_for_each_string(node, "groups", prop, group_name)

I *really* like this macro.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ