Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: make PCI device id constant

The id_table field of the struct pci_driver is constant in <linux/pci.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: Németh Márton <nm127@freemail.hu>
Cc: Julia Lawall <julia@diku.dk>
Cc: cocci@diku.dk
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Németh Márton and committed by
Greg Kroah-Hartman
13ac58da 75b16013

+6 -6
+1 -1
drivers/staging/phison/phison.c
··· 69 69 return ret; 70 70 } 71 71 72 - static struct pci_device_id phison_pci_tbl[] = { 72 + static const struct pci_device_id phison_pci_tbl[] = { 73 73 { PCI_VENDOR_ID_PHISON, PCI_DEVICE_ID_PS5000, PCI_ANY_ID, PCI_ANY_ID, 74 74 PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 0 }, 75 75 { 0, },
+1 -1
drivers/staging/rar/rar_driver.c
··· 71 71 static int __devinit rar_probe(struct pci_dev *pdev, 72 72 const struct pci_device_id *ent); 73 73 74 - static struct pci_device_id rar_pci_id_tbl[] = { 74 + static const struct pci_device_id rar_pci_id_tbl[] = { 75 75 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4110) }, 76 76 { 0 } 77 77 };
+1 -1
drivers/staging/sep/sep_driver.c
··· 2587 2587 return error; 2588 2588 } 2589 2589 2590 - static struct pci_device_id sep_pci_id_tbl[] = { 2590 + static const struct pci_device_id sep_pci_id_tbl[] = { 2591 2591 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x080c)}, 2592 2592 {0} 2593 2593 };
+1 -1
drivers/staging/sm7xx/smtcfb.c
··· 1103 1103 1104 1104 1105 1105 /* Jason (08/11/2009) PCI_DRV wrapper essential structs */ 1106 - static struct pci_device_id smtcfb_pci_table[] = { 1106 + static const struct pci_device_id smtcfb_pci_table[] = { 1107 1107 {0x126f, 0x710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1108 1108 {0x126f, 0x712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1109 1109 {0x126f, 0x720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+1 -1
drivers/staging/vme/bridges/vme_ca91cx42.c
··· 61 61 62 62 static char driver_name[] = "vme_ca91cx42"; 63 63 64 - static struct pci_device_id ca91cx42_ids[] = { 64 + static const struct pci_device_id ca91cx42_ids[] = { 65 65 { PCI_DEVICE(PCI_VENDOR_ID_TUNDRA, PCI_DEVICE_ID_TUNDRA_CA91C142) }, 66 66 { }, 67 67 };
+1 -1
drivers/staging/vme/bridges/vme_tsi148.c
··· 81 81 82 82 static char driver_name[] = "vme_tsi148"; 83 83 84 - static struct pci_device_id tsi148_ids[] = { 84 + static const struct pci_device_id tsi148_ids[] = { 85 85 { PCI_DEVICE(PCI_VENDOR_ID_TUNDRA, PCI_DEVICE_ID_TUNDRA_TSI148) }, 86 86 { }, 87 87 };