public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Owens <kaos@ocs.com.au>
To: "Adam J. Richter" <adam@yggdrasil.com>, linux-kernel@vger.kernel.org
Subject: Re: Patch(?): pci_device_id tables for drivers/scsi in 2.4.0-test11
Date: Thu, 23 Nov 2000 18:00:19 +1100	[thread overview]
Message-ID: <882.974962819@ocs3.ocs-net> (raw)
In-Reply-To: Your message of "Thu, 23 Nov 2000 00:02:07 MDT." <20001123000207.O2918@wire.cadcamlab.org>

[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/

  reply	other threads:[~2000-11-23  7:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-22 12:51 Patch(?): pci_device_id tables for drivers/scsi in 2.4.0-test11 Adam J. Richter
2000-11-22 13:04 ` Christoph Hellwig
2000-11-23  6:02 ` Peter Samuelson
2000-11-23  7:00   ` Keith Owens [this message]
2000-11-23  7:25     ` Jeff Garzik
2000-11-23  7:31       ` Keith Owens
  -- strict thread matches above, loose matches on Subject: below --
2000-11-22 13:11 Adam J. Richter
2000-11-23 10:20 Adam J. Richter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=882.974962819@ocs3.ocs-net \
    --to=kaos@ocs.com.au \
    --cc=adam@yggdrasil.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox