Skip to content

Commit 79bf7fc

Browse files
committed
Merge branch 'pci/misc' into next
* pci/misc: PCI/checkpatch: Deprecate DEFINE_PCI_DEVICE_TABLE
2 parents 47e0ab3 + 92e112f commit 79bf7fc

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎Documentation/PCI/pci.txt‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ initialization with a pointer to a structure describing the driver
123123

124124

125125
The ID table is an array of struct pci_device_id entries ending with an
126-
all-zero entry; use of the macro DEFINE_PCI_DEVICE_TABLE is the preferred
127-
method of declaring the table. Each entry consists of:
126+
all-zero entry. Definitions with static const are generally preferred.
127+
Use of the deprecated macro DEFINE_PCI_DEVICE_TABLE should be avoided.
128+
129+
Each entry consists of:
128130

129131
vendor,device Vendor and device ID to match (or PCI_ANY_ID)
130132

‎include/linux/pci.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,7 @@ struct pci_driver {
635635
* DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table
636636
* @_table: device table name
637637
*
638-
* This macro is used to create a struct pci_device_id array (a device table)
639-
* in a generic manner.
638+
* This macro is deprecated and should not be used in new code.
640639
*/
641640
#define DEFINE_PCI_DEVICE_TABLE(_table) \
642641
const struct pci_device_id _table[]

‎scripts/checkpatch.pl‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,10 +2634,13 @@ sub process {
26342634
$herecurr);
26352635
}
26362636

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+
}
26412644
}
26422645

26432646
# check for new typedefs, only function parameters and sparse annotations

0 commit comments

Comments
 (0)