File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,8 +123,10 @@ initialization with a pointer to a structure describing the driver
123123
124124
125125The 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
Original file line number Diff line number Diff 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[]
Original file line number Diff line number Diff line change @@ -2634,10 +2634,13 @@ sub process {
26342634 $herecurr );
26352635 }
26362636
2637- # check for declarations of struct pci_device_id
2638- if ($line =~ / \b struct\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 =~ / \b DEFINE_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
You can’t perform that action at this time.
0 commit comments