From: Borislav Petkov <bp@alien8.de>
To: Daniel J Blueman <daniel@numascale-asia.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
H Peter Anvin <hpa@zytor.com>,
Steffen Persvold <sp@numascale.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4 v7] AMD64 EDAC: Fix PCI function lookup
Date: Thu, 29 Nov 2012 14:36:50 +0100 [thread overview]
Message-ID: <20121129133650.GA30789@liondog.tnic> (raw)
In-Reply-To: <1353997932-8475-3-git-send-email-daniel@numascale-asia.com>
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 <daniel@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.
next prev parent reply other threads:[~2012-11-29 13:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-27 6:32 [PATCH 1/4 v7] AMD64 EDAC: Add multi-domain support Daniel J Blueman
2012-11-27 6:32 ` [PATCH 2/4 v7] AMD64 EDAC: Consistently use u16 for northbridge IDs in amd_get_nb_id Daniel J Blueman
2013-01-22 16:50 ` [tip:x86/platform] x86, AMD, NB: Use " tip-bot for Daniel J Blueman
2012-11-27 6:32 ` [PATCH 3/4 v7] AMD64 EDAC: Fix PCI function lookup Daniel J Blueman
2012-11-29 13:36 ` Borislav Petkov [this message]
2012-11-27 6:32 ` [PATCH 4/4 v7] AMD64 EDAC: Fix type usage in NB IDs and memory ranges Daniel J Blueman
2012-11-29 14:34 ` Borislav Petkov
2013-01-22 16:49 ` [tip:x86/platform] x86, AMD, NB: Add multi-domain support tip-bot for Daniel J Blueman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121129133650.GA30789@liondog.tnic \
--to=bp@alien8.de \
--cc=daniel@numascale-asia.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=sp@numascale.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®