Skip to content

Commit

Permalink
aw2013: set default state
Browse files Browse the repository at this point in the history
  • Loading branch information
hanwckf committed Jul 27, 2019
1 parent a521477 commit d2b3f63
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
aw2013,hold-time-ms = <1>;
aw2013,fall-time-ms = <2>;
aw2013,off-time-ms = <1>;
default-state = "on";
};

aw2013,blue {
Expand Down
26 changes: 26 additions & 0 deletions linux-marvell/drivers/leds/leds-aw2013.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,30 @@ static int aw2013_led_parse_child_node(struct aw2013_led *led_array,
return rc;
}

static int aw2013_led_default_set(struct aw2013_led *led_array,
struct device_node *node)
{
struct aw2013_led *led;
struct device_node *temp;
int parsed_leds = 0;
const char* state;

for_each_child_of_node(node, temp) {
led = &led_array[parsed_leds];
state = of_get_property(temp, "default-state", NULL);
if (state) {
if (!strcmp(state, "on")) {
aw2013_set_brightness(&led->cdev, led->cdev.max_brightness);
} else {
aw2013_set_brightness(&led->cdev, LED_OFF);
}
}
parsed_leds++;
}

return 0;
}

static int aw2013_led_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
Expand Down Expand Up @@ -681,6 +705,8 @@ static int aw2013_led_probe(struct i2c_client *client,
goto fail_parsed_node;
}

aw2013_led_default_set(led_array, node);

return 0;

fail_parsed_node:
Expand Down

0 comments on commit d2b3f63

Please sign in to comment.