Skip to contentSkip to conversation

PCI hotplug changes for 2.5.54

PATCH New Greg KH 1 participant 4 messages Jan 8, 2003 PCI

lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 PCI hotplug changes for 2.5.54

Here are some minor PCI hotplug changes for 2.5.54.

Please pull from: bk://linuxusb.bkbits.net/pci_hp-2.5

thanks,

greg k-h

 drivers/hotplug/ibmphp_core.c      |   10 ++++-----
 drivers/hotplug/pci_hotplug_core.c |   41 ++++++++++++++++++-------------------
 drivers/pci/hotplug.c              |    2 -
 3 files changed, 26 insertions(+), 27 deletions(-)

-----

[email protected], 2003-01-07 16:41:22-08:00, [email protected]
PCI hotplug: clean up the try_module_get() logic a bit.

 drivers/hotplug/pci_hotplug_core.c |   41 ++++++++++++++++++-------------------
 1 files changed, 20 insertions(+), 21 deletions(-)

------

[email protected], 2003-01-07 16:29:23-08:00, [email protected]
PCI: properly unregister a PCI device if it is removed.

This is only used by pci hotplug and cardbus systems.

 drivers/pci/hotplug.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

------

[email protected], 2003-01-07 16:24:14-08:00, [email protected]
IBM PCI Hotplug: fix compile time error due to find_bus() function name.

 drivers/hotplug/ibmphp_core.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

------

author
#1 lore raw

PATCH 1/1 PCI hotplug changes for 2.5.54

ChangeSet 1.894, 2003/01/07 16:24:14-08:00, [email protected]

IBM PCI Hotplug: fix compile time error due to find_bus() function name.

drivers/hotplug/ibmphp_core.c +5 -5
diff -Nru a/drivers/hotplug/ibmphp_core.c b/drivers/hotplug/ibmphp_core.c
@@ -769,11 +769,11 @@
  * Parameters: bus number
  * Returns : pci_bus *  or NULL if not found
  */
-static struct pci_bus *find_bus (u8 busno)
+static struct pci_bus *ibmphp_find_bus (u8 busno)
 {
 	const struct list_head *tmp;
 	struct pci_bus *bus;
-	debug ("inside find_bus, busno = %x \n", busno);
+	debug ("inside %s, busno = %x \n", __FUNCTION__, busno);
 
 	list_for_each (tmp, &pci_root_buses) {
 		bus = (struct pci_bus *) pci_bus_b (tmp);
@@ -1002,7 +1002,7 @@
 	struct pci_dev *dev;
 	u16 l;
 
-	if (find_bus (busno) || !(ibmphp_find_same_bus_num (busno)))
+	if (ibmphp_find_bus (busno) || !(ibmphp_find_same_bus_num (busno)))
 		return 1;
 
 	bus = kmalloc (sizeof (*bus), GFP_KERNEL);
@@ -1056,7 +1056,7 @@
 		func->dev = pci_find_slot (func->busno, (func->device << 3) | (func->function & 0x7));
 
 	if (func->dev == NULL) {
-		dev0.bus = find_bus (func->busno);
+		dev0.bus = ibmphp_find_bus (func->busno);
 		dev0.devfn = ((func->device << 3) + (func->function & 0x7));
 		dev0.sysdata = dev0.bus->sysdata;
 
@@ -1636,7 +1636,7 @@
 		return -ENOMEM;
 	}
 
-	bus = find_bus (0);
+	bus = ibmphp_find_bus (0);
 	if (!bus) {
 		err ("Can't find the root pci bus, can not continue\n");
 		return -ENODEV;
author
#2 lore raw

ChangeSet 1.895, 2003/01/07 16:29:23-08:00, [email protected]

PCI: properly unregister a PCI device if it is removed.

This is only used by pci hotplug and cardbus systems.

drivers/pci/hotplug.c +1 -1
diff -Nru a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
@@ -105,7 +105,7 @@
 void
 pci_remove_device(struct pci_dev *dev)
 {
-	put_device(&dev->dev);
+	device_unregister(&dev->dev);
 	list_del(&dev->bus_list);
 	list_del(&dev->global_list);
 	pci_free_resources(dev);
author
#3 lore raw

ChangeSet 1.896, 2003/01/07 16:41:22-08:00, [email protected]

PCI hotplug: clean up the try_module_get() logic a bit.

drivers/hotplug/pci_hotplug_core.c +20 -21
diff -Nru a/drivers/hotplug/pci_hotplug_core.c b/drivers/hotplug/pci_hotplug_core.c
@@ -561,7 +561,7 @@
 	up(&parent->d_inode->i_sem);
 }
 
-/* yuck, WFT is this? */
+/* Weee, fun with macros... */
 #define GET_STATUS(name,type)	\
 static int get_##name (struct hotplug_slot *slot, type *value)		\
 {									\
@@ -661,29 +661,26 @@
 	power = (u8)(lpower & 0xff);
 	dbg ("power = %d\n", power);
 
+	if (!try_module_get(slot->ops->owner)) {
+		retval = -ENODEV;
+		goto exit;
+	}
 	switch (power) {
 		case 0:
-			if (!slot->ops->disable_slot)
-				break;
-			if (try_module_get(slot->ops->owner)) {
+			if (slot->ops->disable_slot)
 				retval = slot->ops->disable_slot(slot);
-				module_put(slot->ops->owner);
-			}
 			break;
 
 		case 1:
-			if (!slot->ops->enable_slot)
-				break;
-			if (try_module_get(slot->ops->owner)) {
+			if (slot->ops->enable_slot)
 				retval = slot->ops->enable_slot(slot);
-				module_put(slot->ops->owner);
-			}
 			break;
 
 		default:
 			err ("Illegal value specified for power\n");
 			retval = -EINVAL;
 	}
+	module_put(slot->ops->owner);
 
 exit:	
 	kfree (buff);
@@ -770,12 +767,13 @@
 	attention = (u8)(lattention & 0xff);
 	dbg (" - attention = %d\n", attention);
 
-	if (slot->ops->set_attention_status) {
-		if (try_module_get(slot->ops->owner)) {
-			retval = slot->ops->set_attention_status(slot, attention);
-			module_put(slot->ops->owner);
-		}
+	if (!try_module_get(slot->ops->owner)) {
+		retval = -ENODEV;
+		goto exit;
 	}
+	if (slot->ops->set_attention_status)
+		retval = slot->ops->set_attention_status(slot, attention);
+	module_put(slot->ops->owner);
 
 exit:	
 	kfree (buff);
@@ -1007,12 +1005,13 @@
 	test = (u32)(ltest & 0xffffffff);
 	dbg ("test = %d\n", test);
 
-	if (slot->ops->hardware_test) {
-		if (try_module_get(slot->ops->owner)) {
-			retval = slot->ops->hardware_test(slot, test);
-			module_put(slot->ops->owner);
-		}
+	if (!try_module_get(slot->ops->owner)) {
+		retval = -ENODEV;
+		goto exit;
 	}
+	if (slot->ops->hardware_test)
+		retval = slot->ops->hardware_test(slot, test);
+	module_put(slot->ops->owner);
 
 exit:	
 	kfree (buff);