Re: [PATCH 3/6] PCI: introduce pci_trim_stale_devices()

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

 



On Tue, Jun 25, 2013 at 7:22 PM, Mika Westerberg
<mika.westerberg@xxxxxxxxxxxxxxx> 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);
   }

> +}

--
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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