[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20130625175625.3F434E0090@blue.fi.intel.com>
Date: Tue, 25 Jun 2013 20:56:25 +0300 (EEST)
From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Mika Westerberg <mika.westerberg@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Jesse Barnes <jbarnes@...tuousgeek.org>,
Yinghai Lu <yinghai@...nel.org>, john.ronciak@...el.com,
miles.j.penner@...el.com, bruce.w.allan@...el.com,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
linux-pci@...r.kernel.org, x86@...nel.org
Subject: Re: [PATCH 3/6] PCI: introduce pci_trim_stale_devices()
Andy Shevchenko wrote:
> On Tue, Jun 25, 2013 at 7:22 PM, Mika Westerberg
> <mika.westerberg@...ux.intel.com> wrote:
>
> > The new function stops and removes the device if it doesn't respond.
> > If the device responds and it's a bus we apply the function to all
> > subdevices recursively.
> >
> > It's useful for hotplug bus check case, when you need drop all unplugged
> > devices before looking for new ones.
>
> One comment below.
>
> > +void pci_trim_stale_devices(struct pci_dev *dev)
> > +{
> > + struct pci_bus *bus = dev->subordinate;
> > + struct pci_dev *child, *tmp;
> > + bool alive;
> > + u32 l;
> > +
> > + /* check if the device responds */
> > + alive = pci_bus_read_dev_vendor_id(dev->bus, dev->devfn, &l, 0);
> > + if (!alive)
> > + pci_stop_and_remove_bus_device(dev);
> > +
> > + if (alive && bus)
> > + list_for_each_entry_safe(child, tmp, &bus->devices, bus_list)
> > + pci_trim_stale_devices(child);
>
> It's not a tail call anyway, so, what about
>
> if (!pci_bus_read_dev_vendor_id(dev->bus, dev->devfn, &l, 0)) {
> pci_stop_and_remove_bus_device(dev);
> } else if (bus) {
> list_for_each_entry_safe(child, tmp, &bus->devices, bus_list)
> pci_trim_stale_devices(child);
> }
Why? It looks uglier.
--
Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists