values from pci_dev or read from config space - pci

Oscar Salvador osalvador.vilardaga at gmail.com
Tue Aug 26 02:33:18 EDT 2014


Hi everybody!

I was thinking about post this question in the linux-pci list, but I'm
not sure if this question is very basic for it, so maybe it's better
aks here.
If not, I'll ask there.

My question is about that I'm writing a driver for a old realtek
network card, only for learning purposes, and I was conviced that I
could read the values from the config space( values related to IRQ,
I/O memory regions), examples:

pci_read_config_byte(dev, IRQ_OFFSET, &irq);
rtiomemr_start = pci_resource_start(dev, IO_MEM);
rtiomemr_len = pci_resource_len(dev, IO_MEM);
rtiomemr_end = pci_resource_end(dev, IO_MEM);

But then I read in the Documentation/pci.text that the correct way to
achieve this values are reading the valzes stored in the pci_dev
structure.

Actually, with the values from I/O memory regions I didn't have any
problem, but I got a different values for IRQ.

If I get the IRQ from the pci_dev, I get a X, but if I get the IRQ
from the config space, I get another different number Y.

Would be you so kind to explain:

1- Why it's better use the values stored in pci_dev structure instead
of read from config space.
2- Why the IRQ number is different? (Maybe this question is answered
with the first question hehe)

Thank you very much
Best regards



More information about the Kernelnewbies mailing list