All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] pciback: Fix invalid use of pci_match_id()
Date: Fri, 27 Feb 2009 17:34:59 +0900	[thread overview]
Message-ID: <49A7A5B3.6010302@ab.jp.nec.com> (raw)

We cannot use pci_match_id() because the first argument (tmp_quirk->devid)
is not an array of pci device ids. Instead this patch adds a utility function
to compare a pci_device_id and a pci_dev.

Thank you,
-----------------------
Yosuke Iwamatsu
        NEC Corporation


Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>

diff -r 2f1b770d84e5 drivers/xen/pciback/conf_space_quirks.c
--- a/drivers/xen/pciback/conf_space_quirks.c	Tue Feb 17 11:31:13 2009 +0000
+++ b/drivers/xen/pciback/conf_space_quirks.c	Thu Feb 26 17:09:13 2009 +0900
@@ -13,13 +13,25 @@
 
 LIST_HEAD(pciback_quirks);
 
+static inline const struct pci_device_id *
+match_one_device(const struct pci_device_id *id, const struct pci_dev *dev)
+{
+	if ((id->vendor == PCI_ANY_ID || id->vendor == dev->vendor) &&
+	    (id->device == PCI_ANY_ID || id->device == dev->device) &&
+	    (id->subvendor == PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) &&
+	    (id->subdevice == PCI_ANY_ID || id->subdevice == dev->subsystem_device) &&
+	    !((id->class ^ dev->class) & id->class_mask))
+		return id;
+	return NULL;
+}
+
 struct pciback_config_quirk *pciback_find_quirk(struct pci_dev *dev)
 {
 	struct pciback_config_quirk *tmp_quirk;
 
 	list_for_each_entry(tmp_quirk, &pciback_quirks, quirks_list)
-	    if (pci_match_id(&tmp_quirk->devid, dev))
-		goto out;
+		if (match_one_device(&tmp_quirk->devid, dev) != NULL)
+			goto out;
 	tmp_quirk = NULL;
 	printk(KERN_DEBUG
 	       "quirk didn't match any device pciback knows about\n");

                 reply	other threads:[~2009-02-27  8:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=49A7A5B3.6010302@ab.jp.nec.com \
    --to=y-iwamatsu@ab.jp.nec.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.