lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240225-regulator-mp8859-v1-1-68ee2c839ded@kernel.org>
Date: Sun, 25 Feb 2024 14:59:27 +0000
From: Mark Brown <broonie@...nel.org>
To: Liam Girdwood <lgirdwood@...il.com>
Cc: linux-kernel@...r.kernel.org, Markus Reichl <m.reichl@...etechno.de>, 
 Mark Brown <broonie@...nel.org>
Subject: [PATCH 1/8] regulator: mp8859: Specify register accessibility and
 enable caching

Avoid needless accesses to the hardware by caching register values that
we know, marking status registers as volatile as appropriate.

Signed-off-by: Mark Brown <broonie@...nel.org>
---
 drivers/regulator/mp8859.c | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/mp8859.c b/drivers/regulator/mp8859.c
index b820bd6043e5..689b56680d93 100644
--- a/drivers/regulator/mp8859.c
+++ b/drivers/regulator/mp8859.c
@@ -77,11 +77,47 @@ static const struct linear_range mp8859_dcdc_ranges[] = {
 	REGULATOR_LINEAR_RANGE(0, VOL_MIN_IDX, VOL_MAX_IDX, 10000),
 };
 
+static bool mp8859_readable(struct device *dev, unsigned int reg)
+{
+	switch (reg) {
+	case MP8859_VOUT_L_REG:
+	case MP8859_VOUT_H_REG:
+	case MP8859_VOUT_GO_REG:
+	case MP8859_IOUT_LIM_REG:
+	case MP8859_CTL1_REG:
+	case MP8859_CTL2_REG:
+	case MP8859_STATUS_REG:
+	case MP8859_INTERRUPT_REG:
+	case MP8859_MASK_REG:
+	case MP8859_ID1_REG:
+	case MP8859_MFR_ID_REG:
+	case MP8859_DEV_ID_REG:
+	case MP8859_IC_REV_REG:
+		return true;
+	default:
+		return false;
+	}
+}
+
+static bool mp8859_volatile(struct device *dev, unsigned int reg)
+{
+	switch (reg) {
+	case MP8859_VOUT_GO_REG:
+	case MP8859_STATUS_REG:
+	case MP8859_INTERRUPT_REG:
+		return true;
+	default:
+		return false;
+	}
+}
+
 static const struct regmap_config mp8859_regmap = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.max_register = MP8859_MAX_REG,
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
+	.readable_reg = mp8859_readable,
+	.volatile_reg = mp8859_volatile,
 };
 
 static const struct regulator_ops mp8859_ops = {

-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ