hid: make USB device id constant
PATCH 1/1 hid: make USB device id constant
From: Márton Németh <[email protected]>
The id_table field of the struct usb_device_id is constant in <linux/usb.h> so it is worth to make the initialization data also constant.
The semantic match that finds this kind of pattern is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r@
disable decl_init,const_decl_init;
identifier I1, I2, x;
@@
struct I1 {
...
const struct I2 *x;
...
};@s@
identifier r.I1, y;
identifier r.x, E;
@@
struct I1 y = {
.x = E,
};@c@
identifier r.I2;
identifier s.E;
@@
const struct I2 E[] = ... ;
@depends on !c@
identifier r.I2;
identifier s.E;
@@
+ const
struct I2 E[] = ...;
// </smpl>
---
drivers/hid/usbhid/hid-core.c 2010-01-08 18:55:16.000000000 +0100 renamed from drivers/hid/usbhid/hid-core.c 2010-01-07 19:08:40.000000000 +0100 +1 -1
@@ -1342,7 +1342,7 @@ static int hid_reset_resume(struct usb_i #endif /* CONFIG_PM */ -static struct usb_device_id hid_usb_ids [] = { +static const struct usb_device_id hid_usb_ids[] = { { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS, .bInterfaceClass = USB_INTERFACE_CLASS_HID }, { } /* Terminating entry */
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)
Jiri Kosina
AppliedQuoted 4 lines · Németh Márton
From: Márton Németh <[email protected]>
The
id_tablefield of the structusb_device_idis constant in <linux/usb.h> so it is worth to make the initialization data also constant.
Applied, thanks.
Signature · 6 lines
Jiri Kosina SUSE Labs, Novell Inc. -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html