Merge tag 'iio-fixes-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / drivers / iio / trigger / iio-trig-sysfs.c
index 2a4b758..d6c5e96 100644 (file)
@@ -176,21 +176,21 @@ out1:
 
 static int iio_sysfs_trigger_remove(int id)
 {
-       bool foundit = false;
-       struct iio_sysfs_trig *t;
+       struct iio_sysfs_trig *t = NULL, *iter;
 
        mutex_lock(&iio_sysfs_trig_list_mut);
-       list_for_each_entry(t, &iio_sysfs_trig_list, l)
-               if (id == t->id) {
-                       foundit = true;
+       list_for_each_entry(iter, &iio_sysfs_trig_list, l)
+               if (id == iter->id) {
+                       t = iter;
                        break;
                }
-       if (!foundit) {
+       if (!t) {
                mutex_unlock(&iio_sysfs_trig_list_mut);
                return -EINVAL;
        }
 
        iio_trigger_unregister(t->trig);
+       irq_work_sync(&t->work);
        iio_trigger_free(t->trig);
 
        list_del(&t->l);