From: sashiko-bot@kernel.org
To: "Roman Vivchar" <rva333@protonmail.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v5 3/4] mfd: mt6397-core: add mt6323 AUXADC support
Date: Thu, 09 Jul 2026 11:04:21 +0000 [thread overview]
Message-ID: <20260709110422.527111F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709-mt6323-adc-v5-3-d11b8332a735@protonmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] The AUXADC clock is explicitly powered down instead of being enabled during initialization, resulting in a dead IP block.
- [Medium] The child driver directly accesses the grandparent's regmap instead of retrieving it via standard MFD parent data accessors, violating API contracts and risking a NULL pointer dereference.
- [Medium] The AUXADC request and release functions fail to clean up partially acquired hardware state if an intermediate register write fails.
- [Low] The commit message description is not capitalized, violating MFD subsystem guidelines.
--
--- Patch [3]: [PATCH v5 3/4] mfd: mt6397-core: add mt6323 AUXADC support ---
commit 7593019cba73d4a6a4b6233e95fc0594442ed409
Author: Roman Vivchar <rva333@protonmail.com>
mfd: mt6397-core: add mt6323 AUXADC support
The mt6323 PMIC includes an AUXADC. Register the AUXADC in the mt6323
devices array to allow the corresponding driver to probe using compatible
string.
> mfd: mt6397-core: add mt6323 AUXADC support
[Severity: Low]
This isn't a bug, but the commit message description is not capitalized,
violating MFD subsystem guidelines.
> diff --git a/drivers/iio/adc/mt6323-auxadc.c b/drivers/iio/adc/mt6323-auxadc.c
> new file mode 100644
> index 0000000000000..c450fb6f09cb5
> --- /dev/null
> +++ b/drivers/iio/adc/mt6323-auxadc.c
[ ... ]
> +static int mt6323_auxadc_request(struct mt6323_auxadc *auxadc,
> + unsigned long channel)
> +{
> + struct regmap *map = auxadc->regmap;
> + int ret;
> +
> + ret = regmap_set_bits(map, MT6323_AUXADC_CON11, AUXADC_CON11_VBUF_EN);
> + if (ret)
> + return ret;
> +
> + return regmap_set_bits(map, MT6323_AUXADC_CON22, BIT(channel));
[Severity: Medium]
Could this leave the voltage buffer enabled indefinitely if setting the
channel bit fails? There appears to be no rollback for AUXADC_CON11_VBUF_EN
when the second register write returns an error.
> +}
> +
> +static int mt6323_auxadc_release(struct mt6323_auxadc *auxadc,
> + unsigned long channel)
> +{
> + struct regmap *map = auxadc->regmap;
> + int ret;
> +
> + ret = regmap_clear_bits(map, MT6323_AUXADC_CON22, BIT(channel));
> + if (ret)
> + return ret;
> +
> + return regmap_clear_bits(map, MT6323_AUXADC_CON11, AUXADC_CON11_VBUF_EN);
[Severity: Medium]
If clearing the channel bit fails here, will this prevent AUXADC_CON11_VBUF_EN
from being cleared and leave the hardware in an inconsistent state?
[ ... ]
> +static int mt6323_auxadc_init(struct mt6323_auxadc *auxadc)
> +{
> + struct regmap *map = auxadc->regmap;
> + int ret;
> +
> + ret = regmap_set_bits(map, MT6323_STRUP_CON10,
> + AUXADC_STRUP_CON10_RSTB_SW |
> + AUXADC_STRUP_CON10_RSTB_SEL);
> + if (ret)
> + return ret;
> +
> + ret = regmap_set_bits(map, MT6323_TOP_CKPDN2, AUXADC_TOP_CKPDN2_CTL_CK);
[Severity: High]
Is this actually powering down the AUXADC clock instead of enabling it?
In MediaTek PMICs, CKPDN registers control clock power down. Setting this
bit to 1 explicitly powers down the clock, which would render the AUXADC
IP block non-functional. Should this be using regmap_clear_bits() instead?
> + if (ret)
> + return ret;
[ ... ]
> +static int mt6323_auxadc_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct mt6323_auxadc *auxadc;
> + struct regmap *regmap;
> + struct iio_dev *iio;
> + int ret;
> +
> + regmap = dev_get_regmap(dev->parent->parent, NULL);
[Severity: Medium]
Is it safe to directly access dev->parent->parent here?
If the device tree topology changes or the parent device does not have a
parent, dev->parent->parent will evaluate to NULL. Calling dev_get_regmap()
with a NULL device would then trigger a NULL pointer dereference.
The MFD subsystem guidelines state that child drivers must retrieve parent data
using standard APIs like dev_get_drvdata(pdev->dev.parent) instead of bypassing
the parent to access the grandparent directly.
> + if (!regmap)
> + return dev_err_probe(dev, -ENODEV, "failed to get regmap\n");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-mt6323-adc-v5-0-d11b8332a735@protonmail.com?part=3
next prev parent reply other threads:[~2026-07-09 11:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 10:52 [PATCH v5 0/4] AUXADC driver for the MediaTek mt6323 PMIC Roman Vivchar
2026-07-09 10:52 ` Roman Vivchar via B4 Relay
2026-07-09 10:52 ` [PATCH v5 1/4] dt-bindings: iio: adc: mediatek,mt6359-auxadc: add mt6323 PMIC AUXADC Roman Vivchar
2026-07-09 10:52 ` Roman Vivchar via B4 Relay
2026-07-09 10:52 ` [PATCH v5 2/4] iio: adc: mt6323-auxadc: add mt6323 PMIC AUXADC driver Roman Vivchar
2026-07-09 10:52 ` Roman Vivchar via B4 Relay
2026-07-09 11:06 ` sashiko-bot
2026-07-10 7:39 ` Uwe Kleine-König
2026-07-10 10:06 ` Roman Vivchar
2026-07-12 1:41 ` Jonathan Cameron
2026-07-09 10:52 ` [PATCH v5 3/4] mfd: mt6397-core: add mt6323 AUXADC support Roman Vivchar
2026-07-09 10:52 ` Roman Vivchar via B4 Relay
2026-07-09 11:04 ` sashiko-bot [this message]
2026-07-09 10:52 ` [PATCH v5 4/4] ARM: dts: mediatek: mt6323: add " Roman Vivchar
2026-07-09 10:52 ` Roman Vivchar via B4 Relay
2026-07-09 11:33 ` [PATCH v5 0/4] AUXADC driver for the MediaTek mt6323 PMIC AngeloGioacchino Del Regno
2026-07-09 23:54 ` Jonathan Cameron
2026-07-13 8:11 ` AngeloGioacchino Del Regno
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=20260709110422.527111F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=rva333@protonmail.com \
--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.