* [PATCH] pinctrl: amlogic: a4: Allow functions without groups
@ 2026-11-06 7:08 Xianwei Zhao via B4 Relay
2026-11-06 7:18 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Xianwei Zhao via B4 Relay @ 2026-11-06 7:08 UTC (permalink / raw)
To: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl
Cc: linux-amlogic, linux-gpio, linux-arm-kernel, linux-kernel, Xianwei Zhao
From: Xianwei Zhao <xianwei.zhao@amlogic.com>
Allow function nodes without child groups during device tree
parsing instead of returning an error.
Only count and parse nodes with the "func-" prefix as pinctrl
functions, ignoring other non-GPIO child nodes.
Also handle zero-sized allocations when no groups are defined
by checking for ZERO_SIZE_PTR in addition to NULL.
This allows the driver to support function nodes without
groups and avoid treating unrelated device tree nodes as
pinctrl functions.
Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
Add debugging information for error dts and Error pinctrl config not affect normal pin work.
---
drivers/pinctrl/meson/pinctrl-amlogic-a4.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
index 39eb8cc7fc0d..d0e3cec3ead0 100644
--- a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
+++ b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
@@ -821,8 +821,10 @@ static int aml_pctl_parse_functions(struct device_node *np,
func = &info->functions[index];
func->name = np->name;
func->ngroups = of_get_child_count(np);
- if (func->ngroups == 0)
- return dev_err_probe(dev, -EINVAL, "No groups defined\n");
+ if (func->ngroups == 0) {
+ dev_dbg(dev, "func %s No groups defined\n", func->name);
+ return 0;
+ }
func->groups = devm_kcalloc(dev, func->ngroups, sizeof(*func->groups), GFP_KERNEL);
if (!func->groups)
@@ -899,8 +901,12 @@ static void aml_pctl_dt_child_count(struct aml_pinctrl *info,
if (of_property_read_bool(child, "gpio-controller")) {
info->nbanks++;
} else {
- info->nfunctions++;
- info->ngroups += of_get_child_count(child);
+ if (!strncmp(child->name, "func-", 5)) {
+ info->nfunctions++;
+ info->ngroups += of_get_child_count(child);
+ } else {
+ dev_dbg(info->dev, "func node defined err %s\n", child->name);
+ }
}
}
}
@@ -1128,7 +1134,8 @@ static int aml_pctl_probe_dt(struct platform_device *pdev,
info->banks = devm_kcalloc(dev, info->nbanks, sizeof(*info->banks), GFP_KERNEL);
- if (!info->functions || !info->groups || !info->banks)
+ if (IS_ERR_OR_NULL(info->functions) || IS_ERR_OR_NULL(info->groups) ||
+ IS_ERR_OR_NULL(info->banks))
return -ENOMEM;
info->data = (struct aml_pctl_data *)of_device_get_match_data(dev);
@@ -1166,10 +1173,11 @@ static int aml_pctl_probe_dt(struct platform_device *pdev,
}
bank++;
} else {
- ret = aml_pctl_parse_functions(child, info,
- i++, &grp_index);
- if (ret)
- return ret;
+ if (!strncmp(child->name, "func-", 5)) {
+ ret = aml_pctl_parse_functions(child, info, i++, &grp_index);
+ if (ret)
+ return ret;
+ }
}
}
---
base-commit: 89edcad9f23925f5706b7555b02165d1990444d5
change-id: 20261106-debug-info-bb5611e36717
Best regards,
--
Xianwei Zhao <xianwei.zhao@amlogic.com>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] pinctrl: amlogic: a4: Allow functions without groups
2026-11-06 7:08 [PATCH] pinctrl: amlogic: a4: Allow functions without groups Xianwei Zhao via B4 Relay
@ 2026-11-06 7:18 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-06 7:18 UTC (permalink / raw)
To: Xianwei Zhao; +Cc: linux-amlogic, linux-gpio, neil.armstrong
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] pinctrl: amlogic: a4: bogus IS_ERR_OR_NULL() check in
aml_pctl_probe_dt()
--
commit 52848e3d0d015ec420063e02e0337040b95e6237
Author: Xianwei Zhao <xianwei.zhao@amlogic.com>
pinctrl: amlogic: a4: Allow functions without groups
This commit allows pinctrl function nodes in the device tree to have no
child groups and ignores non-GPIO child nodes without a "func-" prefix.
> diff --git a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
> index 39eb8cc7fc0d1..d0e3cec3ead03 100644
> --- a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
> +++ b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
[ ... ]
> @@ -1128,7 +1134,8 @@ static int aml_pctl_probe_dt(struct platform_device *pdev,
>
> info->banks = devm_kcalloc(dev, info->nbanks, sizeof(*info->banks), GFP_KERNEL);
>
> - if (!info->functions || !info->groups || !info->banks)
> + if (IS_ERR_OR_NULL(info->functions) || IS_ERR_OR_NULL(info->groups) ||
> + IS_ERR_OR_NULL(info->banks))
> return -ENOMEM;
[Severity: Medium]
Does IS_ERR_OR_NULL() match what devm_kcalloc() returns here?
devm_kcalloc() returns NULL on failure or ZERO_SIZE_PTR ((void *)16) for a
zero-sized allocation, never an ERR_PTR(). Although the commit message
states that this checks for ZERO_SIZE_PTR, IS_ERR_OR_NULL(ZERO_SIZE_PTR)
is false, and rejecting ZERO_SIZE_PTR with -ENOMEM would fail probing
whenever info->ngroups or info->nfunctions is zero. The original NULL
checks already caught allocation failures while allowing ZERO_SIZE_PTR.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106-debug-info-v1-1-067c5c554f91@amlogic.com?part=1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-06 7:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 7:08 [PATCH] pinctrl: amlogic: a4: Allow functions without groups Xianwei Zhao via B4 Relay
2026-11-06 7:18 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®