Skip to contentSkip to conversation

HID: lenovo: Make array tp10ubkbd_led static const

PATCH Applied Colin Ian King 2 participants 2 messages Oct 5, 2022 – Oct 18, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 HID: lenovo: Make array tp10ubkbd_led static const

Don't populate the read-only array tp10ubkbd_led on the stack but instead make it static const. Also makes the object code a little smaller.

---
V2: Fix commit message, somehow I fat fingered the first one.

---
 drivers/hid/hid-lenovo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-lenovo.c +1 -1
index 9dabd6323234..44763c0da444 100644
@@ -985,7 +985,7 @@ static int lenovo_led_brightness_set(struct led_classdev *led_cdev,
 	struct device *dev = led_cdev->dev->parent;
 	struct hid_device *hdev = to_hid_device(dev);
 	struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
-	u8 tp10ubkbd_led[] = { TP10UBKBD_MUTE_LED, TP10UBKBD_MICMUTE_LED };
+	static const u8 tp10ubkbd_led[] = { TP10UBKBD_MUTE_LED, TP10UBKBD_MICMUTE_LED };
 	int led_nr = 0;
 	int ret = 0;
 
Signature · 1 line
2.37.3
maintainer Applied
#1 lore raw
Quoted 15 lines · Colin Ian King

Don't populate the read-only array tp10ubkbd_led on the stack but instead make it static const. Also makes the object code a little smaller.

---
V2: Fix commit message, somehow I fat fingered the first one.

---
 drivers/hid/hid-lenovo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-lenovo.c +0 -0
index 9dabd6323234..44763c0da444 100644

drivers/hid/hid-lenovo.c static int lenovo_led_brightness_set(struct led_classdev *led_cdev, · line 990

Quoted 7 lines
drivers/hid/hid-lenovo.c +1 -1
@@ -985,7 +985,7 @@ static int lenovo_led_brightness_set(struct led_classdev *led_cdev,
 	struct device *dev = led_cdev->dev->parent;
 	struct hid_device *hdev = to_hid_device(dev);
 	struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
-	u8 tp10ubkbd_led[] = { TP10UBKBD_MUTE_LED, TP10UBKBD_MICMUTE_LED };
+	static const u8 tp10ubkbd_led[] = { TP10UBKBD_MUTE_LED, TP10UBKBD_MICMUTE_LED };
 	int led_nr = 0;
 	int ret = 0;

Applied, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs