From 205aaf1b9b66f8a001be0ce37c1f5fc7c3fdfc01 Mon Sep 17 00:00:00 2001 From: shengfei Xu Date: Sun, 31 Mar 2024 17:15:27 +0800 Subject: [PATCH] regulator: rk806: Solve the initialization of non integer multiple step voltage Resolve system error caused by the set voltage not being an integer multiple of the uV_step. Signed-off-by: shengfei Xu Change-Id: Icdae0985e0173289c66c1d6cc182da92508acd4c --- drivers/regulator/rk806-regulator.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/rk806-regulator.c b/drivers/regulator/rk806-regulator.c index 3e33b3f585be..9d5d64bed3f4 100644 --- a/drivers/regulator/rk806-regulator.c +++ b/drivers/regulator/rk806-regulator.c @@ -681,7 +681,9 @@ static int rk806_regulator_resume(struct regulator_dev *rdev) static int rk806_set_suspend_voltage_range(struct regulator_dev *rdev, int uv) { struct rk806_regulator_data *pdata = rdev_get_drvdata(rdev); - int sel = regulator_map_voltage_linear_range(rdev, uv, uv); + int sel = regulator_map_voltage_linear_range(rdev, + uv, + rdev->constraints->max_uV); struct rk806 *rk806 = pdata->rk806; int rid = rdev_get_id(rdev); int reg_offset; @@ -725,6 +727,8 @@ static int rk806_set_voltage(struct regulator_dev *rdev, int ret; int sel; + if (req_min_uV == req_max_uV) + req_max_uV = rdev->constraints->max_uV; ret = regulator_map_voltage_linear_range(rdev, req_min_uV, req_max_uV); if (ret >= 0) { *selector = ret;