PCI drivers - Linux

This is a discussion on PCI drivers - Linux ; Hello, I've been exploring several linux PCI drivers and now I wonder why most of developers don't use definitions of VENDOR_ID and DEVICE_ID when filling the 'struct pci_device_id'. Most are using numeric values. Is this sort of rule or there're ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: PCI drivers

  1. PCI drivers

    Hello,

    I've been exploring several linux PCI drivers and now I wonder why most of
    developers don't use definitions of VENDOR_ID and
    DEVICE_ID when filling the 'struct pci_device_id'.

    Most are using numeric values. Is this sort of rule or there're other deep
    reasons?

    "Linix device drivers, 3rd edition" doesn't explain it neither.

    Thank you.

    With best regards, Roman Mashak. E-mail: mrv@tusur.ru



  2. Re: PCI drivers

    Roman Mashak wrote:
    > I've been exploring several linux PCI drivers and now I wonder why
    > most of developers don't use definitions of
    > VENDOR_ID and DEVICE_ID when filling the 'struct pci_device_id'.


    Two guesses:
    1. At the time the drivers were written, the IDs weren't registered yet.
    2. They were too lazy to look them up. Using lspci you get the IDs and that
    should be enough for your driver.

    As far as I'm concerned, I'd be happy to see patches (and I wouldn't be
    surprised if you found some errors/discrepancies/missing IDs along the
    way).

    BTW: this is kind of a generic answer, considering that PCI IDs are just
    another form of 'magic numbers' in the code.

    cheers

    Uli


  3. Re: PCI drivers

    Hello, Ulrich!
    You wrote on Tue, 09 Jan 2007 08:12:59 +0100:

    UE> Two guesses:
    UE> 1. At the time the drivers were written, the IDs weren't registered
    UE> yet. 2. They were too lazy to look them up. Using lspci you get the IDs
    UE> and that should be enough for your driver.

    Your guesses seem to be correct. Though I always though 'magic numbers'
    should be eliminated and replaced with descriptive names, considering some
    kind of support kernel provides (pci_ids.h etc.)

    IMHO, it merely helps to have consistent, readable & self-documenting code
    :-)

    UE> BTW: this is kind of a generic answer, considering that PCI IDs are
    UE> just another form of 'magic numbers' in the code.


    With best regards, Roman Mashak. E-mail: mrv@tusur.ru



  4. Re: PCI drivers

    "Roman Mashak" wrote:
    >
    >I've been exploring several linux PCI drivers and now I wonder why most of
    >developers don't use definitions of VENDOR_ID and
    >DEVICE_ID when filling the 'struct pci_device_id'.


    Lag time. If I create a new device driver and add the symbols to my
    personal copy of pci_ids.h, no one else can build my driver unless they
    also edit their copy of pci_ids.h.

    It's possible to work around that by putting something like this in a
    private .h file:

    #ifndef PCI_VENDOR_GREATCO
    #define PCI_VENDOR_GREATCO 0xabcd
    #endif
    #ifndef PCI_DEVICE_SPUDKICKER
    #define PCI_DEVICE_SPUDKICKER 0xef10
    #endif
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

+ Reply to Thread