iio: adc: tsc2046: rework the trigger state machine
authorOleksij Rempel <o.rempel@pengutronix.de>
Tue, 11 Jan 2022 13:04:02 +0000 (14:04 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 23 Jan 2022 18:03:36 +0000 (18:03 +0000)
commit84e5d88953d765e5da14f96dd30b0b1cc215c157
treee35a2a986e627f4e91f2d7a196886c1eb9a65741
parent0f66edfb0722bc424c5d8300e5a938b1b7c5c78f
iio: adc: tsc2046: rework the trigger state machine

Initially this was designed to:
| Fix sleeping in atomic context warning and a deadlock after iio_trigger_poll()
| call
|
| If iio_trigger_poll() is called after IRQ was disabled, we will call
| reenable_trigger() directly from hard IRQ or hrtimer context instead of
| IRQ thread. In this case we will run in to multiple issue as sleeping in atomic
| context and a deadlock.
|
| To avoid this issue, rework the trigger to use state machine. All state
| changes are done over the hrtimer, so it allows us to drop fsleep() and
| avoid the deadlock.

Since this issue was fixed by: 9020ef659885 ("iio: trigger: Fix a scheduling
whilst atomic issue seen on tsc2046"). This patch is a cleanup to make
state machine easier to follow.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.kernel.org/r/20220111130402.3404769-1-o.rempel@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ti-tsc2046.c