On Tue, Nov 27, 2012 at 02:32:11PM +0800, Daniel J Blueman wrote:
> Fix locating sibling memory controller PCI functions by using the
> correct PCI domain.
> 
> v7: Refactor patches grouping changes
> 
> Signed-off-by: Daniel J Blueman <dan...@numascale-asia.com>
> ---
>  drivers/edac/amd64_edac.c |   40 +++++++++++++++++++++-------------------
>  1 file changed, 21 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
> index 60e93fa..62b7b17 100644
> --- a/drivers/edac/amd64_edac.c
> +++ b/drivers/edac/amd64_edac.c
> @@ -983,6 +983,24 @@ static u64 get_error_address(struct mce *m)
>       return addr;
>  }
>  
> +static struct pci_dev *pci_get_related_function(unsigned int vendor,
> +                                             unsigned int device,
> +                                             struct pci_dev *related)
> +{
> +     struct pci_dev *dev = NULL;
> +
> +     dev = pci_get_device(vendor, device, dev);
> +     while (dev) {
> +             if (pci_domain_nr(dev->bus) == pci_domain_nr(related->bus) &&
> +                 (dev->bus->number == related->bus->number) &&
> +                 (PCI_SLOT(dev->devfn) == PCI_SLOT(related->devfn)))
> +                     break;
> +             dev = pci_get_device(vendor, device, dev);
> +     }

This loop looks strange and I'm wondering, wouldn't it be more
straightforward to simply do:

        while (dev = pci_get_device(vendor, device, dev)) {
                if (...)
                        break;
        }

        return dev;

I realize the original code does this pci_get_device twice but it is
crap IMO.

Thanks.

-- 
Regards/Gruss,
    Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to