aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/iio
diff options
context:
space:
mode:
authorDmitry Rokosov <DDRokosov@sberdevices.ru>2022-06-07 18:39:18 +0000
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2022-06-18 14:26:17 +0100
commit4a08069461ac9822855116d24fbf11d5fb223cd1 (patch)
tree94ebd37612bc3f5f4f828bdad2215e0b3b2ff2ff /include/linux/iio
parentMerge branch 'immutable-qcom-spmi-rradc' into togreg (diff)
downloadwireguard-linux-4a08069461ac9822855116d24fbf11d5fb223cd1.tar.xz
wireguard-linux-4a08069461ac9822855116d24fbf11d5fb223cd1.zip
iio: trigger: warn about non-registered iio trigger getting attempt
As a part of patch series about wrong trigger register() and get() calls order in the some IIO drivers trigger initialization path: https://lore.kernel.org/all/20220524181150.9240-1-ddrokosov@sberdevices.ru/ runtime WARN_ONCE() is added to alarm IIO driver authors who make such a mistake. When an IIO driver allocates a new IIO trigger, it should register it before calling the get() operation. In other words, each IIO driver must abide by IIO trigger alloc()/register()/get() calls order. Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru> Link: https://lore.kernel.org/r/20220607183907.20017-1-ddrokosov@sberdevices.ru Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'include/linux/iio')
-rw-r--r--include/linux/iio/trigger.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
index 4c69b144677b..03b1d6863436 100644
--- a/include/linux/iio/trigger.h
+++ b/include/linux/iio/trigger.h
@@ -93,6 +93,11 @@ static inline void iio_trigger_put(struct iio_trigger *trig)
static inline struct iio_trigger *iio_trigger_get(struct iio_trigger *trig)
{
get_device(&trig->dev);
+
+ WARN_ONCE(list_empty(&trig->list),
+ "Getting non-registered iio trigger %s is prohibited\n",
+ trig->name);
+
__module_get(trig->owner);
return trig;