From patchwork Tue Sep 26 14:58:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aastha Gupta X-Patchwork-Id: 9972267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6EB4560365 for ; Tue, 26 Sep 2017 14:59:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 639622894B for ; Tue, 26 Sep 2017 14:59:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5871628BCD; Tue, 26 Sep 2017 14:59:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03C182894B for ; Tue, 26 Sep 2017 14:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031159AbdIZO7Q (ORCPT ); Tue, 26 Sep 2017 10:59:16 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:34292 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031141AbdIZO7P (ORCPT ); Tue, 26 Sep 2017 10:59:15 -0400 Received: by mail-pg0-f68.google.com with SMTP id u18so6926659pgo.1 for ; Tue, 26 Sep 2017 07:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T82mtHC7RXq7EU3nP3/cAckcvqC+AZLWrj+aUueutig=; b=tK1xUHmT1z8fokeHape2OpmvpL2mDIsmSk1k37LWSRiTc72nu5I2rrt+lRBbb9M4eP 3XfKGTDfILQnF0hSwVn1CgeQzOID0sJtgEGFSggG/inkSBOeiNp3TKuZ2NkLE4Zjik/B UA7mySqg1U18HcBF5v3PV091dlecrjsf2gjTL8gDhHQM0GGBrzHEV/qT9urLWTsQtpOv Y9Rc3h+puecBlugPNZ9g2t3qF8r+6IDv5u0mhCwwcPl/Lh+AVcLD/TaYG0uJK2WSVR95 5mq4DL7jo0gF0yofdthqIVk2VRU+rH+32fYygvdTWx+DPPx1766wjZBIVIhnvO12MOW7 dDPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=T82mtHC7RXq7EU3nP3/cAckcvqC+AZLWrj+aUueutig=; b=rK1wzEhI5C41r4L2K8Oo60NstPy8PrxlPI6VtrlD3cxcN3sThNRnxl3pMTqXR2UGsB NrFgo6N7Mqo+AY8KWc6fW99qv/5AejmoDKy1Ggho8lcDKT/XLLlFVAPZM+foc/hBFMRq QzuK9IGQVU+f0ELyMiJWriLP+sPNdReN5XyZAPYFLVT/DqzbsDLldyQgJIlqH6Tw4+/K nT5g40GEvcRETuen9Ae4R/jEf9J7gsQsMmTKAh6mZm/06F2Ohy2ZpT8kc37Q30PUbuxS SOd62pBGGSKp7mzQrCErCWHeCAWST4rBy6/xOjdk46eM3FJI+KyQA7ZXGWky173mpGPZ Po0g== X-Gm-Message-State: AHPjjUiWaguVL+N3fV8Fy4RFy8bYpkF+NBQpAi2Do+dV65BQ3iG5Qkmt sLsUseZtu2+SzyNLwZeI91Q= X-Google-Smtp-Source: AOwi7QAFko1K7MIJ8plWxxgTLQjqe5CW0wlcKNDeinLMbFMfH/iBDvd3HW4B2Xj+BDy/ebTTD57ijw== X-Received: by 10.98.141.138 with SMTP id p10mr1012698pfk.283.1506437954731; Tue, 26 Sep 2017 07:59:14 -0700 (PDT) Received: from aastha-HP-Pavilion-15-Notebook-PC ([47.31.3.154]) by smtp.gmail.com with ESMTPSA id w12sm19148064pfk.83.2017.09.26.07.59.12 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 07:59:14 -0700 (PDT) From: Aastha Gupta 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 Subject: [PATCH 2/2] staging: iio: adc: ad7192: add lock to protect hardware state changes Date: Tue, 26 Sep 2017 20:28:37 +0530 Message-Id: <1506437917-7219-3-git-send-email-aastha.gupta4104@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506437917-7219-1-git-send-email-aastha.gupta4104@gmail.com> References: <1506437917-7219-1-git-send-email-aastha.gupta4104@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In this driver, private driver lock is being used to protect hardware state changes. Signed-off-by: Aastha Gupta --- 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) {