Author: kevans
Date: Sun Jan 12 04:07:03 2020
New Revision: 356649
URL: https://svnweb.freebsd.org/changeset/base/356649

Log:
  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

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

Modified: head/sys/dev/extres/regulator/regulator.c
==============================================================================
--- head/sys/dev/extres/regulator/regulator.c   Sun Jan 12 04:05:18 2020        
(r356648)
+++ head/sys/dev/extres/regulator/regulator.c   Sun Jan 12 04:07:03 2020        
(r356649)
@@ -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, &regnode_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();
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to