[PATCH] ppc64: remove phb_set_model

Anton Blanchard anton at samba.org
Sun Nov 14 17:18:25 EST 2004


phb_set_model does a lot of work just to set up a text string that
almost nothing uses. Replace this all with an is_python() check.

Signed-off-by: Anton Blanchard <anton at samba.org>

diff -puN arch/ppc64/kernel/iSeries_pci.c~pci2 arch/ppc64/kernel/iSeries_pci.c
--- gr_base/arch/ppc64/kernel/iSeries_pci.c~pci2	2004-11-12 04:50:34.571616109 -0600
+++ gr_base-anton/arch/ppc64/kernel/iSeries_pci.c	2004-11-12 04:50:34.613609258 -0600
@@ -256,7 +256,7 @@ unsigned long __init find_and_init_phbs(
 		int ret = HvCallXm_testBus(bus);
 		if (ret == 0) {
 			printk("bus %d appears to exist\n", bus);
-			phb = pci_alloc_pci_controller(phb_type_hypervisor);
+			phb = pci_alloc_pci_controller();
 			if (phb == NULL)
 				return -1;
 			phb->pci_mem_offset = phb->local_number = bus;
diff -puN arch/ppc64/kernel/maple_pci.c~pci2 arch/ppc64/kernel/maple_pci.c
--- gr_base/arch/ppc64/kernel/maple_pci.c~pci2	2004-11-12 04:50:34.576615293 -0600
+++ gr_base-anton/arch/ppc64/kernel/maple_pci.c	2004-11-12 04:50:34.614609095 -0600
@@ -325,7 +325,7 @@ static int __init add_bridge(struct devi
        			       dev->full_name);
        	}
 
-       	hose = pci_alloc_pci_controller(phb_type_apple);
+       	hose = pci_alloc_pci_controller();
        	if (!hose)
        		return -ENOMEM;
        	hose->arch_data = dev;
diff -puN arch/ppc64/kernel/pSeries_pci.c~pci2 arch/ppc64/kernel/pSeries_pci.c
--- gr_base/arch/ppc64/kernel/pSeries_pci.c~pci2	2004-11-12 04:50:34.581614478 -0600
+++ gr_base-anton/arch/ppc64/kernel/pSeries_pci.c	2004-11-12 04:50:34.617608606 -0600
@@ -149,6 +149,16 @@ struct pci_ops rtas_pci_ops = {
 	rtas_pci_write_config
 };
 
+static int is_python(struct device_node *dev)
+{
+	char *model = (char *)get_property(dev, "model", NULL);
+
+	if (model && strstr(model, "Python"))
+		return 1;
+
+	return 0;
+}
+
 static void python_countermeasures(unsigned long addr)
 {
 	void __iomem *chip_regs;
@@ -218,33 +228,6 @@ unsigned long __devinit get_phb_buid (st
 	return buid;
 }
 
-static enum phb_types get_phb_type(struct device_node *dev)
-{
-	enum phb_types type;
-	char *model;
-
-	model = (char *)get_property(dev, "model", NULL);
-
-	if (!model) {
-		printk(KERN_ERR "%s: phb has no model property\n",
-				__FUNCTION__);
-		model = "<empty>";
-	}
-
-	if (strstr(model, "Python")) {
-		type = phb_type_python;
-	} else if (strstr(model, "Speedwagon")) {
-		type = phb_type_speedwagon;
-	} else if (strstr(model, "Winnipeg")) {
-		type = phb_type_winnipeg;
-	} else {
-		printk(KERN_ERR "%s: unknown PHB %s\n", __FUNCTION__, model);
-		type = phb_type_unknown;
-	}
-
-	return type;
-}
-
 static int get_phb_reg_prop(struct device_node *dev,
 			    unsigned int addr_size_words,
 			    struct reg_property64 *reg)
@@ -288,21 +271,18 @@ static struct pci_controller *alloc_phb(
 {
 	struct pci_controller *phb;
 	struct reg_property64 reg_struct;
-	enum phb_types phb_type;
 	struct property *of_prop;
 	int rc;
 
-	phb_type = get_phb_type(dev);
-
 	rc = get_phb_reg_prop(dev, addr_size_words, &reg_struct);
 	if (rc)
 		return NULL;
 
-	phb = pci_alloc_pci_controller(phb_type);
+	phb = pci_alloc_pci_controller();
 	if (phb == NULL)
 		return NULL;
 
-	if (phb_type == phb_type_python)
+	if (is_python(dev))
 		python_countermeasures(reg_struct.address);
 
 	rc = phb_set_bus_ranges(dev, phb);
@@ -336,20 +316,17 @@ static struct pci_controller * __devinit
 {
 	struct pci_controller *phb;
 	struct reg_property64 reg_struct;
-	enum phb_types phb_type;
 	int rc;
 
-	phb_type = get_phb_type(dev);
-
 	rc = get_phb_reg_prop(dev, addr_size_words, &reg_struct);
 	if (rc)
 		return NULL;
 
-	phb = pci_alloc_phb_dynamic(phb_type);
+	phb = pci_alloc_phb_dynamic();
 	if (phb == NULL)
 		return NULL;
 
-	if (phb_type == phb_type_python)
+	if (is_python(dev))
 		python_countermeasures(reg_struct.address);
 
 	rc = phb_set_bus_ranges(dev, phb);
diff -puN arch/ppc64/kernel/pci.c~pci2 arch/ppc64/kernel/pci.c
--- gr_base/arch/ppc64/kernel/pci.c~pci2	2004-11-12 04:50:34.587613499 -0600
+++ gr_base-anton/arch/ppc64/kernel/pci.c	2004-11-12 04:50:34.619608279 -0600
@@ -181,43 +181,10 @@ void pcibios_align_resource(void *data, 
 	res->start = start;
 }
 
-static void phb_set_model(struct pci_controller *hose, 
-			  enum phb_types controller_type)
-{
-	char *model;
-
-	switch(controller_type) {
-#ifdef CONFIG_PPC_ISERIES
-	case phb_type_hypervisor:
-		model = "PHB HV";
-		break;
-#endif
-	case phb_type_python:
-		model = "PHB PY";
-		break;
-	case phb_type_speedwagon:
-		model = "PHB SW";
-		break;
-	case phb_type_winnipeg:
-		model = "PHB WP";
-		break;
-	case phb_type_apple:
-		model = "PHB APPLE";
-		break;
-	default:
-		model = "PHB UK";
-		break;
-	}
-
-        if(strlen(model) < 8)
-		strcpy(hose->what,model);
-        else
-		memcpy(hose->what,model,7);
-}
 /*
  * Allocate pci_controller(phb) initialized common variables.
  */
-struct pci_controller * __init pci_alloc_pci_controller(enum phb_types controller_type)
+struct pci_controller * __init pci_alloc_pci_controller()
 {
 	struct pci_controller *hose;
 
@@ -233,10 +200,7 @@ struct pci_controller * __init pci_alloc
 	}
 	memset(hose, 0, sizeof(struct pci_controller));
 
-	phb_set_model(hose, controller_type);
-
 	hose->is_dynamic = 0;
-	hose->type = controller_type;
 	hose->global_number = global_phb_number++;
 
 	list_add_tail(&hose->list_node, &hose_list);
@@ -247,7 +211,7 @@ struct pci_controller * __init pci_alloc
 /*
  * Dymnamically allocate pci_controller(phb), initialize common variables.
  */
-struct pci_controller * pci_alloc_phb_dynamic(enum phb_types controller_type)
+struct pci_controller * pci_alloc_phb_dynamic()
 {
 	struct pci_controller *hose;
 
@@ -259,10 +223,7 @@ struct pci_controller * pci_alloc_phb_dy
 	}
 	memset(hose, 0, sizeof(struct pci_controller));
 
-	phb_set_model(hose, controller_type);
-
 	hose->is_dynamic = 1;
-	hose->type = controller_type;
 	hose->global_number = global_phb_number++;
 
 	list_add_tail(&hose->list_node, &hose_list);
diff -puN arch/ppc64/kernel/pci.h~pci2 arch/ppc64/kernel/pci.h
--- gr_base/arch/ppc64/kernel/pci.h~pci2	2004-11-12 04:50:34.591612846 -0600
+++ gr_base-anton/arch/ppc64/kernel/pci.h	2004-11-12 04:50:34.621735837 -0600
@@ -14,8 +14,8 @@
 
 extern unsigned long isa_io_base;
 
-extern struct pci_controller* pci_alloc_pci_controller(enum phb_types controller_type);
-extern struct pci_controller* pci_alloc_phb_dynamic(enum phb_types controller_type);
+extern struct pci_controller* pci_alloc_pci_controller(void);
+extern struct pci_controller* pci_alloc_phb_dynamic(void);
 extern void pci_setup_phb_io(struct pci_controller *hose, int primary);
 
 extern struct pci_controller* pci_find_hose_for_OF_device(struct device_node* node);
@@ -50,7 +50,8 @@ void pci_addr_cache_remove_device(struct
 void init_pci_config_tokens (void);
 unsigned long get_phb_buid (struct device_node *);
 
-extern int pci_probe_only;
+extern unsigned long pci_probe_only;
+extern unsigned long pci_assign_all_buses;
 extern int pci_read_irq_line(struct pci_dev *pci_dev);
 
 #endif /* __PPC_KERNEL_PCI_H__ */
diff -puN arch/ppc64/kernel/pmac_pci.c~pci2 arch/ppc64/kernel/pmac_pci.c
--- gr_base/arch/ppc64/kernel/pmac_pci.c~pci2	2004-11-12 04:50:34.597611868 -0600
+++ gr_base-anton/arch/ppc64/kernel/pmac_pci.c	2004-11-12 04:50:34.623735511 -0600
@@ -614,7 +614,7 @@ static int __init add_bridge(struct devi
        			       dev->full_name);
        	}
 
-       	hose = pci_alloc_pci_controller(phb_type_apple);
+       	hose = pci_alloc_pci_controller();
        	if (!hose)
        		return -ENOMEM;
        	hose->arch_data = dev;
diff -puN include/asm-ppc64/pci-bridge.h~pci2 include/asm-ppc64/pci-bridge.h
--- gr_base/include/asm-ppc64/pci-bridge.h~pci2	2004-11-12 04:50:34.601611215 -0600
+++ gr_base-anton/include/asm-ppc64/pci-bridge.h	2004-11-12 04:50:34.624735348 -0600
@@ -18,21 +18,11 @@ struct pci_controller;
 extern struct pci_controller*
 pci_find_hose_for_OF_device(struct device_node* node);
 
-enum phb_types { 
-	phb_type_unknown    = 0x0,
-	phb_type_hypervisor = 0x1,
-	phb_type_python     = 0x10,
-	phb_type_speedwagon = 0x11,
-	phb_type_winnipeg   = 0x12,
-	phb_type_apple      = 0xff
-};
-
 /*
  * Structure of a PCI controller (host bridge)
  */
 struct pci_controller {
 	char what[8];                     /* Eye catcher      */
-	enum phb_types type;              /* Type of hardware */
 	struct pci_bus *bus;
 	char is_dynamic;
 	void *arch_data;
_



More information about the Linuxppc64-dev mailing list