Prefer use of the direct definition of struct pci_device_id instead of indirection via macro DEFINE_PCI_DEVICE_TABLE. Update the PCI documentation to deprecate DEFINE_PCI_DEVICE_TABLE. Update checkpatch adding --fix option.
Showing the changes to scripts/checkpatch.pl (1 of 3 files). Show all
Unified · Split
| @@ -2634,10 +2634,13 @@ sub process { · 2633 unmodified lines | ||
| 2634 | 2634 | $herecurr); |
| 2635 | 2635 | } |
| 2636 | 2636 | |
| 2637 | −# check for declarations of struct pci_device_id | |
| 2638 | − if ($line =~ /\bstruct\s+pci_device_id\s+\w+\s*\[\s*\]\s*\=\s*\{/) { | |
| 2639 | − WARN("DEFINE_PCI_DEVICE_TABLE", | |
| 2640 | − "Use DEFINE_PCI_DEVICE_TABLE for struct pci_device_id\n" . $herecurr); | |
| 2637 | +# check for uses of DEFINE_PCI_DEVICE_TABLE | |
| 2638 | + if ($line =~ /\bDEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=/) { | |
| 2639 | + if (WARN("DEFINE_PCI_DEVICE_TABLE", | |
| 2640 | + "Prefer struct pci_device_id over deprecated DEFINE_PCI_DEVICE_TABLE\n" . $herecurr) && | |
| 2641 | + $fix) { | |
| 2642 | + $fixed[$linenr - 1] =~ s/\b(?:static\s+|)DEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=\s*/static const struct pci_device_id $1\[\] = /; | |
| 2643 | + } | |
| 2641 | 2644 | } |
| 2642 | 2645 | |
| 2643 | 2646 | # check for new typedefs, only function parameters and sparse annotations |