Commit a046c1e8 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Greg Kroah-Hartman

staging:iio:events: Use non-atmoic bitops

We always hold the waitqueue lock when modifying the flags field. So it is safe
to use the non-atomic bitops here instead of the atomic versions.

The lock has to be held, because we need to clear the busy flag and flush the
event FIFO in one atomic operation when closing the event file descriptor.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Acked-by: default avatarJonathan Cameron <jic23@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e18045ed
...@@ -124,7 +124,7 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep) ...@@ -124,7 +124,7 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep)
struct iio_event_interface *ev_int = filep->private_data; struct iio_event_interface *ev_int = filep->private_data;
spin_lock(&ev_int->wait.lock); spin_lock(&ev_int->wait.lock);
clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags);
/* /*
* In order to maintain a clean state for reopening, * In order to maintain a clean state for reopening,
* clear out any awaiting events. The mask will prevent * clear out any awaiting events. The mask will prevent
...@@ -153,7 +153,7 @@ int iio_event_getfd(struct iio_dev *indio_dev) ...@@ -153,7 +153,7 @@ int iio_event_getfd(struct iio_dev *indio_dev)
return -ENODEV; return -ENODEV;
spin_lock(&ev_int->wait.lock); spin_lock(&ev_int->wait.lock);
if (test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) { if (__test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) {
spin_unlock(&ev_int->wait.lock); spin_unlock(&ev_int->wait.lock);
return -EBUSY; return -EBUSY;
} }
...@@ -162,7 +162,7 @@ int iio_event_getfd(struct iio_dev *indio_dev) ...@@ -162,7 +162,7 @@ int iio_event_getfd(struct iio_dev *indio_dev)
&iio_event_chrdev_fileops, ev_int, O_RDONLY); &iio_event_chrdev_fileops, ev_int, O_RDONLY);
if (fd < 0) { if (fd < 0) {
spin_lock(&ev_int->wait.lock); spin_lock(&ev_int->wait.lock);
clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags);
spin_unlock(&ev_int->wait.lock); spin_unlock(&ev_int->wait.lock);
} }
return fd; return fd;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment