From patchwork Tue Sep 26 14:58:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aastha Gupta X-Patchwork-Id: 9972265 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 A125160365 for ; Tue, 26 Sep 2017 14:59:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9588D2894B for ; Tue, 26 Sep 2017 14:59:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A5E728BCD; Tue, 26 Sep 2017 14:59:07 +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 2EC872894B for ; Tue, 26 Sep 2017 14:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031158AbdIZO7G (ORCPT ); Tue, 26 Sep 2017 10:59:06 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35509 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031141AbdIZO7F (ORCPT ); Tue, 26 Sep 2017 10:59:05 -0400 Received: by mail-pg0-f67.google.com with SMTP id j16so6918389pga.2 for ; Tue, 26 Sep 2017 07:59:05 -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=MGRVxhyQZLDAsI3xNgMyn0mbObdQw9uOfytryYaBF0o=; b=Wr9f1SpbtojvfNtgPYzG17WgH56WYoMsQp1OgEeuBbsV66/12AVWIg2ZL5Nrpqk8c7 AdNbG7ecyAzSzAaMuB/+8Wz/vAjRrucy+44EeVKZ+U7cxLOIrl/lOS2o+mYlugQ6ye4Z kIbGQOLIPJ/OSrQz2MO5+/m6gPszPCSGGS+rpkS70L2tcsvNPx8Je7Ea2v+zeHouWkK1 YD0XQX09BmBf6m7Nb4vzVERg+DjxjuQb6xoWMuSY+4EE/myJqXQp3ufFDXRzvNpbw1jI xh2OMkwXpIqHLiN5XChPfRVvPv2KATyGKBVJRI/ytK+Bo85HczGF/6S889GAwyyf3H/Z h3LQ== 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=MGRVxhyQZLDAsI3xNgMyn0mbObdQw9uOfytryYaBF0o=; b=VDpnVya971ThMWrm1U9rGw/FTwxvC2cBTfxH3+oNCeMOnQnASVc4/88t5a6bM+Jvgp agVOL1wZnq3RgjsLtwOpO0MqpmcarryWhS4a7pcaU9yCK5qgbUQcygFfEOHlwitBjTEp 28b9SpYygeKR8Q+4c/wDWmpmgOXkhHPZc2HOg7UeovUF7JY7NcKZ0RqaufXdaWmmqmox XRT1FqwkY4aWgRXOR0s4rfAZFyA4cjFhIAskFNQ2D9cHv/uK642Nqrqs3D5HAXyQtrsU Yeo0RN4HxivC1kGZoSrbBydOWaRu0fUzYK05t5hBCCAM8BqC+63rKD4owH8rB04wBzqp 5DLA== X-Gm-Message-State: AHPjjUhifsbCEV9PikULbyU4H6O5i+J41WQ+CbC4mY6bxYvhOyOYku7v tzDA/lw1ZXhnEkHs/uRY3W8= X-Google-Smtp-Source: AOwi7QBRMSheZmMqv722PVEkd8eUuiDnM4Jvl+Z9pZYnYtOgQ0STyXybxODthLce9TSUd64byOn1eQ== X-Received: by 10.84.129.226 with SMTP id b89mr10695719plb.6.1506437945414; Tue, 26 Sep 2017 07:59:05 -0700 (PDT) Received: from aastha-HP-Pavilion-15-Notebook-PC ([47.31.6.55]) by smtp.gmail.com with ESMTPSA id q67sm18356740pfg.160.2017.09.26.07.59.04 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 07:59:04 -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 1/2] staging: iio: adc: ad7192: Replace mlock with driver private lock Date: Tue, 26 Sep 2017 20:28:36 +0530 Message-Id: <1506437917-7219-2-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, 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);