Re: [PATCH v3 1/4] PCI: Clean up pci_scan_slot()

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

 



> > > +	return (fn <= 6) ? fn + 1 : -ENODEV;
> > >  }
> > >  
> > >  static int only_one_child(struct pci_bus *bus)
> > > @@ -2643,24 +2645,19 @@ static int only_one_child(struct pci_bus *bus)
> > >   */
> > >  int pci_scan_slot(struct pci_bus *bus, int devfn)
> > >  {
> > > -	unsigned int fn, nr = 0;
> > > -	struct pci_dev *dev;
> > > +	int fn, nr = 0;
> > > +	struct pci_dev *dev = NULL;
> > >  
> > >  	if (only_one_child(bus) && (devfn > 0))
> > >  		return 0; /* Already scanned the entire slot */
> > >  
> > > -	dev = pci_scan_single_device(bus, devfn);
> > > -	if (!dev)
> > > -		return 0;
> > > 

As it might not have been clear in my previous mail. The above !dev
test just for the "devfn + 0" case is equivalent to the new:

if (!dev && fn == 0)
	return -ENODEV;

As fn doesn't wrap around anymore fn == 0 is true only for the first
iteration. Both in the existing and in the changed code the first
pci_scan_single_device() happens before the first next_fn() call though
with the new code that then breaks the loop instead of the above
return. This makes sense in my mind because if the first function
doesn't exist there are no more functions except if we have isolated
PCI functions due to a hypervisor.

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux