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-next>] [day] [month] [year] [list]
Message-ID: <FD47E76E-F8D0-4EE4-A050-E3A569806BFA@live.com>
Date: Wed, 12 Feb 2025 16:09:04 +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 Kernel Mailing List <linux-kernel@...r.kernel.org>,
	"linux-input@...r.kernel.org" <linux-input@...r.kernel.org>
Subject: [PATCH v2 1/2] HID: hid-appletb-kbd: simplify logic used to switch
 between media and function keys on pressing fn key

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

This commit simplifies the logic in appletb_kbd_inp_event used for
switching between the media and function keys on pressing the fn key.

We now also prevent touching the kbd->saved_mode variable in case the esc
key only mode is chosen.

The following small fixes have also been done in this patch:

- A small comment style error has been fixed
- Fixed spelling in MODULE_DESCRIPTION
- I have added myself to MODULE_AUTHOR

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

diff --git a/drivers/hid/hid-appletb-kbd.c b/drivers/hid/hid-appletb-kbd.c
index 38fc0e58c..2c74ac2e1 100644
--- a/drivers/hid/hid-appletb-kbd.c
+++ b/drivers/hid/hid-appletb-kbd.c
@@ -236,13 +236,13 @@ static void appletb_kbd_inp_event(struct input_handle *handle, unsigned int type
 
 	reset_inactivity_timer(kbd);
 
-	if (type == EV_KEY && code == KEY_FN && appletb_tb_fn_toggle) {
+	if (type == EV_KEY && code == KEY_FN && appletb_tb_fn_toggle &&
+		(kbd->current_mode == APPLETB_KBD_MODE_SPCL ||
+		 kbd->current_mode == APPLETB_KBD_MODE_FN)) {
 		if (value == 1) {
 			kbd->saved_mode = kbd->current_mode;
-			if (kbd->current_mode == APPLETB_KBD_MODE_SPCL)
-				appletb_kbd_set_mode(kbd, APPLETB_KBD_MODE_FN);
-			else if (kbd->current_mode == APPLETB_KBD_MODE_FN)
-				appletb_kbd_set_mode(kbd, APPLETB_KBD_MODE_SPCL);
+			appletb_kbd_set_mode(kbd, kbd->current_mode == APPLETB_KBD_MODE_SPCL
+						? APPLETB_KBD_MODE_FN : APPLETB_KBD_MODE_SPCL);
 		} else if (value == 0) {
 			if (kbd->saved_mode != kbd->current_mode)
 				appletb_kbd_set_mode(kbd, kbd->saved_mode);
@@ -497,10 +497,11 @@ static struct hid_driver appletb_kbd_hid_driver = {
 };
 module_hid_driver(appletb_kbd_hid_driver);
 
-/* The backlight driver should be loaded before the keyboard driver is initialised*/
+/* The backlight driver should be loaded before the keyboard driver is initialised */
 MODULE_SOFTDEP("pre: hid_appletb_bl");
 
 MODULE_AUTHOR("Ronald Tschalär");
 MODULE_AUTHOR("Kerem Karabay <kekrby@...il.com>");
-MODULE_DESCRIPTION("MacBookPro Touch Bar Keyboard Mode Driver");
+MODULE_AUTHOR("Aditya Garg <gargaditya08@...e.com>");
+MODULE_DESCRIPTION("MacBook Pro Touch Bar Keyboard Mode driver");
 MODULE_LICENSE("GPL");
-- 
2.39.5 (Apple Git-154)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ