summaryrefslogtreecommitdiff
path: root/common/device_state.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /common/device_state.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-release-R101-14588.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'common/device_state.c')
-rw-r--r--common/device_state.c83
1 files changed, 0 insertions, 83 deletions
diff --git a/common/device_state.c b/common/device_state.c
deleted file mode 100644
index 0ba94d6115..0000000000
--- a/common/device_state.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "console.h"
-#include "device_state.h"
-#include "hooks.h"
-
-#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
-
-/**
- * Return text description for a state
- *
- * @param state State
- * @return String describing that state
- */
-static const char *state_desc(enum device_state state)
-{
- return state == DEVICE_STATE_ON ? "on" :
- state == DEVICE_STATE_OFF ? "off" : "unknown";
-}
-
-enum device_state device_get_state(enum device_type device)
-{
- return device_states[device].state;
-}
-
-int device_set_state(enum device_type device, enum device_state state)
-{
- struct device_config *dc = device_states + device;
-
- /*
- * It'd be handy for debugging if we could print to the console when
- * device_set_state() is called. But unfortunately, it'll be called a
- * LOT when debouncing UART activity on DETECT_EC or DETECT_AP. So
- * only print when the last known state changes below.
- */
-
- dc->state = state;
-
- if (state != DEVICE_STATE_UNKNOWN && dc->last_known_state != state) {
- dc->last_known_state = state;
- CPRINTS("DEV %s -> %s", dc->name, state_desc(state));
- return 1;
- }
-
- return 0;
-}
-
-/**
- * Periodic check of device states.
- *
- * The board does all the work.
- *
- * Note that device states can change outside of this context as well, for
- * example, from a GPIO interrupt handler.
- */
-static void check_device_state(void)
-{
- int i;
-
- for (i = 0; i < DEVICE_COUNT; i++)
- board_update_device_state(i);
-}
-DECLARE_HOOK(HOOK_SECOND, check_device_state, HOOK_PRIO_DEFAULT);
-
-static int command_devices(int argc, char **argv)
-{
- const struct device_config *dc = device_states;
- int i;
-
- ccprintf("Device State LastKnown\n");
-
- for (i = 0; i < DEVICE_COUNT; i++, dc++)
- ccprintf("%-9s %-7s %s\n", dc->name, state_desc(dc->state),
- state_desc(dc->last_known_state));
-
- return EC_SUCCESS;
-}
-DECLARE_SAFE_CONSOLE_COMMAND(devices, command_devices,
- "",
- "Get the device states");