Skip to contentSkip to conversation

HID: hid-appletb-kbd: make struct attribute *appletb_kbd_attrs[] static

PATCH In review Aditya Garg 2 participants 3 messages Feb 9, 2025 – Feb 10, 2025 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 HID: hid-appletb-kbd: make struct attribute *appletb_kbd_attrs[] static

From: Aditya Garg <[email protected]>

This commit addresses the sparse warning flagged by the kernel test robot.

---
 drivers/hid/hid-appletb-kbd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/hid-appletb-kbd.c +2 -2
index fa28a691d..38fc0e58c 100644
@@ -4,7 +4,7 @@
  *
  * Copyright (c) 2017-2018 Ronald Tschalär
  * Copyright (c) 2022-2023 Kerem Karabay <[email protected]>
- * Copyright (c) 2024 Aditya Garg <[email protected]>
+ * Copyright (c) 2024-2025 Aditya Garg <[email protected]>
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -143,7 +143,7 @@ static ssize_t mode_store(struct device *dev,
 }
 static DEVICE_ATTR_RW(mode);
 
-struct attribute *appletb_kbd_attrs[] = {
+static struct attribute *appletb_kbd_attrs[] = {
 	&dev_attr_mode.attr,
 	NULL
 };
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/2 HID: hid-appletb-bl: use appletb_bl_brightness_map instead of magic numbers to set default brightness

From: Aditya Garg <[email protected]>

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.

---
 drivers/hid/hid-appletb-bl.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/hid/hid-appletb-bl.c +2 -6
index 819157686..1a3dcd44b 100644
@@ -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");
Signature · 1 line
2.43.0