Re: [PATCH kvm-unit-tests 06/17] pci: introduce struct pci_dev

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

 



On Fri, Nov 04, 2016 at 05:41:01PM +0100, Andrew Jones wrote:
> >  /* Scan bus look for a specific device. Only bus 0 scanned for now. */
> > -pcidevaddr_t pci_find_dev(uint16_t vendor_id, uint16_t device_id)
> > +int pci_find_dev(struct pci_dev *pci_dev, uint16_t vendor_id, uint16_t device_id)
> >  {
> >  	pcidevaddr_t dev;
> >  
> > -	for (dev = 0; dev < 256; ++dev) {
> > +	for (dev = 0; dev < PCI_DEVFN_MAX; ++dev) {
> 
> Why introduce this PCI_DEVFN_MAX define?
> 
> >  		if (pci_config_readw(dev, PCI_VENDOR_ID) == vendor_id &&
> > -		    pci_config_readw(dev, PCI_DEVICE_ID) == device_id)
> > -			return dev;
> > +		    pci_config_readw(dev, PCI_DEVICE_ID) == device_id) {
> > +			pci_dev_init(pci_dev, dev);
> > +			return 0;
> > +		}
> >  	}
> >  
> > -	return PCIDEVADDR_INVALID;
> > +	return -1;
> 
> Why not use bool for the ret type; true=good, false=bad?

Both ways look strange to me. I would leave pci_find_dev() as is (low-
level) and move pci_dev_init() outside - so a usage would be i.e.:

	dev = pci_find_dev(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_TEST);
	if (dev == PCIDEVADDR_INVALID)
		...
	pci_dev_init(&pci_dev, dev);

> Thanks,
> drew
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux