Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp412438ybh; Thu, 12 Mar 2020 04:26:55 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsoWUUnH1NbmsouczhT7A7vTjtiMMPT3J3n0ucU1bO+V4X35v1LqFnMxcvOQZGcsaZB8HTy X-Received: by 2002:a9d:3b09:: with SMTP id z9mr6055107otb.195.1584012415404; Thu, 12 Mar 2020 04:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584012415; cv=none; d=google.com; s=arc-20160816; b=MQPR1yNH12pK1qbE/GKqhuM86g5+br73FLsn5mAu8M0QaGchEahBDMa3/PbbsHdLpB hUWWIqGFPrIcA8ZNX9D0YJh4dO5L30jVcRM09dgp+cwmAFL3oJOf5s4CP8yvrYwe8If7 Qbb6/ya6vsIZ6GOLsFrb/gapPXJ0xChAbgjoUkAThFHJv2rQ8IBOsfzfm1FQMqQ3IX4j IuGlW1lspaYg6MWFGoGTFHKBQUHgWIzumfx86CJbpMND51bCMkMxONUjTCBvmp5vBXod /dEa98dGSNEtMogCtE6JBlOLjc9N3msaJr9PdRsXTGMucTww73AIDsJl00840CAg4LG7 3CaQ== 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=hCHUtum807cKX3xslDRMcG8mu6VO9rXiNzUSRhB+hEo=; b=M0nfyaoFdMn17BnOuFRNIU9aIwaMAbMYt2VGrj6HbrTvluOhxM3GbBnSJF44pezPab mJ5mroQdF/7ExF2jIv9dok7gN7WzietSubmr60R679FuPyXDqdd+eUMHgxulqytgTvWK emqPsiEcNjjAYBIBk+o7o2J05Pj3fXUIS3xUGGGs2ukEl12OlHVt7ikeiQ97LvLgZpWd 2axArpWLjpzcNwB2A51KRDr/PjiuLBknqpsxXJBzjGeVd00YEsBSp9I/aqrUUnvfDWtt 78dhMBmV2++HPG5ivvkYArl5VF/27lpcokVuC9I4bYLFgM9dDcmdN73JwX/6os32hNjV B52Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HGx8U17O; 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 e9si2534436oig.116.2020.03.12.04.26.43; Thu, 12 Mar 2020 04:26:55 -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=HGx8U17O; 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 S1727026AbgCLL0F (ORCPT + 99 others); Thu, 12 Mar 2020 07:26:05 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41769 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbgCLL0E (ORCPT ); Thu, 12 Mar 2020 07:26:04 -0400 Received: by mail-pl1-f196.google.com with SMTP id t14so2546215plr.8; Thu, 12 Mar 2020 04:26:02 -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=hCHUtum807cKX3xslDRMcG8mu6VO9rXiNzUSRhB+hEo=; b=HGx8U17OPOy4dfSA8M7JE2HX4PnapDtKokLj3HRXNIVSlxYUHDY7LSMcDsEceVkUKY y+dzO5/zCLeNDOiJwo37Ja/GW1VzOJqaNlXvXJVi0XlP3vRROAu79sLV/CsDX6jgzaVm wEkud6VGKIXscsmWmibvlcCsYOzxfCK+vwiGAM/pmm2L8lddYq8ocLixyfNT5DQ6razi BZNIqXPuBQzTif0M8qgOzw28AtY44fa30TtAebrRYfqS0qU1ECqEddkIAOTW3LdSp3qC ptXXDlA9FiQG2OnCuSd2xRiJZQNkYHFBeT0DPIkW691MigcJH9Dsq3hjTytvIygOxBEV agNA== 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=hCHUtum807cKX3xslDRMcG8mu6VO9rXiNzUSRhB+hEo=; b=FupObyigwJ5UwBP8A31URHxOISrWzK8ANRXQaIC7geBqRSPXVtBVDvq3OTGcopQ6HR t3IS4TSFKzrMeHczYbOvER/yhWTzlLAWw1T8uo35y7Cv4vmBzbitJzySM84wWgyExRyn c4jaAhseBMBSInRIHybURlHZzcnTSbs7xjbr3lLznS/3MqM5R3VArPH6Z0IUImPY3qQd Qc3ByRnT20TpRyyQPaFZ/3aveRmtaL2+3UoMsWbN84g24xPIOd3xL4VWfaVG4KgO7ajO HcHx6QOLMdqQZE/QH7XWgyKDQTruPcMlZywM5yLluEjbB20vus7sksZtRD21ZOaA70y6 nlnA== X-Gm-Message-State: ANhLgQ1zziiiIVX3EUKR/iUpbUyOEnoiER43aJqB5fE0+ITcqMoi336x PpibEGIBFBkM32VzCBwDMQg= X-Received: by 2002:a17:90a:a10f:: with SMTP id s15mr3647162pjp.40.1584012362234; Thu, 12 Mar 2020 04:26:02 -0700 (PDT) Received: from syed ([106.210.44.120]) by smtp.gmail.com with ESMTPSA id h2sm8372011pjc.7.2020.03.12.04.25.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Mar 2020 04:26:01 -0700 (PDT) Date: Thu, 12 Mar 2020 16:55:52 +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 v3 3/3] counter: 104-quad-8: Add lock guards for filter clock prescaler Message-ID: <20200312112552.GA32509@syed> 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 in the 104-quad-8 counter driver for filter clock prescaler related changes. There is no IRQ handling so used spin_lock calls for protection. Fixes: 9b74dddf79be ("counter: 104-quad-8: Support Filter Clock Prescaler") Signed-off-by: Syed Nayyar Waris Split the patch from generic interface and differential encoder cable status changes. Also, include more code statements for protection using spin_lock calls and remove protection from few code statements which are unnecessary. --- 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..58615e4 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; + spin_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); + spin_unlock(&priv->lock); + return len; } -- 2.7.4