Index: util/sconfig/main.c
===================================================================
--- util/sconfig/main.c	(Revision 5743)
+++ util/sconfig/main.c	(Arbeitskopie)
@@ -23,7 +23,7 @@
 
 extern int linenum;
 
-struct device *head, *lastdev;
+struct device *head, *lastdev, *first;
 
 struct header headers;
 
@@ -127,6 +127,13 @@
 	new_chip->type = chip;
 	new_chip->chip = new_chip;
 
+	if (strncmp(path, "mainboard/", 10) == 0) {
+		new_chip->id = 0;
+		new_chip->name_underscore = "mainboard";
+		root.chip = new_chip;
+		first = new_chip;
+	}
+
 	struct stat st;
 	char *chip_h = malloc(strlen(path)+12);
 	sprintf(chip_h, "src/%s/chip.h", path);
@@ -397,17 +404,17 @@
 		printf("usage: sconfig vendor/mainboard outputdir\n");
 		return 1;
 	}
-	char *mainboard=argv[1];
+	char *mainboard_name=argv[1];
 	char *outputdir=argv[2];
-	char *devtree=malloc(strlen(mainboard)+30);
+	char *devtree=malloc(strlen(mainboard_name)+30);
 	char *outputc=malloc(strlen(outputdir)+10);
-	sprintf(devtree, "src/mainboard/%s/devicetree.cb", mainboard);
+	sprintf(devtree, "src/mainboard/%s/devicetree.cb", mainboard_name);
 	sprintf(outputc, "%s/static.c", outputdir);
 
 	headers.next = malloc(sizeof(struct header));
-	headers.next->name = malloc(strlen(mainboard)+12);
+	headers.next->name = malloc(strlen(mainboard_name)+12);
 	headers.next->next = 0;
-	sprintf(headers.next->name, "mainboard/%s", mainboard);
+	sprintf(headers.next->name, "mainboard/%s", mainboard_name);
 
 	FILE *filec = fopen(devtree, "r");
 	if (!filec) {
@@ -419,6 +426,7 @@
 	yyrestart(filec);
 
 	lastdev = head = &root;
+	first = &mainboard;
 
 	yyparse();
 
@@ -446,8 +454,12 @@
 	}
 	fprintf(staticc, "\n/* pass 0 */\n");
 	walk_device_tree(staticc, &root, pass0, NULL);
-	fprintf(staticc, "\n/* pass 1 */\nstruct mainboard_config mainboard_info_0;\nstruct device **last_dev_p = &%s.next;\n", lastdev->name);
-	walk_device_tree(staticc, &root, pass1, NULL);
+	fprintf(staticc, "\n/* pass 1 */\nstruct device **last_dev_p = &%s.next;\n", lastdev->name);
+	if (first == &mainboard)
+		pass1(staticc, first);
+	if (root.next_sibling)
+		walk_device_tree(staticc, root.next_sibling, pass1, NULL);
+	pass1(staticc, &root);
 
 	fclose(staticc);
 
