[PATCH] regulator: tps6287x: Supply range data during registration
From: raoxu
Date: Mon Nov 09 2026 - 04:31:45 EST
From: Xu Rao <raoxu@xxxxxxxxxxxxx>
The regulator core can call tps6287x_map_voltage() while applying
voltage constraints during registration. However, the driver only sets
rdev->reg_data after devm_regulator_register() returns. The callback
therefore falls back to searching all voltage ranges instead of using
the range selected from the DT constraints.
For example, constraints of 600-900 mV select VRANGE 1. If the initial
voltage is 500 mV, the core raises it to 600 mV during registration.
Without the private data, this selects VRANGE 0. A later request for
800 mV uses VRANGE 1, causing a range change on a running regulator.
As described in the range-selection fix, such changes can bypass the
configured slew rate and cause a current surge.
Pass the initialized range data through config.driver_data so that the
core installs it before applying constraints, and remove the assignment
after registration.
The supplied fix was reviewed and this commit message prepared with
OpenCode AI assistance.
Fixes: 3028583d1314 ("regulator: TPS6287X: Use min/max uV to get VRANGE")
Signed-off-by: Xu Rao <raoxu@xxxxxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
---
drivers/regulator/tps6287x-regulator.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/regulator/tps6287x-regulator.c b/drivers/regulator/tps6287x-regulator.c
index e6403398facc..6367c35dc98d 100644
--- a/drivers/regulator/tps6287x-regulator.c
+++ b/drivers/regulator/tps6287x-regulator.c
@@ -204,6 +204,7 @@ static int tps6287x_i2c_probe(struct i2c_client *i2c)
&tps6287x_reg);
reg_data->range = tps6287x_best_range(&config, &tps6287x_reg);
+ config.driver_data = reg_data;
rdev = devm_regulator_register(dev, &tps6287x_reg, &config);
if (IS_ERR(rdev)) {
@@ -211,7 +212,6 @@ static int tps6287x_i2c_probe(struct i2c_client *i2c)
return PTR_ERR(rdev);
}
- rdev->reg_data = (void *)reg_data;
dev_dbg(dev, "Probed regulator\n");
return 0;
--
2.50.1