[PATCH 8/9] mfd: ezx-pcap: Avoid rescheduling after destroying workqueue
Krzysztof Kozlowski
krzysztof.kozlowski at oss.qualcomm.com
Sun Feb 22 23:27:36 PST 2026
Driver allocates workqueue and then registers additional interrupt
handler with devm interface. This means that device removal will not
use a reversed order, but first destroy workqueue and then, via devm
release handlers, free the interrupt.
The interrupt handler registered with devm does not directly
use/schedule work items on the workqueue and the remove() function
correctly removes other IRQs handlers, however the code mixing devm and
non-devm interfaces is difficult to analyze and read.
Make the code flow much more obvious by using devm interface for
allocating the workqueue, so it will be freed with the rest of devm
resources.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski at oss.qualcomm.com>
---
Depends on devm_create_singlethread_workqueue() from earlier patches.
---
drivers/mfd/ezx-pcap.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c
index b929559d84ae..a06fc3447104 100644
--- a/drivers/mfd/ezx-pcap.c
+++ b/drivers/mfd/ezx-pcap.c
@@ -375,8 +375,6 @@ static void ezx_pcap_remove(struct spi_device *spi)
/* cleanup irqchip */
for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++)
irq_set_chip_and_handler(i, NULL, NULL);
-
- destroy_workqueue(pcap->workqueue);
}
static int ezx_pcap_probe(struct spi_device *spi)
@@ -411,7 +409,7 @@ static int ezx_pcap_probe(struct spi_device *spi)
/* setup irq */
pcap->irq_base = pdata->irq_base;
- pcap->workqueue = create_singlethread_workqueue("pcapd");
+ pcap->workqueue = devm_create_singlethread_workqueue(&spi->dev, "pcapd");
if (!pcap->workqueue)
return -ENOMEM;
@@ -463,9 +461,7 @@ static int ezx_pcap_probe(struct spi_device *spi)
free_irqchip:
for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++)
irq_set_chip_and_handler(i, NULL, NULL);
-/* destroy_workqueue: */
- destroy_workqueue(pcap->workqueue);
-ret:
+
return ret;
}
--
2.51.0
More information about the linux-arm-kernel
mailing list