From: sashiko-bot@kernel.org
To: "Jisheng Zhang" <jszhang@kernel.org>
Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
linux-gpio@vger.kernel.org, mfd@lists.linux.dev, robh@kernel.org,
conor+dt@kernel.org, lee@kernel.org
Subject: Re: [PATCH v4 04/13] pinctrl: berlin: add optional pinconf support
Date: Fri, 04 Dec 2026 15:22:59 +0000 [thread overview]
Message-ID: <sashiko-outbox-250087@kernel.org> (raw)
In-Reply-To: <20261204140732.31223-5-jszhang@kernel.org>
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [Medium] pinctrl: berlin: wrong errno -EOPNOTSUPP in
berlin_pinconf_group_get()
- [Medium] pinctrl: berlin: map memory leak on error in
berlin_pinctrl_dt_node_to_map()
- [Medium] pinctrl: berlin: raw DS register values used for
PIN_CONFIG_DRIVE_STRENGTH
- [Low] pinctrl: berlin: map over-allocation in
berlin_pinctrl_dt_node_to_map()
- [Low] pinctrl: berlin: berlin_pinctrl_dt_node_to_map() duplicates core
helper
- [Low] pinctrl: berlin: berlin_pinconf_group_get() ignores
PINCFG_SPU_10BIT
--
commit feaf1efaaaf2673c7dd44e0c2079579524261efa
Author: Jisheng Zhang <jszhang@kernel.org>
pinctrl: berlin: add optional pinconf support
This commit adds optional generic pinconf support to the Berlin pinctrl
driver, extending DT node-to-map parsing and adding group get/set callbacks
for 8-bit and 10-bit pad configuration registers.
> diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c
> index 9337de1973af9..82215c36b856a 100644
> --- a/drivers/pinctrl/berlin/berlin.c
> +++ b/drivers/pinctrl/berlin/berlin.c
[ ... ]
> @@ -75,11 +95,19 @@ static int berlin_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrl_dev,
> return -EINVAL;
> }
>
> + ret = pinconf_generic_parse_dt_config(node, pctrl_dev, &configs,
> + &num_configs);
> + if (ret < 0) {
> + dev_err(pctrl->dev, "%s: could not parse node property\n",
> + node->name);
> + return ret;
> + }
> +
> ret = pinctrl_utils_reserve_map(pctrl_dev, map, &reserved_maps,
> - num_maps, ngroups);
> + num_maps, ngroups * (num_configs + 1));
[Severity: Low]
Does this over-allocate the pinctrl_map array when a node has more than one
pinconf property?
pinctrl_utils_add_map_configs() stores all num_configs items in a single
struct pinctrl_map entry per group, so each group needs at most two slots
(ngroups * (num_configs ? 2 : 1)). Because dt_remember_or_free_map() keeps
the allocated array without shrinking it, the excess slots remain allocated
for the lifetime of the mapping.
[ ... ]
> @@ -88,11 +116,22 @@ static int berlin_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrl_dev,
> function_name);
> if (ret) {
> dev_err(pctrl->dev, "can't add map: %d\n", ret);
> - return ret;
> + goto exit;
> + }
> +
> + if (num_configs) {
> + ret = pinctrl_utils_add_map_configs(pctrl_dev, map,
> + &reserved_maps, num_maps, group_name,
> + configs, num_configs,
> + PIN_MAP_TYPE_CONFIGS_GROUP);
> + if (ret < 0)
> + goto exit;
> }
> }
>
> - return 0;
> +exit:
> + kfree(configs);
> + return ret;
> }
[Severity: Medium]
Does the error path leak *map and any previously duplicated per-group
configs?
If pinctrl_utils_add_map_configs() fails with -ENOMEM in kmemdup_array() (or
pinctrl_utils_add_map_mux() fails), jumping to exit frees only the temporary
configs buffer. dt_to_map_one_config() does not call dt_free_map() when
dt_node_to_map() returns a negative error, so pinctrl_utils_free_map() is
needed on the error path.
> static const struct pinctrl_ops berlin_pinctrl_ops = {
[Severity: Low]
Now that PINCTRL_BERLIN selects GENERIC_PINCONF, can
berlin_pinctrl_ops.dt_node_to_map use pinconf_generic_dt_node_to_map_group()
directly instead of maintaining berlin_pinctrl_dt_node_to_map()?
The core helper already handles group-based mux and generic pinconf mapping
with exact map reservation and pinctrl_utils_free_map() cleanup on failure.
[ ... ]
> @@ -177,6 +216,186 @@ static const struct pinmux_ops berlin_pinmux_ops = {
> .set_mux = &berlin_pinmux_set,
> };
>
> +static int berlin_pinconf_group_get(struct pinctrl_dev *pctrl_dev,
> + unsigned int group, unsigned long *configs)
> +{
> + enum pin_config_param param = pinconf_to_config_param(*configs);
> + struct berlin_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
> + const struct berlin_desc_group *group_desc = pctrl->desc->groups + group;
> + bool enabled;
> + u32 val;
> + int ret;
> + u8 conf_bits = group_desc->conf_bits;
> +
> + if (!conf_bits)
> + return -EOPNOTSUPP;
[Severity: Medium]
Should berlin_pinconf_group_get() and berlin_pinconf_group_set() return
-ENOTSUPP instead of -EOPNOTSUPP here and in their default branches?
struct pinconf_ops requires -ENOTSUPP for unsupported configurations, and
pinconf_generic_dump_one() only treats -EINVAL and -ENOTSUPP as legal
errors. Because berlin_confops is registered unconditionally with
is_generic = true, reading debugfs pinconf-groups prints
"ERROR READING CONFIG SETTING" for unsupported parameters and for every
group on older Berlin/AS370 SoCs where conf_bits is 0.
[ ... ]
> + case PIN_CONFIG_BIAS_DISABLE:
> + if (conf_bits == 10)
> + enabled = !(val & PINCFG_PE_10BIT);
> + else
> + enabled = !(val & (PINCFG_PD_8BIT | PINCFG_PU_8BIT));
> + val = 0;
> + break;
> + case PIN_CONFIG_BIAS_PULL_DOWN:
> + if (conf_bits == 10)
> + enabled = (val & (PINCFG_PE_10BIT | PINCFG_PS_10BIT)) == PINCFG_PE_10BIT;
> + else
> + enabled = val & PINCFG_PD_8BIT;
> + val = enabled ? 1 : 0;
> + break;
> + case PIN_CONFIG_BIAS_PULL_UP:
> + if (conf_bits == 10)
> + enabled = (val & (PINCFG_PE_10BIT | PINCFG_PS_10BIT)) ==
> + (PINCFG_PE_10BIT | PINCFG_PS_10BIT);
> + else
> + enabled = val & PINCFG_PU_8BIT;
> + val = enabled ? 1 : 0;
> + break;
[Severity: Low]
Should these 10-bit bias cases also check PINCFG_SPU_10BIT?
berlin_pinconf_group_set() includes and clears PINCFG_SPU_10BIT alongside
PINCFG_PE_10BIT and PINCFG_PS_10BIT on bias writes, but
berlin_pinconf_group_get() ignores it. If reset defaults or firmware leave
PINCFG_SPU_10BIT set before a kernel write, reading pinconf-groups can
misreport the pad as bias-disabled or pull-down instead of pull-up.
> + case PIN_CONFIG_DRIVE_STRENGTH:
> + enabled = true;
> + if (conf_bits == 10)
> + val = FIELD_GET(PINCFG_DS_10BIT, val);
> + else
> + val = FIELD_GET(PINCFG_DS_8BIT, val);
> + break;
[Severity: Medium]
Does PIN_CONFIG_DRIVE_STRENGTH need conversion between milliamps and the raw
3-bit/4-bit DS register field in berlin_pinconf_group_get() and
berlin_pinconf_group_set()?
Both PIN_CONFIG_DRIVE_STRENGTH and pincfg-node.yaml define drive-strength in
mA, and pinconf_generic_dump_one() prints the returned value with an mA
unit. Passing the raw selector through directly reports values like 0 mA in
debugfs, rejects valid mA values above 15 (or 7 for 8-bit pads) with
-EINVAL, and risks locking raw register selectors into the SL2610 DT ABI.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204140732.31223-1-jszhang@kernel.org?part=4
next prev parent reply other threads:[~2026-12-04 15:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 14:07 [PATCH v4 00/13] arm64: add Synaptics SL2610 SoCs and RDK boards Jisheng Zhang
2026-12-04 14:07 ` [PATCH v4 01/13] arm64: kconfig: let ARCH_BERLIN cover Synaptics arm64 SoCs Jisheng Zhang
2026-12-04 14:07 ` [PATCH v4 02/13] pinctrl: berlin: use u16 instead of u8 for the offset Jisheng Zhang
2026-12-04 14:07 ` [PATCH v4 03/13] pinctrl: berlin: enable module build support Jisheng Zhang
2026-12-04 15:03 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 04/13] pinctrl: berlin: add optional pinconf support Jisheng Zhang
2026-12-04 15:22 ` sashiko-bot [this message]
2026-12-04 14:07 ` [PATCH v4 05/13] dt-bindings: soc: synaptics: add SL2610 system controllers Jisheng Zhang
2026-12-04 15:41 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 06/13] mfd: synaptics: add SL2610 system controller support Jisheng Zhang
2026-12-04 15:58 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 07/13] reset: add Synaptics SL2610 reset " Jisheng Zhang
2026-12-04 16:24 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 08/13] pinctrl: berlin: add Synaptics SL2610 pin " Jisheng Zhang
2026-12-04 16:51 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 09/13] clk: berlin: add Synaptics clock controller helpers Jisheng Zhang
2026-12-04 17:13 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 10/13] clk: berlin: add Synaptics SL2610 clocks and PLLs Jisheng Zhang
2026-12-04 17:39 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 11/13] dt-bindings: arm: berlin: add Synaptics SL2610 SoCs and RDK boards Jisheng Zhang
2026-12-04 14:07 ` [PATCH v4 12/13] arm64: dts: synaptics: add SL2610 family SoCs Jisheng Zhang
2026-12-04 18:05 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 13/13] arm64: dts: synaptics: add SL2610 family RDK boards Jisheng Zhang
2026-12-04 18:19 ` sashiko-bot
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=sashiko-outbox-250087@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jszhang@kernel.org \
--cc=lee@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.