mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] HID: hid-appletb-kbd: simplify logic used to switch between media and function keys on pressing fn key
@ 2025-02-12 10:02 Aditya Garg
  2025-02-12 10:03 ` [PATCH 2/2] HID: hid-appletb-bl: fix incorrect error message for default brightness Aditya Garg
  0 siblings, 1 reply; 2+ messages in thread
From: Aditya Garg @ 2025-02-12 10:02 UTC (permalink / raw)
  To: Jiri Kosina, jkosina, Benjamin Tissoires, bentiss
  Cc: Orlando Chamberlain, Kerem Karabay, Linux Kernel Mailing List,
	linux-input

From: Aditya Garg <gargaditya08@live.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.

A small comment style error has also been fixed and I have added myself to
MODULE_AUTHOR.

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

diff --git a/drivers/hid/hid-appletb-kbd.c b/drivers/hid/hid-appletb-kbd.c
index 38fc0e58c..c248ce825 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@gmail.com>");
+MODULE_AUTHOR("Aditya Garg <gargaditya08@live.com>");
 MODULE_DESCRIPTION("MacBookPro Touch Bar Keyboard Mode Driver");
 MODULE_LICENSE("GPL");
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] HID: hid-appletb-bl: fix incorrect error message for default brightness
  2025-02-12 10:02 [PATCH 1/2] HID: hid-appletb-kbd: simplify logic used to switch between media and function keys on pressing fn key Aditya Garg
@ 2025-02-12 10:03 ` Aditya Garg
  0 siblings, 0 replies; 2+ messages in thread
From: Aditya Garg @ 2025-02-12 10:03 UTC (permalink / raw)
  To: Jiri Kosina, jkosina, Benjamin Tissoires, bentiss
  Cc: Orlando Chamberlain, Kerem Karabay, Linux Kernel Mailing List,
	linux-input

From: Aditya Garg <gargaditya08@live.com>

The error message responsible to show failure to set default backlight
brightness incorrectly showed the intended brightness as off irrespective
of what the user had set it. This patch intends to fix the same.

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

diff --git a/drivers/hid/hid-appletb-bl.c b/drivers/hid/hid-appletb-bl.c
index 1a3dcd44b..8e15ad5b6 100644
--- a/drivers/hid/hid-appletb-bl.c
+++ b/drivers/hid/hid-appletb-bl.c
@@ -145,7 +145,8 @@ static int appletb_bl_probe(struct hid_device *hdev, const struct hid_device_id
 		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");
+		dev_err_probe(dev, ret, "Failed to set default touch bar brightness to %d\n",
+			      appletb_bl_def_brightness);
 		goto close_hw;
 	}
 
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-12 10:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-12 10:02 [PATCH 1/2] HID: hid-appletb-kbd: simplify logic used to switch between media and function keys on pressing fn key Aditya Garg
2025-02-12 10:03 ` [PATCH 2/2] HID: hid-appletb-bl: fix incorrect error message for default brightness Aditya Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®