Add drivers to module and make start/stop optional (#580)

This commit is contained in:
Ken Van Hoeylandt
2026-07-23 23:28:09 +02:00
committed by GitHub
parent 08eac48e64
commit 429125734a
131 changed files with 488 additions and 2381 deletions
+9 -23
View File
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
#include <drivers/axp2101.h>
#include <tactility/check.h>
#include <tactility/driver.h>
#include <tactility/module.h>
@@ -10,6 +9,13 @@ extern Driver axp2101_driver;
extern Driver axp2101_power_supply_driver;
extern Driver axp2101_backlight_driver;
static Driver* const axp2101_drivers[] = {
&axp2101_driver,
&axp2101_power_supply_driver,
&axp2101_backlight_driver,
nullptr
};
const struct ModuleSymbol axp2101_module_symbols[] = {
DEFINE_MODULE_SYMBOL(axp2101_is_dcdc_enabled),
DEFINE_MODULE_SYMBOL(axp2101_set_dcdc_enabled),
@@ -28,30 +34,10 @@ const struct ModuleSymbol axp2101_module_symbols[] = {
MODULE_SYMBOL_TERMINATOR
};
static error_t start() {
/* We crash when construct fails, because if a single driver fails to construct,
* there is no guarantee that the previously constructed drivers can be destroyed */
check(driver_construct_add(&axp2101_driver) == ERROR_NONE);
check(driver_construct_add(&axp2101_power_supply_driver) == ERROR_NONE);
check(driver_construct_add(&axp2101_backlight_driver) == ERROR_NONE);
return ERROR_NONE;
}
static error_t stop() {
/* We crash when destruct fails, because if a single driver fails to destruct,
* there is no guarantee that the previously destroyed drivers can be recovered */
check(driver_remove_destruct(&axp2101_backlight_driver) == ERROR_NONE);
check(driver_remove_destruct(&axp2101_power_supply_driver) == ERROR_NONE);
check(driver_remove_destruct(&axp2101_driver) == ERROR_NONE);
return ERROR_NONE;
}
Module axp2101_module = {
.name = "axp2101",
.start = start,
.stop = stop,
.symbols = axp2101_module_symbols,
.internal = nullptr
.drivers = axp2101_drivers,
.symbols = axp2101_module_symbols
};
}