Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp672652lqt; Thu, 6 Jun 2024 15:12:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBUqgbLjB+r81HlxOkJZFmrOGcNDDGSYKz2MWh/ZtWtIq6BtLccZ22Kng/wmNI6XcgLJNFXOqHtUR3YL+7vZqSK6ttMJ151irU3jOtdQ== X-Google-Smtp-Source: AGHT+IFJj0LDcK8OPND0SpSssYcG41AuK9xrPdcoOgfrTQ1N0z6T/qG3q2SvJV9LeVvqCuyUgi+Y X-Received: by 2002:a05:6358:9392:b0:19f:13dd:b7a7 with SMTP id e5c5f4694b2df-19f1ffa8f74mr110600855d.29.1717711938167; Thu, 06 Jun 2024 15:12:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717711938; cv=pass; d=google.com; s=arc-20160816; b=Qi9xHSOQGgOO/ahWf7rEM80ad1B8yJmMp22aEIUiPlE6k/N7TrzE8rpnim6w/8hlp3 JLT0LLtTWBZRDmFaWcTQyW9nM1cKlVyWp7HQXMoqm4Vh+yOmaLfoP09nQIDTNY+RVzB3 0MAIfLC1uNNe4+VkocT2umtBC7OFq/rVDYnxHnG9wr3xmikbvwA8z6mVkqIibmzdmxJB ZPasYWuGNrSqkf9sshohxqBVJ8f2SgncMyCLMDZ3lls7YmVP4oW9BObiNWUxFlCuhiha HiXoQnO1utlP+xq16Q44AWwwIYTHLmWAh8FPNwrCZ6ZP6Hg/VgqMlC17fXYAQpwJaAdI +MRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=pB95QjVOd+o1pnquTTSFYO26tnihdXS1c7wiTnpaFIw=; fh=OAx35mhqT7w49CH4c7T09ig2LJq7E8PsKb2Beisg6Ag=; b=j+4f9VsmXbLue9LsNSi+4FgwSOMXaGKQtlnvv9M2hCTDPJzB5hIZYV/x8tL2CMUZDc Xotc5pGlzqo0OnDEqg9xnOgv6WdBuvk+gpjWAy+gr3BTZ2XxGCxwxt1TwUlM+WeDR7aa j9U/02a1sg6DihB7Foj+ogHZ+b4fyc5xb1yq7YIQMOA6TWGGqn+quExNU8GmJaPYvHYy mJILMS9yMqPAd82QcpD/ffpyzV0AFcx3aeIj6Ljh7bVzJ5hkD02jbkMMtekiAVmN+yge 2ADieliG+YAerEfz6YE2Zr2Q9cofR+cVD1yFYXhjCe4HmB/u7AvBBFO5U+L2U6o0Og9i XEcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lWd8iso7; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-205017-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205017-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de27cc6380si1809141a12.558.2024.06.06.15.12.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 15:12:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205017-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lWd8iso7; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-205017-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205017-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 37943B23A35 for ; Thu, 6 Jun 2024 20:58:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D547E1993A6; Thu, 6 Jun 2024 20:57:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lWd8iso7" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B2C6196449; Thu, 6 Jun 2024 20:57:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717707446; cv=none; b=kmNOkekVFwQKmfMMbuQ6yQamhLkRU7o21JWD//m3RBIrMZEkZP6LwoQQ87j7fVy0wO+MKcIHDH0tpAMwyDYvcwXeQ9L5M9kD/SuvRGEhgN1DkqUbek6dVWIEeGLFEtNN9NQLPHNJ7SASFNK8/KS8ZVfYrbc6LFUzNEy6DZZm/YM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717707446; c=relaxed/simple; bh=0YDydmrLM+QcJt9k0PKK2l8blVDYOm5Dy8R+sDL5ZoU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vm6/Pc6qLmMkMZs7kVdV/5h4Il5PAvhStQ/eDr+2zFpomPwwc4Rha5xHW8T+hlWTc5zft9S4fLSC5Ig5NZM1gnHomkWTZRfckkLWSmm2EXt2zCbOGBYM+5DSBsOAogdMPkO3MXeqL7gqs3/0U1IiLLxIlN1HgcVCMncQEgkzPNg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lWd8iso7; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717707444; x=1749243444; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0YDydmrLM+QcJt9k0PKK2l8blVDYOm5Dy8R+sDL5ZoU=; b=lWd8iso7ncPBVMDHPDZqSm1UdXabLd9DS4MIHLkz040N/JkG5mj5bRR4 mFOkTpqC4ylpO4NNnwMD5YbNtyTZTqOfUt12v+5kKhUCeyW1nfmhtLtLY iUqj7EzQdKura++P687bqkNqOH1QIYM9b5syrHtcnrtBvHaiWQeil85pj ude6C3oKRHakHzFZGoLqLekUmPyFfq2AARCa0U9Mhc38VhEcXxNAWvrM0 2jXbn5e+9p2WlTT3A/ntcGt+F7mfgHmyTR565cczVgAfQY0kYYS7NGrG5 hNCKBPpRASue4cW2LCXwyZrCQedbzHSXy/hoTj/hsgOUOlJiOhgZdFXx9 A==; X-CSE-ConnectionGUID: PHsBnh2LSACVk+4Ir8lLpQ== X-CSE-MsgGUID: acCcdXXKQXCQh+jrZcwqPw== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="25037103" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="25037103" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 13:57:21 -0700 X-CSE-ConnectionGUID: eCSDLjILRbWzkLQGw6eCCQ== X-CSE-MsgGUID: oRLCIz2TRByKgYpSFipjnw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="61304490" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa002.fm.intel.com with ESMTP; 06 Jun 2024 13:57:19 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 82B4F30B; Thu, 06 Jun 2024 23:57:18 +0300 (EEST) From: Andy Shevchenko To: Mika Westerberg , Andy Shevchenko , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , Andy Shevchenko , Hans de Goede Subject: [PATCH v4 3/3] ACPI: PMIC: Replace open coded be16_to_cpu() Date: Thu, 6 Jun 2024 23:54:16 +0300 Message-ID: <20240606205712.3187675-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240606205712.3187675-1-andriy.shevchenko@linux.intel.com> References: <20240606205712.3187675-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit It's easier to understand the nature of a data type when it's written explicitly. With that, replace open coded endianess conversion. As a side effect it fixes the returned value of intel_crc_pmic_update_aux() since ACPI PMIC core code expects negative or zero and never uses positive one. While at it, use macros from bits.h to reduce a room for mistake. Signed-off-by: Andy Shevchenko Reviewed-by: Mika Westerberg --- drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c index 35744a0307aa..79f9df552524 100644 --- a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c +++ b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c @@ -8,12 +8,16 @@ */ #include +#include #include #include #include +#include #include "intel_pmic.h" /* registers stored in 16bit BE (high:low, total 10bit) */ +#define PMIC_REG_MASK GENMASK(9, 0) + #define CHTDC_TI_VBAT 0x54 #define CHTDC_TI_DIETEMP 0x56 #define CHTDC_TI_BPTHERM 0x58 @@ -73,7 +77,7 @@ static int chtdc_ti_pmic_get_power(struct regmap *regmap, int reg, int bit, if (regmap_read(regmap, reg, &data)) return -EIO; - *value = data & 1; + *value = data & BIT(0); return 0; } @@ -85,13 +89,12 @@ static int chtdc_ti_pmic_update_power(struct regmap *regmap, int reg, int bit, static int chtdc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg) { - u8 buf[2]; + __be16 buf; - if (regmap_bulk_read(regmap, reg, buf, sizeof(buf))) + if (regmap_bulk_read(regmap, reg, &buf, sizeof(buf))) return -EIO; - /* stored in big-endian */ - return ((buf[0] & 0x03) << 8) | buf[1]; + return be16_to_cpu(buf) & PMIC_REG_MASK; } static const struct intel_pmic_opregion_data chtdc_ti_pmic_opregion_data = { -- 2.43.0.rc1.1336.g36b5255a03ac