2021-08-16 03:21:23

by Jianqun Xu

[permalink] [raw]
Subject: [PATCH 2/4] regulator: core: notify regulator enable with the voltage value

Get the voltage of regulator and then pass it as the parameter of
notify, the driver could take it.

The origin parameter for notify is NULL, so this patch do nothing effect
to other driver who not care about the voltage value.

Signed-off-by: Jianqun Xu <[email protected]>
---
drivers/regulator/core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index f192bf19492e..a53f1644a6f4 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2658,8 +2658,12 @@ static int _regulator_enable(struct regulator *regulator)
if (ret < 0)
goto err_consumer_disable;

+ ret = _regulator_get_voltage(rdev);
+ if (ret < 0)
+ ret = 0;
+
_notifier_call_chain(rdev, REGULATOR_EVENT_ENABLE,
- NULL);
+ &ret);
} else if (ret < 0) {
rdev_err(rdev, "is_enabled() failed: %pe\n", ERR_PTR(ret));
goto err_consumer_disable;
--
2.25.1




2021-08-16 12:05:17

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 2/4] regulator: core: notify regulator enable with the voltage value

On Mon, Aug 16, 2021 at 11:20:01AM +0800, Jianqun Xu wrote:

> + ret = _regulator_get_voltage(rdev);
> + if (ret < 0)
> + ret = 0;
> +
> _notifier_call_chain(rdev, REGULATOR_EVENT_ENABLE,
> - NULL);
> + &ret);

This is going to be really expensive for devices without a cache and
it's going to be *very* rarely used if ever.


Attachments:
(No filename) (366.00 B)
signature.asc (499.00 B)
Download all attachments