spi: mpc52xx: clean up interrupt handling

The driver is relying on the assumption that the invalid interrupt 0 can
be freed without any side effects, but that is not the case on
architectures like x86 where it would trigger a warning about freeing an
already free interrupt.

This should not cause any trouble on powerpc where this driver is used,
but make the code more portable (and obviously correct) by making sure
that the interrupts have been requested before freeing them.

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260423075801.2252318-1-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Johan Hovold 2026-04-23 09:58:01 +02:00 committed by Mark Brown
parent 254f49634e
commit 76645c1fd6
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -472,13 +472,15 @@ static int mpc52xx_spi_probe(struct platform_device *op)
if (ms->irq0 && ms->irq1) {
rc = request_irq(ms->irq0, mpc52xx_spi_irq, 0,
"mpc5200-spi-modf", ms);
rc |= request_irq(ms->irq1, mpc52xx_spi_irq, 0,
"mpc5200-spi-spif", ms);
if (rc) {
free_irq(ms->irq0, ms);
free_irq(ms->irq1, ms);
ms->irq0 = ms->irq1 = 0;
if (rc == 0) {
rc = request_irq(ms->irq1, mpc52xx_spi_irq, 0,
"mpc5200-spi-spif", ms);
if (rc)
free_irq(ms->irq0, ms);
}
if (rc)
ms->irq0 = ms->irq1 = 0;
} else {
/* operate in polled mode */
ms->irq0 = ms->irq1 = 0;
@ -498,8 +500,10 @@ static int mpc52xx_spi_probe(struct platform_device *op)
err_register:
dev_err(&ms->host->dev, "initialization failed\n");
free_irq(ms->irq0, ms);
free_irq(ms->irq1, ms);
if (ms->irq0) {
free_irq(ms->irq0, ms);
free_irq(ms->irq1, ms);
}
cancel_work_sync(&ms->work);
err_gpio:
while (i-- > 0)
@ -522,8 +526,10 @@ static void mpc52xx_spi_remove(struct platform_device *op)
spi_unregister_controller(host);
free_irq(ms->irq0, ms);
free_irq(ms->irq1, ms);
if (ms->irq0) {
free_irq(ms->irq0, ms);
free_irq(ms->irq1, ms);
}
cancel_work_sync(&ms->work);