From: Lars-Peter Clausen <lars@metafoo.de>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Jonathan Cameron <jic23@kernel.org>, <devel@driverdev.osuosl.org>,
<linux-iio@vger.kernel.org>, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH v2 5/6] staging:iio:events: Use non-atomic bitops
Date: Wed, 1 Feb 2012 19:45:55 +0100 [thread overview]
Message-ID: <1328121956-29596-6-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1328121956-29596-1-git-send-email-lars@metafoo.de>
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: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
---
Changes since v1:
* Fix typo in subject
---
drivers/staging/iio/industrialio-event.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/iio/industrialio-event.c b/drivers/staging/iio/industrialio-event.c
index 2e7cf88..14e505a 100644
--- a/drivers/staging/iio/industrialio-event.c
+++ b/drivers/staging/iio/industrialio-event.c
@@ -103,7 +103,7 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep)
struct iio_event_interface *ev_int = filep->private_data;
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,
* clear out any awaiting events. The mask will prevent
@@ -131,7 +131,7 @@ int iio_event_getfd(struct iio_dev *indio_dev)
return -ENODEV;
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);
return -EBUSY;
}
@@ -140,7 +140,7 @@ int iio_event_getfd(struct iio_dev *indio_dev)
&iio_event_chrdev_fileops, ev_int, O_RDONLY);
if (fd < 0) {
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);
}
return fd;
--
1.7.8.3
next prev parent reply other threads:[~2012-02-01 18:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-01 18:45 [PATCH v2 0/6] staging:iio: Event handling updates Lars-Peter Clausen
2012-02-01 18:45 ` [PATCH v2 1/6] staging:iio: Update iio_event_interface documentation Lars-Peter Clausen
2012-02-01 18:45 ` [PATCH v2 2/6] staging:iio: Factor out event handling into its own file Lars-Peter Clausen
2012-02-01 18:45 ` [PATCH v2 3/6] staging:iio:events: Use kfifo for event queue Lars-Peter Clausen
2012-02-01 18:45 ` [PATCH v2 4/6] staging:iio:events: Use waitqueue lock to protect " Lars-Peter Clausen
2012-02-01 18:45 ` Lars-Peter Clausen [this message]
2012-02-02 6:20 ` [PATCH v2 5/6] staging:iio:events: Use non-atomic bitops Dan Carpenter
2012-02-02 9:14 ` Lars-Peter Clausen
2012-02-02 11:19 ` Dan Carpenter
2012-02-02 11:49 ` Dan Carpenter
2012-02-02 14:15 ` J.I. Cameron
2012-02-01 18:45 ` [PATCH v2 6/6] staging:iio:events: Add poll support Lars-Peter Clausen
2012-02-01 19:49 ` [PATCH v2 0/6] staging:iio: Event handling updates Lars-Peter Clausen
2012-02-01 23:21 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2012-02-01 21:17 Lars-Peter Clausen
2012-02-01 21:17 ` [PATCH v2 5/6] staging:iio:events: Use non-atomic bitops Lars-Peter Clausen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1328121956-29596-6-git-send-email-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).