From patchwork Thu Jun 6 20:54:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 802031 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 F17D413A40F; Thu, 6 Jun 2024 20:57:23 +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=1717707445; cv=none; b=q2mo4N2XTyB7chDsoH5Z0QJZxrM2fQxskLWmkMyaBy2yX3BbQ7Zb+Vojfrc9cReR2i5vfRgIr1fumoaqEkg/DTCrk1zq7EtYFbyBHXX0uTiCi1rmchQo0wjsxr84CVt0BziRighFUsFYv+w999LMWprZ+mtKUjbTjn1ecDhvpww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717707445; c=relaxed/simple; bh=LdMVV7VYjMW/QGtJELET0s9Ow3c8JeYwxFjxuDpdc1I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ccWAwJ6gwll4NTHtdOk+z1kphp/1T4f1aHExF823qqcS13R3HJBzBThNLskgGAyLjHzPtpai/VuQ2WHSMs61A0dC2rpKWRNZ38xfjfkYkA6pKAIt51WhLEPIvjoRgHaw/QN849Y9l1BP8dYOnt17tRZgGPULCpssIA58vsB0FK8= 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=n1NVa/OF; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="n1NVa/OF" 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=LdMVV7VYjMW/QGtJELET0s9Ow3c8JeYwxFjxuDpdc1I=; b=n1NVa/OFNJmqbCwvwTHnAlEr2uGX9r9tejZDIx5x3yzVuGZ/K1z0/hBZ 3LNhTr0bHU/IVgqdTR3kE+9LVwAZTGhLQj0090DLeO4KqpRtxypJHzF2R 0xNtdInqxnwaTrnJP3uyjpltBJb3hzuWCgKCwveIGMij5T59KuJiUO33A roPmySORCOo8p3NhvS9aWw06wmnrXO6Ys2Enzh9Bs/ZGp6iQttquceJzT S2cw2iiK0e8dYkEB4Xpuu10DmNune5UyDxwA3ABUfDTgfesbwfiNPe3qM GlzGG2bU3BzeK3geBbkeFQPMDUJWG7Gkt6nwWcdKDt4qNCFhu5u7rb3W7 A==; X-CSE-ConnectionGUID: eTsRbNaISamf2w24eWj59g== X-CSE-MsgGUID: ufW2pL5jRBmQJO0eGyAcOA== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="25037096" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="25037096" 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: 520WyKoZReKiXykETOskaA== X-CSE-MsgGUID: NUIPwQjTQZaMlnGwMWS0RA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="61304491" 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 6B4A6F7; 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 1/3] ACPI: PMIC: Use sizeof() instead of hard coded value Date: Thu, 6 Jun 2024 23:54:14 +0300 Message-ID: <20240606205712.3187675-2-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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It's better to use sizeof() of a given buffer than spreading a hard coded value. Signed-off-by: Andy Shevchenko Reviewed-by: Mika Westerberg --- drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 2 +- drivers/acpi/pmic/intel_pmic_xpower.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c index c84ef3d15181..35744a0307aa 100644 --- a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c +++ b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c @@ -87,7 +87,7 @@ static int chtdc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg) { u8 buf[2]; - if (regmap_bulk_read(regmap, reg, buf, 2)) + if (regmap_bulk_read(regmap, reg, buf, sizeof(buf))) return -EIO; /* stored in big-endian */ diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c index 61bbe4c24d87..33c5e85294cd 100644 --- a/drivers/acpi/pmic/intel_pmic_xpower.c +++ b/drivers/acpi/pmic/intel_pmic_xpower.c @@ -255,7 +255,7 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg) if (ret) return ret; - ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2); + ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, sizeof(buf)); if (ret == 0) ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f); From patchwork Thu Jun 6 20:54:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 802387 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 62BDB4AEC3; Thu, 6 Jun 2024 20:57:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717707443; cv=none; b=mq5bgdEE+R14ho0MdDNG2Qn03nk0Jl7P7vfxdGgMDhuOx5kWxUpdFJHIY5dGCmQPLCEd7obGZoqfa0Q6yIkkAr9rlEf8TprcYIw8hkoLa39fkOMz3wZnIElF+p9B4ZeBceaFSRhpKBqj/xrDBrK1RS4768foFSagd3Kudh6PR20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717707443; c=relaxed/simple; bh=ngr0dpqQ8SleCp2Ne5jcEzrIZLckdn+bTl/6fh4gbMk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nKTvRpby7Wz0fJDYV5Umh5yYbJobP70oeT2WyHgBsp+Se5VTmA42icFF6jjekgcRqLxfUtq47DZZihOfUiGXMbvHo7L0X60CANJPMPJehwbfimAdn25uhFTKB5GZdQ0uJpmBBkIPLDuXlNlo+FVh3SbplH+UhDFHIZ+9yjlsf44= 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=NxvaJO12; arc=none smtp.client-ip=198.175.65.12 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NxvaJO12" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717707442; x=1749243442; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ngr0dpqQ8SleCp2Ne5jcEzrIZLckdn+bTl/6fh4gbMk=; b=NxvaJO12v+K0kZ6nzamqKiDqRBOVbKB45gFWo6lKLccEXTNCI4v/EEIu pUYYeQnHQ7L9Eq2Ti6u70kiuw9BPzW4gVbh+ZrM8PrsHfXBHby6+d9SYl FmpPRld9BhY2s9zpYVHM6l3kqD/nPHogZDeUfBYE8jC3xpdc/2PAdKlnP 5O56BaQLMe1SIFbjRb2s/aDHod6Yfhw8rM/Pw/6dT6SYzaFanfhepSdRL qlmXY2adSHhv2uUC1/BzCW9j7TRelyoaYod1bSa7qOlzlQ4gyTdfTefrQ PStXaMApG5FiXVV7ZissCgSSiahb9L1twLN+VjESL5mwnmQCFx2raKeT1 w==; X-CSE-ConnectionGUID: 1qiVjW8UQD6li1L/w0iItA== X-CSE-MsgGUID: 6ze5cL8gTRCjmweb5tUWcQ== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="25812556" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="25812556" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 13:57:22 -0700 X-CSE-ConnectionGUID: KdjEOdf4QaaOLJMA4lwAxg== X-CSE-MsgGUID: zjgdXO7wSFKo6stZcuLx7w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="75570843" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 06 Jun 2024 13:57:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 75BE52CF; 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 2/3] ACPI: PMIC: Convert pr_*() to dev_*() printing macros Date: Thu, 6 Jun 2024 23:54:15 +0300 Message-ID: <20240606205712.3187675-3-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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since we have a device pointer in the regmap, use it for error messages. Signed-off-by: Andy Shevchenko Reviewed-by: Mika Westerberg --- drivers/acpi/pmic/intel_pmic_chtwc.c | 5 +++-- drivers/acpi/pmic/intel_pmic_xpower.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/pmic/intel_pmic_chtwc.c b/drivers/acpi/pmic/intel_pmic_chtwc.c index f2c42f4c79ca..25aa3e33b09a 100644 --- a/drivers/acpi/pmic/intel_pmic_chtwc.c +++ b/drivers/acpi/pmic/intel_pmic_chtwc.c @@ -236,11 +236,12 @@ static int intel_cht_wc_exec_mipi_pmic_seq_element(struct regmap *regmap, u32 reg_address, u32 value, u32 mask) { + struct device *dev = regmap_get_device(regmap); u32 address; if (i2c_client_address > 0xff || reg_address > 0xff) { - pr_warn("%s warning addresses too big client 0x%x reg 0x%x\n", - __func__, i2c_client_address, reg_address); + dev_warn(dev, "warning addresses too big client 0x%x reg 0x%x\n", + i2c_client_address, reg_address); return -ERANGE; } diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c index 33c5e85294cd..43c5850b4bf3 100644 --- a/drivers/acpi/pmic/intel_pmic_xpower.c +++ b/drivers/acpi/pmic/intel_pmic_xpower.c @@ -274,11 +274,12 @@ static int intel_xpower_exec_mipi_pmic_seq_element(struct regmap *regmap, u16 i2c_address, u32 reg_address, u32 value, u32 mask) { + struct device *dev = regmap_get_device(regmap); int ret; if (i2c_address != 0x34) { - pr_err("%s: Unexpected i2c-addr: 0x%02x (reg-addr 0x%x value 0x%x mask 0x%x)\n", - __func__, i2c_address, reg_address, value, mask); + dev_err(dev, "Unexpected i2c-addr: 0x%02x (reg-addr 0x%x value 0x%x mask 0x%x)\n", + i2c_address, reg_address, value, mask); return -ENXIO; } From patchwork Thu Jun 6 20:54:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 802386 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lWd8iso7" 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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 = {