From patchwork Mon Sep 18 06:59:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshi Jain X-Patchwork-Id: 9955575 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 7AC8260208 for ; Mon, 18 Sep 2017 07:00:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B71A2885D for ; Mon, 18 Sep 2017 07:00:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6035B28B71; Mon, 18 Sep 2017 07:00:52 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 E708828BA0 for ; Mon, 18 Sep 2017 07:00:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752408AbdIRHAE (ORCPT ); Mon, 18 Sep 2017 03:00:04 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:36141 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752038AbdIRHAD (ORCPT ); Mon, 18 Sep 2017 03:00:03 -0400 Received: by mail-it0-f68.google.com with SMTP id e134so4356383ite.3 for ; Mon, 18 Sep 2017 00:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=xFLzYzFE1YyAKQXylhfyyOmRHfVrp9hrhj3/sGeqPyc=; b=FWhm1iKbE/sPauGPb+AtxIyTaZ63wVWHp6cttTMb3CVZlOhz+1iSfbkiaeU+AdSQql ZDdj/tjmgXT7p500TkYCKGDhgkp1d/nlPVKzB//3pgDz6Do9HgdbYM80BCHC7V227uZl qduz7ZV3lzVg94V4vWFuIU/Ew6sGGsFZ9FhxY/6lcFNsNz8qGvu5UI635yNGuDSD9vj0 E4JyPacHQrjWH6G9c6mXIWVqFqASsMFlxcD09X+WdmlyxR1WsjITd/o3SW1MMnVM1VjV 4dSitxC0XQb2QFInJSyG1gM20ZVsaqHGbYNHSW+cUk5u4Gcg/fvk4VM9aW/lQgKTbLdy PJ0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=xFLzYzFE1YyAKQXylhfyyOmRHfVrp9hrhj3/sGeqPyc=; b=RSXppS/4UrUj+A0kvZXn7nLnL8Nuzj5izMg6SdxC9OmDo1zTeY52fEVVQ0Del5Wjev 7LFZ7520AU3wpAvqxnCsiiD78xReaLxOAPLSySFuoE7zJy/SGCSLTnIY33vp5vwm4Da0 6teIS+bpTgNDaIZdOvWFeRUrrnjV9wjAefbc49RfXnh5JmndddDa6kef8TkPulhhHucO FkA2WvToE76KG6hI0jTfrH7TNax9IP5Lo7/FA0zgYTV8SNsbCvdDixA1BeulqDmpHmsX h3dYYskE8PAYDV/UzTra8kLdz3lm9RG0shCb1sGnZYN88HMS6rfUwhkLdXSPllX5Uutd mzOQ== X-Gm-Message-State: AHPjjUiNPTzxn9temtj0iengXLkrpJBKjrPJ5xzyNnJNRecbswB5e4W6 Px3JzwBt0aYeTqnJ27j/ZkA= X-Google-Smtp-Source: AOwi7QDqVGIipuMi7Z7R1UAdddtvf2WZ79uvfoxMP3HRkXI9k1OlNO0TAcJ9LB8gJEuInL8hIt9JTQ== X-Received: by 10.36.245.138 with SMTP id k132mr14771834ith.124.1505718002626; Mon, 18 Sep 2017 00:00:02 -0700 (PDT) Received: from localhost ([223.190.121.125]) by smtp.gmail.com with ESMTPSA id y198sm2622224itc.30.2017.09.18.00.00.01 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 18 Sep 2017 00:00:02 -0700 (PDT) Date: Mon, 18 Sep 2017 12:29:52 +0530 From: Himanshi Jain To: outreachy-kernel@googlegroups.com, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, linux-iio@vger.kernel.org, daniel.baluta@gmail.com, amsfield22@gmail.com, Michael.Hennerich@analog.com, gregkh@linuxfoundation.org Subject: [PATCH] staging: iio: ade7753: replace mlock with driver private lock Message-ID: <20170918065952.GA5386@himanshi-Inspiron-5558> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 Replace driver usage of mlock with driver private lock to meet the new model where usage of iio_dev->mlock is being redefined as protecting operating mode changes(changes between BUFFER* and DIRECT modes). Signed-off-by: Himanshi Jain --- drivers/staging/iio/meter/ade7753.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index ce26abdea..745c5a6 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -81,10 +81,12 @@ * @tx: transmit buffer * @rx: receive buffer * @buf_lock: mutex to protect tx and rx + * @lock: protect sensor data **/ struct ade7753_state { struct spi_device *us; struct mutex buf_lock; + struct mutex lock; /* protect sensor data */ u8 tx[ADE7753_MAX_TX] ____cacheline_aligned; u8 rx[ADE7753_MAX_RX]; }; @@ -483,7 +485,7 @@ static ssize_t ade7753_write_frequency(struct device *dev, if (!val) return -EINVAL; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); t = 27900 / val; if (t > 0) @@ -504,7 +506,7 @@ static ssize_t ade7753_write_frequency(struct device *dev, ret = ade7753_spi_write_reg_16(dev, ADE7753_MODE, reg); out: - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret ? ret : len; } @@ -580,6 +582,7 @@ static int ade7753_probe(struct spi_device *spi) st = iio_priv(indio_dev); st->us = spi; mutex_init(&st->buf_lock); + mutex_init(&st->lock); indio_dev->name = spi->dev.driver->name; indio_dev->dev.parent = &spi->dev;