linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hid: make USB device id constant
@ 2010-01-10 16:59 Németh Márton
  2010-01-12 13:30 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Németh Márton @ 2010-01-10 16:59 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: LKML, cocci, linux-input

From: Márton Németh <nm127@freemail.hu>

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>

Signed-off-by: Márton Németh <nm127@freemail.hu>
Cc: Julia Lawall <julia@diku.dk>
Cc: cocci@diku.dk
---
diff -u -p a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
--- a/drivers/hid/usbhid/hid-core.c 2010-01-07 19:08:40.000000000 +0100
+++ b/drivers/hid/usbhid/hid-core.c 2010-01-08 18:55:16.000000000 +0100
@@ -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
Cocci@diku.dk
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] hid: make USB device id constant
  2010-01-10 16:59 [PATCH] hid: make USB device id constant Németh Márton
@ 2010-01-12 13:30 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2010-01-12 13:30 UTC (permalink / raw)
  To: Németh Márton; +Cc: linux-input, LKML, Julia Lawall, cocci

On Sun, 10 Jan 2010, Németh Márton wrote:

> From: Márton Németh <nm127@freemail.hu>
> 
> 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.

Applied, thanks.

-- 
Jiri Kosina
SUSE Labs, Novell Inc.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-01-12 13:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-10 16:59 [PATCH] hid: make USB device id constant Németh Márton
2010-01-12 13:30 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).