summaryrefslogtreecommitdiff
path: root/zephyr/shim/src
diff options
context:
space:
mode:
authorFabio Baltieri <fabiobaltieri@google.com>2022-12-15 20:13:31 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-12-19 10:51:34 +0000
commit8d4c7c9afe575ff8bdffb170a6802aec134e1350 (patch)
tree60bfe89e5244cd671a14b414ba1b382f69c9db8f /zephyr/shim/src
parent7e5283549f8be6c3efb610b55e3e37ac1da0c5e7 (diff)
downloadchrome-ec-8d4c7c9afe575ff8bdffb170a6802aec134e1350.tar.gz
zephyr: adc: add a dedicated NAMED_ADC_CHANNELS option
Add a dedicated NAMED_ADC_CHANNELS option to decouple the platforms setting from the Zephyr ADC one. This allows running tests for code that uses only the Zephyr APIs without having to define named channels as well. Also allows dropping some #if guards that made no sense since they were guarding a data structure used outside of the guard. BRANCH=none BUG=none TEST=cq dry run TEST=zmake compare-builds -a Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I4193a8c41d3bfd684ec03407eee57660aba2c56c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4111644 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Sam Hurst <shurst@google.com>
Diffstat (limited to 'zephyr/shim/src')
-rw-r--r--zephyr/shim/src/CMakeLists.txt2
-rw-r--r--zephyr/shim/src/adc.c6
2 files changed, 1 insertions, 7 deletions
diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt
index 0491d8c842..d2a35dda49 100644
--- a/zephyr/shim/src/CMakeLists.txt
+++ b/zephyr/shim/src/CMakeLists.txt
@@ -18,7 +18,7 @@ endif()
zephyr_library_sources_ifdef(no_libgcc libgcc_${ARCH}.S)
-zephyr_library_sources_ifdef(CONFIG_ADC adc.c)
+zephyr_library_sources_ifdef(CONFIG_NAMED_ADC_CHANNELS adc.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY
battery.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER_RT9490
diff --git a/zephyr/shim/src/adc.c b/zephyr/shim/src/adc.c
index b448823eee..0041335662 100644
--- a/zephyr/shim/src/adc.c
+++ b/zephyr/shim/src/adc.c
@@ -16,9 +16,6 @@ LOG_MODULE_REGISTER(shim_adc, LOG_LEVEL_ERR);
#error "Define only one 'adc' console command."
#endif
-#define HAS_NAMED_ADC_CHANNELS DT_NODE_EXISTS(DT_INST(0, named_adc_channels))
-
-#if HAS_NAMED_ADC_CHANNELS
#define ADC_CHANNEL_INIT(node_id) \
[ZSHIM_ADC_ID(node_id)] = { \
.name = DT_NODE_FULL_NAME(node_id), \
@@ -42,13 +39,11 @@ struct adc_t adc_channels[] = { DT_FOREACH_CHILD(DT_INST(0, named_adc_channels),
const struct adc_t adc_channels[] = { DT_FOREACH_CHILD(
DT_INST(0, named_adc_channels), ADC_CHANNEL_INIT) };
#endif
-#endif /* named_adc_channels */
static int init_device_bindings(const struct device *device)
{
ARG_UNUSED(device);
-#if HAS_NAMED_ADC_CHANNELS
for (int i = 0; i < ARRAY_SIZE(adc_channels); i++) {
if (!device_is_ready(adc_channels[i].dev))
k_oops();
@@ -56,7 +51,6 @@ static int init_device_bindings(const struct device *device)
adc_channel_setup(adc_channels[i].dev,
&adc_channels[i].channel_cfg);
}
-#endif
return 0;
}