From f7153012eff53b28dfa77b3ea2f76fb75d9fc812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fin=20Maa=C3=9F?= Date: Mon, 28 Apr 2025 13:55:34 +0200 Subject: [PATCH] dts: enum_macros: make sure that they are lowercase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DT_ENUM_HAS_VALUE_BY_IDX states, that the value must be lowercase-and-underscores, this makes sure, that they can match. Signed-off-by: Fin Maaß --- drivers/comparator/comparator_nrf_comp.c | 6 +++--- drivers/comparator/comparator_nrf_lpcomp.c | 2 +- scripts/dts/gen_defines.py | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/comparator/comparator_nrf_comp.c b/drivers/comparator/comparator_nrf_comp.c index b60aef17987..311a864303b 100644 --- a/drivers/comparator/comparator_nrf_comp.c +++ b/drivers/comparator/comparator_nrf_comp.c @@ -17,16 +17,16 @@ _CONCAT(COMP_NRF_COMP_REFSEL_, DT_INST_STRING_TOKEN(inst, refsel)) #define SHIM_NRF_COMP_DT_INST_REFSEL_IS_AREF(inst) \ - DT_INST_ENUM_HAS_VALUE(inst, refsel, AREF) + DT_INST_ENUM_HAS_VALUE(inst, refsel, aref) #define SHIM_NRF_COMP_DT_INST_EXTREFSEL(inst) \ _CONCAT(COMP_NRF_COMP_EXTREFSEL_, DT_INST_STRING_TOKEN(inst, extrefsel)) #define SHIM_NRF_COMP_DT_INST_MAIN_MODE_IS_SE(inst) \ - DT_INST_ENUM_HAS_VALUE(inst, main_mode, SE) + DT_INST_ENUM_HAS_VALUE(inst, main_mode, se) #define SHIM_NRF_COMP_DT_INST_MAIN_MODE_IS_DIFF(inst) \ - DT_INST_ENUM_HAS_VALUE(inst, main_mode, DIFF) + DT_INST_ENUM_HAS_VALUE(inst, main_mode, diff) #define SHIM_NRF_COMP_DT_INST_TH_DOWN(inst) \ DT_INST_PROP(inst, th_down) diff --git a/drivers/comparator/comparator_nrf_lpcomp.c b/drivers/comparator/comparator_nrf_lpcomp.c index a3de2b8069c..623c7adacd4 100644 --- a/drivers/comparator/comparator_nrf_lpcomp.c +++ b/drivers/comparator/comparator_nrf_lpcomp.c @@ -19,7 +19,7 @@ _CONCAT(COMP_NRF_LPCOMP_REFSEL_, DT_INST_STRING_TOKEN(inst, refsel)) #define SHIM_NRF_LPCOMP_DT_INST_REFSEL_IS_AREF(inst) \ - DT_INST_ENUM_HAS_VALUE(inst, refsel, AREF) + DT_INST_ENUM_HAS_VALUE(inst, refsel, aref) #define SHIM_NRF_LPCOMP_DT_INST_EXTREFSEL(inst) \ _CONCAT(COMP_NRF_LPCOMP_EXTREFSEL_, DT_INST_STRING_TOKEN(inst, extrefsel)) diff --git a/scripts/dts/gen_defines.py b/scripts/dts/gen_defines.py index 65ae177b63c..ee6a88dd1d1 100755 --- a/scripts/dts/gen_defines.py +++ b/scripts/dts/gen_defines.py @@ -679,6 +679,9 @@ def enum_macros(prop: edtlib.Property, macro: str): val = prop.val_as_tokens if spec.enum_tokenizable else (prop.val if isinstance(prop.val, list) else [prop.val]) for i, subval in enumerate(val): + # make sure the subval is a formated right. + if isinstance(subval, str): + subval = str2ident(subval) # DT_N__P__IDX__EXISTS ret[f"{macro}_IDX_{i}_EXISTS"] = 1 # DT_N__P__IDX__ENUM_VAL__EXISTS 1