Re: ioremap of PCI resources

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2013-04-10 17:16, H Hartley Sweeten wrote:
On Wednesday, March 06, 2013 4:34 PM, H Hartley Sweeten wrote:

Question, when doing an ioremap() of a PCI resource which is more correct?

	iobase = pci_resource_start(pcidev, bar);
	len = pci_resource_len(pcidev, bar);
	mmio = ioremap(iobase, len);

or

	mmio = pci_ioremap_bar(pcidev, bar);

pci_ioremap_bar() does some extra sanity checking to make sure the bar
is actually a memory resource and then does an ioremap_nocache().

If the ioremap() is in order to talk to the registers on the PCI device wouldn't
the pci_ioremap_bar() be more correct?

Greg / Ian / Dan,

Do you have any ideas/opinions on the question above?

Saves a couple of lines of code, I suppose. The extra sanity makes sense for the function to do for defensive programming reasons, but is not particularly useful for the caller unless there are some (presumably older) variants of a PCI card that match the driver's PCI ID table, but have registers in I/O space instead of memory space (in which case, it's better that pci_ioremap_bar() returns the NULL rather than ioremap_nocache() attempting to remap a port address (though that would probably fail and return NULL anyway).

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux