From 690eebb44794ae7fb19a5784314b69039b2833db Mon Sep 17 00:00:00 2001 From: Konrad Sztyber Date: Mon, 4 Jul 2022 14:15:36 +0200 Subject: [PATCH] vmd: extract removing devices to separate function Signed-off-by: Konrad Sztyber Change-Id: Idc9c7d0e5d0ebce8278e089bcfe5b7f76b86c270 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13953 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Tom Nabarro Reviewed-by: Jim Harris --- lib/vmd/vmd.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/vmd/vmd.c b/lib/vmd/vmd.c index 788ab5455..6df093919 100644 --- a/lib/vmd/vmd.c +++ b/lib/vmd/vmd.c @@ -1369,6 +1369,17 @@ vmd_bus_handle_hotplug(struct vmd_pci_bus *bus) } } +static void +vmd_remove_device(struct vmd_pci_device *device) +{ + device->pci.internal.pending_removal = true; + + /* If the device isn't attached, remove it immediately */ + if (!device->pci.internal.attached) { + vmd_dev_detach(&device->pci); + } +} + static void vmd_bus_handle_hotremove(struct vmd_pci_bus *bus) { @@ -1376,12 +1387,7 @@ vmd_bus_handle_hotremove(struct vmd_pci_bus *bus) TAILQ_FOREACH_SAFE(device, &bus->dev_list, tailq, tmpdev) { if (!vmd_bus_device_present(bus, device->devfn)) { - device->pci.internal.pending_removal = true; - - /* If the device isn't attached, remove it immediately */ - if (!device->pci.internal.attached) { - vmd_dev_detach(&device->pci); - } + vmd_remove_device(device); } } }