When blocklisting some device, the per type count was wrong.

Signed-off-by: David Marchand <[email protected]>
---
Changes since RFC v1:
- moved counter decrement to the free helper,

---
 drivers/bus/fslmc/fslmc_bus.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 322b023652..e4aed1bb1a 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -83,6 +83,9 @@ insert_in_device_list(struct rte_dpaa2_device *newdev)
 
        if (!inserted)
                rte_bus_add_device(&rte_fslmc_bus, &newdev->device);
+
+       if (newdev->dev_type < DPAA2_DEVTYPE_MAX)
+               fslmc_bus_device_count[newdev->dev_type]++;
 }
 
 static void
@@ -90,6 +93,8 @@ fslmc_free_device(struct rte_device *rte_dev)
 {
        struct rte_dpaa2_device *dev = RTE_BUS_DEVICE(rte_dev, *dev);
 
+       if (dev->dev_type < DPAA2_DEVTYPE_MAX)
+               fslmc_bus_device_count[dev->dev_type]--;
        rte_intr_instance_free(dev->intr_handle);
        free(dev);
 }
@@ -203,9 +208,6 @@ scan_one_fslmc_device(char *dev_name)
        dev->device.name = dev->name;
        dev->device.devargs = rte_bus_find_devargs(&rte_fslmc_bus, dev_name);
 
-       /* Update the device found into the device_count table */
-       fslmc_bus_device_count[dev->dev_type]++;
-
        /* Add device in the fslmc device list */
        insert_in_device_list(dev);
 
-- 
2.54.0

Reply via email to