Author: manu
Date: Fri Apr 20 20:30:33 2018
New Revision: 332843
URL: https://svnweb.freebsd.org/changeset/base/332843

Log:
  regulator: Check status before disabling
  
  When disabling regulator when they are unused, check before is they are
  enabled.
  While here don't check the enable_cnt on the regulator entry as it is
  checked by regnode_stop.
  This solve the panic on any board using a fixed regulator that is driven
  by a gpio when the regulator is unused.
  
  Tested On: OrangePi One
  Pointy Hat to:            myself
  Reported by:  kevans, Milan Obuch (freebsd-...@dino.sk)

Modified:
  head/sys/dev/extres/regulator/regulator.c

Modified: head/sys/dev/extres/regulator/regulator.c
==============================================================================
--- head/sys/dev/extres/regulator/regulator.c   Fri Apr 20 20:18:10 2018        
(r332842)
+++ head/sys/dev/extres/regulator/regulator.c   Fri Apr 20 20:30:33 2018        
(r332843)
@@ -166,17 +166,19 @@ static void
 regulator_shutdown(void *dummy)
 {
        struct regnode *entry;
+       int status, ret;
        int disable = 1;
 
        REG_TOPO_SLOCK();
        TUNABLE_INT_FETCH("hw.regulator.disable_unused", &disable);
        TAILQ_FOREACH(entry, &regnode_list, reglist_link) {
-               if (entry->enable_cnt == 0 &&
-                   entry->std_param.always_on == 0 && disable) {
+               if (entry->std_param.always_on == 0 && disable) {
                        if (bootverbose)
                                printf("regulator: shuting down %s\n",
                                    entry->name);
-                       regnode_stop(entry, 0);
+                       ret = regnode_status(entry, &status);
+                       if (ret == 0 && status == REGULATOR_STATUS_ENABLED)
+                               regnode_stop(entry, 0);
                }
        }
        REG_TOPO_UNLOCK();
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to