From patchwork Tue Sep 26 15:41:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aastha Gupta X-Patchwork-Id: 9972291 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 3DC4360365 for ; Tue, 26 Sep 2017 15:41:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C3E228C44 for ; Tue, 26 Sep 2017 15:41:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F34D28A42; Tue, 26 Sep 2017 15:41:45 +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 AC6CC28A42 for ; Tue, 26 Sep 2017 15:41:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754194AbdIZPlo (ORCPT ); Tue, 26 Sep 2017 11:41:44 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:32839 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753160AbdIZPln (ORCPT ); Tue, 26 Sep 2017 11:41:43 -0400 Received: by mail-pg0-f66.google.com with SMTP id i130so6978127pgc.0 for ; Tue, 26 Sep 2017 08:41:43 -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=pUwXie9CIT/XOthT3Ma2zKAfjvodkEgASD7+owdJ9l0=; b=MSHD9cKCUVtx8Xn0kfjyHqVgVzNgclqQin1RNGrLbxyF/wywU8Gw2iImf1b2Zafzt4 vJq+RS1hSbDecWHkT8ycABxul89IKBkGlUkvTrEvz6e68XgFZ1a2dVa3yaqPQnCL1hy1 NbZWi7fNbxqPaD+MZx8k7QryVJRtbsOTEtALP5k0I4/NdzjcAwojwFLyW4XU50rB20h7 HgYxcds/mx/cxqfd4UzLakI8mP8Dj4Qb6F/tQ0e4Fw+QnwtOPYnfvnJxvEhLtmAyyBR7 6lwxUsPkY9wFJhc38m76PMXu2ariU5rkWKwm3ySBpRA4ylCWjh5pJaabfHZGAHo9A92h G3aw== 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=pUwXie9CIT/XOthT3Ma2zKAfjvodkEgASD7+owdJ9l0=; b=Yvl2pkx4PX7xOiHOaw5vnbdE8hUfu1Sochz2uTzyxBdpXqxA+qirUxRxiVf7UiOxff tRusM7Ba9S/9Ua2bj+YhXLgyB7Ut+lXG9LJAU/1Gfj6smv20KxXrLUH73sS6HaupzZun mHbBmlwf46zS5ub2K7fqI5Q164IsEiFV9fhZfkU02BQLKJME5xtrJoaRjtIZ258exflr q6IJf3X1+DncQIxqLP9vHg6p8uz7+i/+cYHBwQHWJaZhlcM7wQFqOuPJATh+nwgB56CW QsP/zSzcYg3C3LqRIA0BMPwnOoiIsb8PiZwhJVUshupPWm/eInfwoJclA6hpBqc+vVUJ HSLQ== X-Gm-Message-State: AHPjjUhKf7lhQRaGycfrX3dLKEDll+TcoArQGKRWBYNKPZcUfs4bvpxc DSIlY6eSRlyQq95Mc6B1RvY= X-Google-Smtp-Source: AOwi7QAxRUR2diQvLKtOi/CuKtFd344gSsPOp8zGLj1V3E50FtZaxcdFaY7seXThtRNXNmYMYdNPIw== X-Received: by 10.101.91.134 with SMTP id i6mr11331918pgr.428.1506440502818; Tue, 26 Sep 2017 08:41:42 -0700 (PDT) Received: from aastha-HP-Pavilion-15-Notebook-PC ([47.31.6.55]) by smtp.gmail.com with ESMTPSA id 126sm16058626pgd.17.2017.09.26.08.41.41 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 08:41:42 -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 1/2] staging: iio: adc: ad7192: Replace mlock with driver private lock Date: Tue, 26 Sep 2017 21:11:07 +0530 Message-Id: <1506440468-5081-2-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, mlock was being used to protect hardware state changes. Replace it with a lock in the devices global data. Signed-off-by: Aastha Gupta --- drivers/staging/iio/adc/ad7192.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index d11c6de..096d29d 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -162,6 +162,7 @@ struct ad7192_state { u32 scale_avail[8][2]; u8 gpocon; u8 devid; + struct mutex lock; struct ad_sigma_delta sd; }; @@ -463,10 +464,10 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: switch (chan->type) { case IIO_VOLTAGE: - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); *val = st->scale_avail[AD7192_CONF_GAIN(st->conf)][0]; *val2 = st->scale_avail[AD7192_CONF_GAIN(st->conf)][1]; - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return IIO_VAL_INT_PLUS_NANO; case IIO_TEMP: *val = 0; @@ -634,6 +635,8 @@ static int ad7192_probe(struct spi_device *spi) st = iio_priv(indio_dev); + mutex_init(&st->lock); + st->avdd = devm_regulator_get(&spi->dev, "avdd"); if (IS_ERR(st->avdd)) return PTR_ERR(st->avdd);