All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aastha Gupta <aastha.gupta4104@gmail.com>
To: outreachy-kernel@googlegroups.com,
	hennerich@blackfin.uclinux.org, jic23@kernel.org,
	knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
	linux-iio@vger.kernel.org
Cc: Aastha Gupta <aastha.gupta4104@gmail.com>
Subject: [PATCH 2/2] staging: iio: adc: ad7192: add lock to protect hardware state changes
Date: Tue, 26 Sep 2017 20:28:37 +0530	[thread overview]
Message-ID: <1506437917-7219-3-git-send-email-aastha.gupta4104@gmail.com> (raw)
In-Reply-To: <1506437917-7219-1-git-send-email-aastha.gupta4104@gmail.com>

In this driver, private driver lock is being used to protect hardware
state changes.

Signed-off-by: Aastha Gupta <aastha.gupta4104@gmail.com>
---
 drivers/staging/iio/adc/ad7192.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index 096d29d..609a649 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -511,6 +511,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev,
 	switch (mask) {
 	case IIO_CHAN_INFO_SCALE:
 		ret = -EINVAL;
+		mutex_lock(&st->lock);
 		for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++)
 			if (val2 == st->scale_avail[i][1]) {
 				ret = 0;
@@ -524,6 +525,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev,
 				ad7192_calibrate_all(st);
 				break;
 			}
+		mutex_unlock(&st->lock);
 		break;
 	case IIO_CHAN_INFO_SAMP_FREQ:
 		if (!val) {
-- 
2.7.4



  parent reply	other threads:[~2017-09-26 14:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-26 14:58 [PATCH 0/2] staging: iio: adc: ad7192: use private driver lock to protect hardware changes Aastha Gupta
2017-09-26 14:58 ` [PATCH 1/2] staging: iio: adc: ad7192: Replace mlock with driver private lock Aastha Gupta
2017-09-26 15:16   ` [Outreachy kernel] " Julia Lawall
2017-09-26 14:58 ` Aastha Gupta [this message]
2017-09-26 15:17   ` [Outreachy kernel] [PATCH 2/2] staging: iio: adc: ad7192: add lock to protect hardware state changes Julia Lawall

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=1506437917-7219-3-git-send-email-aastha.gupta4104@gmail.com \
    --to=aastha.gupta4104@gmail.com \
    --cc=hennerich@blackfin.uclinux.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=outreachy-kernel@googlegroups.com \
    --cc=pmeerw@pmeerw.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.