[PATCH v2 1/4] iio: gyro: mpu3050: Fix incorrect free_irq() variable

Ethan Tidmore posted 4 patches 1 month, 1 week ago
[PATCH v2 1/4] iio: gyro: mpu3050: Fix incorrect free_irq() variable
Posted by Ethan Tidmore 1 month, 1 week ago
The handler for the IRQ part of this driver is mpu3050->trig but,
in the teardown free_irq() is called with handler mpu3050:

	ret = request_threaded_irq(irq,
				   mpu3050_irq_handler,
				   mpu3050_irq_thread,
				   irq_trig,
				   mpu3050->trig->name,
				   mpu3050->trig);

...

void mpu3050_common_remove(struct device *dev)
{

...

	if (mpu3050->irq)
		free_irq(mpu3050->irq, mpu3050);
	iio_device_unregister(indio_dev);
	mpu3050_power_down(mpu3050);
}

Use correct IRQ handler when calling free_irq().

Fixes: 3904b28efb2c7 ("iio: gyro: Add driver for the MPU-3050 gyroscope")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 drivers/iio/gyro/mpu3050-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
index ee2fcd20545d..06162d886b59 100644
--- a/drivers/iio/gyro/mpu3050-core.c
+++ b/drivers/iio/gyro/mpu3050-core.c
@@ -1261,7 +1261,7 @@ void mpu3050_common_remove(struct device *dev)
 	pm_runtime_disable(dev);
 	iio_triggered_buffer_cleanup(indio_dev);
 	if (mpu3050->irq)
-		free_irq(mpu3050->irq, mpu3050);
+		free_irq(mpu3050->irq, mpu3050->trig);
 	iio_device_unregister(indio_dev);
 	mpu3050_power_down(mpu3050);
 }
-- 
2.53.0
Re: [PATCH v2 1/4] iio: gyro: mpu3050: Fix incorrect free_irq() variable
Posted by Andy Shevchenko 1 month, 1 week ago
On Mon, Feb 23, 2026 at 08:35:08PM -0600, Ethan Tidmore wrote:
> The handler for the IRQ part of this driver is mpu3050->trig but,
> in the teardown free_irq() is called with handler mpu3050:
> 
> 	ret = request_threaded_irq(irq,
> 				   mpu3050_irq_handler,
> 				   mpu3050_irq_thread,
> 				   irq_trig,
> 				   mpu3050->trig->name,
> 				   mpu3050->trig);

No need to cite the full snippet (we may easily open the file and read that),
it's enough to mention like

	request_threaded_irq(..., mpu3050->trig)

or just in free words without any code.

...

> void mpu3050_common_remove(struct device *dev)
> {
> 
> ...
> 
> 	if (mpu3050->irq)
> 		free_irq(mpu3050->irq, mpu3050);
> 	iio_device_unregister(indio_dev);
> 	mpu3050_power_down(mpu3050);
> }

Ditto.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2 1/4] iio: gyro: mpu3050: Fix incorrect free_irq() variable
Posted by Linus Walleij 1 month, 1 week ago
On Tue, Feb 24, 2026 at 3:35 AM Ethan Tidmore <ethantidmore06@gmail.com> wrote:

> The handler for the IRQ part of this driver is mpu3050->trig but,
> in the teardown free_irq() is called with handler mpu3050:
>
>         ret = request_threaded_irq(irq,
>                                    mpu3050_irq_handler,
>                                    mpu3050_irq_thread,
>                                    irq_trig,
>                                    mpu3050->trig->name,
>                                    mpu3050->trig);
>
> ...
>
> void mpu3050_common_remove(struct device *dev)
> {
>
> ...
>
>         if (mpu3050->irq)
>                 free_irq(mpu3050->irq, mpu3050);
>         iio_device_unregister(indio_dev);
>         mpu3050_power_down(mpu3050);
> }
>
> Use correct IRQ handler when calling free_irq().
>
> Fixes: 3904b28efb2c7 ("iio: gyro: Add driver for the MPU-3050 gyroscope")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>

Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij