Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Luca Leonardo Scorcia" <l.scorcia@gmail.com>
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	mfd@lists.linux.dev, linux-gpio@vger.kernel.org, robh@kernel.org,
	conor+dt@kernel.org, dmitry.torokhov@gmail.com, lee@kernel.org
Subject: Re: [PATCH v11 8/9] regulator: Add MediaTek MT6392 regulator
Date: Wed, 21 Oct 2026 11:07:47 +0000	[thread overview]
Message-ID: <sashiko-outbox-180142@kernel.org> (raw)
In-Reply-To: <20261021105109.199886-9-l.scorcia@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] regulator: mt6392: OF node leak in mt6392_regulator_probe()
- [Low] regulator: mt6392: malformed kernel-doc comment on mt6392_regulator_info
--

commit e3d039af08fd4f6095c705dd23ad9451cd2c1fd1
Author: Fabien Parent <parent.f@gmail.com>

regulator: Add MediaTek MT6392 regulator

This commit adds a regulator driver for the MediaTek MT6392 power management
integrated circuit, supporting buck and linear regulators controlled over
regmap.

> diff --git a/drivers/regulator/mt6392-regulator.c b/drivers/regulator/mt6392-regulator.c
> new file mode 100644
> index 0000000000000..3db52268363e0
> --- /dev/null
> +++ b/drivers/regulator/mt6392-regulator.c

[ ... ]

> +/**
> + * MT6392 regulators' information
> + *
> + * @desc: standard fields of regulator description.
> + * @qi_status_reg: Register to query enable signal status of regulators
> + * @qi_status_mask: Mask to query enable signal status of regulators (RO)
> + * @vselctrl_reg: Vsel control mode selector register
> + * @vselctrl_mask: Vsel control mode selector mask (RO)
> + * @vsel_reg_mode_reg: Vsel register when Vsel control mode selector = 0 (Register mode)
> + * @vsel_reg_mode_mask: Vsel register mask in Register mode (RW)
> + * @vsel_normal_mode_reg: Vsel register when Vsel control mode selector = 1 (Normal mode)
> + * @vsel_normal_mode_mask: Vsel register mask in Register mode (RW)
> + * @pwm_modeset_reg: Register to control buck mode (Auto/Force PWM)
> + * @pwm_modeset_mask: Mask to control buck mode (RW)
> + * @lp_modeget_reg: Register to get LDO low-power mode
> + * @lp_modeget_mask: Mask to get LDO low-power mode (RO)
> + * @lp_modeset_reg: Register to control LDO low-power mode
> + * @lp_modeset_mask: Mask to control LDO low-power mode (WO)
> + */
> +struct mt6392_regulator_info {

[Severity: Low]
Because this comment above struct mt6392_regulator_info in
drivers/regulator/mt6392-regulator.c starts with /**, scripts/kernel-doc
parses it during W=1 builds and warns that the opening line does not match
"struct mt6392_regulator_info - ...".

Also, @vsel_normal_mode_mask is described as "Register mode" rather than
"Normal mode".

Should the header line be formatted as a kernel-doc struct header and the
@vsel_normal_mode_mask description updated?

[ ... ]

> +static int mt6392_regulator_probe(struct platform_device *pdev)
> +{
> +	struct mt6397_chip *mt6392 = dev_get_drvdata(pdev->dev.parent);
> +	struct regulator_config config = {};
> +	struct regulator_dev *rdev;
> +	int i;
> +
> +	device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
> +
> +	// Initialize the bucks' vsel_reg and vsel_mask according to current HW state
> +	if (mt6392_set_buck_vsel_reg(pdev))
> +		return -EIO;
> +
> +	config.dev = mt6392->dev;

[Severity: Medium]
Does calling device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent) in
mt6392_regulator_probe() in drivers/regulator/mt6392-regulator.c leak a
reference to pdev->dev.parent->of_node when the platform device is released
(for example, if mt6392_set_buck_vsel_reg() or devm_regulator_register()
fails, or when the parent device is unbound)?

In drivers/mfd/mt6397-core.c, the regulator child is defined with
MFD_CELL_NAME("mt6392-regulator"), so mfd_add_device() allocates the child
platform_device with pdev->dev.of_node and pdev->dev.fwnode both set to
null.

Calling device_set_of_node_from_dev() increments the reference count on
dev2->of_node and assigns it to pdev->dev.of_node without setting
pdev->dev.fwnode:

drivers/base/core.c:device_set_of_node_from_dev() {
	of_node_put(dev->of_node);
	dev->of_node = of_node_get(dev2->of_node);
	dev_set_of_node_reused(dev);
}

When the platform device is destroyed, platform_device_release() only drops
the reference on pa->pdev.dev.fwnode:

drivers/base/platform.c:platform_device_release() {
	...
	if (!is_software_node(dev_fwnode(dev)))
		fwnode_handle_put(pa->pdev.dev.fwnode);
	...
}

Because pdev->dev.fwnode is still null, the reference held by
pdev->dev.of_node is never dropped (unlike
platform_device_set_of_node_from_dev(), which also assigns
pdev->dev.fwnode = of_fwnode_handle(pdev->dev.of_node)).

Since mt6392_regulator_probe() already sets config.dev = mt6392->dev for
regulator_register() to look up the regulators node and supplies on the
parent device, should device_set_of_node_from_dev() be removed here (or
replaced with platform_device_set_of_node_from_dev())?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261021105109.199886-1-l.scorcia@gmail.com?part=8

  reply	other threads:[~2026-10-21 11:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 10:47 [PATCH v11 0/9] Add support for MT6392 PMIC Luca Leonardo Scorcia
2026-10-21 10:47 ` [PATCH v11 1/9] dt-bindings: mfd: mt6397: Add " Luca Leonardo Scorcia
2026-10-21 10:47 ` [PATCH v11 2/9] dt-bindings: input: mtk-pmic-keys: Add MT6392 PMIC keys Luca Leonardo Scorcia
2026-10-21 10:47 ` [PATCH v11 3/9] regulator: dt-bindings: Add MediaTek MT6392 PMIC Luca Leonardo Scorcia
2026-10-21 10:47 ` [PATCH v11 4/9] mfd: mt6397: Use MFD_CELL_* to describe sub-devices Luca Leonardo Scorcia
2026-10-21 10:47 ` [PATCH v11 5/9] mfd: mt6397: Add support for MT6392 PMIC Luca Leonardo Scorcia
2026-10-21 10:47 ` [PATCH v11 6/9] input: keyboard: mtk-pmic-keys: Add MT6392 support Luca Leonardo Scorcia
2026-10-21 10:47 ` [PATCH v11 7/9] pinctrl: mediatek: mt6397: Add MediaTek MT6392 Luca Leonardo Scorcia
2026-10-21 10:47 ` [PATCH v11 8/9] regulator: Add MediaTek MT6392 regulator Luca Leonardo Scorcia
2026-10-21 11:07   ` sashiko-bot [this message]
2026-10-21 10:47 ` [PATCH v11 9/9] arm64: dts: mediatek: Add MediaTek MT6392 PMIC dtsi Luca Leonardo Scorcia
2026-10-21 11:18   ` 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-180142@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=l.scorcia@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-input@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox