]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/sysfs.c
update-pciids: Re-compress pci.ids if needed
[pciutils.git] / lib / sysfs.c
index 735c14445ab8992ce9878820ba7c0bb394e5047b..8cab869306894822344597ea7875c1e2416e8de3 100644 (file)
@@ -4,7 +4,9 @@
  *     Copyright (c) 2003 Matthew Wilcox <matthew@wil.cx>
  *     Copyright (c) 1997--2008 Martin Mares <mj@ucw.cz>
  *
- *     Can be freely distributed and used under the terms of the GNU GPL.
+ *     Can be freely distributed and used under the terms of the GNU GPL v2+.
+ *
+ *     SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #define _GNU_SOURCE
@@ -461,6 +463,20 @@ sysfs_fill_info(struct pci_dev *d, unsigned int flags)
        }
     }
 
+  if (want_fill(d, flags, PCI_FILL_DRIVER))
+    {
+      char *driver_path = sysfs_deref_link(d, "driver");
+      if (driver_path)
+        {
+          char *driver = strrchr(driver_path, '/');
+          driver = driver ? driver+1 : driver_path;
+          pci_set_property(d, PCI_FILL_DRIVER, driver);
+          free(driver_path);
+        }
+      else
+        clear_fill(d, PCI_FILL_DRIVER);
+    }
+
   pci_generic_fill_info(d, flags);
 }