Linux of_platform_depopulate() does not remove drivers

30 Views Asked by At

I have a MFD driver that is populating child nodes from the device tree using of_platform_default_populate(). I am using this function instead of devm_of_platform_populate() because it uses of_default_bus_match_table that includes simple-bus.

It works well, but when calling of_platform_depopulate() the child driver is not unloaded. The child driver is a platform driver with the initialization code provided below. I can see in the log that calling of_platform_default_populate() results in cca_dma_remove() function being executed, because "DMA driver removed" is present in dmesg. Yet lsmod still shows the driver being loaded. Do I need to do anything extra to get the driver totally removed? rmmod cca_dma works without any issues.

static const struct of_device_id cca_dma_of_ids[] = {
    { .compatible = "cca,dma" },
    {}
};
MODULE_DEVICE_TABLE(of, cca_dma_of_ids);

static int cca_dma_remove(struct platform_device *pdev)
{
    pr_info("DMA driver removed\n");
    return 0;
}

static struct platform_driver cca_dma_driver = {
    .driver = {
        .name = DEVICE_NAME,
        .of_match_table = cca_dma_of_ids,
    },
    .probe = cca_dma_probe,
    .remove = cca_dma_remove,
};
module_platform_driver(cca_dma_driver);

I am using Linux kernel v5.15.32.

0

There are 0 best solutions below