From 75b2f5abede44cba76e38388831c904df56faa45 Mon Sep 17 00:00:00 2001 From: Aaron Massey Date: Fri, 14 Apr 2023 14:39:52 -0600 Subject: [PATCH] emul: Fuel gauge tests direct access to emul_sbs The fuel gauge tests should *not* have to enable CONFIG_SENSOR in order to get access to the sbs gauge emulator. Allow fuel_gauge sbs_gauge direct access to emul_sbs_gauge.c Signed-off-by: Aaron Massey --- drivers/fuel_gauge/sbs_gauge/CMakeLists.txt | 2 +- drivers/fuel_gauge/sbs_gauge/Kconfig | 2 ++ drivers/fuel_gauge/sbs_gauge/Kconfig.emul_sbs_gauge | 12 ++++++++++++ .../sbs_gauge/emul_sbs_gauge.c | 0 drivers/sensor/sbs_gauge/CMakeLists.txt | 2 +- drivers/sensor/sbs_gauge/Kconfig | 8 ++------ tests/drivers/fuel_gauge/sbs_gauge/prj.conf | 1 - 7 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 drivers/fuel_gauge/sbs_gauge/Kconfig.emul_sbs_gauge rename drivers/{sensor => fuel_gauge}/sbs_gauge/emul_sbs_gauge.c (100%) diff --git a/drivers/fuel_gauge/sbs_gauge/CMakeLists.txt b/drivers/fuel_gauge/sbs_gauge/CMakeLists.txt index a0c311285e5..5d62cd13b3f 100644 --- a/drivers/fuel_gauge/sbs_gauge/CMakeLists.txt +++ b/drivers/fuel_gauge/sbs_gauge/CMakeLists.txt @@ -3,4 +3,4 @@ zephyr_library() zephyr_library_sources(sbs_gauge.c) zephyr_include_directories_ifdef(CONFIG_EMUL_SBS_GAUGE .) -zephyr_library_sources_ifdef(CONFIG_EMUL_SBS_GAUGE ../../sensor/sbs_gauge/emul_sbs_gauge.c) +zephyr_library_sources_ifdef(CONFIG_EMUL_SBS_GAUGE emul_sbs_gauge.c) diff --git a/drivers/fuel_gauge/sbs_gauge/Kconfig b/drivers/fuel_gauge/sbs_gauge/Kconfig index 8c3a7e281f3..fe904cb4ce5 100644 --- a/drivers/fuel_gauge/sbs_gauge/Kconfig +++ b/drivers/fuel_gauge/sbs_gauge/Kconfig @@ -8,3 +8,5 @@ config SBS_GAUGE_NEW_API select I2C help Enable I2C-based/SMBus-based driver for a Smart Battery Fuel Gauge. + +rsource "Kconfig.emul_sbs_gauge" diff --git a/drivers/fuel_gauge/sbs_gauge/Kconfig.emul_sbs_gauge b/drivers/fuel_gauge/sbs_gauge/Kconfig.emul_sbs_gauge new file mode 100644 index 00000000000..fe9f668cf02 --- /dev/null +++ b/drivers/fuel_gauge/sbs_gauge/Kconfig.emul_sbs_gauge @@ -0,0 +1,12 @@ +# Copyright 2023 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +# Keep this Kconfig separate from the fuel_gauge/sbs_gauge Kconfig so it may be shared with the +# sensor/sbs_gauge Kconfig. + +config EMUL_SBS_GAUGE + bool "Emulate an SBS 1.1 compliant smart battery fuel gauge" + depends on EMUL + help + It provides readings which follow a simple sequence, thus allowing + test code to check that things are working as expected. diff --git a/drivers/sensor/sbs_gauge/emul_sbs_gauge.c b/drivers/fuel_gauge/sbs_gauge/emul_sbs_gauge.c similarity index 100% rename from drivers/sensor/sbs_gauge/emul_sbs_gauge.c rename to drivers/fuel_gauge/sbs_gauge/emul_sbs_gauge.c diff --git a/drivers/sensor/sbs_gauge/CMakeLists.txt b/drivers/sensor/sbs_gauge/CMakeLists.txt index 5d62cd13b3f..3decd07d292 100644 --- a/drivers/sensor/sbs_gauge/CMakeLists.txt +++ b/drivers/sensor/sbs_gauge/CMakeLists.txt @@ -3,4 +3,4 @@ zephyr_library() zephyr_library_sources(sbs_gauge.c) zephyr_include_directories_ifdef(CONFIG_EMUL_SBS_GAUGE .) -zephyr_library_sources_ifdef(CONFIG_EMUL_SBS_GAUGE emul_sbs_gauge.c) +zephyr_library_sources_ifdef(CONFIG_EMUL_SBS_GAUGE ../../fuel_gauge/sbs_gauge/emul_sbs_gauge.c) diff --git a/drivers/sensor/sbs_gauge/Kconfig b/drivers/sensor/sbs_gauge/Kconfig index 58be1e519e5..2542b94bfbd 100644 --- a/drivers/sensor/sbs_gauge/Kconfig +++ b/drivers/sensor/sbs_gauge/Kconfig @@ -9,9 +9,5 @@ config SBS_GAUGE help Enable I2C-based/SMBus-based driver for a Smart Battery Fuel Gauge. -config EMUL_SBS_GAUGE - bool "Emulate an SBS 1.1 compliant smart battery fuel gauge" - depends on EMUL - help - It provides readings which follow a simple sequence, thus allowing - test code to check that things are working as expected. +# Maintain access to emul_sbs_gauge. +source "drivers/fuel_gauge/sbs_gauge/Kconfig.emul_sbs_gauge" diff --git a/tests/drivers/fuel_gauge/sbs_gauge/prj.conf b/tests/drivers/fuel_gauge/sbs_gauge/prj.conf index cdbbc113c31..23ceb0b3cdd 100644 --- a/tests/drivers/fuel_gauge/sbs_gauge/prj.conf +++ b/tests/drivers/fuel_gauge/sbs_gauge/prj.conf @@ -3,6 +3,5 @@ CONFIG_ZTEST_NEW_API=y CONFIG_I2C=y CONFIG_TEST_USERSPACE=y CONFIG_LOG=y -CONFIG_SENSOR=y CONFIG_FUEL_GAUGE=y