[Mesa-dev] [PATCH v3 6/8] loader: Move debug logging to where we find the driver

Kristian Høgsberg krh at bitplanet.net
Wed Feb 5 02:18:16 CET 2014


Trying to figure out where a driver name comes from by looking at
whether or not chip_id is -1 isn't very roboust.

Signed-off-by: Kristian Høgsberg <krh at bitplanet.net>
---
 src/loader/loader.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/loader/loader.c b/src/loader/loader.c
index 319bcf5..7131d46 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -105,11 +105,20 @@ lookup_driver_for_pci_id(int vendor_id, int chip_id, unsigned int driver_types)
          continue;
 
       if (driver_map[i].num_chips_ids == -1)
-         return strdup(driver_map[i].driver);
+         goto out;
 
       for (j = 0; j < driver_map[i].num_chips_ids; j++)
          if (driver_map[i].chip_ids[j] == chip_id)
-            return strdup(driver_map[i].driver);
+            goto out;
+   }
+
+ out:
+   if (driver_map[i].driver) {
+      log_(_LOADER_DEBUG,
+           "pci id: %04x:%04x, driver %s from internal db",
+           vendor_id, chip_id, driver_map[i].driver);
+
+      return strdup(driver_map[i].driver);
    }
 
    return NULL;
@@ -235,6 +244,7 @@ loader_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id, char **driver)
 
    hwdb_driver = udev_device_get_property_value(parent, "DRI_DRIVER");
    if (hwdb_driver != NULL) {
+      log_(_LOADER_INFO, "using driver %s from udev hwdb", driver);
       *driver = strdup(hwdb_driver);
       goto out;
    }
@@ -386,13 +396,8 @@ loader_get_driver_for_fd(int fd, unsigned int driver_types)
    if (driver == NULL)
       driver = lookup_driver_for_pci_id(vendor_id, chip_id, driver_types);
 
-   if (driver && chip_id == -1) {
-      log_(_LOADER_INFO, "using driver %s from udev hwdb", driver);
-   } else {
-      log_(driver ? _LOADER_DEBUG : _LOADER_WARNING,
-           "pci id for fd %d: %04x:%04x, driver %s",
-           fd, vendor_id, chip_id, driver);
-   }
+   if (driver == NULL)
+      log_(_LOADER_WARNING, "no driver %s for %d\n", fd);
 
    return driver;
 }
-- 
1.8.4.2



More information about the mesa-dev mailing list