From: Linus Walleij <linus.walleij@linaro.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Andy Shevchenko <andy@kernel.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Dipen Patel <dipenp@nvidia.com>,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [RFC/RFT PATCH] gpiolib: reverse-assign the fwnode to struct gpio_chip
Date: Sat, 7 Oct 2023 00:14:14 +0200 [thread overview]
Message-ID: <CACRpkdZP_nOgj77iek_V28Ny8Pb03Xyy-=ho+WqzMHzXajtfqA@mail.gmail.com> (raw)
In-Reply-To: <20231006115147.18559-1-brgl@bgdev.pl>
On Fri, Oct 6, 2023 at 1:51 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> struct gpio_chip is not only used to carry the information needed to
> set-up a GPIO device but is also used in all GPIOLIB callbacks and is
> passed to the matching functions of lookup helpers.
>
> In that last case, it is currently impossible to match a GPIO device by
> fwnode unless it was explicitly assigned to the chip in the provider
> code. If the fwnode is taken from the parent device, the pointer in
> struct gpio_chip will remain NULL.
>
> If we have a parent device but gc->fwnode was not assigned by the
> provider, let's assign it ourselves so that lookup by fwnode can work in
> all cases.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
because we want the code to work (rough consensus and running code)
> - if (gc->fwnode)
> + if (gc->fwnode) {
> device_set_node(&gdev->dev, gc->fwnode);
> - else if (gc->parent)
> - device_set_node(&gdev->dev, dev_fwnode(gc->parent));
> + } else if (gc->parent) {
> + parent_fwnode = dev_fwnode(gc->parent);
> + device_set_node(&gdev->dev, parent_fwnode);
> + gc->fwnode = parent_fwnode;
The core of the crux is that we have
information duplication with a reference to the fwnode in two
places. One in gdev->dev and one in gc->fwnode.
gc->of_node was the same duplicated before.
A gdev is created for each gpio_chip so in my naive brain we could
get rid of gc->fwnode and only have the one inside gdev->dev?
+/- some helpful getters/setters if need be.
Or what am I thinking wrong here?
Yours,
Linus Walleij
next prev parent reply other threads:[~2023-10-06 22:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-06 11:51 [RFC/RFT PATCH] gpiolib: reverse-assign the fwnode to struct gpio_chip Bartosz Golaszewski
2023-10-06 13:14 ` Andy Shevchenko
2023-10-06 19:07 ` Bartosz Golaszewski
2023-10-07 7:45 ` Andy Shevchenko
2023-10-07 15:53 ` Linus Walleij
2023-10-09 18:28 ` Bartosz Golaszewski
2023-10-06 13:24 ` Andy Shevchenko
2023-10-06 19:07 ` Bartosz Golaszewski
2023-10-06 22:22 ` Linus Walleij
2023-10-07 7:39 ` Andy Shevchenko
2023-10-07 7:36 ` Andy Shevchenko
2023-10-06 22:14 ` Linus Walleij [this message]
2023-10-07 7:03 ` Andy Shevchenko
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='CACRpkdZP_nOgj77iek_V28Ny8Pb03Xyy-=ho+WqzMHzXajtfqA@mail.gmail.com' \
--to=linus.walleij@linaro.org \
--cc=andy@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=dipenp@nvidia.com \
--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).