Re: Patch(?): pci_device_id tables for drivers/scsi in 2.4.0-test11

From: Keith Owens (kaos@ocs.com.au)
Date: Thu Nov 23 2000 - 02:00:19 EST


[Adam J. Richter]
> +static struct pci_device_id atp870u_pci_tbl[] __initdata = {
> +{vendor: 0x1191, device: 0x8002, subvendor: PCI_ANY_ID, subdevice: PCI_ANY_ID},
> +{vendor: 0x1191, device: 0x8010, subvendor: PCI_ANY_ID, subdevice: PCI_ANY_ID},

It would make it easier to read and safer to type if you used a macro
to generate the fields.

#define PCITBL(v,d,sv,sd) \
 { PCI_VENDOR_ID_##v, PCI_DEVICE_ID_##d, \
   PCI_VENDOR_ID_##sv, PCI_DEVICE_ID_##sd }

#define PCITBL_END {0,0,0,0}

static struct pci_device_id foo_pci_tbl[] __initdata = {
  PCITBL(INTEL, INTEL_82437VX, ANY, ANY),
  PCITBL_END
}

Shorter is easier to read. Using a prefix on the fields makes it much
harder for somebody to accidentally swap device and vendor codes. If
they swap the parameters and type
  PCITBL(INTEL_82437VX, INTEL, ANY, ANY),
by mistake then they get compile errors, PCI_VENDOR_ID_INTEL_82437VX
and PCI_DEVICE_ID_INTEL are undefined.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Nov 23 2000 - 21:00:25 EST