aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/industrialio-core.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-09-18 16:02:00 -0400
committerJonathan Cameron <jic23@kernel.org>2013-09-21 07:45:07 -0400
commitcadc2125e140f7122bf1b59d42486cfc778c7286 (patch)
tree9f4bffd9518d76850a981c877599cc1339de2b0e /drivers/iio/industrialio-core.c
parenta87c82e454f184a9473f8cdfd4d304205f585f65 (diff)
iio: fix: Keep a reference to the IIO device for open file descriptors
Make sure that the IIO device is not freed while we still have file descriptors for it. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/industrialio-core.c')
-rw-r--r--drivers/iio/industrialio-core.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 2cc0778a7328..8f7b6c9f92dc 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -970,6 +970,8 @@ static int iio_chrdev_open(struct inode *inode, struct file *filp)
970 if (test_and_set_bit(IIO_BUSY_BIT_POS, &indio_dev->flags)) 970 if (test_and_set_bit(IIO_BUSY_BIT_POS, &indio_dev->flags))
971 return -EBUSY; 971 return -EBUSY;
972 972
973 iio_device_get(indio_dev);
974
973 filp->private_data = indio_dev; 975 filp->private_data = indio_dev;
974 976
975 return 0; 977 return 0;
@@ -983,6 +985,8 @@ static int iio_chrdev_release(struct inode *inode, struct file *filp)
983 struct iio_dev *indio_dev = container_of(inode->i_cdev, 985 struct iio_dev *indio_dev = container_of(inode->i_cdev,
984 struct iio_dev, chrdev); 986 struct iio_dev, chrdev);
985 clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags); 987 clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);
988 iio_device_put(indio_dev);
989
986 return 0; 990 return 0;
987} 991}
988 992