Add name to pci_device
authorXiao Jia <stfairy@gmail.com>
Thu, 17 Sep 2015 03:34:17 +0000 (20:34 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 23 Sep 2015 20:46:28 +0000 (16:46 -0400)
kern/arch/x86/pci.c
kern/arch/x86/pci.h
kern/include/linux/compat_todo.h

index 0871507..c9caebe 100644 (file)
@@ -204,6 +204,9 @@ void pci_init(void)
                                pcidev->bus = i;
                                pcidev->dev = j;
                                pcidev->func = k;
+                               snprintf(pcidev->name, sizeof(pcidev->name),
+                                        "%02x:%02x.%x", pcidev->bus,
+                                        pcidev->dev, pcidev->func);
                                pcidev->dev_id = dev_id;
                                pcidev->ven_id = ven_id;
                                /* Get the Class/subclass */
index 6d18084..0c173fe 100644 (file)
@@ -167,6 +167,7 @@ struct pci_bar {
 struct pci_device {
        STAILQ_ENTRY(pci_device)        all_dev;        /* list of all devices */
        SLIST_ENTRY(pci_device)         irq_dev;        /* list of all devs off an irq */
+       char                                            name[9];
        spinlock_t                                      lock;
        void                                            *dev_data;      /* device private pointer */
        bool                                            in_use;         /* prevent double discovery */
index be2ce34..73da8c0 100644 (file)
@@ -858,7 +858,7 @@ static int pcie_capability_read_dword(struct pci_device *dev, int pos,
 
 static inline const char *pci_name(const struct pci_device *pdev)
 {
-       return "pci"; // TODO
+       return pdev->name;
 }
 
 #define dev_name(dev) ("ether0" /* XXX */)