Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Jul 2021 17:17:05 GMT
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 1e372b049426 - stable/13 - extres: regulator: Fix regulator_status for already enable regulators
Message-ID:  <202107221717.16MHH5tt091437@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=1e372b0494264bb0b449b88c94f103566c00f80a

commit 1e372b0494264bb0b449b88c94f103566c00f80a
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2021-05-16 14:21:43 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2021-07-22 17:09:43 +0000

    extres: regulator: Fix regulator_status for already enable regulators
    
    If a regulator hasn't been enable by a driver but is enabled in hardware
    (most likely enabled by U-Boot), regulator_status will returns that it
    is enabled and so any call to regulator_disable will panic as it wasn't
    enabled by one of our drivers.
    
    Sponsored by:   Diablotin Systems
    Differential Revision:  https://reviews.freebsd.org/D30293
    
    (cherry picked from commit f52072b06da761c05dcb636dd1a02dea7214174a)
---
 sys/dev/extres/regulator/regulator.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/dev/extres/regulator/regulator.c b/sys/dev/extres/regulator/regulator.c
index 63b7d116f416..eab79e9dfbc3 100644
--- a/sys/dev/extres/regulator/regulator.c
+++ b/sys/dev/extres/regulator/regulator.c
@@ -985,6 +985,10 @@ regulator_status(regulator_t reg, int *status)
 	KASSERT(regnode->ref_cnt > 0,
 	   ("Attempt to access unreferenced regulator: %s\n", regnode->name));
 
+	if (reg->enable_cnt == 0) {
+		*status = 0;
+		return (0);
+	}
 	REG_TOPO_SLOCK();
 	rv = regnode_status(regnode, status);
 	REG_TOPO_UNLOCK();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107221717.16MHH5tt091437>