staging:iio:sysfs-trigger: Use irq_work to properly active trigger
authorLars-Peter Clausen <lars@metafoo.de>
Thu, 6 Sep 2012 09:05:00 +0000 (10:05 +0100)
committerJonathan Cameron <jic23@kernel.org>
Thu, 6 Sep 2012 21:00:28 +0000 (22:00 +0100)
commitf38bc926d022ebd67baad6ac7fc22c95fbc6238c
tree807902c14117a60e161adec48ee00dd8c0e74cb6
parented5514c925a0e1266e70630092a77bd0c89aee1f
staging:iio:sysfs-trigger: Use irq_work to properly active trigger

Since iio_trigger_poll() calls generic_handle_irq() it need to be called from
hardirq context. The sysfs trigger is kicked from userspace, so it is obviously
not possible to fulfill this requirement by calling iio_trigger_poll directly.
As a workaround commit 1f785681 ("staging:iio:trigger sysfs userspace trigger
rework.") added iio_trigger_poll_chained() which uses handle_nested_irq instead
of generic_handle_irq. This in itself is a hack and only works by chance.
handle_nested_irq is intended to be called from the threaded interrupt handler
of the parent IRQ. Using handle_nested_irq is also problematic since it will
only call the threaded handler of the IRQ. But quite a few IIO drivers rely on
their hardirq handler being called or undefined behaviour will occur.

This patch uses the irq_work framework to schedule the call to
iio_trigger_poll() from hardirq context, which fixes the issues described above.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/trigger/Kconfig
drivers/staging/iio/trigger/iio-trig-sysfs.c