}
static noinline_for_stack
-char *device_node_string(char *buf, char *end, struct device_node *dn,
- struct printf_spec spec, const char *fmt)
+char *device_node_string(struct printf_state *ps, struct device_node *dn)
{
char tbuf[sizeof("xxxx") + 1];
const char *p;
int ret;
- char *buf_start = buf;
+ char *buf_start = ps->buf;
+ const char *fmt = ps->fmt + 2;
struct property *prop;
bool has_mult, pass;
static const struct printf_spec num_spec = {
.base = 10,
};
- struct printf_spec str_spec = spec;
+ struct printf_spec str_spec = ps->spec;
str_spec.field_width = -1;
- if (!IS_ENABLED(CONFIG_OF))
- return string(buf, end, "(!OF)", spec);
+ if (!IS_ENABLED(CONFIG_OF)) {
+ printf_string(ps, "(!OF)");
+ return ps->buf;
+ }
- if ((unsigned long)dn < PAGE_SIZE)
- return string(buf, end, "(null)", spec);
+ if ((unsigned long)dn < PAGE_SIZE) {
+ printf_string(ps, "(null)");
+ return ps->buf;
+ }
/* simple case without anything any more format specifiers */
- fmt++;
- if (fmt[0] == '\0' || strcspn(fmt,"fnpPFcC") > 0)
+ if (fmt[0] == '\0' || strcspn(fmt, "fnpPFcC") > 0)
fmt = "f";
for (pass = false; strspn(fmt,"fnpPFcC"); fmt++, pass = true) {
int precision;
if (pass) {
- if (buf < end)
- *buf = ':';
- buf++;
+ if (ps->buf < ps->end)
+ *ps->buf = ':';
+ ps->buf++;
}
switch (*fmt) {
case 'f': /* full_name */
- buf = device_node_gen_full_name(dn, buf, end);
+ ps->buf = device_node_gen_full_name(dn, ps->buf, ps->end);
break;
case 'n': /* name */
p = kbasename(of_node_full_name(dn));
precision = str_spec.precision;
str_spec.precision = strchrnul(p, '@') - p;
- buf = string(buf, end, p, str_spec);
+ ps->buf = string(ps->buf, ps->end, p, str_spec);
str_spec.precision = precision;
break;
case 'p': /* phandle */
- buf = number(buf, end, (unsigned int)dn->phandle, num_spec);
+ ps->buf = number(ps->buf, ps->end,
+ (unsigned int)dn->phandle, num_spec);
break;
case 'P': /* path-spec */
p = kbasename(of_node_full_name(dn));
if (!p[1])
p = "/";
- buf = string(buf, end, p, str_spec);
+ ps->buf = string(ps->buf, ps->end, p, str_spec);
break;
case 'F': /* flags */
tbuf[0] = of_node_check_flag(dn, OF_DYNAMIC) ? 'D' : '-';
tbuf[2] = of_node_check_flag(dn, OF_POPULATED) ? 'P' : '-';
tbuf[3] = of_node_check_flag(dn, OF_POPULATED_BUS) ? 'B' : '-';
tbuf[4] = 0;
- buf = string(buf, end, tbuf, str_spec);
+ ps->buf = string(ps->buf, ps->end, tbuf, str_spec);
break;
case 'c': /* major compatible string */
ret = of_property_read_string(dn, "compatible", &p);
if (!ret)
- buf = string(buf, end, p, str_spec);
+ ps->buf = string(ps->buf, ps->end, p, str_spec);
break;
case 'C': /* full compatible string */
has_mult = false;
of_property_for_each_string(dn, "compatible", prop, p) {
if (has_mult)
- buf = string(buf, end, ",", str_spec);
- buf = string(buf, end, "\"", str_spec);
- buf = string(buf, end, p, str_spec);
- buf = string(buf, end, "\"", str_spec);
+ ps->buf = string(ps->buf, ps->end, ",", str_spec);
+ ps->buf = string(ps->buf, ps->end, "\"", str_spec);
+ ps->buf = string(ps->buf, ps->end, p, str_spec);
+ ps->buf = string(ps->buf, ps->end, "\"", str_spec);
has_mult = true;
}
}
}
- return widen_string(buf, buf - buf_start, end, spec);
+ printf_widen_string(ps, ps->buf - buf_start);
+ return ps->buf;
}
/*
case 'G':
return flags_string(ps, ptr);
case 'O':
- switch (fmt[1]) {
+ switch (ps->fmt[1]) {
case 'F':
- return device_node_string(buf, end, ptr, spec, fmt + 1);
+ return device_node_string(ps, ptr);
}
break;
case 'x':