Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2570704ybh; Mon, 16 Mar 2020 05:51:32 -0700 (PDT) X-Google-Smtp-Source: ADFU+vstC+nwwujJMNopeunFKm4wpDaUHhf98dQ2y30oEaaw5kbW/aSmvQPj4JNuorrrz1PlCJKw X-Received: by 2002:a9d:6a0b:: with SMTP id g11mr21210416otn.31.1584363092042; Mon, 16 Mar 2020 05:51:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584363092; cv=none; d=google.com; s=arc-20160816; b=dMmR9fYDyYNw9PyduulO+bM9v1J/bUTZGDbG9Mn1aqqfsVM70+bHNX3rJJeDzsxBgb jN/ZyVUGMbHmHEOD/ncV+f55QfBV6Uq07ZRoPNdj2+b58lKiL5t4qpjPAUnhro4JgRVv 98jsQHcMef0mRmMc5AGiVThUjZz7pSzoHeP/ofYOMO24H7xOlc7JRJALykSjZHtKWwj1 32r7srDElLN6QDEEnAAb+Uiw2PsOmJsciaGAsJU/rbifUiRdmesHmPuuFscxQLyEppOr gwzKE1i1+lTB+40oXsCcSUAhi+hrS4BvTj97ExjmzOhCVnpgRw2k7VPcFcHI7n2zJphf S7fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=ZpMGbXXqa6m8v2kNHAjkP9KJ7pUf2Se2goyp9p1li6k=; b=Gc9C5slktnLs/VUTsaecbdbpyUseEGM3e/r835erdsTQqrlAZ4ANVTvyZVxy4zii/0 8+I2rKg0gr+hVEsoQif8ibYsQ9eUDzB3Su34SxuBJRxd4Q1sYu6P1OhgZ0c4CcV5kUvJ 0KeHLDBUicLcYviI5dC0P6dJPQIpKUcE7w440nb5XIyF416qUg13l3HFUaans8IEMWBv SNVBjSzUTDfuPjOORo2Pn0Vg5WAQYNTk+8EtRNHDKvHXf/Qwj4pYQBg0imrf8sIYMv2I ZJHBYPb7psflq2KwiresbHMNF0pjBcJwyvS2X6DF77NuA3skCI5RLa1WmpxWkxfjUJkR HcYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NnXOaYWU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b197si9100424oii.198.2020.03.16.05.51.19; Mon, 16 Mar 2020 05:51:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NnXOaYWU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731051AbgCPMuw (ORCPT + 99 others); Mon, 16 Mar 2020 08:50:52 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:34613 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730919AbgCPMuw (ORCPT ); Mon, 16 Mar 2020 08:50:52 -0400 Received: by mail-pl1-f193.google.com with SMTP id a23so7977603plm.1; Mon, 16 Mar 2020 05:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=ZpMGbXXqa6m8v2kNHAjkP9KJ7pUf2Se2goyp9p1li6k=; b=NnXOaYWUoKo1njr2t55uW/zLpCKfUWwvjr3b+cokM1mR9fcQFQRpINqCBE8U1i5BQK zVdwbJPsBri/RXvJL3SEulKlFkZiQWBy83dxvT/IQVWbFERoFxFt+WFTX52Uwwv6h6E7 eT1Gd8B9WV9ukU2/LorE2hsqhMxIVNx2X7HDTiBzMh2ZmSCB6MNsVxa0R3w4x6z5rb8I chO2G14Y1l4NvF4evo8hpkmHigA4IRUMtPkopNLMouvx2ygRbnCZCJnzKPLIcc30p+iL jx3XUmc3WYkSRLzfSfUOa8Iq0mOESfGQUS6vaJ8bCyr354blfoIQNpWKNPrYn39HtCQw 446Q== 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:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=ZpMGbXXqa6m8v2kNHAjkP9KJ7pUf2Se2goyp9p1li6k=; b=rlr+dMMu/P60ZmOrzwBF8h4D3wanJB5oOK1PmPkoMo+smLr2ZIomaB+a/WgvwVz5PZ ONHEe/RYQyiEylln1ZDsdzqKLOLK+/kG2Ex4MdWGdhbfC+QlEOAVPBFxZn3cRSs0ZUAK uhZmIASKV2B3wNNHQf6ZhaxHKd6P0/McBLH0yUrU3qj6EJjbI6y/I84PCbPCfkO+t0kR gzKRIP7YCgLpi5xyLRWUWw7r8seqhNYnwppm1w8VtE7SANWUHBsVesARJ5sfHvcLroqv mSai1G+ngbE+o2NZwl9c0FYKX9OU8agNk1MN3hEM8+moGvsgXOsO/OXd0cW1F2gnOAQ7 cvsA== X-Gm-Message-State: ANhLgQ3zND0UiMdFdJxNaWHDwqdG/TB/C5tgGBf5BlZEExVFfcHXiPzp 3mvqDDzrl83KMZfEF78gxl36XuWk X-Received: by 2002:a17:902:bc47:: with SMTP id t7mr27046019plz.47.1584363051640; Mon, 16 Mar 2020 05:50:51 -0700 (PDT) Received: from syed.domain.name ([103.201.127.108]) by smtp.gmail.com with ESMTPSA id e189sm61874290pfa.139.2020.03.16.05.50.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Mar 2020 05:50:51 -0700 (PDT) Date: Mon, 16 Mar 2020 18:20:46 +0530 From: Syed Nayyar Waris To: vilhelm.gray@gmail.com Cc: jic23@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/3] counter: 104-quad-8: Add lock guards - filter clock prescaler Message-ID: <20200316125046.GA447@syed.domain.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add lock protection from race conditions to the 104-quad-8 counter driver for filter clock prescaler code changes. Mutex calls used for protection. Signed-off-by: Syed Nayyar Waris --- Changes in v5: - Change spin lock calls to mutex lock calls. - Modify the title description. drivers/counter/104-quad-8.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index 9dab190..b268165 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -1230,6 +1230,8 @@ static ssize_t quad8_signal_fck_prescaler_write(struct counter_device *counter, if (ret) return ret; + mutex_lock(&priv->lock); + priv->fck_prescaler[channel_id] = prescaler; /* Reset Byte Pointer */ @@ -1240,6 +1242,8 @@ static ssize_t quad8_signal_fck_prescaler_write(struct counter_device *counter, outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, base_offset + 1); + mutex_unlock(&priv->lock); + return len; } -- 2.7.4