Skip to contentSkip to conversation

HID: Constify static struct hid_device_id

PATCH Applied Rikard Falkeborn 2 participants 4 messages Jul 27, 2020 – Aug 17, 2020 HID

lore
Share & tools
lore
#0 lore raw

cover HID: Constify static struct hid_device_id

Constify hid_device_id in two drivers (these were the only drivers that didn't already have it as const).

Rikard Falkeborn (2):
HID: cougar: Constify cougar_id_table
HID: macally: Constify macally_id_table

 drivers/hid/hid-cougar.c  | 2 +-
 drivers/hid/hid-macally.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/2 HID: cougar: Constify cougar_id_table

cougar_id_table[] is not changed and can be made const to allow the compiler to put it in read-only memory.

---
 drivers/hid/hid-cougar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-cougar.c +1 -1
index 4ff3bc1d25e2..28d671c5e0ca 100644
@@ -321,7 +321,7 @@ static const struct kernel_param_ops cougar_g6_is_space_ops = {
 };
 module_param_cb(g6_is_space, &cougar_g6_is_space_ops, &g6_is_space, 0644);
 
-static struct hid_device_id cougar_id_table[] = {
+static const struct hid_device_id cougar_id_table[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SOLID_YEAR,
 			 USB_DEVICE_ID_COUGAR_500K_GAMING_KEYBOARD) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SOLID_YEAR,
Signature · 1 line
2.27.0
#2 lore raw

PATCH 2/2 HID: macally: Constify macally_id_table

In reply to Rikard Falkeborn

macally_id_table is not modified and can be made const to allow the compiler to put it in read-only memory.

---
 drivers/hid/hid-macally.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-macally.c +1 -1
index 9a4fc7dffb14..aea46e522008 100644
@@ -29,7 +29,7 @@ static __u8 *macally_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 	return rdesc;
 }
 
-static struct hid_device_id macally_id_table[] = {
+static const struct hid_device_id macally_id_table[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SOLID_YEAR,
 			 USB_DEVICE_ID_MACALLY_IKEY_KEYBOARD) },
 	{ }
Signature · 1 line
2.27.0
maintainer Applied
#3 lore raw
In reply to Rikard Falkeborn
Quoted 10 lines · Rikard Falkeborn

Constify hid_device_id in two drivers (these were the only drivers that didn't already have it as const).

Rikard Falkeborn (2):
HID: cougar: Constify cougar_id_table
HID: macally: Constify macally_id_table

 drivers/hid/hid-cougar.c  | 2 +-
 drivers/hid/hid-macally.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Applied both patches, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs