From 1a4b0c999101b2532723f9bd9818b70ffa7580f4 Mon Sep 17 00:00:00 2001 From: Adam Ford Date: Mon, 9 Feb 2026 23:37:04 -0600 Subject: [PATCH 1/4] regulator: mt6363: Fix interrmittent timeout Sometimes, the mt6363 regulator would fail to initialize and return with a TIMEOUT error, so add an extra instruction to wake up the bus before issuing the commands. Fixes: 3c36965df808 ("regulator: Add support for MediaTek MT6363 SPMI PMIC Regulators") Signed-off-by: Adam Ford Link: https://patch.msgid.link/20260210053708.17239-4-aford173@gmail.com Signed-off-by: Mark Brown --- drivers/regulator/mt6363-regulator.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/mt6363-regulator.c b/drivers/regulator/mt6363-regulator.c index e0fbf92e7685..03af5fa53600 100644 --- a/drivers/regulator/mt6363-regulator.c +++ b/drivers/regulator/mt6363-regulator.c @@ -861,7 +861,7 @@ static int mt6363_regulator_probe(struct platform_device *pdev) struct irq_domain *domain; struct irq_fwspec fwspec; struct spmi_device *sdev; - int i, ret; + int i, ret, val; config.regmap = mt6363_spmi_register_regmap(dev); if (IS_ERR(config.regmap)) @@ -870,6 +870,13 @@ static int mt6363_regulator_probe(struct platform_device *pdev) config.dev = dev; sdev = to_spmi_device(dev->parent); + /* + * The first read may fail if the bootloader sets sleep mode: wake up + * this PMIC with W/R on the SPMI bus and ignore the first result. + * This matches the MT6373 driver behavior. + */ + regmap_read(config.regmap, MT6363_TOP_TRAP, &val); + interrupt_parent = of_irq_find_parent(dev->of_node); if (!interrupt_parent) return dev_err_probe(dev, -EINVAL, "Cannot find IRQ parent\n"); From e243cdd87b911ce9968b62e4ab2b680dfadc4341 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Wed, 11 Feb 2026 21:37:14 -0600 Subject: [PATCH 2/4] regulator: core: Remove regulator supply_name length limit When creating the regulator object, associated with a consumer device, the supply_name is string formatted into a statically sized buffer on the stack, then strdup()'ed onto the heap. Not only is the dance on the stack unnecessary, but when the device's name is long we might not fit the constructed supply_name in the fixed 64 byte buffer on the stack. One such case can be seen on the Qualcomm Rb3Gen2 board, where we find a PCIe controller, with a PCIe switch, with a USB controller, with a USB hub, consuming a regulator. In this example the dev->kobj.name itself is 62 characters long. Drop the temporary buffer on the stack and kasprintf() the string directly on the heap, both to simplify the code, and to remove the length limitation. Signed-off-by: Bjorn Andersson Link: https://patch.msgid.link/20260211-regulator-supply-name-length-v1-1-3875541c1576@oss.qualcomm.com Signed-off-by: Mark Brown --- drivers/regulator/core.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 8c2fd20edd50..80bb95750a20 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1965,8 +1965,6 @@ static const struct file_operations constraint_flags_fops = { #endif }; -#define REG_STR_SIZE 64 - static void link_and_create_debugfs(struct regulator *regulator, struct regulator_dev *rdev, struct device *dev) { @@ -2014,15 +2012,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, lockdep_assert_held_once(&rdev->mutex.base); if (dev) { - char buf[REG_STR_SIZE]; - int size; - - size = snprintf(buf, REG_STR_SIZE, "%s-%s", - dev->kobj.name, supply_name); - if (size >= REG_STR_SIZE) - return NULL; - - supply_name = kstrdup(buf, GFP_KERNEL); + supply_name = kasprintf(GFP_KERNEL, "%s-%s", dev->kobj.name, supply_name); if (supply_name == NULL) return NULL; } else { From 5a1256acaa856e6770d74dd786b1b12548969c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Draszik?= Date: Tue, 10 Feb 2026 17:23:50 +0000 Subject: [PATCH 3/4] regulator: s2mps11: drop redundant sanity checks in s2mpg10_of_parse_cb() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sanity checks being removed in this commit are useless as earlier code already checks for all conditions, including all error cases like out-of-bounds conditions. In other words, the code being removed here has no effect, as any potential error it could catch will already have been caught by earlier code. The checks removed here are also incomplete (as they're off-by-one) - they should have been checking >= ARRAY_SIZE() to be complete. Simply remove this redundant and incorrect code. No functional change. Reported-by: Dan Carpenter Closes: https://lore.kernel.org/all/aYmsu8qREppwBESH@stanley.mountain/ Reviewed-by: Krzysztof Kozlowski Signed-off-by: André Draszik Link: https://patch.msgid.link/20260210-s2mpg1x-regulators-fixes-v2-1-ab3d3457f1ae@linaro.org Signed-off-by: Mark Brown --- drivers/regulator/s2mps11.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 2d5510acd078..2d67c5c16f48 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -478,8 +478,6 @@ static int s2mpg10_of_parse_cb(struct device_node *np, return -EINVAL; } - if (ext_control > ARRAY_SIZE(ext_control_s2mpg10)) - return -EINVAL; ext_control = ext_control_s2mpg10[ext_control]; break; @@ -503,8 +501,6 @@ static int s2mpg10_of_parse_cb(struct device_node *np, return -EINVAL; } - if (ext_control > ARRAY_SIZE(ext_control_s2mpg11)) - return -EINVAL; ext_control = ext_control_s2mpg11[ext_control]; break; From 09ad01a530bb6ad260bda4fa56bab84619d90968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Draszik?= Date: Tue, 10 Feb 2026 17:23:51 +0000 Subject: [PATCH 4/4] regulator: s2mps11: fix pctrlsel macro usage in s2mpg10_of_parse_cb() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 979dd8da76eb ("regulator: s2mps11: add S2MPG11 regulator") incorrectly ended up using macros for S2MPG10 in the S2MPG11 case. They happen to end up giving the same result, but for clarity, the correct macros should be used. No functional change. Signed-off-by: André Draszik Link: https://patch.msgid.link/20260210-s2mpg1x-regulators-fixes-v2-2-ab3d3457f1ae@linaro.org Signed-off-by: Mark Brown --- drivers/regulator/s2mps11.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 2d67c5c16f48..81cfd60460f8 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -440,15 +440,15 @@ static int s2mpg10_of_parse_cb(struct device_node *np, [S2MPG10_EXTCTRL_LDO20M_EN] = S2MPG10_PCTRLSEL_LDO20M_EN, }; static const u32 ext_control_s2mpg11[] = { - [S2MPG11_EXTCTRL_PWREN] = S2MPG10_PCTRLSEL_PWREN, - [S2MPG11_EXTCTRL_PWREN_MIF] = S2MPG10_PCTRLSEL_PWREN_MIF, - [S2MPG11_EXTCTRL_AP_ACTIVE_N] = S2MPG10_PCTRLSEL_AP_ACTIVE_N, - [S2MPG11_EXTCTRL_G3D_EN] = S2MPG10_PCTRLSEL_CPUCL1_EN, - [S2MPG11_EXTCTRL_G3D_EN2] = S2MPG10_PCTRLSEL_CPUCL1_EN2, - [S2MPG11_EXTCTRL_AOC_VDD] = S2MPG10_PCTRLSEL_CPUCL2_EN, - [S2MPG11_EXTCTRL_AOC_RET] = S2MPG10_PCTRLSEL_CPUCL2_EN2, - [S2MPG11_EXTCTRL_UFS_EN] = S2MPG10_PCTRLSEL_TPU_EN, - [S2MPG11_EXTCTRL_LDO13S_EN] = S2MPG10_PCTRLSEL_TPU_EN2, + [S2MPG11_EXTCTRL_PWREN] = S2MPG11_PCTRLSEL_PWREN, + [S2MPG11_EXTCTRL_PWREN_MIF] = S2MPG11_PCTRLSEL_PWREN_MIF, + [S2MPG11_EXTCTRL_AP_ACTIVE_N] = S2MPG11_PCTRLSEL_AP_ACTIVE_N, + [S2MPG11_EXTCTRL_G3D_EN] = S2MPG11_PCTRLSEL_G3D_EN, + [S2MPG11_EXTCTRL_G3D_EN2] = S2MPG11_PCTRLSEL_G3D_EN2, + [S2MPG11_EXTCTRL_AOC_VDD] = S2MPG11_PCTRLSEL_AOC_VDD, + [S2MPG11_EXTCTRL_AOC_RET] = S2MPG11_PCTRLSEL_AOC_RET, + [S2MPG11_EXTCTRL_UFS_EN] = S2MPG11_PCTRLSEL_UFS_EN, + [S2MPG11_EXTCTRL_LDO13S_EN] = S2MPG11_PCTRLSEL_LDO13S_EN, }; u32 ext_control;