Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp491320rdh; Thu, 26 Oct 2023 07:45:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPNUSFIfGdiw9hocPmXcbf4RcNpQAV26igjmjrGJNUmk4ldC5iWx26pAkJYU1svjBhAq/2 X-Received: by 2002:aca:908:0:b0:3b2:ee67:71e5 with SMTP id 8-20020aca0908000000b003b2ee6771e5mr18272575oij.42.1698331536552; Thu, 26 Oct 2023 07:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698331536; cv=none; d=google.com; s=arc-20160816; b=wUmbgMMm6WtNv5gSwdBeIBbBLEV0MIk+Pq/kZqkvWYSzeQ4JIDbm/p14Z88+MRaJnc Ok686AZ7JM4qI56/QeHM7y3GDHzIW1LTiF9CfEqNST2LWr17C4LxT3EcniqMp4gJ7+pQ CY44j0gFl2VNiKUDLJb/gdj0iHTy5tsgJZ7rf+NuUm4w829hvB+l5k/junY+jFo+FWwj KnpVSXC4plTOdy6eaWY6aWdvElpyWLpuEwZ498aR/bk6WoCUujlBFW8Of0fDMgsfSUTM sFdS7T9VBxLC2VRX7wvgaUxnCe5VdTjGgeim4rhzIVTseJDjMKyOXCj4do2GZipU6pqf Q5AQ== 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=NTMjnxRBxjdun1J4Eeyw61Sd/+aLjQeTbxwAQomyEfA=; fh=OtfKHskbM0V42W4LQu+GyPaIuRQVbl2aDJTBaZis/qE=; b=vT0DCGnClhLNimIOXK/ySuu/G9GKgteVjk3K4DGGmbAJkod/EINEujJo0MQFkn7gDT aZZRYtyznKibGlo/VG/IdnyeiKYjJwoW5JN+msFOiPITmr5lgZBjN30rxMrZfOoPzjIE QNwNeHV+R1Dvpixp31wII9kE3uUxGspY00o2edAnDERo3M6iPYSrpqqqx4KY1NO77RQa k98gYCjXo0Ecg4HtRIBCentavCKp0FFdGwH9eThvScyrtIWHXeXE8dR5ToWQj8YE4tFS tzBYyTdGqUpRpMwsn/VW1s2rY2aXOX0814MSGi7gs3fsqOj4W3cZVXN/hO2dyMYdQxfv odDw== 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:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id 190-20020a2503c7000000b00da053aa07f1si7272020ybd.297.2023.10.26.07.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 07:45:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id F1EF980FC0B3; Thu, 26 Oct 2023 07:45:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235062AbjJZOov (ORCPT + 99 others); Thu, 26 Oct 2023 10:44:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231178AbjJZOou (ORCPT ); Thu, 26 Oct 2023 10:44:50 -0400 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24AA9B9; Thu, 26 Oct 2023 07:44:48 -0700 (PDT) Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 39QD24tb024132; Thu, 26 Oct 2023 10:44:33 -0400 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3ty72k6q1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 10:44:33 -0400 (EDT) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 39QEiWMm009116 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 26 Oct 2023 10:44:32 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Thu, 26 Oct 2023 10:44:31 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Thu, 26 Oct 2023 10:44:31 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Thu, 26 Oct 2023 10:44:31 -0400 Received: from daniel-Precision-5530.ad.analog.com ([10.48.65.198]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 39QEiEix031489; Thu, 26 Oct 2023 10:44:25 -0400 From: Daniel Matyas CC: Daniel Matyas , Jean Delvare , Guenter Roeck , Jonathan Corbet , , , Subject: [PATCH v5 3/4] hwmon: max31827: Update bits with shutdown_write() Date: Thu, 26 Oct 2023 17:44:03 +0300 Message-ID: <20231026144405.546822-3-daniel.matyas@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026144405.546822-1-daniel.matyas@analog.com> References: <20231026144405.546822-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-ORIG-GUID: XMx0_Opqf3q6wxY7VYTyubhB0Wi8RxwA X-Proofpoint-GUID: XMx0_Opqf3q6wxY7VYTyubhB0Wi8RxwA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-26_13,2023-10-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 priorityscore=1501 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2310170000 definitions=main-2310260127 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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 26 Oct 2023 07:45:30 -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 -> v5: No change. 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 446232fa1710..8ba387b51157 100644 --- a/drivers/hwmon/max31827.c +++ b/drivers/hwmon/max31827.c @@ -84,7 +84,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; @@ -101,7 +101,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; } @@ -116,7 +119,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; @@ -134,7 +141,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