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: <20250407095119.588920-4-mitltlatltl@gmail.com>
Date: Mon,  7 Apr 2025 17:51:18 +0800
From: Pengyu Luo <mitltlatltl@...il.com>
To: Jianhua Lu <lujianhua000@...il.com>,
	Lee Jones <lee@...nel.org>,
	Daniel Thompson <danielt@...nel.org>,
	Jingoo Han <jingoohan1@...il.com>,
	Pavel Machek <pavel@...nel.org>,
	Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Helge Deller <deller@....de>
Cc: dri-devel@...ts.freedesktop.org,
	linux-leds@...r.kernel.org,
	devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	linux-fbdev@...r.kernel.org,
	Pengyu Luo <mitltlatltl@...il.com>
Subject: [PATCH 3/4] backlight: ktz8866: improve current sinks setting

I polled all registers when the module was loading, found that
current sinks have already been configured. Bootloader would set
when booting. So checking it before setting the all channels.

Signed-off-by: Pengyu Luo <mitltlatltl@...il.com>
---
 drivers/video/backlight/ktz8866.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/video/backlight/ktz8866.c b/drivers/video/backlight/ktz8866.c
index 017ad80dd..b67ca136d 100644
--- a/drivers/video/backlight/ktz8866.c
+++ b/drivers/video/backlight/ktz8866.c
@@ -46,6 +46,8 @@
 #define LCD_BIAS_EN 0x9F
 #define PWM_HYST 0x5
 
+#define CURRENT_SINKS_MASK GENMASK(5, 0)
+
 struct ktz8866_slave {
 	struct i2c_client *client;
 	struct regmap *regmap;
@@ -65,6 +67,12 @@ static const struct regmap_config ktz8866_regmap_config = {
 	.max_register = REG_MAX,
 };
 
+static inline void ktz8866_read(struct ktz8866 *ktz, unsigned int reg,
+				unsigned int *val)
+{
+	regmap_read(ktz->regmap, reg, &val);
+}
+
 static void ktz8866_write(struct ktz8866 *ktz, unsigned int reg,
 			  unsigned int val)
 {
@@ -112,11 +120,18 @@ static void ktz8866_init(struct ktz8866 *ktz)
 {
 	unsigned int val = 0;
 
-	if (!of_property_read_u32(ktz->client->dev.of_node, "current-num-sinks", &val))
+	if (!of_property_read_u32(ktz->client->dev.of_node, "current-num-sinks", &val)) {
 		ktz8866_write(ktz, BL_EN, BIT(val) - 1);
-	else
-		/* Enable all 6 current sinks if the number of current sinks isn't specified. */
-		ktz8866_write(ktz, BL_EN, BIT(6) - 1);
+	} else {
+		/*
+		 * Enable all 6 current sinks if the number of current
+		 * sinks isn't specified and the bootloader didn't set
+		 * the value.
+		 */
+		ktz8866_read(ktz, BL_EN, &val);
+		if (!(val && CURRENT_SINKS_MASK))
+			ktz8866_write(ktz, BL_EN, CURRENT_SINKS_MASK);
+	}
 
 	if (!of_property_read_u32(ktz->client->dev.of_node, "kinetic,current-ramp-delay-ms", &val)) {
 		if (val <= 128)
-- 
2.49.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ