From patchwork Tue Sep 26 15:41:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aastha Gupta X-Patchwork-Id: 9972293 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 E4A0160365 for ; Tue, 26 Sep 2017 15:41:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2E5328A42 for ; Tue, 26 Sep 2017 15:41:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6F0228C48; Tue, 26 Sep 2017 15:41:54 +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 6B35E28A42 for ; Tue, 26 Sep 2017 15:41:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754407AbdIZPly (ORCPT ); Tue, 26 Sep 2017 11:41:54 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:38854 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753160AbdIZPlx (ORCPT ); Tue, 26 Sep 2017 11:41:53 -0400 Received: by mail-pg0-f68.google.com with SMTP id m30so6981604pgn.5 for ; Tue, 26 Sep 2017 08:41:53 -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=LL3/9oMVC9LA/aMoiCvIGPAHyuMV9cP0IX5x13sOmu0=; b=d4kD4AHt42uHYeVl8LO8ToZ2G5hQJSwh9LCJflIvY57GaYytA78/RjHwIH8K8QmZ7A Qvy7/ZzdS5l1TSivUYWyCEmoY6d/siPWEi01mWKyPEvMKNu8TOu0Rc8qPV/XXR+b3NoD GdACqiS8HrXMYLw/FiyKNi5oiUDRZxpSE6Qapjkem/ruh+jwFDMdP3JGe5cYZBf2FEXG +7+yWQji9PSJkHH0OE00e2dNti8D5PHJZweYBks6xI9lK55SPx21acYJdXgqUATCM/1q ua3390BCE7Dk5UkGl5z/m8371CNTza5g97K+oHG/ECRhgluKZB7zA7jVEUynpQNAqCKt ASfQ== 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=LL3/9oMVC9LA/aMoiCvIGPAHyuMV9cP0IX5x13sOmu0=; b=JPkOHVyzwOAsh3nl1MI+qtIDKfqIzMURj9dvgV6+pD3yauBVFOzVYlTkMz18lpwXll dTqRskLK04dKy0P5lihvam0dZjFR7z9BekXXJjEarxqf/zBvtOlIdjyqMC8XZZUjNPdi xZcZM7PS7OSiiPoBFTc9349aMtMAIpResT5S8NNsJnoMC1p8N0i4hP1QZ7RCzLXNisB6 LxiNF8gDViIa7LvhB5n6Y9ObrVdLDYHw1DdWJFLDkzU7JOrUXcIZxxOa0jYvZYgyMrcN tD61JnzQsYFsBRFRvGsC82CL7qg+cMEK1YRlXiCoDCclYpix3sWy6AyAyF+BvC/9J0YY UspQ== X-Gm-Message-State: AHPjjUjbo6sbWVVFTqgbH5AwSOcMulmvMhkdyHpojdqPtjfcFzL32JZE tiNyeiHoCBIDElp5MX613JM= X-Google-Smtp-Source: AOwi7QCpfdAakP/1bZdf2yVnNkrUBnEdXsJCa1GKxhYQzn1XbCuAOAwvqodxeuKNqiyDiZboYWtNQg== X-Received: by 10.99.109.142 with SMTP id i136mr11358225pgc.353.1506440511391; Tue, 26 Sep 2017 08:41:51 -0700 (PDT) Received: from aastha-HP-Pavilion-15-Notebook-PC ([47.31.3.154]) by smtp.gmail.com with ESMTPSA id m15sm14890370pfh.35.2017.09.26.08.41.49 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 08:41:50 -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 v2 2/2] staging: iio: adc: ad7192: add lock to protect hardware state changes Date: Tue, 26 Sep 2017 21:11:08 +0530 Message-Id: <1506440468-5081-3-git-send-email-aastha.gupta4104@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506440468-5081-1-git-send-email-aastha.gupta4104@gmail.com> References: <1506440468-5081-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 The IIO subsystem is redefining iio_dev->mlock to be used by the IIO core only for protecting device operating mode changes. ie. Changes between INDIO_DIRECT_MODE, INDIO_BUFFER_* modes. In this driver, private driver lock is being used to protect hardware state changes as here state variables are being changed. 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) {