Skip to contentSkip to conversation

PCI: make pci_bus_add_device() void

PATCH Applied Yijing Wang 2 participants 2 messages May 30, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 PCI: make pci_bus_add_device() void

Kernel will WARN_ON(retval < 0) if device_attach() fail with error in pci_bus_add_device(). currently, all the kernel code to check pci_bus_add_device() return value only for printing warning message, no other actions. So make pci_bus_add_device() void and clean all the unnecessary checkingi codes.

---
v1->v2: Convert pci_bus_add_device() void, squash all changes into a single patch

---
 drivers/edac/i82875p_edac.c         |    7 +------
 drivers/pci/bus.c                   |   10 ++--------
 drivers/pci/iov.c                   |    2 +-
 drivers/platform/x86/asus-wmi.c     |    3 +--
 drivers/platform/x86/eeepc-laptop.c |    3 +--
 include/linux/pci.h                 |    2 +-
 6 files changed, 7 insertions(+), 20 deletions(-)
drivers/edac/i82875p_edac.c +1 -6
index 8d0450b..8705ba6 100644
@@ -293,12 +293,7 @@ static int i82875p_setup_overfl_dev(struct pci_dev *pdev,
 		if (dev == NULL)
 			return 1;
 
-		err = pci_bus_add_device(dev);
-		if (err) {
-			i82875p_printk(KERN_ERR,
-				"%s(): pci_bus_add_device() Failed\n",
-				__func__);
-		}
+		pci_bus_add_device(dev);
 		pci_bus_assign_resources(dev->bus);
 	}
 
drivers/pci/bus.c +2 -8
index ba2bf55..447d393 100644
@@ -235,7 +235,7 @@ void __weak pcibios_resource_survey_bus(struct pci_bus *bus) { }
  *
  * This adds add sysfs entries and start device drivers
  */
-int pci_bus_add_device(struct pci_dev *dev)
+void pci_bus_add_device(struct pci_dev *dev)
 {
 	int retval;
 
@@ -252,8 +252,6 @@ int pci_bus_add_device(struct pci_dev *dev)
 	WARN_ON(retval < 0);
 
 	dev->is_added = 1;
-
-	return 0;
 }
 
 /**
@@ -266,16 +264,12 @@ void pci_bus_add_devices(const struct pci_bus *bus)
 {
 	struct pci_dev *dev;
 	struct pci_bus *child;
-	int retval;
 
 	list_for_each_entry(dev, &bus->devices, bus_list) {
 		/* Skip already-added devices */
 		if (dev->is_added)
 			continue;
-		retval = pci_bus_add_device(dev);
-		if (retval)
-			dev_err(&dev->dev, "Error adding device (%d)\n",
-				retval);
+		pci_bus_add_device(dev);
 	}
 
 	list_for_each_entry(dev, &bus->devices, bus_list) {
drivers/pci/iov.c +1 -1
index de7a747..cb6f247 100644
@@ -106,7 +106,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
 	pci_device_add(virtfn, virtfn->bus);
 	mutex_unlock(&iov->dev->sriov->lock);
 
-	rc = pci_bus_add_device(virtfn);
+	pci_bus_add_device(virtfn);
 	sprintf(buf, "virtfn%u", id);
 	rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);
 	if (rc)
drivers/platform/x86/asus-wmi.c +1 -2
index c5e082f..91ef69a 100644
@@ -642,8 +642,7 @@ static void asus_rfkill_hotplug(struct asus_wmi *asus)
 			dev = pci_scan_single_device(bus, 0);
 			if (dev) {
 				pci_bus_assign_resources(bus);
-				if (pci_bus_add_device(dev))
-					pr_err("Unable to hotplug wifi\n");
+				pci_bus_add_device(dev);
 			}
 		} else {
 			dev = pci_get_slot(bus, 0);
drivers/platform/x86/eeepc-laptop.c +1 -2
index 399e8c5..9b0c57c 100644
@@ -633,8 +633,7 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
 			dev = pci_scan_single_device(bus, 0);
 			if (dev) {
 				pci_bus_assign_resources(bus);
-				if (pci_bus_add_device(dev))
-					pr_err("Unable to hotplug wifi\n");
+				pci_bus_add_device(dev);
 			}
 		} else {
 			dev = pci_get_slot(bus, 0);
include/linux/pci.h +1 -1
index 65f22e8..71d9673 100644
@@ -781,7 +781,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn);
 struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
 void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
 unsigned int pci_scan_child_bus(struct pci_bus *bus);
-int __must_check pci_bus_add_device(struct pci_dev *dev);
+void pci_bus_add_device(struct pci_dev *dev);
 void pci_read_bridge_bases(struct pci_bus *child);
 struct resource *pci_find_parent_resource(const struct pci_dev *dev,
 					  struct resource *res);
Signature · 1 line
1.7.1
maintainer Applied
#1 lore raw
Quoted 7 lines · Yijing Wang

Kernel will WARN_ON(retval < 0) if device_attach() fail with error in pci_bus_add_device(). currently, all the kernel code to check pci_bus_add_device() return value only for printing warning message, no other actions. So make pci_bus_add_device() void and clean all the unnecessary checkingi codes.

Applied to pci/misc for v3.16, thanks!

Quoted 131 lines

---
v1->v2: Convert pci_bus_add_device() void, squash all changes into a single patch

---
 drivers/edac/i82875p_edac.c         |    7 +------
 drivers/pci/bus.c                   |   10 ++--------
 drivers/pci/iov.c                   |    2 +-
 drivers/platform/x86/asus-wmi.c     |    3 +--
 drivers/platform/x86/eeepc-laptop.c |    3 +--
 include/linux/pci.h                 |    2 +-
 6 files changed, 7 insertions(+), 20 deletions(-)
drivers/edac/i82875p_edac.c +1 -6
index 8d0450b..8705ba6 100644
@@ -293,12 +293,7 @@ static int i82875p_setup_overfl_dev(struct pci_dev *pdev,
 		if (dev == NULL)
 			return 1;
 
-		err = pci_bus_add_device(dev);
-		if (err) {
-			i82875p_printk(KERN_ERR,
-				"%s(): pci_bus_add_device() Failed\n",
-				__func__);
-		}
+		pci_bus_add_device(dev);
 		pci_bus_assign_resources(dev->bus);
 	}
 
drivers/pci/bus.c +2 -8
index ba2bf55..447d393 100644
@@ -235,7 +235,7 @@ void __weak pcibios_resource_survey_bus(struct pci_bus *bus) { }
  *
  * This adds add sysfs entries and start device drivers
  */
-int pci_bus_add_device(struct pci_dev *dev)
+void pci_bus_add_device(struct pci_dev *dev)
 {
 	int retval;
 
@@ -252,8 +252,6 @@ int pci_bus_add_device(struct pci_dev *dev)
 	WARN_ON(retval < 0);
 
 	dev->is_added = 1;
-
-	return 0;
 }
 
 /**
@@ -266,16 +264,12 @@ void pci_bus_add_devices(const struct pci_bus *bus)
 {
 	struct pci_dev *dev;
 	struct pci_bus *child;
-	int retval;
 
 	list_for_each_entry(dev, &bus->devices, bus_list) {
 		/* Skip already-added devices */
 		if (dev->is_added)
 			continue;
-		retval = pci_bus_add_device(dev);
-		if (retval)
-			dev_err(&dev->dev, "Error adding device (%d)\n",
-				retval);
+		pci_bus_add_device(dev);
 	}
 
 	list_for_each_entry(dev, &bus->devices, bus_list) {
drivers/pci/iov.c +1 -1
index de7a747..cb6f247 100644
@@ -106,7 +106,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
 	pci_device_add(virtfn, virtfn->bus);
 	mutex_unlock(&iov->dev->sriov->lock);
 
-	rc = pci_bus_add_device(virtfn);
+	pci_bus_add_device(virtfn);
 	sprintf(buf, "virtfn%u", id);
 	rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);
 	if (rc)
drivers/platform/x86/asus-wmi.c +1 -2
index c5e082f..91ef69a 100644
@@ -642,8 +642,7 @@ static void asus_rfkill_hotplug(struct asus_wmi *asus)
 			dev = pci_scan_single_device(bus, 0);
 			if (dev) {
 				pci_bus_assign_resources(bus);
-				if (pci_bus_add_device(dev))
-					pr_err("Unable to hotplug wifi\n");
+				pci_bus_add_device(dev);
 			}
 		} else {
 			dev = pci_get_slot(bus, 0);
drivers/platform/x86/eeepc-laptop.c +1 -2
index 399e8c5..9b0c57c 100644
@@ -633,8 +633,7 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
 			dev = pci_scan_single_device(bus, 0);
 			if (dev) {
 				pci_bus_assign_resources(bus);
-				if (pci_bus_add_device(dev))
-					pr_err("Unable to hotplug wifi\n");
+				pci_bus_add_device(dev);
 			}
 		} else {
 			dev = pci_get_slot(bus, 0);
include/linux/pci.h +1 -1
index 65f22e8..71d9673 100644
@@ -781,7 +781,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn);
 struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
 void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
 unsigned int pci_scan_child_bus(struct pci_bus *bus);
-int __must_check pci_bus_add_device(struct pci_dev *dev);
+void pci_bus_add_device(struct pci_dev *dev);
 void pci_read_bridge_bases(struct pci_bus *child);
 struct resource *pci_find_parent_resource(const struct pci_dev *dev,
 					  struct resource *res);
Signature · 7 lines
1.7.1


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html