Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3829571ioo; Wed, 25 May 2022 08:59:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcz8tTB33pQMRqx9vtkdtgBkN1tYVD9Fjt2RIqLPq1MLMy/koQnRwHDNN/hW+26/9TH7pp X-Received: by 2002:a05:6402:40d4:b0:42b:3203:aafe with SMTP id z20-20020a05640240d400b0042b3203aafemr26559740edb.376.1653494368179; Wed, 25 May 2022 08:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653494368; cv=none; d=google.com; s=arc-20160816; b=tXFq09RP/ide+odd8DoALPem5zagCMYL+cMpF0XpmEN/JyrUQxenKFkP80ahPrtzjH qYa1F/UTUyt1HSpUvpIvrF32Ad9nyQbiSS41LfoWGdXYOsQ6fqhm7FrLpt74v5WULuJ1 Lubl0qvSVzR3wNG2TbG4QAZrTWVN+wVRSG9PQigoj1r4h9WuE9wsOQpHq1L/SzubFLCL uWuqV3Iy4/hnnjLhRi9yaAN1auEcfPCz31cxLKL9j6FJosgD1rKCTEdLCI4JpK3cuZ3t udoPQAO6JNOCgP3hOk/64EhNPeyTMzRQwzNNhfbdEfAML1v8RFNitnG/MJFfrUZcLmMw k2Ig== 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 :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=i26/JCkysf9GDfl6ljkBEdIPEPYakKxwIC/n6VFnoCw=; b=FiOIVvqKbsmGDu9dTJcDOaWzsNm3XVIiQxdoHwMUoDHNQU9Y4uSA6sIRkI0HnqSDLS /E6RVZUzYtDKXRMYBxXXGYkRbA9LJM7Unw4yazF5nnYleuIu1edqsevzHf5y5FFi7IzB P3kADd2xhlnm0Kn/CKE7rM1gTqpXbWhjFTSevyoIfGnEWXzMrf47SWDfu1TEsRnrSHHi lV4hZQvrUiZV82orCSGe430GXIaB4Isrd/I6itY/qRPEPpdQ4rZrtD2mu9Bl7abdFkOw ITq5TVi9W6+U9b6KC2AfGZVnhHU9sDUCQJ/g4XhaLfx0K93/klkMwNdb8VUJHVj1jKtt AYVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=i036EpaK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ec25-20020a0564020d5900b0042baf3d4379si3221987edb.461.2022.05.25.08.59.01; Wed, 25 May 2022 08:59:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=i036EpaK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244708AbiEYN7r (ORCPT + 99 others); Wed, 25 May 2022 09:59:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244626AbiEYN6c (ORCPT ); Wed, 25 May 2022 09:58:32 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D74DAB0FC; Wed, 25 May 2022 06:58:29 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id r3-20020a9d5cc3000000b0060ae1789875so12003207oti.13; Wed, 25 May 2022 06:58:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i26/JCkysf9GDfl6ljkBEdIPEPYakKxwIC/n6VFnoCw=; b=i036EpaKoeLbMcvL5tu+2JGtgzrYIty8FqztTyFkjy/HYq474kSEcHcpO5WgkgOlbB wUfbObh3ms72byJZhtgxpnoIhPtlwqNukVn6guG4I/aotHGwN+kfvkXHt59uVRtd0/os Y3K4Rim6TMGjzw31oyNnmpe8nTj3bid9GUocbm0zKCvx2PHDGcKLpgb33N/BTJfwCKHI 2ozEybJzpG8YmnRYk7d2ILTklmg74CHcptAyQJp0nXbVt1e1nkYZNDUHBcJNxRtz0jLJ hQzvzI3Rulntk8uZBXG5XPlHduBON/jc0saYJSaMtOy/RFo0/3UiDsf1QkUWTM905Zb3 YuAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=i26/JCkysf9GDfl6ljkBEdIPEPYakKxwIC/n6VFnoCw=; b=ED9f9LPLGJrPILqcy6caL8otNJONbpiLG+7m5gDm4eVkqtA6UOk7HkfAjqY1k1Osni EusBwrc3+rfltsdKIDDwRH8JJmJfUVR6t6AkK0jYlcrAj4fPMvU6uP9s8YLaDC15xi6c WDAJ9lTouT+g3qk0o92vz1+9kXvb4eA7IQa+TWT8G+mADPYMdxA/bOEwGe//ouszl4tJ 3Or4jDBezgWiGWyO204+BqGcPpud6yJGcTzZe6nfNkXTUMPQYnnfDLWInecuDnjBADWE waZZbj9nbQWorbgFN79iBGPiBhlAvt5z7DVgeXQBy5+VftN+dfpHNTVLIPrqqCjAYTi3 ONkA== X-Gm-Message-State: AOAM532l0k+STqP0UtDYMXiv3Ne/Bm90VScFf/TLw54iHpUvQOHKEmBV YUo7HGz/3HqZoknTbNlKvX8zQ8cB8I7Deg== X-Received: by 2002:a9d:1b68:0:b0:606:ae01:ce2e with SMTP id l95-20020a9d1b68000000b00606ae01ce2emr12762044otl.121.1653487108637; Wed, 25 May 2022 06:58:28 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e125-20020aca3783000000b0032b7788af61sm2273372oia.41.2022.05.25.06.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 06:58:28 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jean Delvare , Slawomir Stepien , Guenter Roeck Subject: [PATCH 14/40] hwmon: (lm90) Use single flag to indicate extended temperature support Date: Wed, 25 May 2022 06:57:32 -0700 Message-Id: <20220525135758.2944744-15-linux@roeck-us.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220525135758.2944744-1-linux@roeck-us.net> References: <20220525135758.2944744-1-linux@roeck-us.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since temperature conversion functions are now unified, there is no need to keep "the chip supports a configurable extended temperature range" and "the chip has extended temperature range enabled" flags separate. Use a single flag instead to reflect both. Signed-off-by: Guenter Roeck --- drivers/hwmon/lm90.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 8e5f791aca07..a0a91aa66177 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -164,11 +164,8 @@ enum chips { adm1032, adt7461, adt7461a, g781, lm86, lm90, lm99, #define TMP461_REG_CHEN 0x16 #define TMP461_REG_DFC 0x24 -/* - * Device flags - */ -#define LM90_FLAG_ADT7461_EXT BIT(0) /* ADT7461 extended mode */ /* Device features */ +#define LM90_HAVE_EXTENDED_TEMP BIT(0) /* extended temperature support */ #define LM90_HAVE_OFFSET BIT(1) /* temperature offset register */ #define LM90_HAVE_UNSIGNED_TEMP BIT(2) /* temperatures are unsigned */ #define LM90_HAVE_REM_LIMIT_EXT BIT(3) /* extended remote limit */ @@ -176,12 +173,11 @@ enum chips { adm1032, adt7461, adt7461a, g781, lm86, lm90, lm99, #define LM90_HAVE_EMERGENCY_ALARM BIT(5)/* emergency alarm */ #define LM90_HAVE_TEMP3 BIT(6) /* 3rd temperature sensor */ #define LM90_HAVE_BROKEN_ALERT BIT(7) /* Broken alert */ -#define LM90_HAVE_EXTENDED_TEMP BIT(8) /* extended temperature support */ -#define LM90_PAUSE_FOR_CONFIG BIT(9) /* Pause conversion for config */ -#define LM90_HAVE_CRIT BIT(10) /* Chip supports CRIT/OVERT register */ -#define LM90_HAVE_CRIT_ALRM_SWP BIT(11) /* critical alarm bits swapped */ -#define LM90_HAVE_PEC BIT(12) /* Chip supports PEC */ -#define LM90_HAVE_PARTIAL_PEC BIT(13) /* Partial PEC support (adm1032)*/ +#define LM90_PAUSE_FOR_CONFIG BIT(8) /* Pause conversion for config */ +#define LM90_HAVE_CRIT BIT(9) /* Chip supports CRIT/OVERT register */ +#define LM90_HAVE_CRIT_ALRM_SWP BIT(10) /* critical alarm bits swapped */ +#define LM90_HAVE_PEC BIT(11) /* Chip supports PEC */ +#define LM90_HAVE_PARTIAL_PEC BIT(12) /* Partial PEC support (adm1032)*/ /* LM90 status */ #define LM90_STATUS_LTHRM BIT(0) /* local THERM limit tripped */ @@ -1109,7 +1105,7 @@ static int lm90_temp_from_reg(u32 flags, u16 regval, u8 resolution) { int val; - if (flags & LM90_FLAG_ADT7461_EXT) + if (flags & LM90_HAVE_EXTENDED_TEMP) val = regval - 0x4000; else if (flags & LM90_HAVE_UNSIGNED_TEMP) val = regval; @@ -1136,7 +1132,7 @@ static u16 lm90_temp_to_reg(u32 flags, long val, u8 resolution) int fraction = resolution > 8 ? 1000 - DIV_ROUND_CLOSEST(1000, BIT(resolution - 8)) : 0; - if (flags & LM90_FLAG_ADT7461_EXT) { + if (flags & LM90_HAVE_EXTENDED_TEMP) { val = clamp_val(val, -64000, 191000 + fraction); val += 64000; } else if (flags & LM90_HAVE_UNSIGNED_TEMP) { @@ -1764,9 +1760,8 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data) if (data->flags & LM90_HAVE_EXTENDED_TEMP) { if (of_property_read_bool(np, "ti,extended-range-enable")) config |= 0x04; - - if (config & 0x04) - data->flags |= LM90_FLAG_ADT7461_EXT; + if (!(config & 0x04)) + data->flags &= ~LM90_HAVE_EXTENDED_TEMP; } /* -- 2.35.1