This is to do with dynamically allocated triggers and the need to ensure
the underlying structures don't go away when a consumer is using them.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  */
 
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/idr.h>
 #include <linux/err.h>
 #include <linux/device.h>
                                          IRQ_NOPROBE);
                }
                iio_get();
+               get_device(&trig->dev);
        }
        return trig;
 }
 
 int iio_device_unregister_trigger_consumer(struct iio_dev *dev_info)
 {
+       /* Clean up and associated but not attached triggers references */
+       if (dev_info->trig)
+               iio_put_trigger(dev_info->trig);
        sysfs_remove_group(&dev_info->dev.kobj,
                           &iio_trigger_consumer_attr_group);
        return 0;