lkml.org 
[lkml]   [2022]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3 1/4] PCI: Clean up pci_scan_slot()
From
Date
> > > +	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.
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2022-04-21 13:15    [W:0.086 / U:2.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site