All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Andi Kleen <ak@suse.de>
Cc: davej@codemonkey.org.uk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix improper use of pci_module_init() in drivers/char/agp/amd64-agp.c
Date: Thu, 30 Sep 2004 13:09:02 -0700	[thread overview]
Message-ID: <20040930200902.GA18271@kroah.com> (raw)
In-Reply-To: <20040930195905.GA18162@kroah.com>

On Thu, Sep 30, 2004 at 12:59:05PM -0700, Greg KH wrote:
> > The idea is to run it as fallback when no devices are found. 
> > 
> > How about this patch?
> 
> That does not work the way you are asking it to work.  pci_module_init()
> is just a replacement for pci_register_driver these days.  It will
> return either "0" if the driver is successfully registered, or a
> negative value if something bad happened.  It will not return the number
> of devices that this driver bound to.
> 
> So, if no devices are in the system, it will return 0, and again, the
> code you are wanting to run, will not.
> 
> So, how about using the new pci_dev_present() call instead?  That should
> be what you want, right?

Something like this perhaps?  (warning, not even compile tested...)

greg k-h

===== amd64-agp.c 1.33 vs edited =====
--- 1.33/drivers/char/agp/amd64-agp.c	2004-09-30 13:00:52 -07:00
+++ edited/amd64-agp.c	2004-09-30 13:07:07 -07:00
@@ -627,8 +627,15 @@
 	int err = 0;
 	if (agp_off)
 		return -EINVAL;
-	if (pci_module_init(&agp_amd64_pci_driver) > 0) {
+	if (pci_dev_present(agp_amd_pci_table))
+		return pci_register_driver(&agp_amd64_pci_driver);
+	else {
 		struct pci_dev *dev;
+		static struct pci_device_id amd64NB[] = {
+			{ PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1103) },
+			{ },
+		};
+
 		if (!agp_try_unsupported && !agp_try_unsupported_boot) {
 			printk(KERN_INFO PFX "No supported AGP bridge found.\n");
 #ifdef MODULE
@@ -640,13 +647,13 @@
 		}
 
 		/* First check that we have at least one AMD64 NB */
-		if (!pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, NULL))
+		if (!pci_dev_present(amd64NB))
 			return -ENODEV;
 
 		/* Look for any AGP bridge */
 		dev = NULL;
 		err = -ENODEV;
-		while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev))) {
+		while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev))) {
 			if (!pci_find_capability(dev, PCI_CAP_ID_AGP))
 				continue;
 			/* Only one bridge supported right now */

  parent reply	other threads:[~2004-09-30 20:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-30 18:42 [PATCH] fix improper use of pci_module_init() in drivers/char/agp/amd64-agp.c Greg KH
2004-09-30 19:20 ` Andi Kleen
2004-09-30 19:59   ` Greg KH
2004-09-30 20:06     ` Andi Kleen
2004-09-30 21:05       ` Greg KH
2004-09-30 20:09     ` Greg KH [this message]
2004-10-01  1:56 ` Dave Jones

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=20040930200902.GA18271@kroah.com \
    --to=greg@kroah.com \
    --cc=ak@suse.de \
    --cc=davej@codemonkey.org.uk \
    --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.