All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antoine Tenart <antoine.tenart@free-electrons.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Antoine Tenart <antoine.tenart@free-electrons.com>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/4] pinctrl: add helpers for group based drivers
Date: Thu, 30 Oct 2014 20:48:39 +0100	[thread overview]
Message-ID: <20141030194839.GB6764@kwain> (raw)
In-Reply-To: <CACRpkdaPPcUkWrQ8G19igEdDGCXGUGd=utFzny54oRpZ=UNuYA@mail.gmail.com>

Hi Linus,

On Tue, Oct 28, 2014 at 04:38:27PM +0100, Linus Walleij wrote:
> On Mon, Oct 20, 2014 at 10:04 AM, Antoine Tenart
> <antoine.tenart@free-electrons.com> wrote:
> 
> > +#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?

We could have an additional pin_name parameter and return an error if both
function_name *and* pin_name are NULL. That could also allow to have nodes with
both a function and a pin, if that make any sense.

Maybe the of_pinctrl_utils_node_is_mux/config() solution is more
appropriate to avoid having a confusing function. Plus we would have a
dedicated of_pinctrl_utils_read_pins() function.

I think I prefer the second solution because it could avoid some
confusion and the logic would stay in the pinctrl core functions. 

I'll cook up a new version if the of_pinctrl_utils_node_is_mux/config()
is okay with you.

Antoine

-- 
Antoine Ténart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

  reply	other threads:[~2014-10-30 19:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-20  8:04 [PATCH 0/4] pinctrl: add helpers for group based drivers Antoine Tenart
2014-10-20  8:04 ` [PATCH 1/4] Documentation: bindings: pinctrl: document the generic groups property Antoine Tenart
2014-10-28 15:29   ` Linus Walleij
2014-10-28 15:33     ` Linus Walleij
2014-10-20  8:04 ` [PATCH 2/4] pinctrl: add helpers for group based drivers Antoine Tenart
2014-10-28 15:38   ` Linus Walleij
2014-10-30 19:48     ` Antoine Tenart [this message]
2014-11-03 13:25       ` Linus Walleij
2014-10-20  8:04 ` [PATCH 3/4] pinctrl: add a generic way to map node to map " Antoine Tenart
2014-10-28 15:40   ` Linus Walleij
2014-10-20  8:04 ` [PATCH 4/4] pinctrl: berlin: use the generic node to map function Antoine Tenart
2014-10-20  8:04   ` Antoine Tenart
2014-10-28 15:41   ` Linus Walleij
2014-10-28 15:41     ` Linus Walleij
2014-10-25 10:44 ` [PATCH 0/4] pinctrl: add helpers for group based drivers Sebastian Hesselbarth

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=20141030194839.GB6764@kwain \
    --to=antoine.tenart@free-electrons.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    /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.