pr_out(" ");
}
+static bool is_binary_eol(int i)
+{
+ return !(i%16);
+}
+
+static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
+{
+ int i = 0;
+
+ while (i < len) {
+ if (dl->json_output)
+ print_int(PRINT_JSON, NULL, NULL, data[i]);
+ else
+ pr_out("%02x ", data[i]);
+ i++;
+ if (!dl->json_output && is_binary_eol(i))
+ __pr_out_newline();
+ }
+ if (!dl->json_output && !is_binary_eol(i))
+ __pr_out_newline();
+}
+
+static void pr_out_name(struct dl *dl, const char *name)
+{
+ __pr_out_indent_newline(dl);
+ if (dl->json_output)
+ print_string(PRINT_JSON, name, NULL, NULL);
+ else
+ pr_out("%s:", name);
+}
+
+static void pr_out_u64(struct dl *dl, const char *name, uint64_t val)
+{
+ __pr_out_indent_newline(dl);
+ if (val == (uint64_t) -1)
+ return print_string_name_value(name, "unlimited");
+
+ if (dl->json_output)
+ print_u64(PRINT_JSON, name, NULL, val);
+ else
+ pr_out("%s %"PRIu64, name, val);
+}
+
+static void pr_out_section_start(struct dl *dl, const char *name)
+{
+ if (dl->json_output) {
+ open_json_object(NULL);
+ open_json_object(name);
+ }
+}
+
+static void pr_out_section_end(struct dl *dl)
+{
+ if (dl->json_output) {
+ if (dl->arr_last.present)
+ close_json_array(PRINT_JSON, NULL);
+ close_json_object();
+ close_json_object();
+ }
+}
+
+static void pr_out_array_start(struct dl *dl, const char *name)
+{
+ if (dl->json_output) {
+ open_json_array(PRINT_JSON, name);
+ } else {
+ __pr_out_indent_inc();
+ __pr_out_newline();
+ pr_out("%s:", name);
+ __pr_out_indent_inc();
+ __pr_out_newline();
+ }
+}
+
+static void pr_out_array_end(struct dl *dl)
+{
+ if (dl->json_output) {
+ close_json_array(PRINT_JSON, NULL);
+ } else {
+ __pr_out_indent_dec();
+ __pr_out_indent_dec();
+ }
+}
+
+static void pr_out_object_start(struct dl *dl, const char *name)
+{
+ if (dl->json_output) {
+ open_json_object(name);
+ } else {
+ __pr_out_indent_inc();
+ __pr_out_newline();
+ pr_out("%s:", name);
+ __pr_out_indent_inc();
+ __pr_out_newline();
+ }
+}
+
+static void pr_out_object_end(struct dl *dl)
+{
+ if (dl->json_output) {
+ close_json_object();
+ } else {
+ __pr_out_indent_dec();
+ __pr_out_indent_dec();
+ }
+}
+
+static void pr_out_entry_start(struct dl *dl)
+{
+ if (dl->json_output)
+ open_json_object(NULL);
+}
+
+static void pr_out_entry_end(struct dl *dl)
+{
+ if (dl->json_output)
+ close_json_object();
+ else
+ __pr_out_newline();
+}
+
static void check_indent_newline(struct dl *dl)
{
__pr_out_indent_newline(dl);
pr_out("\n");
}
-static void pr_out_u64(struct dl *dl, const char *name, uint64_t val)
-{
- __pr_out_indent_newline(dl);
- if (val == (uint64_t) -1)
- return print_string_name_value(name, "unlimited");
-
- if (dl->json_output)
- print_u64(PRINT_JSON, name, NULL, val);
- else
- pr_out("%s %"PRIu64, name, val);
-}
-
-static bool is_binary_eol(int i)
-{
- return !(i%16);
-}
-
-static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
-{
- int i = 0;
-
- while (i < len) {
- if (dl->json_output)
- print_int(PRINT_JSON, NULL, NULL, data[i]);
- else
- pr_out("%02x ", data[i]);
- i++;
- if (!dl->json_output && is_binary_eol(i))
- __pr_out_newline();
- }
- if (!dl->json_output && !is_binary_eol(i))
- __pr_out_newline();
-}
-
-static void pr_out_name(struct dl *dl, const char *name)
-{
- __pr_out_indent_newline(dl);
- if (dl->json_output)
- print_string(PRINT_JSON, name, NULL, NULL);
- else
- pr_out("%s:", name);
-}
-
static void pr_out_region_chunk_start(struct dl *dl, uint64_t addr)
{
if (dl->json_output) {
pr_out_region_chunk_end(dl);
}
-static void pr_out_section_start(struct dl *dl, const char *name)
-{
- if (dl->json_output) {
- open_json_object(NULL);
- open_json_object(name);
- }
-}
-
-static void pr_out_section_end(struct dl *dl)
-{
- if (dl->json_output) {
- if (dl->arr_last.present)
- close_json_array(PRINT_JSON, NULL);
- close_json_object();
- close_json_object();
- }
-}
-
-static void pr_out_array_start(struct dl *dl, const char *name)
-{
- if (dl->json_output) {
- open_json_array(PRINT_JSON, name);
- } else {
- __pr_out_indent_inc();
- __pr_out_newline();
- pr_out("%s:", name);
- __pr_out_indent_inc();
- __pr_out_newline();
- }
-}
-
-static void pr_out_array_end(struct dl *dl)
-{
- if (dl->json_output) {
- close_json_array(PRINT_JSON, NULL);
- } else {
- __pr_out_indent_dec();
- __pr_out_indent_dec();
- }
-}
-
-static void pr_out_object_start(struct dl *dl, const char *name)
-{
- if (dl->json_output) {
- open_json_object(name);
- } else {
- __pr_out_indent_inc();
- __pr_out_newline();
- pr_out("%s:", name);
- __pr_out_indent_inc();
- __pr_out_newline();
- }
-}
-
-static void pr_out_object_end(struct dl *dl)
-{
- if (dl->json_output) {
- close_json_object();
- } else {
- __pr_out_indent_dec();
- __pr_out_indent_dec();
- }
-}
-
-static void pr_out_entry_start(struct dl *dl)
-{
- if (dl->json_output)
- open_json_object(NULL);
-}
-
-static void pr_out_entry_end(struct dl *dl)
-{
- if (dl->json_output)
- close_json_object();
- else
- __pr_out_newline();
-}
-
static void pr_out_stats(struct dl *dl, struct nlattr *nla_stats)
{
struct nlattr *tb[DEVLINK_ATTR_STATS_MAX + 1] = {};