Re: [PATCH] edac: move const pci_device_id tables from __devinitdatato __devinitconst.

From: Julia Lawall
Date: Sun Mar 04 2012 - 17:17:14 EST


I also looked at whether PCI_DEVICE and PCI_DEVICE_CLASS could be used more often, and came up with the semantic patch shown below. This should work with the current release of Coccinelle. This affects 40 files, only one of which can use PCI_DEVICE_CLASS. Perhaps it could be useful to generalize it. Again, I don't have time now to look into it in more detail, but can provide the results if somone is interested.

julia

@@
identifier id;
expression dev_class, dev_class_mask;
@@

struct pci_device_id id[] = {
...,
{
- .class = (dev_class), .class_mask = (dev_class_mask),
- .vendor = PCI_ANY_ID, .device = PCI_ANY_ID,
- .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
+ PCI_DEVICE_CLASS(dev_class,dev_class_mask),
},
...
};

@@
identifier id;
declarer name DEFINE_PCI_DEVICE_TABLE;
expression dev_class, dev_class_mask;
@@

DEFINE_PCI_DEVICE_TABLE(id) = {
...,
{
- .class = (dev_class), .class_mask = (dev_class_mask),
- .vendor = PCI_ANY_ID, .device = PCI_ANY_ID,
- .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
+ PCI_DEVICE_CLASS(dev_class,dev_class_mask),
},
...
};

@@
identifier id;
expression vend, dev;
@@

struct pci_device_id id[] = {
...,
{
- .vendor = (vend), .device = (dev),
- .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
+ PCI_DEVICE(vend,dev),
},
...
};

@@
identifier id;
expression vend, dev;
@@

DEFINE_PCI_DEVICE_TABLE(id) = {
...,
{
- .vendor = (vend), .device = (dev),
- .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
+ PCI_DEVICE(vend,dev),
},
...
};
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/