Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp525836rdb; Tue, 19 Sep 2023 02:40:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNNhJm4247pcmnw23Ux3gZ1bPVHbja4tnMOQfBSISihlqJNDZmzu5yN6Nqg6IObsWAT5T0 X-Received: by 2002:a17:90a:590c:b0:274:67d0:f57 with SMTP id k12-20020a17090a590c00b0027467d00f57mr7640067pji.48.1695116440544; Tue, 19 Sep 2023 02:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695116440; cv=none; d=google.com; s=arc-20160816; b=LjnZKUAox26pzvMDpsPz36ORLhYOw/2pt9E2k08eU+DEiQkAVtiJucFT7GOicQOJkk FoPVjK5VesbfWBn7nI2CcGzHEOvw7ZfQtfGT3dhO688uBrqFNLReNbU0ziGuWjwIyZR1 pcc9AEZVvtESDmjb8HnZqsY0TXfDk0NK6rj1Cvi4OAhkIEm6uktyKr68i4YK+opEeF2t 0ksdFg+xo+KlfRvnXpBMYdPu27lDpYCC/6Tv0294E2xTXriH29lQLm1XGmY4ozd61VxL tHXm0cDFpC8Tbe0OI8J92UP8X8KryKagfGW7MgXVyrqq7/JdC8dkI+DpLXnz3KQnsUJZ nJKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=XX0jNs4hoBQB3rjgU34TYeTS5tMj2SPlj4AJB9ffVM8=; fh=qc7N/hGS3iGcR+Lz5dqizgi3ctiqy3jSIXMybcGB+CE=; b=PVJW77CGmnl9VxFHCb89lNaJI1Oz90eBWBTrw6jXReUPVgO8kWGVUAyK2y2YFCSiXN nepGtY8Yoc4h7zuL4MWKd6Z9VejR2b4JB4Pv14BFgRlZWr+LoKz23Zld6dynZSarDpqd viyk8j4Xv1q+snt6qeklIVMa8BGRKkZ2/Tw75QlkER2NWScb0D+y/l+BDyfOjQf3ab23 8aMJhXZjMvNyKJgDWk8AghrDbkAYy3F7jenRzd1m4MKrgGOdUUG7Wvvm/2mPXCmT9stX OO94efHU9QQdSYI0kppP2DBlxeohkLb8Je6b0HBTzQZXRxmxsLE/UWTIM7nGUpEGRpUz HR7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c1-20020a17090a108100b0025960d035c6si9365155pja.138.2023.09.19.02.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 02:40:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 030B680BC507; Tue, 19 Sep 2023 02:36:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231311AbjISJgT (ORCPT + 99 others); Tue, 19 Sep 2023 05:36:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231531AbjISJgC (ORCPT ); Tue, 19 Sep 2023 05:36:02 -0400 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ACF3FB; Tue, 19 Sep 2023 02:35:55 -0700 (PDT) Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 38J7UX37031310; Tue, 19 Sep 2023 05:35:36 -0400 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3t6gc20e2t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Sep 2023 05:35:35 -0400 (EDT) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 38J9ZY4Q007720 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 19 Sep 2023 05:35:34 -0400 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 19 Sep 2023 05:35:33 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 19 Sep 2023 05:35:33 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 19 Sep 2023 05:35:33 -0400 Received: from daniel-Precision-5530.ad.analog.com ([10.48.65.230]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 38J9Z1dB030605; Tue, 19 Sep 2023 05:35:25 -0400 From: Daniel Matyas CC: Daniel Matyas , Jean Delvare , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , , , , Subject: [PATCH v4 6/7] hwmon: max31827: Update bits with shutdown_write() Date: Tue, 19 Sep 2023 12:34:54 +0300 Message-ID: <20230919093456.10592-6-daniel.matyas@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230919093456.10592-1-daniel.matyas@analog.com> References: <20230919093456.10592-1-daniel.matyas@analog.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: M1j5ySn8LoWOo3QV9A5Esyx_6TUjdOk1 X-Proofpoint-ORIG-GUID: M1j5ySn8LoWOo3QV9A5Esyx_6TUjdOk1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-19_04,2023-09-18_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 suspectscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2309190078 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 02:36:46 -0700 (PDT) Added 'mask' parameter to the shutdown_write() function. Now it can either write or update bits, depending on the value of mask. This is needed, because for alarms a write is necessary, but for resolution only the resolution bits should be updated. Signed-off-by: Daniel Matyas --- v4: Added patch. drivers/hwmon/max31827.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/max31827.c b/drivers/hwmon/max31827.c index d4127440ee32..957d898978fb 100644 --- a/drivers/hwmon/max31827.c +++ b/drivers/hwmon/max31827.c @@ -94,7 +94,7 @@ static const struct regmap_config max31827_regmap = { }; static int shutdown_write(struct max31827_state *st, unsigned int reg, - unsigned int val) + unsigned int mask, unsigned int val) { unsigned int cfg; unsigned int cnv_rate; @@ -111,7 +111,10 @@ static int shutdown_write(struct max31827_state *st, unsigned int reg, mutex_lock(&st->lock); if (!st->enable) { - ret = regmap_write(st->regmap, reg, val); + if (!mask) + ret = regmap_write(st->regmap, reg, val); + else + ret = regmap_update_bits(st->regmap, reg, mask, val); goto unlock; } @@ -126,7 +129,11 @@ static int shutdown_write(struct max31827_state *st, unsigned int reg, if (ret) goto unlock; - ret = regmap_write(st->regmap, reg, val); + if (!mask) + ret = regmap_write(st->regmap, reg, val); + else + ret = regmap_update_bits(st->regmap, reg, mask, val); + if (ret) goto unlock; @@ -144,7 +151,7 @@ static int write_alarm_val(struct max31827_state *st, unsigned int reg, { val = MAX31827_M_DGR_TO_16_BIT(val); - return shutdown_write(st, reg, val); + return shutdown_write(st, reg, 0, val); } static umode_t max31827_is_visible(const void *state, -- 2.34.1