PCI/VGA: Simplify vga_arbiter_notify_clients()
authorSui Jingfeng <suijingfeng@loongson.cn>
Tue, 8 Aug 2023 22:34:06 +0000 (06:34 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 23 Aug 2023 22:19:14 +0000 (17:19 -0500)
In vga_arbiter_notify_clients(), "new_state" was computed during every loop
iteration even though it doesn't depend on anything that changes during the
loop.   Move the computation outside the loop.

[bhelgaas: drop renames that obscure the purpose, commit log]
Link: https://lore.kernel.org/r/20230808223412.1743176-6-sui.jingfeng@linux.dev
Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/vgaarb.c

index 443cf1a..685681b 100644 (file)
@@ -1477,12 +1477,10 @@ static void vga_arbiter_notify_clients(void)
        if (!vga_arbiter_used)
                return;
 
+       new_state = (vga_count > 1) ? false : true;
+
        spin_lock_irqsave(&vga_lock, flags);
        list_for_each_entry(vgadev, &vga_list, list) {
-               if (vga_count > 1)
-                       new_state = false;
-               else
-                       new_state = true;
                if (vgadev->set_decode) {
                        new_decodes = vgadev->set_decode(vgadev->pdev,
                                                         new_state);