Browse Source

scripts: kconfig: functions: add dt_compat_enabled_num function

Add dt_compat_enabled_num Kconfig helper function for counting the number
of compatible nodes with status okay.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
pull/92320/head
Henrik Brix Andersen 2 weeks ago committed by Daniel DeGrasse
parent
commit
08175f816a
  1. 1
      doc/build/kconfig/preprocessor-functions.rst
  2. 12
      scripts/kconfig/kconfigfunctions.py

1
doc/build/kconfig/preprocessor-functions.rst vendored

@ -42,6 +42,7 @@ while the ``*_hex`` version returns a hexadecimal value starting with ``0x``. @@ -42,6 +42,7 @@ while the ``*_hex`` version returns a hexadecimal value starting with ``0x``.
$(dt_compat_any_has_prop,<compatible string>,<prop>[,<value>])
$(dt_compat_any_on_bus,<compatible string>,<prop>)
$(dt_compat_enabled,<compatible string>)
$(dt_compat_enabled_num,<compatible string>)
$(dt_compat_on_bus,<compatible string>,<bus>)
$(dt_gpio_hogs_enabled)
$(dt_has_compat,<compatible string>)

12
scripts/kconfig/kconfigfunctions.py

@ -771,6 +771,17 @@ def dt_compat_enabled(kconf, _, compat): @@ -771,6 +771,17 @@ def dt_compat_enabled(kconf, _, compat):
return "y" if compat in edt.compat2okay else "n"
def dt_compat_enabled_num(kconf, _, compat):
"""
This function takes a 'compat' and the returns number of status "okay"
compatible nodes in the EDT.
"""
if doc_mode or edt is None:
return "0"
return str(len(edt.compat2okay[compat]))
def dt_compat_on_bus(kconf, _, compat, bus):
"""
This function takes a 'compat' and returns "y" if we find an enabled
@ -1074,6 +1085,7 @@ def inc_dec(kconf, name, *args): @@ -1074,6 +1085,7 @@ def inc_dec(kconf, name, *args):
functions = {
"dt_has_compat": (dt_has_compat, 1, 1),
"dt_compat_enabled": (dt_compat_enabled, 1, 1),
"dt_compat_enabled_num": (dt_compat_enabled_num, 1, 1),
"dt_compat_on_bus": (dt_compat_on_bus, 2, 2),
"dt_compat_any_has_prop": (dt_compat_any_has_prop, 2, 3),
"dt_compat_any_not_has_prop": (dt_compat_any_not_has_prop, 2, 2),

Loading…
Cancel
Save