From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
To: linux-mediatek@lists.infradead.org
Cc: lee@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, matthias.bgg@gmail.com,
angelogioacchino.delregno@collabora.com, lgirdwood@gmail.com,
broonie@kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, kernel@collabora.com,
wenst@chromium.org, igor.belwon@mentallysanemainliners.org,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Subject: Re: [PATCH v8 4/9] regulator: Add support for MediaTek MT6363 SPMI PMIC Regulators
Date: Thu, 09 Oct 2025 16:41:56 +0200 [thread overview]
Message-ID: <5635636.31r3eYUQgx@workhorse> (raw)
In-Reply-To: <20251003091158.26748-5-angelogioacchino.delregno@collabora.com>
On Friday, 3 October 2025 11:11:53 Central European Summer Time AngeloGioacchino Del Regno wrote:
> Add a driver for the regulators found on the MT6363 PMIC, fully
> controlled by SPMI interface.
> This PMIC regulates voltage with an input range of 2.6-5.0V, and
> features 10 buck converters and 26 LDOs.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
> drivers/regulator/Kconfig | 10 +
> drivers/regulator/Makefile | 1 +
> drivers/regulator/mt6363-regulator.c | 935 +++++++++++++++++++++
> include/linux/regulator/mt6363-regulator.h | 330 ++++++++
> 4 files changed, 1276 insertions(+)
> create mode 100644 drivers/regulator/mt6363-regulator.c
> create mode 100644 include/linux/regulator/mt6363-regulator.h
>
> [...]
> diff --git a/drivers/regulator/mt6363-regulator.c b/drivers/regulator/mt6363-regulator.c
> new file mode 100644
> index 000000000000..812775072eb5
> --- /dev/null
> +++ b/drivers/regulator/mt6363-regulator.c
> [...]
> +
> +static int mt6363_regulator_set_mode(struct regulator_dev *rdev,
> + unsigned int mode)
> +{
> + struct mt6363_regulator_info *info = rdev_get_drvdata(rdev);
> + struct regmap *regmap = rdev->regmap;
> + int cur_mode, ret;
> +
> + if (!info->modeset_reg && mode == REGULATOR_MODE_FAST)
> + return -EOPNOTSUPP;
> +
> + switch (mode) {
> + case REGULATOR_MODE_FAST:
> + ret = mt6363_buck_unlock(regmap, true);
> + if (ret)
> + break;
> +
> + ret = regmap_set_bits(regmap, info->modeset_reg, info->modeset_mask);
> +
> + mt6363_buck_unlock(regmap, false);
> + break;
> + case REGULATOR_MODE_NORMAL:
> + cur_mode = mt6363_regulator_get_mode(rdev);
> + if (cur_mode < 0) {
> + ret = cur_mode;
> + break;
> + }
> +
> + if (cur_mode == REGULATOR_MODE_FAST) {
> + ret = mt6363_buck_unlock(regmap, true);
> + if (ret)
> + break;
> +
> + ret = regmap_clear_bits(regmap, info->modeset_reg, info->modeset_mask);
> +
> + mt6363_buck_unlock(regmap, false);
> + break;
> + } else if (cur_mode == REGULATOR_MODE_IDLE) {
> + ret = regmap_clear_bits(regmap, info->lp_mode_reg, info->lp_mode_mask);
> + if (ret == 0)
> + usleep_range(100, 200);
> + } else {
> + ret = 0;
Just initialise ret to 0 at the start of the function scope when
you declare it. You've already missed an uninitialised use once,
and playing these branch games is just asking for more trouble
in the future. There's no micro-optimisation you're doing here,
clang produces the same assembly for both zero initialised and
the else branch version you're doing here.
> + }
> + break;
> + case REGULATOR_MODE_IDLE:
> + ret = regmap_set_bits(regmap, info->lp_mode_reg, info->lp_mode_mask);
> + break;
> + default:
> + ret = -EINVAL;
> + }
> +
> + if (ret) {
> + dev_err(&rdev->dev, "Failed to set mode %u: %d\n", mode, ret);
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> [...]
Kind regards,
Nicolas Frattaroli
next prev parent reply other threads:[~2025-10-09 14:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-03 9:11 [PATCH v8 0/9] Add support MT6316/6363/MT6373 PMICs regulators and MFD AngeloGioacchino Del Regno
2025-10-03 9:11 ` [PATCH v8 1/9] dt-bindings: regulator: Document MediaTek MT6316 PMIC Regulators AngeloGioacchino Del Regno
2025-10-09 19:18 ` Rob Herring
2025-10-03 9:11 ` [PATCH v8 2/9] regulator: Add support for MediaTek MT6316 SPMI " AngeloGioacchino Del Regno
2025-10-10 21:17 ` kernel test robot
2025-10-03 9:11 ` [PATCH v8 3/9] dt-bindings: regulator: Document MediaTek MT6363 " AngeloGioacchino Del Regno
2025-10-03 9:11 ` [PATCH v8 4/9] regulator: Add support for MediaTek MT6363 SPMI " AngeloGioacchino Del Regno
2025-10-09 14:41 ` Nicolas Frattaroli [this message]
2025-10-14 11:35 ` AngeloGioacchino Del Regno
2025-10-14 12:35 ` Mark Brown
2025-10-03 9:11 ` [PATCH v8 5/9] dt-bindings: regulator: Document MediaTek MT6373 " AngeloGioacchino Del Regno
2025-10-09 19:21 ` Rob Herring (Arm)
2025-10-03 9:11 ` [PATCH v8 6/9] regulator: Add support for MediaTek MT6373 SPMI " AngeloGioacchino Del Regno
2025-10-11 5:32 ` kernel test robot
2025-10-03 9:11 ` [PATCH v8 7/9] dt-bindings: iio: adc: mt6359: Allow reg for SPMI PMICs AuxADC AngeloGioacchino Del Regno
2025-10-03 9:11 ` [PATCH v8 8/9] dt-bindings: mfd: Add binding for MediaTek MT6363 series SPMI PMIC AngeloGioacchino Del Regno
2025-10-09 19:24 ` Rob Herring
2025-10-03 9:11 ` [PATCH v8 9/9] drivers: mfd: Add support for MediaTek SPMI PMICs and MT6363/73 AngeloGioacchino Del Regno
2025-10-09 20:15 ` Nicolas Frattaroli
2025-10-23 13:53 ` Lee Jones
2025-10-24 6:03 ` 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=5635636.31r3eYUQgx@workhorse \
--to=nicolas.frattaroli@collabora.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=igor.belwon@mentallysanemainliners.org \
--cc=kernel@collabora.com \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh@kernel.org \
--cc=wenst@chromium.org \
/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).