I have seen in mmc driver the function devm_request_threaded_irq
used to launch sdhci_msm_pwr_irq
like following :
ret = devm_request_threaded_irq(&pdev->dev, msm_host->pwr_irq, NULL,
sdhci_msm_pwr_irq, IRQF_ONESHOT,
dev_name(&pdev->dev), host);
But when I call rmmod
I have not seen an release or stop of this irq thread. Can you explain me how this thread works ?
Removal of the sdhci-msm
module results in the module's module_exit
handler function being called, which will call platform_device_unregister
to unregister itself as a platform device driver. (Most of that is hidden by the macro call module_platform_driver(sdhci_msm_driver);
in "drivers/mmc/host/sdhci-msm.c".)
When the platform driver is unregistered, all devices that were successfully probed will be removed automatically. The driver's "remove" handler sdhci_msm_remove
will be called automatically for each successfully probed device.
So you may be wondering why sdhci_msm_remove
doesn't free the interrupt allocated by the devm_request_threaded_irq
call in the "probe" function sdhci_msm_probe
? The answer is that it doesn't need to because the interrupt was allocated as a "managed device resource" (see below).
devm_request_threaded_irq
is a "device resource managed" ("devres") wrapper around the request_threaded_irq
function. Any devres-managed resources get cleaned up automatically when the probed device is being removed. (The clean-up of devres-managed resources happens after the "remove" handler returns.) For devres-managed interrupt resources, the clean-up results in the free_irq
function being called automatically to free the interrupt.