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: <E0BFDD6F-0611-4BBA-8382-7D54AAE1772E@live.com>
Date: Sun, 9 Feb 2025 07:27:52 +0000
From: Aditya Garg <gargaditya08@...e.com>
To: Jiri Kosina <jikos@...nel.org>, "jkosina@...e.com" <jkosina@...e.com>,
	Benjamin Tissoires <benjamin.tissoires@...hat.com>, "bentiss@...nel.org"
	<bentiss@...nel.org>
CC: Orlando Chamberlain <orlandoch.dev@...il.com>, Kerem Karabay
	<kekrby@...il.com>, "linux-input@...r.kernel.org"
	<linux-input@...r.kernel.org>, Linux Kernel Mailing List
	<linux-kernel@...r.kernel.org>
Subject: [PATCH 2/2] HID: hid-appletb-bl: use appletb_bl_brightness_map
 instead of magic numbers to set default brightness

From: Aditya Garg <gargaditya08@...e.com>

This commit makes use of appletb_bl_brightness_map instead of using if
statements and magic numbers to set default brightness, and thus simplifies
the code.

Signed-off-by: Aditya Garg <gargaditya08@...e.com>
---
 drivers/hid/hid-appletb-bl.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/hid-appletb-bl.c b/drivers/hid/hid-appletb-bl.c
index 819157686..1a3dcd44b 100644
--- a/drivers/hid/hid-appletb-bl.c
+++ b/drivers/hid/hid-appletb-bl.c
@@ -141,12 +141,8 @@ static int appletb_bl_probe(struct hid_device *hdev, const struct hid_device_id
 	bl->aux1_field = aux1_field;
 	bl->brightness_field = brightness_field;
 
-	if (appletb_bl_def_brightness == 0)
-		ret = appletb_bl_set_brightness(bl, APPLETB_BL_OFF);
-	else if (appletb_bl_def_brightness == 1)
-		ret = appletb_bl_set_brightness(bl, APPLETB_BL_DIM);
-	else
-		ret = appletb_bl_set_brightness(bl, APPLETB_BL_ON);
+	ret = appletb_bl_set_brightness(bl,
+		appletb_bl_brightness_map[(appletb_bl_def_brightness > 2) ? 2 : appletb_bl_def_brightness]);
 
 	if (ret) {
 		dev_err_probe(dev, ret, "Failed to set touch bar brightness to off\n");
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ