Re: [PATCH] soc: mediatek: mediatek-regulator-coupler: Fix comment

From: AngeloGioacchino Del Regno
Date: Wed Oct 23 2024 - 06:40:50 EST


Il 23/10/24 12:19, Fei Shao ha scritto:
Fix two minor issues in the comments.

1. We balance VSRAM voltage based on the target VGPU voltage, so the
comment likely refers to VGPU.

Function `mediatek_regulator_balance_voltage()` refers, as stated in the comment
located at the top of its signature, to "GPU<->SRAM" voltages relationships.

So, we're taking into consideration only two regulators:
VGPU and VSRAM

The first comment says:
"If we're asked to set a voltage (implicit: to VGPU) less than VSRAM min_uV[...]"

...so, I think that you've misunderstood what the comment says :-)

2. .attach_regulator() returns 0 on success and 1 if the regulator is
not suitable. The context suggests a successful return value (0).

The comment is on top of a "refuse" or "error" case - one that wants to return 1
and not zero.

Besides, it clearly states:
"The regulator core will keep walking through the list of couplers when any
.attach_regulator() callback returns 1"

...which is definitely true.

drivers/regulator/core.c
function `regulator_find_coupler()`:

list_for_each_entry_reverse(coupler, &regulator_coupler_list, list) {
err = coupler->attach_regulator(coupler, rdev);
[.....]
if (err < 0)
return ERR_PTR(err);

if (err == 1)
continue;

break;
}

Is that clear now?

Cheers,
Angelo


Fixes: c200774a6df4 ("soc: mediatek: Introduce mediatek-regulator-coupler driver")
Signed-off-by: Fei Shao <fshao@xxxxxxxxxxxx>
---

drivers/soc/mediatek/mtk-regulator-coupler.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-regulator-coupler.c b/drivers/soc/mediatek/mtk-regulator-coupler.c
index 0b6a2884145e..16df12d1c2e0 100644
--- a/drivers/soc/mediatek/mtk-regulator-coupler.c
+++ b/drivers/soc/mediatek/mtk-regulator-coupler.c
@@ -74,7 +74,7 @@ static int mediatek_regulator_balance_voltage(struct regulator_coupler *coupler,
return ret;
/*
- * If we're asked to set a voltage less than VSRAM min_uV, set
+ * If we're asked to set a voltage less than VGPU min_uV, set
* the minimum allowed voltage on VSRAM, as in this case it is
* safe to ignore the max_spread parameter.
*/
@@ -108,7 +108,7 @@ static int mediatek_regulator_attach(struct regulator_coupler *coupler,
* this means that this is surely not a GPU<->SRAM couple: in that
* case, we may want to use another coupler implementation, if any,
* or the generic one: the regulator core will keep walking through
- * the list of couplers when any .attach_regulator() cb returns 1.
+ * the list of couplers when any .attach_regulator() cb returns 0.
*/
if (rdev->coupling_desc.n_coupled > 2)
return 1;