From patchwork Wed Oct 11 13:57:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 151433 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp557988vqb; Wed, 11 Oct 2023 06:59:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQzE7Motxrv3SmSanxe35WWWBVsGLa1fG3s3iQiLmKW/HFoMacQ5gD5AHb1iNHi3A0gFKD X-Received: by 2002:a92:d3cb:0:b0:345:e438:7381 with SMTP id c11-20020a92d3cb000000b00345e4387381mr20106637ilh.2.1697032741988; Wed, 11 Oct 2023 06:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697032741; cv=none; d=google.com; s=arc-20160816; b=Y+6hLsQ7c+P6F516mXVRS7ElBa18XWKtQauj5JQzcB//39Xc2wOoUm4yB5KfnNj0gi I4rPAAR9yof7IjuLj2msZbRcWugEp0MWhkEPUteXzUNxYVo92gwwepBNukDIPz29D3sm M2yZU2UyKO8MYOdiUKgRuYhahIe45LCXWPZkEi1g0eeqiB53BI1sxBDOfWqn8aphltRZ gEGyi8vxiEvyMtFHxTB/G2dNJzSRR7spyvoWznMwKAzJMKsXVbeZe9Qm0VGzlZELgIiX Zg9cHNeSd0q38DFgVKuapK5mD1WnxVkDPB7x/iEQSdqfrnPS8dQ+Ac2LMVkwBvLAw4j6 crlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=/YW8j2BPx7hjnvsfhf/+/6JkPeCW96pxl10ErG9arys=; fh=iFQ/+LERDT0IJu8vwbGTplk+UVuOuH0N98IFjyUh40A=; b=fkpOuFl3+31zb2LZ/YfkCYfZEomQFaLxNIWOir57XdrNFfmALWDOPv4BHBDbmB9lS1 lbXkMfuzA/v/378cmqgbrq9YwlkhlFkRbrWEl9ey/Mq0slsOvlmrQJSS6E7jxcOdm7Gd p9I+W9C1GWgx94ovClTvbVq3LwegcrnhK74De4Pt0a+lECaNLWW/sKBXXFRSQ5W7mzie JLtvbQjkIz0OUtoygcb6SGJr/nRGtrqbq8FAPY/KOg9tTKJDyGXyrW5wdQZYmFqK/ePq PSuUhDIodyqaTwgVKEJMvv+JlAMm/hb+ECfFwL6u+1JGfAnUv8CyeCCmdCEkYx0AtSu/ 3mJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k190-20020a6384c7000000b0057c24bae994si14468707pgd.355.2023.10.11.06.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 06:59:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 036E08027F76; Wed, 11 Oct 2023 06:59:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232539AbjJKN6o (ORCPT + 18 others); Wed, 11 Oct 2023 09:58:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232075AbjJKN6n (ORCPT ); Wed, 11 Oct 2023 09:58:43 -0400 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28D5898; Wed, 11 Oct 2023 06:58:42 -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 39BDV2m7017505; Wed, 11 Oct 2023 09:58:27 -0400 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3tkm6hcgce-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Oct 2023 09:58:27 -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 39BDwQfm049740 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Oct 2023 09:58:26 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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; Wed, 11 Oct 2023 09:58:24 -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; Wed, 11 Oct 2023 09:58:23 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.194]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 39BDwD3b002538; Wed, 11 Oct 2023 09:58:16 -0400 From: Antoniu Miclaus To: Jean Delvare , Guenter Roeck , , CC: Antoniu Miclaus Subject: [PATCH] drivers: hwmon: ltc2992: avoid division by zero Date: Wed, 11 Oct 2023 16:57:53 +0300 Message-ID: <20231011135754.13508-1-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: aUtQjHIGG5tBnuRvmH1pCtWksEgqcjb4 X-Proofpoint-ORIG-GUID: aUtQjHIGG5tBnuRvmH1pCtWksEgqcjb4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-11_09,2023-10-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 mlxlogscore=827 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 clxscore=1015 bulkscore=0 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2309180000 definitions=main-2310110122 X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Wed, 11 Oct 2023 06:59:00 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779467804560178104 X-GMAIL-MSGID: 1779467804560178104 Do not allow setting shunt resistor to 0. This results in a division by zero when performing current value computations based on input voltages and connected resistor values. Signed-off-by: Antoniu Miclaus --- drivers/hwmon/ltc2992.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/ltc2992.c b/drivers/hwmon/ltc2992.c index 589bcd07ce7f..001799bc28ed 100644 --- a/drivers/hwmon/ltc2992.c +++ b/drivers/hwmon/ltc2992.c @@ -875,8 +875,12 @@ static int ltc2992_parse_dt(struct ltc2992_state *st) } ret = fwnode_property_read_u32(child, "shunt-resistor-micro-ohms", &val); - if (!ret) + if (!ret) { + if (!val) + return dev_err_probe(&st->client->dev, -EINVAL, + "shunt resistor value cannot be zero\n"); st->r_sense_uohm[addr] = val; + } } return 0;