Browse Source

Correctly work with Type-C Current in Setup mode

When we were getting power from Type-C Current advertisements, we used
to not update the location of the configuration object.  This was done
to save time between polling the Type-C Current, and was not a problem
until we started trying to do Power Delivery in Setup mode.  As the
comment correctly said before, when we were trying to get power, the
location of the configuration object wouldn't change, so there was no
need to find its location more than once.

Now that the location of the configuration can change while we're
getting power, we need to check if that's happened.  This can be easily
done by checking the configuration object's status.  If the status is
not VALID, we get the location of the new configuration object.
Clara Hobbs 7 years ago
parent
commit
5492347716
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      src/device_policy_manager.c

+ 3
- 3
src/device_policy_manager.c View File

@@ -180,9 +180,9 @@ bool pdb_dpm_evaluate_typec_current(void)
180 180
     static bool cfg_set = false;
181 181
     static struct pdb_config *cfg = NULL;
182 182
 
183
-    /* Only get the configuration the first time this function runs, since its
184
-     * location will never change without rebooting into setup mode. */
185
-    if (!cfg_set) {
183
+    /* Get the configuration the first time this function runs, and again any
184
+     * time the status is found to not be valid. */
185
+    if (!cfg_set || cfg->status != PDB_CONFIG_STATUS_VALID) {
186 186
         cfg = pdb_config_flash_read();
187 187
         cfg_set = true;
188 188
     }

Loading…
Cancel
Save