device: constify some variables

Change-Id: I6830a65bc9cea2907f4209bb97a53ccebcbf248d
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-on: https://review.coreboot.org/25873
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/arch/x86/mpspec.c b/src/arch/x86/mpspec.c
index 05605ad..7541eeb 100644
--- a/src/arch/x86/mpspec.c
+++ b/src/arch/x86/mpspec.c
@@ -529,12 +529,12 @@
 	struct drivers_generic_ioapic_config *ioapic_config;
 	struct mp_config_table *mc;
 	int isa_bus, pin, parentpin;
-	struct device *dev;
-	struct device *parent;
-	struct device *oldparent;
+	const struct device *dev;
+	const struct device *parent;
+	const struct device *oldparent;
 	void *tmp, *v;
 	int isaioapic = -1, have_fixed_entries;
-	struct pci_irq_info *pci_irq_info;
+	const struct pci_irq_info *pci_irq_info;
 
 	v = smp_write_floating_table(addr, 0);
 	mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
diff --git a/src/device/device.c b/src/device/device.c
index 4c6b6f9..b896f5e 100644
--- a/src/device/device.c
+++ b/src/device/device.c
@@ -66,7 +66,7 @@
  */
 void dev_initialize_chips(void)
 {
-	struct device *dev;
+	const struct device *dev;
 
 	for (dev = all_devices; dev; dev = dev->next) {
 		/* Initialize chip if we haven't yet. */
@@ -88,7 +88,7 @@
  */
 void dev_finalize_chips(void)
 {
-	struct device *dev;
+	const struct device *dev;
 
 	for (dev = all_devices; dev; dev = dev->next) {
 		/* Initialize chip if we haven't yet. */
@@ -247,7 +247,7 @@
 
 struct pick_largest_state {
 	struct resource *last;
-	struct device *result_dev;
+	const struct device *result_dev;
 	struct resource *result;
 	int seen_last;
 };
@@ -283,7 +283,7 @@
 	}
 }
 
-static struct device *largest_resource(struct bus *bus,
+static const struct device *largest_resource(struct bus *bus,
 				       struct resource **result_res,
 				       unsigned long type_mask,
 				       unsigned long type)
@@ -338,7 +338,7 @@
 static void compute_resources(struct bus *bus, struct resource *bridge,
 			      unsigned long type_mask, unsigned long type)
 {
-	struct device *dev;
+	const struct device *dev;
 	struct resource *resource;
 	resource_t base;
 	base = round(bridge->base, bridge->align);
@@ -482,7 +482,7 @@
 static void allocate_resources(struct bus *bus, struct resource *bridge,
 			       unsigned long type_mask, unsigned long type)
 {
-	struct device *dev;
+	const struct device *dev;
 	struct resource *resource;
 	resource_t base;
 	base = bridge->base;
@@ -640,9 +640,9 @@
 	return lim;
 }
 
-static void constrain_resources(struct device *dev, struct constraints* limits)
+static void constrain_resources(const struct device *dev, struct constraints* limits)
 {
-	struct device *child;
+	const struct device *child;
 	struct resource *res;
 	struct resource *lim;
 	struct bus *link;
@@ -696,7 +696,7 @@
 	}
 }
 
-static void avoid_fixed_resources(struct device *dev)
+static void avoid_fixed_resources(const struct device *dev)
 {
 	struct constraints limits;
 	struct resource *res;
@@ -1019,8 +1019,8 @@
 void dev_configure(void)
 {
 	struct resource *res;
-	struct device *root;
-	struct device *child;
+	const struct device *root;
+	const struct device *child;
 
 	set_vga_bridge_bits();
 
diff --git a/src/device/device_util.c b/src/device/device_util.c
index 6bc2730..3d7f5a1 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -269,7 +269,7 @@
  * Warning: This function uses a static buffer. Don't call it more than once
  * from the same print statement!
  */
-const char *dev_path(struct device *dev)
+const char *dev_path(const struct device *dev)
 {
 	static char buffer[DEVICE_PATH_MAX];
 
@@ -814,7 +814,7 @@
 	return 0;
 }
 
-static void resource_tree(struct device *root, int debug_level, int depth)
+static void resource_tree(const struct device *root, int debug_level, int depth)
 {
 	int i = 0;
 	struct device *child;
@@ -846,7 +846,7 @@
 	}
 }
 
-void print_resource_tree(struct device *root, int debug_level, const char *msg)
+void print_resource_tree(const struct device *root, int debug_level, const char *msg)
 {
 	/* Bail if root is null. */
 	if (!root) {
@@ -862,7 +862,7 @@
 	resource_tree(root, debug_level, 0);
 }
 
-void show_devs_tree(struct device *dev, int debug_level, int depth)
+void show_devs_tree(const struct device *dev, int debug_level, int depth)
 {
 	char depth_str[20];
 	int i;
diff --git a/src/include/device/device.h b/src/include/device/device.h
index acead58..48a5bcc 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -184,7 +184,7 @@
 void scan_bridges(struct bus *bus);
 void assign_resources(struct bus *bus);
 const char *dev_name(struct device *dev);
-const char *dev_path(struct device *dev);
+const char *dev_path(const struct device *dev);
 u32 dev_path_encode(struct device *dev);
 const char *bus_path(struct bus *bus);
 void dev_set_enabled(struct device *dev, int enable);
@@ -216,9 +216,9 @@
 	set_cpu_topology(cpu, 0, package, core, thread)
 
 /* Debug functions */
-void print_resource_tree(struct device *root, int debug_level,
+void print_resource_tree(const struct device *root, int debug_level,
 			 const char *msg);
-void show_devs_tree(struct device *dev, int debug_level, int depth);
+void show_devs_tree(const struct device *dev, int debug_level, int depth);
 void show_devs_subtree(struct device *root, int debug_level, const char *msg);
 void show_all_devs(int debug_level, const char *msg);
 void show_all_devs_tree(int debug_level, const char *msg);