If it's not a vga device, just don't care (NOTIFY_DONE). Otherwise
return NOTIFY_OK after processing done.

Signed-off-by: Abel Wu <abe...@icloud.com>
---
 drivers/gpu/vga/vgaarb.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index 5180c5687ee5..2879d4223bf1 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -644,6 +644,11 @@ static void vga_arbiter_check_bridge_sharing(struct 
vga_device *vgadev)
        }
 }
 
+static inline bool vga_class(struct pci_dev *pdev)
+{
+       return (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA;
+}
+
 /*
  * Currently, we assume that the "initial" setup of the system is
  * not sane, that is we come up with conflicting devices and let
@@ -658,10 +663,6 @@ static bool vga_arbiter_add_pci_device(struct pci_dev 
*pdev)
        struct pci_dev *bridge;
        u16 cmd;
 
-       /* Only deal with VGA class devices */
-       if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
-               return false;
-
        /* Allocate structure */
        vgadev = kzalloc(sizeof(struct vga_device), GFP_KERNEL);
        if (vgadev == NULL) {
@@ -1420,6 +1421,9 @@ static int pci_notify(struct notifier_block *nb, unsigned 
long action,
 
        vgaarb_dbg(dev, "%s\n", __func__);
 
+       if (!vga_class(pdev))
+               return NOTIFY_DONE;
+
        /* For now we're only intereted in devices added and removed. I didn't
         * test this thing here, so someone needs to double check for the
         * cases of hotplugable vga cards. */
@@ -1430,7 +1434,8 @@ static int pci_notify(struct notifier_block *nb, unsigned 
long action,
 
        if (notify)
                vga_arbiter_notify_clients();
-       return 0;
+
+       return NOTIFY_OK;
 }
 
 static struct notifier_block pci_notifier = {
@@ -1533,7 +1538,7 @@ static void __init vga_arb_select_default_device(void)
 static int __init vga_arb_device_init(void)
 {
        int rc;
-       struct pci_dev *pdev;
+       struct pci_dev *pdev = NULL;
        struct vga_device *vgadev;
 
        rc = misc_register(&vga_arb_device);
@@ -1544,11 +1549,15 @@ static int __init vga_arb_device_init(void)
 
        /* We add all PCI devices satisfying VGA class in the arbiter by
         * default */
-       pdev = NULL;
-       while ((pdev =
-               pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-                              PCI_ANY_ID, pdev)) != NULL)
-               vga_arbiter_add_pci_device(pdev);
+       while (1) {
+               pdev = pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
+                                     PCI_ANY_ID, pdev);
+               if (!pdev)
+                       break;
+
+               if (vga_class(pdev))
+                       vga_arbiter_add_pci_device(pdev);
+       }
 
        list_for_each_entry(vgadev, &vga_list, list) {
                struct device *dev = &vgadev->pdev->dev;
-- 
2.27.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to