On Wednesday 13 October 2021 16:47:43 Rob Herring wrote: > On Wed, Oct 13, 2021 at 12:17 PM Naveen Naidu <naveennaidu479@xxxxxxxxx> wrote: > > The thread does bring up a good point, about not returning any error > > values in pci_read_config_*() and converting the function definition to > > something like > > > > void pci_read_config_word(struct pci_dev *dev, int where, u16 *val) > > > > The reason stated in the thread was that, the error values returned from > > these functions are either ignored or are not used properly. And > > whenever an error occurs, the error value ~0 is anyway stored in val, we > > could use that to test errors. > > Presumably, there could be some register somewhere where all 1s is > valid? So I think we need the error values. I guess that "Prefetchable Base/Limit Upper 32 Bits" PCI registers can contains all-ones value and it is valid value in these registers. And also PCIe regs like "Slot Capabilities Register" can also have all bits set. So 0xffffffff does not mean that error happened. It is needed some application logic which can decide based on other things (like register number, device state, etc...) if 0xffffffff indicates error or not. Therefore return errno values can help, but only for controllers which provide this additional errno information. > Also, I seem to recall only the vendor/device IDs are defined to be > all 1s for non-existent devices. Other errors are undefined? In PCIe spec for vendor id register is mentioned that 0xffff indicates no Function is present.