linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Drew Fustini <drew@beagleboard.org>
To: Trent Piepho <tpiepho@gmail.com>
Cc: devicetree@vger.kernel.org,
	Jason Kridner <jkridner@beagleboard.org>,
	Tony Lindgren <tony@atomide.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	Rob Herring <robh+dt@kernel.org>,
	Haojian Zhuang <haojian.zhuang@linaro.org>,
	bcousson@baylibre.com, linux-omap@vger.kernel.org,
	Robert Nelson <robertcnelson@gmail.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 1/2] pinctrl: single: parse #pinctrl-cells = 2
Date: Sun, 13 Sep 2020 21:42:33 +0200	[thread overview]
Message-ID: <20200913194233.GA1955808@x1> (raw)
In-Reply-To: <3139716.CMS8C0sQ7x@zen.local>

On Tue, Sep 08, 2020 at 04:52:58PM -0700, Trent Piepho wrote:
> On Tuesday, June 30, 2020 6:33:19 PM PDT Drew Fustini wrote:
> > If "pinctrl-single,pins" has 3 arguments (offset, conf, mux), then
> > pcs_parse_one_pinctrl_entry() does an OR operation on conf and mux to
> > get the value to store in the register.
> 
> 
> > -		vals[found].val = pinctrl_spec.args[1];
> > +
> > +		switch (pinctrl_spec.args_count) {
> > +		case 2:
> > +			vals[found].val = pinctrl_spec.args[1];
> > +			break;
> > +		case 3:
> > +			vals[found].val = (pinctrl_spec.args[1] | 
> pinctrl_spec.args[2]);
> > +			break;
> > +		}
> > 
> >  		dev_dbg(pcs->dev, "%pOFn index: 0x%x value: 0x%x\n",
> >  			pinctrl_spec.np, offset, 
> pinctrl_spec.args[1]);
> 
> If #pinctrl-cells value is greater than 2, nothing will set vals[found].val to 
> anything other than zero (from when it's calloc'ed) and the pinctrl will 
> silently be programmed to zero.

If #pinctrl-cells is 3, then it will be:

	vals[found].val = (pinctrl_spec.args[1] | pinctrl_spec.args[2]);

Do you mean if #pinctrl-cells is great than 3 then it will just have a
default value of zero?

That does appear to be the case and is probably not the behavior we
want.  Thank you for pointing this out.  Earlier, there is a check to
make sure there are at least 2 arguments:

	if (pinctrl_spec.args_count < 2) {
		dev_err(pcs->dev, "invalid args_count for spec: %i\n",
			pinctrl_spec.args_count); 
		break;
	}

I'll submit a patch where the upper bound is also checked:

	if (pinctrl_spec.args_count < 2 || pinctrl_spec.args_count > 3) {
		dev_err(pcs->dev, "invalid args_count for spec: %i\n",
			pinctrl_spec.args_count); 
		break;
	}

> The debug printout was not change to print vals[found].val, so it will 
> continue to print the value of the 2nd cell.

Thank you for pointing this out.  Yes, this is an oversight and I will
submit a patch.

> The result is that a #pinctrl-cells of 3 will produce no warning or error, 
> program the pinctrl to zero, whilst at the same time emit debug log messages 
> that it is programming the expected values.
>
> The device tree documentation still states that #pinctrl-cells must be 1 when 
> using pinctrl-single,pins.  This new special case of ORing two values is not 
> documented.

This is a good point, too.  I will make a patch to update the
documentation.


-Drew

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-09-13 19:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-01  1:33 [PATCH v4 0/2] pinctrl: single: support #pinctrl-cells = 2 Drew Fustini
2020-07-01  1:33 ` [PATCH v4 1/2] pinctrl: single: parse " Drew Fustini
2020-09-08 23:52   ` Trent Piepho
2020-09-13 19:42     ` Drew Fustini [this message]
2020-09-13 23:27       ` Drew Fustini
2020-07-01  1:33 ` [PATCH v4 2/2] ARM: dts: am33xx-l4: change #pinctrl-cells from 1 to 2 Drew Fustini
2020-09-09  0:34   ` Trent Piepho
2021-01-15 18:02   ` Emmanuel Vadot
2021-01-15 21:40     ` Drew Fustini
2021-01-18  7:41       ` Tony Lindgren
2020-07-02 17:36 ` [PATCH v4 0/2] pinctrl: single: support #pinctrl-cells = 2 Tony Lindgren
2020-07-05  9:01 ` Haojian Zhuang
2020-07-07 10:59 ` Linus Walleij
2020-07-07 11:02   ` Drew Fustini
2020-07-11 21:12     ` Linus Walleij

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=20200913194233.GA1955808@x1 \
    --to=drew@beagleboard.org \
    --cc=bcousson@baylibre.com \
    --cc=devicetree@vger.kernel.org \
    --cc=haojian.zhuang@linaro.org \
    --cc=jkridner@beagleboard.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=robertcnelson@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=tony@atomide.com \
    --cc=tpiepho@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 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).