[PATCH pciutils 4/5] libpci: sysfs: Implement PROGIF, REVID and SUBSYS support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In sysfs there are optional nodes with this information.
---
 lib/sysfs.c | 39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/lib/sysfs.c b/lib/sysfs.c
index 7c157a2688ad..7714607f66a0 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -329,6 +329,7 @@ static unsigned int
 sysfs_fill_info(struct pci_dev *d, unsigned int flags)
 {
   unsigned int done = 0;
+  int value;
 
   if (!d->access->buscentric)
     {
@@ -343,10 +344,42 @@ sysfs_fill_info(struct pci_dev *d, unsigned int flags)
 	  d->device_id = sysfs_get_value(d, "device", 1);
 	  done |= PCI_FILL_IDENT;
 	}
-      if (flags & PCI_FILL_CLASS)
+      if (flags & (PCI_FILL_CLASS | PCI_FILL_PROGIF))
 	{
-	  d->device_class = sysfs_get_value(d, "class", 1) >> 8;
-	  done |= PCI_FILL_CLASS;
+	  value = sysfs_get_value(d, "class", 1);
+	  if (flags & PCI_FILL_CLASS)
+	    {
+	      d->device_class = value >> 8;
+	      done |= PCI_FILL_CLASS;
+	    }
+	  if (flags & PCI_FILL_PROGIF)
+	    {
+	      d->prog_if = value & 0xff;
+	      done |= PCI_FILL_PROGIF;
+	    }
+	}
+      if (flags & PCI_FILL_REVID)
+	{
+	  value = sysfs_get_value(d, "revision", 0);
+	  if (value >= 0)
+	    {
+	      d->rev_id = value;
+	      done |= PCI_FILL_REVID;
+	    }
+        }
+      if (flags & PCI_FILL_SUBSYS)
+	{
+	  value = sysfs_get_value(d, "subsystem_vendor", 0);
+	  if (value >= 0)
+	    {
+	      d->subsys_vendor_id = value;
+	      value = sysfs_get_value(d, "subsystem_device", 0);
+	      if (value >= 0)
+	        {
+	          d->subsys_id = value;
+	          done |= PCI_FILL_SUBSYS;
+	        }
+	    }
 	}
       if (flags & PCI_FILL_IRQ)
 	{
-- 
2.20.1




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux