From 0ed02e394ded10a95644c94673b940779102f55a Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Thu, 27 Jul 2023 09:49:26 -0700 Subject: [PATCH] Clean up --- config/boards/shields/rommana/leds.c | 32 +++++++++++++--------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/config/boards/shields/rommana/leds.c b/config/boards/shields/rommana/leds.c index a8a6a817..ecde22e7 100644 --- a/config/boards/shields/rommana/leds.c +++ b/config/boards/shields/rommana/leds.c @@ -1,14 +1,6 @@ -/* - * Copyright (c) 2020 Seagate Technology LLC - * - * SPDX-License-Identifier: Apache-2.0 - */ - #include #include -#include #include -#include #include #include #include @@ -27,21 +19,27 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); static const struct device *led_dev = DEVICE_DT_GET(LED_GPIO_NODE_ID); -struct led_state { +struct led_action { struct k_work_delayable work; - bool turn_on; uint8_t led_idx; + bool turn_on; }; -static struct led_state red_off = {.led_idx = DT_NODE_CHILD_IDX(DT_NODELABEL(led0)), .turn_on = false}; -static struct led_state red_on = {.led_idx = DT_NODE_CHILD_IDX(DT_NODELABEL(led0)), .turn_on = true}; -static struct led_state grn_off = {.led_idx = DT_NODE_CHILD_IDX(DT_NODELABEL(led1)), .turn_on = false}; -static struct led_state grn_on = {.led_idx = DT_NODE_CHILD_IDX(DT_NODELABEL(led1)), .turn_on = true}; -static struct led_state blu_off = {.led_idx = DT_NODE_CHILD_IDX(DT_NODELABEL(led2)), .turn_on = false}; -static struct led_state blu_on = {.led_idx = DT_NODE_CHILD_IDX(DT_NODELABEL(led2)), .turn_on = true}; +static struct led_action red_off = {.led_idx = DT_NODE_CHILD_IDX(DT_NODELABEL(led0)), + .turn_on = false}; +static struct led_action red_on = {.led_idx = DT_NODE_CHILD_IDX(DT_NODELABEL(led0)), + .turn_on = true}; +static struct led_action grn_off = {.led_idx = DT_NODE_CHILD_IDX(DT_NODELABEL(led1)), + .turn_on = false}; +static struct led_action grn_on = {.led_idx = DT_NODE_CHILD_IDX(DT_NODELABEL(led1)), + .turn_on = true}; +static struct led_action blu_off = {.led_idx = DT_NODE_CHILD_IDX(DT_NODELABEL(led2)), + .turn_on = false}; +static struct led_action blu_on = {.led_idx = DT_NODE_CHILD_IDX(DT_NODELABEL(led2)), + .turn_on = true}; static void led_work(struct k_work *work) { - struct led_state *action = CONTAINER_OF(work, struct led_state, work); + struct led_action *action = CONTAINER_OF(work, struct led_action, work); LOG_INF("Switching led %d to state %d", action->led_idx, action->turn_on); if (action->turn_on) { led_on(led_dev, action->led_idx);