Commit bf4e4996 authored by Alejandro Mery's avatar Alejandro Mery
Browse files

fexc: uboot: some refactoring

parent 9abafdf6
...@@ -32,7 +32,8 @@ ...@@ -32,7 +32,8 @@
#define pr_debug(...) #define pr_debug(...)
#endif #endif
static inline void out_u32_member(FILE *out, const char *key, int hexa, uint32_t val) static inline void out_u32_member(FILE *out, const char *key, int hexa,
struct script_single_entry *val)
{ {
const char *fmt; const char *fmt;
if (hexa) if (hexa)
...@@ -40,7 +41,7 @@ static inline void out_u32_member(FILE *out, const char *key, int hexa, uint32_t ...@@ -40,7 +41,7 @@ static inline void out_u32_member(FILE *out, const char *key, int hexa, uint32_t
else else
fmt = "\t.%s = %u,\n"; fmt = "\t.%s = %u,\n";
fprintf(out, fmt, key, val); fprintf(out, fmt, key, val->value);
} }
static inline void out_gpio_member(FILE *out, const char *key, static inline void out_gpio_member(FILE *out, const char *key,
...@@ -63,6 +64,11 @@ static inline void out_gpio_member(FILE *out, const char *key, ...@@ -63,6 +64,11 @@ static inline void out_gpio_member(FILE *out, const char *key,
fputs("),\n", out); fputs("),\n", out);
} }
static inline void out_null_member(FILE *out, const char *key)
{
fprintf(out, "\t/* %s is NULL */\n", key);
}
/* /*
* DRAM * DRAM
*/ */
...@@ -70,7 +76,6 @@ static int generate_dram_struct(FILE *out, struct script_section *sp) ...@@ -70,7 +76,6 @@ static int generate_dram_struct(FILE *out, struct script_section *sp)
{ {
struct list_entry *le; struct list_entry *le;
struct script_entry *ep; struct script_entry *ep;
struct script_single_entry *val;
const char *key; const char *key;
int ret = 1, hexa; int ret = 1, hexa;
...@@ -100,12 +105,15 @@ static int generate_dram_struct(FILE *out, struct script_section *sp) ...@@ -100,12 +105,15 @@ static int generate_dram_struct(FILE *out, struct script_section *sp)
switch (ep->type) { switch (ep->type) {
case SCRIPT_VALUE_TYPE_SINGLE_WORD: case SCRIPT_VALUE_TYPE_SINGLE_WORD:
val = container_of(ep, struct script_single_entry, entry); out_u32_member(out, key, hexa,
if (val->value > 0) container_of(ep, struct script_single_entry, entry));
out_u32_member(out, key, hexa, val->value); break;
/* pass through */
case SCRIPT_VALUE_TYPE_NULL: case SCRIPT_VALUE_TYPE_NULL:
continue; out_null_member(out, key);
break;
case SCRIPT_VALUE_TYPE_GPIO:
out_gpio_member(out, key,
container_of(ep, struct script_gpio_entry, entry));
default: default:
invalid_field: invalid_field:
pr_err("dram_para: %s: invalid field\n", ep->name); pr_err("dram_para: %s: invalid field\n", ep->name);
...@@ -130,7 +138,6 @@ static int generate_pmu_struct(FILE *out, struct script_section *target, ...@@ -130,7 +138,6 @@ static int generate_pmu_struct(FILE *out, struct script_section *target,
struct list_entry *le; struct list_entry *le;
struct script_section *sp; struct script_section *sp;
struct script_entry *ep; struct script_entry *ep;
struct script_single_entry *val;
const char *key; const char *key;
int ret = 1; int ret = 1;
...@@ -141,14 +148,20 @@ static int generate_pmu_struct(FILE *out, struct script_section *target, ...@@ -141,14 +148,20 @@ static int generate_pmu_struct(FILE *out, struct script_section *target,
le = list_next(&sp->entries, le)) { le = list_next(&sp->entries, le)) {
ep = container_of(le, struct script_entry, entries); ep = container_of(le, struct script_entry, entries);
key = ep->name;
switch (ep->type) { switch (ep->type) {
case SCRIPT_VALUE_TYPE_SINGLE_WORD: case SCRIPT_VALUE_TYPE_SINGLE_WORD:
val = container_of(ep, struct script_single_entry, entry); out_u32_member(out, key, 0,
if (val->value > 0) container_of(ep, struct script_single_entry, entry));
out_u32_member(out, ep->name, 0, val->value); break;
/* pass through */
case SCRIPT_VALUE_TYPE_NULL: case SCRIPT_VALUE_TYPE_NULL:
continue; out_null_member(out, key);
break;
case SCRIPT_VALUE_TYPE_GPIO:
out_gpio_member(out, key,
container_of(ep, struct script_gpio_entry, entry));
break;
default: default:
pr_err("target: %s: invalid field\n", ep->name); pr_err("target: %s: invalid field\n", ep->name);
ret = 0; ret = 0;
...@@ -175,10 +188,11 @@ static int generate_pmu_struct(FILE *out, struct script_section *target, ...@@ -175,10 +188,11 @@ static int generate_pmu_struct(FILE *out, struct script_section *target,
switch(ep->type) { switch(ep->type) {
case SCRIPT_VALUE_TYPE_SINGLE_WORD: case SCRIPT_VALUE_TYPE_SINGLE_WORD:
val = container_of(ep, struct script_single_entry, entry); out_u32_member(out, key, 0,
out_u32_member(out, key, 0, val->value); container_of(ep, struct script_single_entry, entry));
break; break;
case SCRIPT_VALUE_TYPE_NULL: case SCRIPT_VALUE_TYPE_NULL:
out_null_member(out, key);
break; break;
case SCRIPT_VALUE_TYPE_GPIO: case SCRIPT_VALUE_TYPE_GPIO:
out_gpio_member(out, key, out_gpio_member(out, key,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment