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
This commit is contained in:
Emmanuel Vadot 2021-05-16 16:21:43 +02:00
parent ce41765c21
commit f52072b06d

View file

@ -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();