public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, pcihpd-discuss@lists.sourceforge.net
Subject: Re: [PATCH] PCI hotplug changes for 2.5.63
Date: Mon, 24 Feb 2003 17:16 -0800	[thread overview]
Message-ID: <1046135763287@kroah.com> (raw)
In-Reply-To: <10461357631881@kroah.com>

ChangeSet 1.1022.1.7, 2003/02/24 16:27:59-08:00, hch@lst.de

[PATCH] PCI: remove check_region abuse (and code duplication) from pci hp code

We have a function pci_dev_driver() to check whether a pci_dev has an
driver attached to it.  It's handling of legacy devices is a bit simpler
than what the hotplug code did (duplicated in various places), but if
that stuff is really needed the generic code should be updated.


diff -Nru a/drivers/hotplug/acpiphp_pci.c b/drivers/hotplug/acpiphp_pci.c
--- a/drivers/hotplug/acpiphp_pci.c	Mon Feb 24 17:15:37 2003
+++ b/drivers/hotplug/acpiphp_pci.c	Mon Feb 24 17:15:37 2003
@@ -217,47 +217,6 @@
 	return 0;
 }
 
-
-static int is_pci_dev_in_use (struct pci_dev* dev)
-{
-	/*
-	 * dev->driver will be set if the device is in use by a new-style
-	 * driver -- otherwise, check the device's regions to see if any
-	 * driver has claimed them
-	 */
-
-	int i, inuse=0;
-
-	if (dev->driver) return 1; //assume driver feels responsible
-
-	for (i = 0; !dev->driver && !inuse && (i < 6); i++) {
-		if (!pci_resource_start(dev, i))
-			continue;
-
-		if (pci_resource_flags(dev, i) & IORESOURCE_IO)
-			inuse = check_region(pci_resource_start(dev, i),
-					     pci_resource_len(dev, i));
-		else if (pci_resource_flags(dev, i) & IORESOURCE_MEM)
-			inuse = check_mem_region(pci_resource_start(dev, i),
-						 pci_resource_len(dev, i));
-	}
-
-	return inuse;
-}
-
-
-static int pci_hp_remove_device (struct pci_dev *dev)
-{
-	if (is_pci_dev_in_use(dev)) {
-		err("***Cannot safely power down device -- "
-		       "it appears to be in use***\n");
-		return -EBUSY;
-	}
-	pci_remove_device(dev);
-	return 0;
-}
-
-
 /* remove device driver */
 static int unconfigure_pci_dev_driver (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus)
 {
@@ -274,7 +233,7 @@
 		dev->driver = NULL;
 	}
 
-	return is_pci_dev_in_use(dev);
+	return (pci_dev_driver(dev) != NULL);
 }
 
 
@@ -285,7 +244,7 @@
 
 	/* Now, remove the Linux Representation */
 	if (dev) {
-		if (pci_hp_remove_device(dev) == 0) {
+		if (pci_remove_device_safe(dev) == 0) {
 			info("Device %s removed\n", dev->slot_name);
 			kfree(dev); /* Now, remove */
 		} else {
diff -Nru a/drivers/hotplug/cpqphp_pci.c b/drivers/hotplug/cpqphp_pci.c
--- a/drivers/hotplug/cpqphp_pci.c	Mon Feb 24 17:15:37 2003
+++ b/drivers/hotplug/cpqphp_pci.c	Mon Feb 24 17:15:37 2003
@@ -44,48 +44,6 @@
 
 static u16 unused_IRQ;
 
-
-static int is_pci_dev_in_use(struct pci_dev* dev) 
-{
-	/* 
-	 * dev->driver will be set if the device is in use by a new-style 
-	 * driver -- otherwise, check the device's regions to see if any
-	 * driver has claimed them
-	 */
-
-	int i, inuse=0;
-
-	if (dev->driver) return 1; //assume driver feels responsible
-
-	for (i = 0; !dev->driver && !inuse && (i < 6); i++) {
-		if (!pci_resource_start(dev, i))
-			continue;
-
-		if (pci_resource_flags(dev, i) & IORESOURCE_IO)
-			inuse = check_region(pci_resource_start(dev, i),
-					     pci_resource_len(dev, i));
-		else if (pci_resource_flags(dev, i) & IORESOURCE_MEM)
-			inuse = check_mem_region(pci_resource_start(dev, i),
-						 pci_resource_len(dev, i));
-	}
-
-	return inuse;
-
-}
-
-
-static int pci_hp_remove_device(struct pci_dev *dev)
-{
-	if (is_pci_dev_in_use(dev)) {
-		err("***Cannot safely power down device -- "
-		       "it appears to be in use***\n");
-		return -EBUSY;
-	}
-	pci_remove_device(dev);
-	return 0;
-}
-
-
 /*
  * detect_HRT_floating_pointer
  *
@@ -176,7 +134,7 @@
 
 	//Now, remove the Linux Representation
 	if (dev) {
-		if (pci_hp_remove_device(dev) == 0) {
+		if (pci_remove_device_safe(dev) == 0) {
 			kfree(dev); //Now, remove
 		} else {
 			return -1; // problems while freeing, abort visitation
@@ -228,7 +186,7 @@
 		dev->driver = NULL;
 	}
 
-	return is_pci_dev_in_use(dev);
+	return (pci_dev_driver(dev) != NULL);
 }
 
 
diff -Nru a/drivers/hotplug/ibmphp_core.c b/drivers/hotplug/ibmphp_core.c
--- a/drivers/hotplug/ibmphp_core.c	Mon Feb 24 17:15:37 2003
+++ b/drivers/hotplug/ibmphp_core.c	Mon Feb 24 17:15:37 2003
@@ -781,39 +781,6 @@
 	debug ("%s -- exit\n", __FUNCTION__);
 }
 
-static int ibm_is_pci_dev_in_use (struct pci_dev *dev)
-{
-	int i = 0;
-	int inuse = 0;
-
-	if (dev->driver)
-		return 1;
-
-	for (i = 0; !dev->driver && !inuse && (i < 6); i++) {
-
-		if (!pci_resource_start (dev, i))
-			continue;
-
-		if (pci_resource_flags (dev, i) & IORESOURCE_IO)
-			inuse = check_region (pci_resource_start (dev, i), pci_resource_len (dev, i));
-
-		else if (pci_resource_flags (dev, i) & IORESOURCE_MEM)
-			inuse = check_mem_region (pci_resource_start (dev, i), pci_resource_len (dev, i));
-	}
-
-	return inuse;
-}
-
-static int ibm_pci_hp_remove_device (struct pci_dev *dev)
-{
-	if (ibm_is_pci_dev_in_use (dev)) {
-		err ("***Cannot safely power down device -- it appears to be in use***\n");
-		return -EBUSY;
-	}
-	pci_remove_device (dev);
-	return 0;
-}
-
 static int ibm_unconfigure_visit_pci_dev_phase2 (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus)
 {
 	struct pci_dev *dev = wrapped_dev->dev;
@@ -825,7 +792,7 @@
 	} while (temp_func && (temp_func->function != (dev->devfn & 0x07)));
 
 	if (dev) {
-		if (ibm_pci_hp_remove_device (dev) == 0)
+		if (pci_remove_device_safe(dev) == 0)
 			kfree (dev);    /* Now, remove */
 		else
 			return -1;
@@ -872,7 +839,7 @@
 		dev->driver = NULL;
 	}
 
-	return ibm_is_pci_dev_in_use (dev);
+	return (pci_dev_driver(dev) != NULL);
 }
 
 static struct pci_visit ibm_unconfigure_functions_phase1 = {
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
--- a/include/linux/pci.h	Mon Feb 24 17:15:37 2003
+++ b/include/linux/pci.h	Mon Feb 24 17:15:37 2003
@@ -692,7 +692,6 @@
 extern int pci_visit_dev(struct pci_visit *fn,
 			 struct pci_dev_wrapped *wrapped_dev,
 			 struct pci_bus_wrapped *wrapped_parent);
-extern int pci_is_dev_in_use(struct pci_dev *dev);
 extern int pci_remove_device_safe(struct pci_dev *dev);
 
 #endif /* CONFIG_PCI */


  reply	other threads:[~2003-02-25  1:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-25  1:13 [BK PATCH] PCI hotplug changes for 2.5.63 Greg KH
2003-02-25  1:15 ` [PATCH] " Greg KH
2003-02-25  1:15   ` Greg KH
2003-02-25  1:16     ` Greg KH
2003-02-25  1:16       ` Greg KH
2003-02-25  1:16         ` Greg KH
2003-02-25  1:16           ` Greg KH
2003-02-25  1:16             ` Greg KH [this message]
2003-02-25  1:16               ` Greg KH
2003-02-25  1:16                 ` Greg KH
2003-02-25  1:16                   ` Greg KH
2003-02-25  1:16                     ` Greg KH
2003-02-25  1:16                       ` Greg KH
2003-02-25  1:16                         ` Greg KH
2003-02-25  1:16                           ` Greg KH
2003-02-28 23:59 ` [BK PATCH] " Greg KH
2003-03-01 18:55   ` Linus Torvalds
2003-03-01 21:38     ` Greg KH
2003-03-01 22:00       ` Linus Torvalds
2003-03-01 22:25         ` Greg KH

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=1046135763287@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pcihpd-discuss@lists.sourceforge.net \
    /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