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: <20240926-add-performance-tuning-configuration-v2-2-fdbb654f5767@gmail.com>
Date: Thu, 26 Sep 2024 00:40:18 +0800
From: Yasin Lee <yasin.lee.x@...il.com>
To: Jonathan Cameron <jic23@...nel.org>, 
 Lars-Peter Clausen <lars@...afoo.de>, Rob Herring <robh@...nel.org>, 
 Krzysztof Kozlowski <krzk+dt@...nel.org>, 
 Conor Dooley <conor+dt@...nel.org>, yasin.lee.x@...look.com
Cc: linux-iio@...r.kernel.org, devicetree@...r.kernel.org, 
 linux-kernel@...r.kernel.org, Yasin Lee <yasin.lee.x@...il.com>
Subject: [PATCH v2 2/2] iio: proximity: hx9023s: Add performance tuning
 function

When hardware design introduces significant sensor data noise,
performance can be improved by adjusting register settings.

Signed-off-by: Yasin Lee <yasin.lee.x@...il.com>
---
 drivers/iio/proximity/hx9023s.c | 45 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/iio/proximity/hx9023s.c b/drivers/iio/proximity/hx9023s.c
index 8b9f84400e00..8f7995816545 100644
--- a/drivers/iio/proximity/hx9023s.c
+++ b/drivers/iio/proximity/hx9023s.c
@@ -582,6 +582,47 @@ static int hx9023s_ch_en(struct hx9023s_data *data, u8 ch_id, bool en)
 	return regmap_write(data->regmap, HX9023S_CH_NUM_CFG, data->ch_en_stat);
 }
 
+static int hx9023s_performance_tuning(struct hx9023s_data *data)
+{
+	int ret;
+	u32 i, len;
+	u8 addr_val[512];
+	struct device *dev = regmap_get_device(data->regmap);
+	struct fwnode_handle *fwnode = dev_fwnode(dev);
+
+	ret = fwnode_property_count_u8(fwnode, "tyhx,performance-tuning");
+	if (ret < 2 || ret > 512) {
+		if (ret < 0) {
+			dev_err(dev, "Failed to get length of property\n");
+			return ret;
+		}
+		dev_err(dev, "The property requires between 2 and 512 elements\n");
+		return -EINVAL;
+	}
+
+	len = ret;
+	if (len % 2 != 0) {
+		dev_err(dev, "The property must contain an even number of elements\n");
+		return -EINVAL;
+	}
+
+	ret = fwnode_property_read_u8_array(fwnode, "tyhx,performance-tuning", addr_val, len);
+	if (ret < 0) {
+		dev_err(dev, "Failed to read property\n");
+		return ret;
+	}
+
+	for (i = 0; i < len; i += 2) {
+		ret = regmap_write(data->regmap, addr_val[i], addr_val[i + 1]);
+		if (ret) {
+			dev_err(dev, "Failed to write register\n");
+			return ret;
+		}
+	}
+
+	return ret;
+}
+
 static int hx9023s_property_get(struct hx9023s_data *data)
 {
 	struct device *dev = regmap_get_device(data->regmap);
@@ -1045,6 +1086,10 @@ static int hx9023s_probe(struct i2c_client *client)
 	if (ret)
 		return dev_err_probe(dev, ret, "channel config failed\n");
 
+	ret = hx9023s_performance_tuning(data);
+	if (ret)
+		dev_warn(dev, "performance tuning not configured\n");
+
 	ret = regcache_sync(data->regmap);
 	if (ret)
 		return dev_err_probe(dev, ret, "regcache sync failed\n");

-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ