linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Ranostay <mranostay@gmail.com>
To: linux-iio@vger.kernel.org
Cc: jic23@kernel.org, Matt Ranostay <mranostay@gmail.com>
Subject: [PATCH] iio: chemical: ams-iaq-core: remove mutex and replace with iio_device_*_direct_mode helpers
Date: Tue, 23 Aug 2016 21:32:39 -0700	[thread overview]
Message-ID: <1472013159-9903-1-git-send-email-mranostay@gmail.com> (raw)

Using a separate mutex doesn't make sense with the
iio_device_*_direct_mode helpers that use the indio_dev->mlock mutex
that already exists.

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
---
 drivers/iio/chemical/ams-iaq-core.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/chemical/ams-iaq-core.c b/drivers/iio/chemical/ams-iaq-core.c
index 41a8e6f2e31d..4dd5a4db6a75 100644
--- a/drivers/iio/chemical/ams-iaq-core.c
+++ b/drivers/iio/chemical/ams-iaq-core.c
@@ -36,7 +36,6 @@ struct ams_iaqcore_reading {
 
 struct ams_iaqcore_data {
 	struct i2c_client *client;
-	struct mutex lock;
 	unsigned long last_update;
 
 	struct ams_iaqcore_reading buffer;
@@ -108,7 +107,10 @@ static int ams_iaqcore_read_raw(struct iio_dev *indio_dev,
 	if (mask != IIO_CHAN_INFO_PROCESSED)
 		return -EINVAL;
 
-	mutex_lock(&data->lock);
+	ret = iio_device_claim_direct_mode(indio_dev);
+	if (ret)
+		return ret;
+
 	ret = ams_iaqcore_get_measurement(data);
 
 	if (ret)
@@ -134,7 +136,7 @@ static int ams_iaqcore_read_raw(struct iio_dev *indio_dev,
 	}
 
 err_out:
-	mutex_unlock(&data->lock);
+	iio_device_release_direct_mode(indio_dev);
 
 	return ret;
 }
@@ -160,7 +162,6 @@ static int ams_iaqcore_probe(struct i2c_client *client,
 
 	/* so initial reading will complete */
 	data->last_update = jiffies - HZ;
-	mutex_init(&data->lock);
 
 	indio_dev->dev.parent = &client->dev;
 	indio_dev->info = &ams_iaqcore_info,
-- 
2.7.4


             reply	other threads:[~2016-08-24  4:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24  4:32 Matt Ranostay [this message]
2016-08-29 16:07 ` [PATCH] iio: chemical: ams-iaq-core: remove mutex and replace with iio_device_*_direct_mode helpers Jonathan Cameron

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=1472013159-9903-1-git-send-email-mranostay@gmail.com \
    --to=mranostay@gmail.com \
    --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).