lkml.org 
[lkml]   [2023]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH RFC v3 2/5] regulator: disable monitors when regulator is disabled
    From: Benjamin Bara <benjamin.bara@skidata.com>

    This disables all enabled monitors before a regulator is disabled. This
    only happens if an protection is enabled in the device-tree. If an error
    occurs while disabling the regulator, the monitors are enabled again.

    Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
    ---
    drivers/regulator/core.c | 12 ++++++++++--
    1 file changed, 10 insertions(+), 2 deletions(-)

    diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
    index 76f112817f9d..e59204920d6c 100644
    --- a/drivers/regulator/core.c
    +++ b/drivers/regulator/core.c
    @@ -2828,7 +2828,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev)

    trace_regulator_enable_complete(rdev_get_name(rdev));

    - return 0;
    + return monitors_set_state(rdev, true);
    }

    /**
    @@ -2989,6 +2989,10 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
    {
    int ret;

    + ret = monitors_set_state(rdev, false);
    + if (ret)
    + return ret;
    +
    trace_regulator_disable(rdev_get_name(rdev));

    if (rdev->ena_pin) {
    @@ -3043,6 +3047,7 @@ static int _regulator_disable(struct regulator *regulator)
    _notifier_call_chain(rdev,
    REGULATOR_EVENT_ABORT_DISABLE,
    NULL);
    + monitors_set_state(rdev, true);
    return ret;
    }
    _notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
    @@ -3109,6 +3114,7 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
    rdev_err(rdev, "failed to force disable: %pe\n", ERR_PTR(ret));
    _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
    REGULATOR_EVENT_ABORT_DISABLE, NULL);
    + monitors_set_state(rdev, true);
    return ret;
    }

    @@ -6251,8 +6257,10 @@ static int regulator_late_cleanup(struct device *dev, void *data)
    */
    rdev_info(rdev, "disabling\n");
    ret = _regulator_do_disable(rdev);
    - if (ret != 0)
    + if (ret != 0) {
    rdev_err(rdev, "couldn't disable: %pe\n", ERR_PTR(ret));
    + monitors_set_state(rdev, true);
    + }
    } else {
    /* The intention is that in future we will
    * assume that full constraints are provided
    --
    2.34.1

    \
     
     \ /
      Last update: 2023-05-21 13:49    [W:5.410 / U:0.092 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site