From: Sam Protsenko <semen.protsenko@linaro.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Cc: Tomasz Figa <tomasz.figa@gmail.com>,
Sylwester Nawrocki <s.nawrocki@samsung.com>,
Linus Walleij <linus.walleij@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org, linux-gpio@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Marek Szyprowski <m.szyprowski@samsung.com>,
Sylwester Nawrocki <snawrocki@kernel.org>,
Chanho Park <chanho61.park@samsung.com>
Subject: Re: [PATCH 02/24] pinctrl: samsung: accept GPIO bank nodes with a suffix
Date: Mon, 3 Jan 2022 20:43:02 +0200 [thread overview]
Message-ID: <CAPLW+4kVjswvcx7PjkBq_cPrmoi1_yJw9qGOO2tcRCDm27zKmA@mail.gmail.com> (raw)
In-Reply-To: <20211231161930.256733-3-krzysztof.kozlowski@canonical.com>
On Fri, 31 Dec 2021 at 18:20, Krzysztof Kozlowski
<krzysztof.kozlowski@canonical.com> wrote:
>
> Existing dt-bindings expected that each GPIO/pin bank within pin
> controller has its own node with name matching the bank (e.g. gpa0,
> gpx2) and "gpio-controller" property. The node name is then used for
> matching between driver data and DTS.
>
> Newly introduced dtschema expects to have nodes ending with "-gpio-bank"
> suffix, so rewrite bank-devicetree matching to look for old and new
> style of naming.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> ---
> drivers/pinctrl/samsung/pinctrl-samsung.c | 57 ++++++++++++++++++-----
> 1 file changed, 45 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
> index f2864a7869b3..561853df8ef7 100644
> --- a/drivers/pinctrl/samsung/pinctrl-samsung.c
> +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
> @@ -1011,13 +1011,56 @@ static void samsung_banks_of_node_put(struct samsung_pinctrl_drv_data *d)
> of_node_put(bank->of_node);
> }
>
> +/*
> + * Iterate over all driver pin banks to find one matching the name of node,
> + * skipping optional "-gpio" node suffix. When found, assign node to the bank.
> + */
> +static void samsung_banks_of_node_get(struct device *dev,
> + struct samsung_pinctrl_drv_data *d,
> + struct device_node *node)
> +{
> + const char *suffix = "-gpio-bank";
> + struct samsung_pin_bank *bank;
> + struct device_node *child;
> + /* Pin bank names are up to 4 characters */
> + char node_name[20];
> + unsigned int i;
> + size_t len;
> +
> + bank = d->pin_banks;
> + for (i = 0; i < d->nr_banks; ++i, ++bank) {
> + strscpy(node_name, bank->name, sizeof(node_name));
> + len = strlcat(node_name, suffix, sizeof(node_name));
> + if (len == sizeof(sizeof(node_name))) {
Double sizeof is probably wrong?
> + dev_err(dev, "Too long pin bank name '%s', ignoring\n",
> + bank->name);
> + continue;
> + }
> +
> + for_each_child_of_node(node, child) {
> + if (!of_find_property(child, "gpio-controller", NULL))
> + continue;
> + if (of_node_name_eq(child, node_name))
> + break;
> + else if (of_node_name_eq(child, bank->name))
> + break;
> + }
> +
> + if (child)
> + bank->of_node = child;
> + else
> + dev_warn(dev, "Missing node for bank %s - invalid DTB\n",
> + bank->name);
> + /* child reference dropped in samsung_drop_banks_of_node() */
> + }
> +}
> +
> /* retrieve the soc specific data */
> static const struct samsung_pin_ctrl *
> samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d,
> struct platform_device *pdev)
> {
> struct device_node *node = pdev->dev.of_node;
> - struct device_node *np;
> const struct samsung_pin_bank_data *bdata;
> const struct samsung_pin_ctrl *ctrl;
> struct samsung_pin_bank *bank;
> @@ -1081,17 +1124,7 @@ samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d,
> */
> d->virt_base = virt_base[0];
>
> - for_each_child_of_node(node, np) {
> - if (!of_find_property(np, "gpio-controller", NULL))
> - continue;
> - bank = d->pin_banks;
> - for (i = 0; i < d->nr_banks; ++i, ++bank) {
> - if (of_node_name_eq(np, bank->name)) {
> - bank->of_node = np;
> - break;
> - }
> - }
> - }
> + samsung_banks_of_node_get(&pdev->dev, d, node);
>
> d->pin_base = pin_base;
> pin_base += d->nr_pins;
> --
> 2.32.0
>
next prev parent reply other threads:[~2022-01-03 18:43 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-31 16:19 [PATCH 00/24] pinctrl: dt-bindings: samsung: convert to dtschema Krzysztof Kozlowski
2021-12-31 16:19 ` [PATCH 01/24] pinctrl: samsung: drop pin banks references on error paths Krzysztof Kozlowski
2022-01-03 14:49 ` Sam Protsenko
2022-01-05 20:24 ` Krzysztof Kozlowski
2021-12-31 16:19 ` [PATCH 02/24] pinctrl: samsung: accept GPIO bank nodes with a suffix Krzysztof Kozlowski
2022-01-03 18:43 ` Sam Protsenko [this message]
2022-01-05 20:31 ` Krzysztof Kozlowski
2021-12-31 16:19 ` [PATCH 03/24] ARM: dts: exynos: drop unused pinctrl defines in Exynos3250 Krzysztof Kozlowski
2022-01-06 18:20 ` Alim Akhtar
2021-12-31 16:19 ` [PATCH 04/24] ARM: dts: exynos: simplify PMIC DVS pin configuration in Odroid XU Krzysztof Kozlowski
2021-12-31 16:19 ` [PATCH 05/24] ARM: dts: exynos: override pins by label in Peach Pit Krzysztof Kozlowski
2022-01-06 18:42 ` Alim Akhtar
2021-12-31 16:19 ` [PATCH 06/24] ARM: dts: exynos: simplify PMIC DVS pin configuration " Krzysztof Kozlowski
2021-12-31 16:21 ` [PATCH 07/24] ARM: dts: exynos: override pins by label in Peach Pi Krzysztof Kozlowski
2022-01-06 18:44 ` Alim Akhtar
2021-12-31 16:21 ` [PATCH 08/24] ARM: dts: exynos: simplify PMIC DVS pin configuration " Krzysztof Kozlowski
2022-01-06 18:47 ` Alim Akhtar
2022-01-07 7:34 ` Krzysztof Kozlowski
2021-12-31 16:21 ` [PATCH 09/24] ARM: dts: s3c64xx: drop unneeded pinctrl wake-up interrupt mapping Krzysztof Kozlowski
2021-12-31 16:21 ` [PATCH 10/24] ARM: dts: exynos: align pinctrl with dtschema in Exynos3250 Krzysztof Kozlowski
2021-12-31 16:21 ` [PATCH 11/24] ARM: dts: exynos: align pinctrl with dtschema in Exynos4210 Krzysztof Kozlowski
2021-12-31 16:21 ` [PATCH 12/24] ARM: dts: exynos: align pinctrl with dtschema in Exynos4412 Krzysztof Kozlowski
2021-12-31 16:21 ` [PATCH 13/24] ARM: dts: exynos: align pinctrl with dtschema in Exynos5250 Krzysztof Kozlowski
2021-12-31 16:21 ` [PATCH 14/24] ARM: dts: exynos: align pinctrl with dtschema in Exynos5260 Krzysztof Kozlowski
2021-12-31 16:21 ` [PATCH 15/24] ARM: dts: exynos: align pinctrl with dtschema in Exynos5410 Krzysztof Kozlowski
2021-12-31 16:21 ` [PATCH 16/24] ARM: dts: exynos: align pinctrl with dtschema in Exynos542x/5800 Krzysztof Kozlowski
2021-12-31 16:22 ` [PATCH 17/24] arm64: dts: exynos: align pinctrl with dtschema in Exynos5433 Krzysztof Kozlowski
2021-12-31 16:23 ` [PATCH 18/24] arm64: dts: exynos: align pinctrl with dtschema in Exynos7 Krzysztof Kozlowski
2021-12-31 16:23 ` [PATCH 19/24] arm64: dts: exynos: align pinctrl with dtschema in Exynos850 Krzysztof Kozlowski
2022-01-03 14:45 ` Sam Protsenko
2021-12-31 16:23 ` [PATCH 20/24] arm64: dts: exynos: align pinctrl with dtschema in ExynosAutov9 Krzysztof Kozlowski
2021-12-31 16:23 ` [PATCH 21/24] ARM: dts: s3c24xx: align pinctrl with dtschema Krzysztof Kozlowski
2021-12-31 16:23 ` [PATCH 22/24] ARM: dts: s3c64xx: " Krzysztof Kozlowski
2021-12-31 16:23 ` [PATCH 23/24] ARM: dts: s5pv210: " Krzysztof Kozlowski
2021-12-31 16:23 ` [PATCH 24/24] dt-bindings: pinctrl: samsung: convert to dtschema Krzysztof Kozlowski
2022-01-03 21:19 ` Sam Protsenko
2022-01-10 20:43 ` Rob Herring
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=CAPLW+4kVjswvcx7PjkBq_cPrmoi1_yJw9qGOO2tcRCDm27zKmA@mail.gmail.com \
--to=semen.protsenko@linaro.org \
--cc=chanho61.park@samsung.com \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski@canonical.com \
--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-samsung-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=robh+dt@kernel.org \
--cc=s.nawrocki@samsung.com \
--cc=snawrocki@kernel.org \
--cc=tomasz.figa@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).