Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp558325rdb; Tue, 31 Oct 2023 15:41:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDiBJakUG/N+7VXHxOplSGp/pX05ewylmTTCrQjBkOczxCD4536coEuDkmO4y99rPI6KOa X-Received: by 2002:a05:6871:3418:b0:1d5:21cd:7069 with SMTP id nh24-20020a056871341800b001d521cd7069mr17482002oac.8.1698792070605; Tue, 31 Oct 2023 15:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698792070; cv=none; d=google.com; s=arc-20160816; b=o8jG3yxa2dI161gqCjEy8Wz6kuDJ3NJrnZJf+Rsxb0jBnwdzcmSHncAdPhtPOS0MIj 9lRrpswDmQ1CWgsLih7lwtiVpGjyl10vzpjKRLLPaKIDsteB/+riJtGs1DBIVN5E66fv VSoLQI3yQt/n8Sm6LZ8xjuYyeWdg4usE1JpuvFDIX9191mgi3OZ+APRncsXv5fJxnJSL tQKCaiKCryh2hYo3dtRWwdTp8DHtkt83NcpTcYoSveQCrGWgfBvNSXl6TZyLyj2PqS3R wBlWL+3Wm18SPudyNMiI7/F9nuqSCzh5HQeDBeWdKFp3dtKFDLw+GWV7sHTLxSROP2Jc RZHQ== 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=xqs8iHcSi/hoEuooCjlsqhRooKz5bcnuoJ1sPN5NnxI=; fh=OtfKHskbM0V42W4LQu+GyPaIuRQVbl2aDJTBaZis/qE=; b=KCV2mKWXgQS9umh1++CbxO1jxR0RvQoBKXvmEnzEJNPbtyb845xJwOzrrhe9vM4OJt 1JOkT/AziHrOdA8sIQYNiw7Qwnd5KhYLwT24wNJQysNCMm/jrOHwsn6VIE0US3Nsvoj9 WQGCRjzdbbaiNhNV0pV3oJg7MxKZCODlBbF5jpZk1ps9RDBxWwAgU0o0vnBed2ohXUYQ MF3G7YV8nnuG52qXPxMDKDRc8QxwcYMwZzHFdTgZwH45iDmXjMKb9s/v5wISNU8ncKac b3tHBhVJXkaM5XI6SOhXYe2vbXMoL84Z3cAEZmsGVktaLEpVhi2djztRDffRB5nGmkmv qQ2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id n13-20020a63f80d000000b005b21d089aa7si1672165pgh.788.2023.10.31.15.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 15:41:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 6B0C0802A0F4; Tue, 31 Oct 2023 15:41:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232088AbjJaWky (ORCPT + 99 others); Tue, 31 Oct 2023 18:40:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231904AbjJaWkx (ORCPT ); Tue, 31 Oct 2023 18:40:53 -0400 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E91AD107; Tue, 31 Oct 2023 15:40:50 -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 39VM9GJE004517; Tue, 31 Oct 2023 18:40:36 -0400 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3u38jds73p-925 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 31 Oct 2023 18:40:36 -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 39VIMLDO034712 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 31 Oct 2023 14:22:21 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) 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, 31 Oct 2023 14:22:20 -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, 31 Oct 2023 14:22:20 -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 39VIM1d5022309; Tue, 31 Oct 2023 14:22:14 -0400 From: Daniel Matyas CC: Daniel Matyas , Jean Delvare , Guenter Roeck , Jonathan Corbet , , , Subject: [PATCH v6 4/5] hwmon: max31827: Return closest value in update_interval Date: Tue, 31 Oct 2023 20:21:56 +0200 Message-ID: <20231031182158.124608-4-daniel.matyas@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231031182158.124608-1-daniel.matyas@analog.com> References: <20231031182158.124608-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: _fSsahaF-pzgaOHeyfgC5Qpb6ZYBvaiw X-Proofpoint-ORIG-GUID: _fSsahaF-pzgaOHeyfgC5Qpb6ZYBvaiw 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-31_09,2023-10-31_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=924 lowpriorityscore=0 suspectscore=0 impostorscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 clxscore=1015 mlxscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2310240000 definitions=main-2310310186 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Tue, 31 Oct 2023 15:41:06 -0700 (PDT) When user writes a value to update_interval which does not match the possible values, instead of returning invalid error, return the closest value. Signed-off-by: Daniel Matyas --- v6: Added patch. drivers/hwmon/max31827.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/max31827.c b/drivers/hwmon/max31827.c index 41e4f716605a..13ebe691475a 100644 --- a/drivers/hwmon/max31827.c +++ b/drivers/hwmon/max31827.c @@ -360,9 +360,8 @@ static int max31827_write(struct device *dev, enum hwmon_sensor_types type, val < max31827_conversions[res]) res++; - if (res == ARRAY_SIZE(max31827_conversions) || - val != max31827_conversions[res]) - return -EINVAL; + if (res == ARRAY_SIZE(max31827_conversions)) + res = ARRAY_SIZE(max31827_conversions) - 1; res = FIELD_PREP(MAX31827_CONFIGURATION_CNV_RATE_MASK, res); -- 2.34.1