All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>,
	Hanna Linder <hannal@us.ibm.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	kernel-janitors@lists.osdl.org, davej@codemonkey.org.uk,
	hpa@zytor.com
Subject: [Kernel-janitors] Re: [PATCH 2.6.9-rc2-mm2] Create new function to
Date: Sun, 26 Sep 2004 14:10:02 +0000	[thread overview]
Message-ID: <20040926141002.GA24942@kroah.com> (raw)
In-Reply-To: <1096059645.10797.1.camel@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 3901 bytes --]

On Fri, Sep 24, 2004 at 10:00:47PM +0100, Alan Cox wrote:
> On Gwe, 2004-09-24 at 22:19, Greg KH wrote:
> > > Please include subdevice/subvendor id
> > 
> > Good idea, but do you see any places in the kernel that would use those
> > fields, instead of always setting them to PCI_ANY_ID?
> 
> If you are taking that path then make it take a pci_device_id table.
> That makes it behave like other interfaces of the same form, and makes
> the implementation remarkably trivial.

Ah, yes, that is a very good idea.  Here's just such an implementation
(compile tested, nothing else, still need to add comments describing the
function...)  Does everyone like this interface?  Hanna, look ok to you?

thanks,

greg k-h

--- 1.42/drivers/pci/pci-driver.c	2004-09-22 16:24:29 -07:00
+++ edited/drivers/pci/pci-driver.c	2004-09-26 06:44:32 -07:00
@@ -14,27 +14,6 @@
  *  Registration of PCI drivers and handling of hot-pluggable devices.
  */
 
-/**
- * pci_match_one_device - Tell if a PCI device structure has a matching
- *                        PCI device id structure
- * @id: single PCI device id structure to match
- * @dev: the PCI device structure to match against
- * 
- * Returns the matching pci_device_id structure or %NULL if there is no match.
- */
-
-static inline const struct pci_device_id *
-pci_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;
-}
-
 /*
  * Dynamic device IDs are disabled for !CONFIG_HOTPLUG
  */
===== drivers/pci/pci.h 1.18 vs edited =====
--- 1.18/drivers/pci/pci.h	2004-09-22 07:07:44 -07:00
+++ edited/drivers/pci/pci.h	2004-09-26 06:44:28 -07:00
@@ -66,3 +66,24 @@
 extern int pcie_mch_quirk;
 extern void pcie_rootport_aspm_quirk(struct pci_dev *pdev);
 extern struct device_attribute pci_dev_attrs[];
+
+/**
+ * pci_match_one_device - Tell if a PCI device structure has a matching
+ *                        PCI device id structure
+ * @id: single PCI device id structure to match
+ * @dev: the PCI device structure to match against
+ * 
+ * Returns the matching pci_device_id structure or %NULL if there is no match.
+ */
+static inline const struct pci_device_id *
+pci_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;
+}
+
===== drivers/pci/search.c 1.31 vs edited =====
--- 1.31/drivers/pci/search.c	2004-08-26 15:16:41 -07:00
+++ edited/drivers/pci/search.c	2004-09-26 07:02:57 -07:00
@@ -11,6 +11,7 @@
 #include <linux/pci.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include "pci.h"
 
 spinlock_t pci_bus_lock = SPIN_LOCK_UNLOCKED;
 
@@ -343,6 +344,29 @@
 	spin_unlock(&pci_bus_lock);
 	return dev;
 }
+
+int pci_dev_present(const struct pci_device_id *ids)
+{
+	struct pci_dev *dev;
+	int found = 0;
+
+	WARN_ON(in_interrupt());
+	spin_lock(&pci_bus_lock);
+	while (ids->vendor || ids->subvendor || ids->class_mask) {
+		list_for_each_entry(dev, &pci_devices, global_list) {
+			if (pci_match_one_device(ids, dev)) {
+				found = 1;
+				goto exit;
+			}
+		}
+		ids++;
+	}
+exit:				
+	spin_unlock(&pci_bus_lock);
+	return found;
+}
+EXPORT_SYMBOL(pci_dev_present);
+
 
 EXPORT_SYMBOL(pci_find_bus);
 EXPORT_SYMBOL(pci_find_device);

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <greg@kroah.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>,
	Hanna Linder <hannal@us.ibm.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	kernel-janitors@lists.osdl.org, davej@codemonkey.org.uk,
	hpa@zytor.com
Subject: Re: [PATCH 2.6.9-rc2-mm2] Create new function to see if pci dev is present
Date: Sun, 26 Sep 2004 07:10:02 -0700	[thread overview]
Message-ID: <20040926141002.GA24942@kroah.com> (raw)
In-Reply-To: <1096059645.10797.1.camel@localhost.localdomain>

On Fri, Sep 24, 2004 at 10:00:47PM +0100, Alan Cox wrote:
> On Gwe, 2004-09-24 at 22:19, Greg KH wrote:
> > > Please include subdevice/subvendor id
> > 
> > Good idea, but do you see any places in the kernel that would use those
> > fields, instead of always setting them to PCI_ANY_ID?
> 
> If you are taking that path then make it take a pci_device_id table.
> That makes it behave like other interfaces of the same form, and makes
> the implementation remarkably trivial.

Ah, yes, that is a very good idea.  Here's just such an implementation
(compile tested, nothing else, still need to add comments describing the
function...)  Does everyone like this interface?  Hanna, look ok to you?

thanks,

greg k-h

--- 1.42/drivers/pci/pci-driver.c	2004-09-22 16:24:29 -07:00
+++ edited/drivers/pci/pci-driver.c	2004-09-26 06:44:32 -07:00
@@ -14,27 +14,6 @@
  *  Registration of PCI drivers and handling of hot-pluggable devices.
  */
 
-/**
- * pci_match_one_device - Tell if a PCI device structure has a matching
- *                        PCI device id structure
- * @id: single PCI device id structure to match
- * @dev: the PCI device structure to match against
- * 
- * Returns the matching pci_device_id structure or %NULL if there is no match.
- */
-
-static inline const struct pci_device_id *
-pci_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;
-}
-
 /*
  * Dynamic device IDs are disabled for !CONFIG_HOTPLUG
  */
===== drivers/pci/pci.h 1.18 vs edited =====
--- 1.18/drivers/pci/pci.h	2004-09-22 07:07:44 -07:00
+++ edited/drivers/pci/pci.h	2004-09-26 06:44:28 -07:00
@@ -66,3 +66,24 @@
 extern int pcie_mch_quirk;
 extern void pcie_rootport_aspm_quirk(struct pci_dev *pdev);
 extern struct device_attribute pci_dev_attrs[];
+
+/**
+ * pci_match_one_device - Tell if a PCI device structure has a matching
+ *                        PCI device id structure
+ * @id: single PCI device id structure to match
+ * @dev: the PCI device structure to match against
+ * 
+ * Returns the matching pci_device_id structure or %NULL if there is no match.
+ */
+static inline const struct pci_device_id *
+pci_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;
+}
+
===== drivers/pci/search.c 1.31 vs edited =====
--- 1.31/drivers/pci/search.c	2004-08-26 15:16:41 -07:00
+++ edited/drivers/pci/search.c	2004-09-26 07:02:57 -07:00
@@ -11,6 +11,7 @@
 #include <linux/pci.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include "pci.h"
 
 spinlock_t pci_bus_lock = SPIN_LOCK_UNLOCKED;
 
@@ -343,6 +344,29 @@
 	spin_unlock(&pci_bus_lock);
 	return dev;
 }
+
+int pci_dev_present(const struct pci_device_id *ids)
+{
+	struct pci_dev *dev;
+	int found = 0;
+
+	WARN_ON(in_interrupt());
+	spin_lock(&pci_bus_lock);
+	while (ids->vendor || ids->subvendor || ids->class_mask) {
+		list_for_each_entry(dev, &pci_devices, global_list) {
+			if (pci_match_one_device(ids, dev)) {
+				found = 1;
+				goto exit;
+			}
+		}
+		ids++;
+	}
+exit:				
+	spin_unlock(&pci_bus_lock);
+	return found;
+}
+EXPORT_SYMBOL(pci_dev_present);
+
 
 EXPORT_SYMBOL(pci_find_bus);
 EXPORT_SYMBOL(pci_find_device);

  reply	other threads:[~2004-09-26 14:10 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-23 22:26 [Kernel-janitors] [PATCH 2.6.9-rc2-mm2] Create new function to see Hanna Linder
2004-09-23 22:26 ` [PATCH 2.6.9-rc2-mm2] Create new function to see if pci dev is present Hanna Linder
2004-09-23 22:28 ` [Kernel-janitors] [PATCH 2.6.9-rc2-mm2] Change cyrix.c driver to Hanna Linder
2004-09-23 22:28   ` [PATCH 2.6.9-rc2-mm2] Change cyrix.c driver to use new pci_dev_present Hanna Linder
2004-09-23 22:28 ` [Kernel-janitors] [PATCH 2.6.9-rc2-mm2] Change irq.c driver to use Hanna Linder
2004-09-23 22:28   ` [PATCH 2.6.9-rc2-mm2] Change irq.c driver to use new pci_dev_present Hanna Linder
2004-09-23 22:50 ` [Kernel-janitors] Re: [PATCH 2.6.9-rc2-mm2] Create new function to Greg KH
2004-09-23 22:50   ` [PATCH 2.6.9-rc2-mm2] Create new function to see if pci dev is present Greg KH
2004-10-02  5:35   ` [Kernel-janitors] Re: [PATCH 2.6.9-rc2-mm4 pci_bus_cvlink.c] Judith Lebzelter
2004-10-02  5:35     ` [PATCH 2.6.9-rc2-mm4 pci_bus_cvlink.c] Replace pci_find_device with pci_get_device Judith Lebzelter
2004-09-24 19:02 ` [Kernel-janitors] Re: [PATCH 2.6.9-rc2-mm2] Create new function to Christoph Hellwig
2004-09-24 19:02   ` [PATCH 2.6.9-rc2-mm2] Create new function to see if pci dev is present Christoph Hellwig
2004-09-24 21:19   ` [Kernel-janitors] Re: [PATCH 2.6.9-rc2-mm2] Create new function to Greg KH
2004-09-24 21:19     ` [PATCH 2.6.9-rc2-mm2] Create new function to see if pci dev is present Greg KH
2004-09-24 21:00     ` [Kernel-janitors] Re: [PATCH 2.6.9-rc2-mm2] Create new function to Alan Cox
2004-09-24 21:00       ` [PATCH 2.6.9-rc2-mm2] Create new function to see if pci dev is present Alan Cox
2004-09-26 14:10       ` Greg KH [this message]
2004-09-26 14:10         ` Greg KH
2004-09-28 17:24         ` [Kernel-janitors] Re: Create new function to see if pci dev is Greg KH
2004-09-28 17:24           ` Create new function to see if pci dev is present Greg KH
2004-09-28 17:25           ` [Kernel-janitors] Re: Create new function to see if pci dev is Greg KH
2004-09-28 17:25             ` Create new function to see if pci dev is present Greg KH
2004-09-28 17:26           ` [Kernel-janitors] Re: Create new function to see if pci dev is Greg KH
2004-09-28 17:26             ` Create new function to see if pci dev is present Greg KH
2004-09-24 21:26     ` [Kernel-janitors] Re: [PATCH 2.6.9-rc2-mm2] Create new function to H. Peter Anvin
2004-09-24 21:26       ` [PATCH 2.6.9-rc2-mm2] Create new function to see if pci dev is present H. Peter Anvin
  -- strict thread matches above, loose matches on Subject: below --
2004-10-01 18:10 [Kernel-janitors] [PATCH 2.6.9-rc2-mm4 pci_bus_cvlink.c] Replace Hanna Linder
2004-10-01 18:10 ` [PATCH 2.6.9-rc2-mm4 pci_bus_cvlink.c] Replace pci_find_device with pci_get_device Hanna Linder

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=20040926141002.GA24942@kroah.com \
    --to=greg@kroah.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davej@codemonkey.org.uk \
    --cc=hannal@us.ibm.com \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=kernel-janitors@lists.osdl.org \
    --cc=linux-kernel@vger.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 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.