Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 May 2021 16:04:19 GMT
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: f52072b06da7 - main - extres: regulator: Fix regulator_status for already enable regulators
Message-ID:  <202105211604.14LG4J7O005179@gitrepo.freebsd.org>

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

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

commit f52072b06da761c05dcb636dd1a02dea7214174a
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2021-05-16 14:21:43 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2021-05-21 15:39:07 +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
---
 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?202105211604.14LG4J7O005179>