+static const struct ec_config_schema ec_node_seq_subschema[] = {
+ {
+ .desc = "A child node which is part of the sequence.",
+ .type = EC_CONFIG_TYPE_NODE,
+ },
+ {
+ .type = EC_CONFIG_TYPE_NONE,
+ },
+};
+
+static const struct ec_config_schema ec_node_seq_schema[] = {
+ {
+ .key = "children",
+ .desc = "The list of children nodes, to be parsed in sequence.",
+ .type = EC_CONFIG_TYPE_LIST,
+ .subschema = ec_node_seq_subschema,
+ },
+ {
+ .type = EC_CONFIG_TYPE_NONE,
+ },
+};
+
+static int ec_node_seq_set_config(struct ec_node *gen_node,
+ const struct ec_config *config)
+{
+ struct ec_node_seq *node = (struct ec_node_seq *)gen_node;
+ struct ec_node **table = NULL;
+ size_t i, len = 0;
+
+ table = ec_node_config_node_list_to_table(
+ ec_config_dict_get(config, "children"), &len);
+ if (table == NULL)
+ goto fail;
+
+ for (i = 0; i < node->len; i++)
+ ec_node_free(node->table[i]);
+ ec_free(node->table);
+ node->table = table;
+ node->len = len;
+
+ return 0;
+
+fail:
+ for (i = 0; i < len; i++)
+ ec_node_free(table[i]);
+ ec_free(table);
+ return -1;
+}
+
+static size_t
+ec_node_seq_get_children_count(const struct ec_node *gen_node)
+{
+ struct ec_node_seq *node = (struct ec_node_seq *)gen_node;
+ return node->len;
+}
+
+static int
+ec_node_seq_get_child(const struct ec_node *gen_node, size_t i,
+ struct ec_node **child, unsigned int *refs)
+{
+ struct ec_node_seq *node = (struct ec_node_seq *)gen_node;
+
+ if (i >= node->len)
+ return -1;
+
+ *child = node->table[i];
+ /* each child node is referenced twice: once in the config and
+ * once in the node->table[] */
+ *refs = 2;
+ return 0;
+}
+