From 4751cebfcbab752d6294273f1d31c404180b4d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kope=C4=87?= Date: Thu, 27 Jun 2024 11:02:36 +0200 Subject: [PATCH] options: save power on AC immediately on set() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Kopeć --- src/board/system76/common/options.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/board/system76/common/options.c b/src/board/system76/common/options.c index 284ccc9e9..1bac36b57 100644 --- a/src/board/system76/common/options.c +++ b/src/board/system76/common/options.c @@ -3,6 +3,7 @@ #include #include #include +#include uint8_t __xdata OPTIONS[NUM_OPTIONS]; @@ -17,6 +18,8 @@ uint8_t DEFAULT_OPTIONS[NUM_OPTIONS] = { }; // clang-format on +#define SAVE_IMMEDIATELY BIT(OPT_POWER_ON_AC) + // Config is in the second to last sector of flash const uint32_t OPTIONS_ADDR = 0x1F800; // Signature is the size of the config @@ -100,8 +103,10 @@ uint8_t options_get(uint16_t index) { bool options_set(uint16_t index, uint8_t value) { if (index < NUM_OPTIONS) { - OPTIONS[index] = value; TRACE("OPTION %x WRITE %x\n", index, value); + OPTIONS[index] = value; + if (SAVE_IMMEDIATELY & BIT(index)) + return options_save_config(); return true; } else { return false;