[Intel-gfx] [PATCH v3 4/9] PCI/VGA: Improve the default VGA device selection
suijingfeng
suijingfeng at loongson.cn
Mon Jul 24 12:28:50 UTC 2023
Hi,
Thanks for you noticed my change.
On 2023/7/20 03:32, Bjorn Helgaas wrote:
>> @@ -1509,13 +1543,24 @@ static int pci_notify(struct notifier_block *nb, unsigned long action,
>> * cases of hotplugable vga cards.
>> */
>>
>> - if (action == BUS_NOTIFY_ADD_DEVICE)
>> + switch (action) {
>> + case BUS_NOTIFY_ADD_DEVICE:
>> notify = vga_arbiter_add_pci_device(pdev);
>> - else if (action == BUS_NOTIFY_DEL_DEVICE)
>> + if (notify)
>> + vga_arbiter_notify_clients();
>> + break;
>> + case BUS_NOTIFY_DEL_DEVICE:
>> notify = vga_arbiter_del_pci_device(pdev);
>> + if (notify)
>> + vga_arbiter_notify_clients();
>> + break;
>> + case BUS_NOTIFY_BOUND_DRIVER:
>> + vga_arbiter_do_arbitration(pdev);
>> + break;
>> + default:
>> + break;
>> + }
> Changing from if/else to switch makes the patch bigger than necessary
> for no real benefit and obscures what is really changing.
Actually, the logic become more clear after this patch applied.
```
switch (action) {
case BUS_NOTIFY_ADD_DEVICE:
notify = vga_arbiter_add_pci_device(pdev);
if (notify)
vga_arbiter_notify_clients();
break;
case BUS_NOTIFY_DEL_DEVICE:
notify = vga_arbiter_del_pci_device(pdev);
if (notify)
vga_arbiter_notify_clients();
break;
case BUS_NOTIFY_BOUND_DRIVER:
vga_arbiter_do_arbitration(pdev);
break;
default:
break;
}
```
Because we only need call vga_arbiter_notify_clients() when action ==
BUS_NOTIFY_ADD_DEVICE or action == BUS_NOTIFY_DEL_DEVICE,
But *NOT* when the action equals to BUS_NOTIFY_BOUND_DRIVER.
More information about the Intel-gfx
mailing list