Skip to contentSkip to conversation

Replace NULL thread handler with a dummy function.

PATCH In review junan 3 participants 3 messages Feb 28 IIO

lore
Share & tools
lore

junan

author
#0 lore raw

PATCH 1/1 Replace NULL thread handler with a dummy function.

Hi,

This is a similar problem as [1]:

[1] https://lore.kernel.org/linux-iio/[email protected]/T/#m15ab81856b42f72169fe51bd87fa399b5147441f

Since commit aef30c8d569c ("genirq: Warn about using IRQF_ONESHOT without a threaded handler"), the IRQ core checks IRQF_ONESHOT flag in IRQ request and gives a warning if there is no threaded handler.

There are two iio devices on my machine:

```
junan@fedora:~$ ls /sys/bus/iio/devices/
iio:device0  trigger0
junan@fedora:~$ cat /sys/bus/iio/devices/*/name
als
als-dev0
```

The function calling chain is as following:

hid_als_probe(hid-sensor-als.c)
=> hid_sensor_setup_trigger(hid-sensor-trigger.c)
=> iio_triggered_buffer_setup_ext(industrialio-triggered-buffer.c)

iio_triggered_buffer_setup_ext is called with a NULL thread handler, and the flag is set to IRQF_ONESHOT inside it. I am not sure which flag to change, so I replace the NULL pointer with a dummy function or can we just change the flag?

---
 drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +6 -1
index 5540e2d28f4a..ec251beeca92 100644
@@ -202,6 +202,11 @@ static void hid_sensor_set_power_work(struct work_struct *work)
 		_hid_sensor_power_state(attrb, true);
 }
 
+static irqreturn_t hid_sensor_dummy_handler(int irq, void *p)
+{
+	return IRQ_HANDLED;
+}
+
 static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
 						bool state)
 {
@@ -240,7 +245,7 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
 		fifo_attrs = NULL;
 
 	ret = iio_triggered_buffer_setup_ext(indio_dev,
-					     &iio_pollfunc_store_time, NULL,
+					     &iio_pollfunc_store_time, &hid_sensor_dummy_handler,
 					     IIO_BUFFER_DIRECTION_IN,
 					     NULL, fifo_attrs);
 	if (ret) {
Signature · 1 line
2.53.0
#1 lore raw
Quoted 6 lines · junan

Hi,

This is a similar problem as [1]:

[1] https://lore.kernel.org/linux-iio/[email protected]/T/#m15ab81856b42f72169fe51bd87fa399b5147441f

Make it a Link tag.

Quoted 4 lines

without a threaded handler"), the IRQ core checks IRQF_ONESHOT flag in IRQ request and gives a warning if there is no threaded handler.

There are two iio devices on my machine:

IIO

Quoted 10 lines
```
junan@fedora:~$ ls /sys/bus/iio/devices/
iio:device0  trigger0
junan@fedora:~$ cat /sys/bus/iio/devices/*/name
als
als-dev0
```

The function calling chain is as following:

Quoted 8 lines

hid_als_probe(hid-sensor-als.c)
=> hid_sensor_setup_trigger(hid-sensor-trigger.c)
=> iio_triggered_buffer_setup_ext(industrialio-triggered-buffer.c)

iio_triggered_buffer_setup_ext is called with a NULL thread handler, and the flag is set to IRQF_ONESHOT inside it.

I am not sure which flag to change, so I replace the NULL pointer with a dummy function or can we just change the flag?

Besides you used way too long lines, the last sentence (question) has to be located in the comment block...

Quoted 2 lines

---

...somewhere here.

And answering to it I think it's band-aid and wrong approach.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#2 lore raw
Quoted 3 lines · On Sat, 28 Feb 2026 12:15:51 +0200 Andy Shevchenko…
Quoted 2 lines · junan

Hi,

Hi.

One general comment is to follow the formating of patch titles used in the particular subsystem you are sending a patch to. So something like:

iio: hid-als: Provide a dummy thread handler to avoid warning.

Quoted 5 lines
Quoted 4 lines

This is a similar problem as [1]:

[1] https://lore.kernel.org/linux-iio/[email protected]/T/#m15ab81856b42f72169fe51bd87fa399b5147441f

https://lore.kernel.org/all/[email protected]/

Is perhaps more relevant here and the preferred approach. These sensors should in theory have never provided a trigger in the first place but we can't fix that now because of ABI issues. The approach used in Srinivas' set gets us to the position where the ABI remains the same but the underlying structure correctly doesn't use a trigger.

I haven't checked how Srinivas' approach would apply here though so I may well be missing something!
+CC Srinivas.

Quoted 24 lines

Make it a Link tag.

Quoted 4 lines

without a threaded handler"), the IRQ core checks IRQF_ONESHOT flag in IRQ request and gives a warning if there is no threaded handler.

There are two iio devices on my machine:

IIO

Quoted 15 lines
```
junan@fedora:~$ ls /sys/bus/iio/devices/
iio:device0  trigger0
junan@fedora:~$ cat /sys/bus/iio/devices/*/name
als
als-dev0
```

The function calling chain is as following:

hid_als_probe(hid-sensor-als.c)
=> hid_sensor_setup_trigger(hid-sensor-trigger.c)
=> iio_triggered_buffer_setup_ext(industrialio-triggered-buffer.c)

iio_triggered_buffer_setup_ext is called with a NULL thread handler, and the flag is set to IRQF_ONESHOT inside it.

It's not as though the top half is valid here either! This is a completely fake registration of an interrupt handler that never gets called.

Quoted 7 lines
Quoted 3 lines

I am not sure which flag to change, so I replace the NULL pointer with a dummy function or can we just change the flag?

Besides you used way too long lines, the last sentence (question) has to be located in the comment block...

Quoted 6 lines
Quoted 2 lines

---

...somewhere here.

And answering to it I think it's band-aid and wrong approach.

We need a bit of a band aid to avoid an ABI break, but the approach in Srinivas' patch for the main hid sensors support is cleaner than the one here.

Jonathan

Quoted 1 line