[PATCH 4/6] pci: improve indentation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The loops in pci_bus_add_devices get indented several layers making it hard
to read. By just slightly recoding using continue, this can be flattened to
improve readablity.

Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxxxx>


--- a/drivers/pci/bus.c	2008-09-08 09:17:58.000000000 -0700
+++ b/drivers/pci/bus.c	2008-09-08 09:18:08.000000000 -0700
@@ -106,14 +106,12 @@ void pci_bus_add_devices(struct pci_bus 
 {
 	struct pci_dev *dev;
 	struct pci_bus *child_bus;
-	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)
+		if (pci_bus_add_device(dev))
 			dev_err(&dev->dev, "Error adding device, continuing\n");
 	}
 
@@ -124,33 +122,35 @@ void pci_bus_add_devices(struct pci_bus 
 		 * If there is an unattached subordinate bus, attach
 		 * it and then scan for unattached PCI devices.
 		 */
-		if (dev->subordinate) {
-		       if (list_empty(&dev->subordinate->node)) {
-			       down_write(&pci_bus_sem);
-			       list_add_tail(&dev->subordinate->node,
-					       &dev->bus->children);
-			       up_write(&pci_bus_sem);
-			}
-			pci_bus_add_devices(dev->subordinate);
-
-			/* register the bus with sysfs as the parent is now
-			 * properly registered. */
-			child_bus = dev->subordinate;
-			if (child_bus->is_added)
-				continue;
-			child_bus->dev.parent = child_bus->bridge;
-			retval = device_register(&child_bus->dev);
-			if (retval)
-				dev_err(&dev->dev, "Error registering pci_bus,"
-					" continuing...\n");
-			else {
-				child_bus->is_added = 1;
-				retval = device_create_file(&child_bus->dev,
-							&dev_attr_cpuaffinity);
-			}
-			if (retval)
-				dev_err(&dev->dev, "Error creating cpuaffinity"
-					" file, continuing...\n");
+		if (!dev->subordinate)
+			continue;
+
+		if (list_empty(&dev->subordinate->node)) {
+			down_write(&pci_bus_sem);
+			list_add_tail(&dev->subordinate->node,
+				      &dev->bus->children);
+			up_write(&pci_bus_sem);
+		}
+		pci_bus_add_devices(dev->subordinate);
+
+		/* register the bus with sysfs as the parent is now
+		 * properly registered. */
+		child_bus = dev->subordinate;
+		if (child_bus->is_added)
+			continue;
+		child_bus->dev.parent = child_bus->bridge;
+
+		if (device_register(&child_bus->dev)) {
+			dev_err(&dev->dev, "Error registering pci_bus,"
+				" continuing...\n");
+			continue;
+		}
+
+		child_bus->is_added = 1;
+		if (device_create_file(&child_bus->dev, &dev_attr_cpuaffinity)) {
+			dev_err(&dev->dev, "Error creating cpuaffinity file,"
+				" continuing...\n");
+			continue;
 		}
 	}
 }

-- 

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

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux