linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: linus.walleij@linaro.org, brgl@bgdev.pl,
	linux-gpio@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH][RFC][resend after bogus] gpio-syscon: do not report bogus error
Date: Fri, 12 Apr 2024 12:44:34 +0200	[thread overview]
Message-ID: <CACRpkdbTdGajQLSGDkD0cWRG+79tpojYkdyF3t0jD7_WEDtQLw@mail.gmail.com> (raw)
In-Reply-To: <ZhgDCKhcHdwGoJ4Y@Z926fQmE5jqhFMgp6>

Hi Etienne,

thanks for your patch!

On Thu, Apr 11, 2024 at 5:35 PM Etienne Buira <etienne.buira@free.fr> wrote:

> Do not call dev_err when gpio,syscon-dev is not set albeit unneeded.
> gpio-syscon is used with rk3328 chip, but this iomem region is
> documented in
> Documentation/devicetree/bindings/gpio/rockchip,rk3328-grf-gpio.yaml and
> does not look like to require gpio,syscon-dev setting.
>
> Signed-off-by: Etienne Buira <etienne.buira@free.fr>
> X-Prefers: kind explanations over rotten tomatoes

If you look in drivers/gpio/gpio-syscon.c you see this:

        priv->syscon = syscon_regmap_lookup_by_phandle(np, "gpio,syscon-dev");
        if (IS_ERR(priv->syscon) && np->parent)
                priv->syscon = syscon_node_to_regmap(np->parent);

So the driver will attempt to grab the syscon from the parent if
it can't be located from a gpio,syscon-dev node.

But it's not optional, look in arch/arm64/boot/dts/rockchip/rk3328.dtsi:

        grf: syscon@ff100000 {
                compatible = "rockchip,rk3328-grf", "syscon", "simple-mfd";
                reg = <0x0 0xff100000 0x0 0x1000>;
(...)
                grf_gpio: gpio {
                        compatible = "rockchip,rk3328-grf-gpio";
                        gpio-controller;
                        #gpio-cells = <2>;
                };

So indeed the parent is a sycon, and syscon_node_to_regmap(np->parent) will
be used to populate priv->syscon on RK3328.

So what you could do insteaf of the kludge is something like:

bool has_parent_syscon = false;

priv->syscon = syscon_regmap_lookup_by_phandle(np, "gpio,syscon-dev");
if (IS_ERR(priv->syscon) && np->parent) {
        priv->syscon = syscon_regmap_lookup_by_phandle(np, "gpio,syscon-dev");
        has_parent_syscon = true;
}
if (IS_ERR(priv->syscon))
        return PTR_ERR(priv->syscon);

Then when you get to the code you disable for the flag instead of:

if (!(priv->data->flags & GPIO_SYSCON_FEAT_NODEV)) {
(...)

instead do:

if (!has_parent_syscon) {
(...)

What do you think about this?

Yours,
Linus Walleij

  reply	other threads:[~2024-04-12 10:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 15:34 [PATCH][RFC][resend after bogus] gpio-syscon: do not report bogus error Etienne Buira
2024-04-12 10:44 ` Linus Walleij [this message]
2024-04-13 11:31   ` Etienne Buira

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=CACRpkdbTdGajQLSGDkD0cWRG+79tpojYkdyF3t0jD7_WEDtQLw@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).