regulator: small enhancements to regulator_shutdown
Highlights: - Exit early if we're not disabling unused regulators; there's no need to take the regulator topology lock and re-evaluate this every iteration, as it's not going to change. - Don't emit a notice that we're shutting down a regulator if it's not enabled, to reduce noise. - Mention the outcome of the shutdown, to aide debugging and easily let developer/user collect list of regulators we actually shutdown to determine problematic one. Reviewed by: manu MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D22213
This commit is contained in:
parent
91de98e6d4
commit
89476f9c99
@ -191,16 +191,36 @@ regulator_shutdown(void *dummy)
|
||||
int status, ret;
|
||||
int disable = 1;
|
||||
|
||||
REG_TOPO_SLOCK();
|
||||
TUNABLE_INT_FETCH("hw.regulator.disable_unused", &disable);
|
||||
if (!disable)
|
||||
return;
|
||||
REG_TOPO_SLOCK();
|
||||
|
||||
if (bootverbose)
|
||||
printf("regulator: shutting down unused regulators\n");
|
||||
TAILQ_FOREACH(entry, ®node_list, reglist_link) {
|
||||
if (!entry->std_param.always_on && disable) {
|
||||
if (bootverbose)
|
||||
printf("regulator: shutting down %s\n",
|
||||
entry->name);
|
||||
if (!entry->std_param.always_on) {
|
||||
ret = regnode_status(entry, &status);
|
||||
if (ret == 0 && status == REGULATOR_STATUS_ENABLED)
|
||||
regnode_stop(entry, 0);
|
||||
if (ret == 0 && status == REGULATOR_STATUS_ENABLED) {
|
||||
if (bootverbose)
|
||||
printf("regulator: shutting down %s... ",
|
||||
entry->name);
|
||||
ret = regnode_stop(entry, 0);
|
||||
if (bootverbose) {
|
||||
/*
|
||||
* Call out busy in particular, here,
|
||||
* because it's not unexpected to fail
|
||||
* shutdown if the regulator is simply
|
||||
* in-use.
|
||||
*/
|
||||
if (ret == EBUSY)
|
||||
printf("busy\n");
|
||||
else if (ret != 0)
|
||||
printf("error (%d)\n", ret);
|
||||
else
|
||||
printf("ok\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
REG_TOPO_UNLOCK();
|
||||
|
Loading…
Reference in New Issue
Block a user