Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/799
-gerrit
commit 5cf235c001073d68e8b1427dd47e15b56e93097f Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Sun Mar 18 20:19:28 2012 +0200
Fix chip name translations in sconfig
Current bootblock initialisation functions do not have chip name in them. Fix sconfig behave the same way.
Fix side-effects of name translation, treats original name as const.
Change-Id: Iae26be8cefe7db11eeb8e62fce6f3b8bc9c1f4ed Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- util/sconfig/main.c | 41 +++++++++++++++++++++++++++++++---------- 1 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 181be38..4e3479b 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -37,6 +37,13 @@ typedef enum {
static scan_t scan_mode = STATIC_MODE;
+typedef enum { + UNSLASH, + SPLIT_1ST, + TO_LOWER, + TO_UPPER, +} translate_t; + static struct device root; static struct device mainboard = { .name = "mainboard", @@ -124,23 +131,31 @@ void postprocess_devtree(void) { } }
-void translate_name(char *str, int uppercase) +char * translate_name(const char *str, translate_t mode) { - char *c; - for (c = str; *c; c++) { + char *b, *c; + b = c = strdup(str); + while (c && *c) { + if ((mode == SPLIT_1ST) && (*c == '/')) { + *c = 0; + break; + } if (*c == '/') *c = '_'; if (*c == '-') *c = '_'; - if (uppercase) + if (mode == TO_UPPER) *c = toupper(*c); + if (mode == TO_LOWER) + *c = tolower(*c); + c++; } + return b; }
struct device *new_chip(struct device *parent, struct device *bus, char *path) { struct device *new_chip = new_dev(parent, bus); new_chip->chiph_exists = 1; new_chip->name = path; - new_chip->name_underscore = strdup(new_chip->name); - translate_name(new_chip->name_underscore, 0); + new_chip->name_underscore = translate_name(new_chip->name, UNSLASH); new_chip->type = chip; new_chip->chip = new_chip;
@@ -580,8 +595,11 @@ int main(int argc, char** argv) { h = &headers; while (h->next) { h = h->next; - translate_name(h->name, 0); - fprintf(autogen, "\tinit_%s();\n", h->name); + char * buf = translate_name(h->name, SPLIT_1ST); + if (buf) { + fprintf(autogen, "\tbootblock_%s_init();\n", buf); + free(buf); + } }
fprintf(autogen, "\treturn 0;\n}\n"); @@ -595,8 +613,11 @@ int main(int argc, char** argv) { h = &headers; while (h->next) { h = h->next; - translate_name(h->name, 1); - fprintf(autogen, "\tselect %s\n", h->name); + char * buf = translate_name(h->name, TO_UPPER); + if (buf) { + fprintf(autogen, "\tselect %s\n", buf); + free(buf); + } } }