lkml.org 
[lkml]   [2000]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Patch(?): pci_device_id tables for drivers/scsi in 2.4.0-test11
Keith Owens wrote:
>
> [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
> }

* your macro fails for the 'ANY' case, because the proper macro is
PCI_ANY_ID not PCI_{VENDOR,DEVICE}_ID_ANY.
* many drivers need to set the driver_data field

That said, the general idea presented above is quite good. The PCITBL
macro will probably change on a per-driver basis... I don't think it
belongs in a common header. For example, ethernet drivers might want to
have a macro that always checks for PCI-CLASS-ETHERNET under the hood,
while visibly looking like

PCITBL(INTEL, 82437VX, {a driver_data value}),
PCITBL(INTEL, 82987VX, {another driver_data value}),
PCITBL_END

Jeff


--
Jeff Garzik |
Building 1024 | The chief enemy of creativity is "good" sense
MandrakeSoft | -- Picasso
-
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/

\
 
 \ /
  Last update: 2005-03-22 12:47    [W:0.066 / U:2.688 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site