[driver_manager] Keep fallback info in Driver

Keep the fallback info in Driver rather than parsing the
version string in multiple places.

Bug: 81107

Change-Id: I0c011179e74c90fb75b2ad4422d21bad92f8a7d7
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/558963
Reviewed-by: Suraj Malhotra <surajmalhotra@google.com>
Commit-Queue: David Gilhooley <dgilhooley@google.com>
diff --git a/src/devices/bin/driver_manager/coordinator.cc b/src/devices/bin/driver_manager/coordinator.cc
index f4e95fd..a187735 100644
--- a/src/devices/bin/driver_manager/coordinator.cc
+++ b/src/devices/bin/driver_manager/coordinator.cc
@@ -1350,21 +1350,19 @@
     fragment_driver_ = driver.get();
   }
 
-  bool fallback = false;
-  if (version[0] == '*') {
-    fallback = true;
+  if (driver->fallback) {
     // TODO(fxbug.dev/44586): remove this once a better solution for driver prioritization is
     // implemented.
     for (auto& name : config_.eager_fallback_drivers) {
       if (driver->name == name) {
         LOGF(INFO, "Marking fallback driver '%s' as eager.", driver->name.c_str());
-        fallback = false;
+        driver->fallback = false;
         break;
       }
     }
   }
 
-  if (fallback) {
+  if (driver->fallback) {
     // fallback driver, load only if all else fails
     fallback_drivers_.push_front(std::move(driver));
   } else if (version[0] == '!') {
diff --git a/src/devices/bin/driver_manager/driver.cc b/src/devices/bin/driver_manager/driver.cc
index 0b144ed..1d52ccf 100644
--- a/src/devices/bin/driver_manager/driver.cc
+++ b/src/devices/bin/driver_manager/driver.cc
@@ -98,6 +98,9 @@
   drv->flags = note->flags;
   drv->libname = context->libname;
   drv->name = note->name;
+  if (note->version[0] == '*') {
+    drv->fallback = true;
+  }
 
   if (context->vmo.is_valid()) {
     drv->dso_vmo = std::move(context->vmo);
diff --git a/src/devices/bin/driver_manager/driver.h b/src/devices/bin/driver_manager/driver.h
index a58bd0a..e30f8e3 100644
--- a/src/devices/bin/driver_manager/driver.h
+++ b/src/devices/bin/driver_manager/driver.h
@@ -34,6 +34,9 @@
   // Number of bytes in the bind rules.
   uint32_t binding_size = 0;
 
+  // If this is true, this driver should only be bound after /system/ comes up.
+  bool fallback = false;
+
   uint32_t flags = 0;
   zx::vmo dso_vmo;
 
diff --git a/src/devices/bin/driver_manager/driver_loader.cc b/src/devices/bin/driver_manager/driver_loader.cc
index c99844c..a201956 100644
--- a/src/devices/bin/driver_manager/driver_loader.cc
+++ b/src/devices/bin/driver_manager/driver_loader.cc
@@ -46,8 +46,8 @@
         LOGF(ERROR, "Driver '%s' '%s' could not cache DSO", driver->name.data(),
              driver->libname.data());
       }
-      if (version[0] == '*') {
-        // de-prioritize drivers that are "fallback"
+      // De-prioritize drivers that are "fallback".
+      if (driver->fallback) {
         drivers.push_back(std::move(driver));
       } else {
         drivers.push_front(std::move(driver));