Skip to contentSkip to conversation

pci: cleanup on confusing variable name for pci_create_root_bus

PATCH In review Wei Yang 2 participants 2 messages Jun 11, 2012 – Aug 15, 2012 PCI

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 pci: cleanup on confusing variable name for pci_create_root_bus

Since there are serverail *bridge* in this function, it would be a little confusion.

Rename the local variable *bridge* to *host_bridge* for easy reading.

---
 drivers/pci/probe.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
drivers/pci/probe.c +9 -9
index 5e1ca3c..2cc6eef 100644
@@ -1648,7 +1648,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	int error;
-	struct pci_host_bridge *bridge;
+	struct pci_host_bridge *host_bridge;
 	struct pci_bus *b, *b2;
 	struct device *dev;
 	struct pci_host_bridge_window *window, *n;
@@ -1657,8 +1657,8 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	char bus_addr[64];
 	char *fmt;
 
-	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
-	if (!bridge)
+	host_bridge = kzalloc(sizeof(*host_bridge), GFP_KERNEL);
+	if (!host_bridge)
 		return NULL;
 
 	b = pci_alloc_bus();
@@ -1704,8 +1704,8 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 
 	b->number = b->secondary = bus;
 
-	bridge->bus = b;
-	INIT_LIST_HEAD(&bridge->windows);
+	host_bridge->bus = b;
+	INIT_LIST_HEAD(&host_bridge->windows);
 
 	if (parent)
 		dev_info(parent, "PCI host bridge to bus %s\n", dev_name(&b->dev));
@@ -1714,7 +1714,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 
 	/* Add initial resources to the bus */
 	list_for_each_entry_safe(window, n, resources, list) {
-		list_move_tail(&window->list, &bridge->windows);
+		list_move_tail(&window->list, &host_bridge->windows);
 		res = window->res;
 		offset = window->offset;
 		pci_bus_add_resource(b, res, 0);
@@ -1732,7 +1732,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	}
 
 	down_write(&pci_bus_sem);
-	list_add_tail(&bridge->list, &pci_host_bridges);
+	list_add_tail(&host_bridge->list, &pci_host_bridges);
 	list_add_tail(&b->node, &pci_root_buses);
 	up_write(&pci_bus_sem);
 
@@ -1742,7 +1742,7 @@ class_dev_reg_err:
 	device_unregister(dev);
 dev_reg_err:
 	down_write(&pci_bus_sem);
-	list_del(&bridge->list);
+	list_del(&host_bridge->list);
 	list_del(&b->node);
 	up_write(&pci_bus_sem);
 err_out:
@@ -1750,7 +1750,7 @@ err_out:
 err_dev:
 	kfree(b);
 err_bus:
-	kfree(bridge);
+	kfree(host_bridge);
 	return NULL;
 }
 
Signature · 1 line
1.7.4.1
maintainer
#1 lore raw
Quoted 7 lines · Wei Yang

Since there are serverail *bridge* in this function, it would be a little confusion.

Rename the local variable *bridge* to *host_bridge* for easy reading.

pci_create_root_bus() has changed somewhat since you posted this patch. I refreshed it and also changed some other occurrences, resulting in the following patch. I'll apply it if it looks OK to you.

Bjorn

commit a634940588f3469b1efa883db1a8a66c3f84c06c

Author: Bjorn Helgaas <[email protected]>
Date:   Wed Aug 15 14:24:25 2012 -0600

PCI: Use "host_bridge" for pci_host_bridge variable names

Rename local pci_host_bridge variables from "bridge" to "host_bridge" to distinguish them from PCI-to-PCI bridges.

drivers/pci/host-bridge.c +7 -7
index a68dc61..6677528 100644
@@ -27,12 +27,12 @@ static struct pci_host_bridge *find_pci_host_bridge(struct pci_dev *dev)
 	return to_pci_host_bridge(bus->bridge);
 }
 
-void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
+void pci_set_host_bridge_release(struct pci_host_bridge *host_bridge,
 				 void (*release_fn)(struct pci_host_bridge *),
 				 void *release_data)
 {
-	bridge->release_fn = release_fn;
-	bridge->release_data = release_data;
+	host_bridge->release_fn = release_fn;
+	host_bridge->release_data = release_data;
 }
 
 static bool resource_contains(struct resource *res1, struct resource *res2)
@@ -43,11 +43,11 @@ static bool resource_contains(struct resource *res1, struct resource *res2)
 void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
 			     struct resource *res)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(dev);
+	struct pci_host_bridge *host_bridge = find_pci_host_bridge(dev);
 	struct pci_host_bridge_window *window;
 	resource_size_t offset = 0;
 
-	list_for_each_entry(window, &bridge->windows, list) {
+	list_for_each_entry(window, &host_bridge->windows, list) {
 		if (resource_type(res) != resource_type(window->res))
 			continue;
 
@@ -71,11 +71,11 @@ static bool region_contains(struct pci_bus_region *region1,
 void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
 			     struct pci_bus_region *region)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(dev);
+	struct pci_host_bridge *host_bridge = find_pci_host_bridge(dev);
 	struct pci_host_bridge_window *window;
 	resource_size_t offset = 0;
 
-	list_for_each_entry(window, &bridge->windows, list) {
+	list_for_each_entry(window, &host_bridge->windows, list) {
 		struct pci_bus_region bus_region;
 
 		if (resource_type(res) != resource_type(window->res))
drivers/pci/probe.c +23 -23

93 lines not on this page · raw message