]> mj.ucw.cz Git - pciutils.git/commitdiff
libpci: sysfs: Implement support for PCI_FILL_DRIVER
authorPali Rohár <pali@kernel.org>
Mon, 27 Dec 2021 13:05:47 +0000 (14:05 +0100)
committerMartin Mares <mj@ucw.cz>
Thu, 10 Feb 2022 12:49:35 +0000 (13:49 +0100)
In sysfs is driver name stored as symlink path of "driver" node.

lib/sysfs.c

index 735c14445ab8992ce9878820ba7c0bb394e5047b..ffa4f9d63d34916fe91945b0e83040049d95c564 100644 (file)
@@ -461,6 +461,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);
 }