Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
flow: Use helper modules in node-types that depend on others
Browse files Browse the repository at this point in the history
So they no longer need a hard dependency on the more basic node-types
being built-in.

Signed-off-by: Iván Briano <ivan.briano@intel.com>
  • Loading branch information
ibriano committed Sep 28, 2015
1 parent 95f4755 commit ce390ee
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/modules/flow/calamari/Kconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
config FLOW_NODE_TYPE_CALAMARI
tristate "Node type: calamari"
depends on (FLOW_NODE_TYPE_GPIO = y) && USE_PWM && USE_SPI
depends on FLOW_NODE_TYPE_GPIO && USE_PWM && USE_SPI
default m
1 change: 0 additions & 1 deletion src/modules/flow/calamari/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
obj-$(FLOW_NODE_TYPE_CALAMARI) += calamari.mod
obj-calamari-$(FLOW_NODE_TYPE_CALAMARI) := calamari.json calamari.o
obj-calamari-$(FLOW_NODE_TYPE_CALAMARI)-deps := flow/gpio.mod
obj-calamari-$(FLOW_NODE_TYPE_CALAMARI)-type := flow
16 changes: 14 additions & 2 deletions src/modules/flow/calamari/calamari.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ static void
calamari_7seg_new_type(const struct sol_flow_node_type **current)
{
struct sol_flow_node_type *type;
const struct sol_flow_node_type *gpio_writer;

static struct sol_flow_static_node_spec nodes[] = {
[SEG_CTL] = { NULL, "segments-ctl", NULL },
Expand Down Expand Up @@ -273,8 +274,13 @@ calamari_7seg_new_type(const struct sol_flow_node_type **current)
.child_opts_set = calamari_7seg_child_opts_set,
};

if (sol_flow_get_node_type("gpio", SOL_FLOW_NODE_TYPE_GPIO_WRITER, &gpio_writer) < 0) {
*current = NULL;
return;
}

nodes[SEG_CTL].type = SOL_FLOW_NODE_TYPE_CALAMARI_SEGMENTS_CTL;
nodes[SEG_CLEAR].type = nodes[SEG_LATCH].type = nodes[SEG_CLOCK].type = nodes[SEG_DATA].type = SOL_FLOW_NODE_TYPE_GPIO_WRITER;
nodes[SEG_CLEAR].type = nodes[SEG_LATCH].type = nodes[SEG_CLOCK].type = nodes[SEG_DATA].type = gpio_writer;

type = sol_flow_static_new_type(&spec);
SOL_NULL_CHECK(type);
Expand Down Expand Up @@ -569,6 +575,7 @@ static void
calamari_rgb_led_new_type(const struct sol_flow_node_type **current)
{
struct sol_flow_node_type *type;
const struct sol_flow_node_type *gpio_writer;

static struct sol_flow_static_node_spec nodes[] = {
[RGB_LED_CTL] = { NULL, "rgb-ctl", NULL },
Expand Down Expand Up @@ -600,8 +607,13 @@ calamari_rgb_led_new_type(const struct sol_flow_node_type **current)
.child_opts_set = calamari_rgb_child_opts_set,
};

if (sol_flow_get_node_type("gpio", SOL_FLOW_NODE_TYPE_GPIO_WRITER, &gpio_writer) < 0) {
*current = NULL;
return;
}

nodes[RGB_LED_CTL].type = SOL_FLOW_NODE_TYPE_CALAMARI_RGB_CTL;
nodes[RGB_LED_RED].type = nodes[RGB_LED_GREEN].type = nodes[RGB_LED_BLUE].type = SOL_FLOW_NODE_TYPE_GPIO_WRITER;
nodes[RGB_LED_RED].type = nodes[RGB_LED_GREEN].type = nodes[RGB_LED_BLUE].type = gpio_writer;

type = sol_flow_static_new_type(&spec);
SOL_NULL_CHECK(type);
Expand Down
24 changes: 21 additions & 3 deletions src/modules/flow/grove/grove.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static void
grove_rotary_sensor_new_type(const struct sol_flow_node_type **current)
{
struct sol_flow_node_type *type;
const struct sol_flow_node_type *aio_reader;

static struct sol_flow_static_node_spec nodes[] = {
{ NULL, "rotary-converter", NULL },
Expand Down Expand Up @@ -107,8 +108,13 @@ grove_rotary_sensor_new_type(const struct sol_flow_node_type **current)
.child_opts_set = rotary_child_opts_set,
};

if (sol_flow_get_node_type("aio", SOL_FLOW_NODE_TYPE_AIO_READER, &aio_reader) < 0) {
*current = NULL;
return;
}

nodes[0].type = SOL_FLOW_NODE_TYPE_GROVE_ROTARY_CONVERTER;
nodes[1].type = SOL_FLOW_NODE_TYPE_AIO_READER;
nodes[1].type = aio_reader;

type = sol_flow_static_new_type(&spec);
SOL_NULL_CHECK(type);
Expand Down Expand Up @@ -208,6 +214,7 @@ static void
grove_light_sensor_new_type(const struct sol_flow_node_type **current)
{
struct sol_flow_node_type *type;
const struct sol_flow_node_type *aio_reader;

static struct sol_flow_static_node_spec nodes[] = {
{ NULL, "light-converter", NULL },
Expand All @@ -234,8 +241,13 @@ grove_light_sensor_new_type(const struct sol_flow_node_type **current)
.child_opts_set = light_child_opts_set,
};

if (sol_flow_get_node_type("aio", SOL_FLOW_NODE_TYPE_AIO_READER, &aio_reader) < 0) {
*current = NULL;
return;
}

nodes[0].type = SOL_FLOW_NODE_TYPE_GROVE_LIGHT_CONVERTER;
nodes[1].type = SOL_FLOW_NODE_TYPE_AIO_READER;
nodes[1].type = aio_reader;

type = sol_flow_static_new_type(&spec);
SOL_NULL_CHECK(type);
Expand Down Expand Up @@ -380,6 +392,7 @@ static void
grove_temperature_sensor_new_type(const struct sol_flow_node_type **current)
{
struct sol_flow_node_type *type;
const struct sol_flow_node_type *aio_reader;

static struct sol_flow_static_node_spec nodes[] = {
{ NULL, "temperature-converter", NULL },
Expand All @@ -406,8 +419,13 @@ grove_temperature_sensor_new_type(const struct sol_flow_node_type **current)
.child_opts_set = temperature_child_opts_set,
};

if (sol_flow_get_node_type("aio", SOL_FLOW_NODE_TYPE_AIO_READER, &aio_reader) < 0) {
*current = NULL;
return;
}

nodes[0].type = SOL_FLOW_NODE_TYPE_GROVE_TEMPERATURE_CONVERTER;
nodes[1].type = SOL_FLOW_NODE_TYPE_AIO_READER;
nodes[1].type = aio_reader;

type = sol_flow_static_new_type(&spec);
SOL_NULL_CHECK(type);
Expand Down

0 comments on commit ce390ee

Please sign in to comment.