diff mbox series

[v4,1/3] HID: hid-appletb-kbd: simplify logic used to switch between media and function keys on pressing fn key

Message ID 8365C1B3-3A38-4F6E-955B-D6BBABA6B00A@live.com (mailing list archive)
State New
Delegated to: Jiri Kosina
Headers show
Series [v4,1/3] HID: hid-appletb-kbd: simplify logic used to switch between media and function keys on pressing fn key | expand

Commit Message

Aditya Garg Feb. 17, 2025, 4:43 a.m. UTC
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.

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@live.com>
---
 drivers/hid/hid-appletb-kbd.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Jiri Kosina Feb. 18, 2025, 7:57 p.m. UTC | #1
On Mon, 17 Feb 2025, Aditya Garg wrote:

> 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.
> 
> 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@live.com>

What a flood of patchseries :) I don't see any mentions on what are the 
v1->v2->v3->v4 changes, could you please document that?
Aditya Garg Feb. 18, 2025, 8:05 p.m. UTC | #2
Hi Jiri

> On 19 Feb 2025, at 1:27 AM, Jiri Kosina <jikos@kernel.org> wrote:
> 
> On Mon, 17 Feb 2025, Aditya Garg wrote:
> 
>> 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.
>> 
>> 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@live.com>
> 
> What a flood of patchseries :) I don't see any mentions on what are the 
> v1->v2->v3->v4 changes, could you please document that?
> 

Extremely sorry for nor giving a changelog. I’ll make sure it’s done next time.

V2: Spellings in MODULE_DESCRIPTION were also fixed.
V3: The 3/3 patch was added since the bug was flagged by kernel test robot
V4: Extra tabs were removed from 3/3 as reported by Dan Carpenter.
> -- 
> Jiri Kosina
> SUSE Labs
Jiri Kosina Feb. 18, 2025, 9:02 p.m. UTC | #3
Applied all three patches to hid.git#for-6.15/apple. Thanks,
diff mbox series

Patch

diff --git a/drivers/hid/hid-appletb-kbd.c b/drivers/hid/hid-appletb-kbd.c
index 38fc0e58c..e45cc3ac4 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_DESCRIPTION("MacBookPro Touch Bar Keyboard Mode Driver");
+MODULE_AUTHOR("Aditya Garg <gargaditya08@live.com>");
+MODULE_DESCRIPTION("MacBook Pro Touch Bar Keyboard Mode driver");
 MODULE_LICENSE("GPL");