summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew McRae <amcrae@google.com>2022-01-06 13:18:27 +1100
committerCommit Bot <commit-bot@chromium.org>2022-01-07 01:40:58 +0000
commit9ce2297ff42e96a08df75012d66072371062ede6 (patch)
treeb2fabe8d5a5cc1d40f3beff9b1d0fc936d54fbb2
parent4a4fa52f07789adc04717a40f12529e0890fe5dc (diff)
downloadchrome-ec-9ce2297ff42e96a08df75012d66072371062ede6.tar.gz
zephyr: Simplify naming of fw_config fields and values
Do not construct enum names, but instead use just the name from the enum-name property directly. It is up to whoever is adding the DTS to ensure that the enum names are unique. BUG=b:212758472 TEST=zmake testall; zmake configure -b nivviks BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: If6a54654d583fba33607e56db63ada92b6f8b74a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3367729 Reviewed-by: Tristan Honscheid <honscheid@google.com>
-rw-r--r--zephyr/include/drivers/cros_cbi.h60
1 files changed, 22 insertions, 38 deletions
diff --git a/zephyr/include/drivers/cros_cbi.h b/zephyr/include/drivers/cros_cbi.h
index 29925181f3..26261764f6 100644
--- a/zephyr/include/drivers/cros_cbi.h
+++ b/zephyr/include/drivers/cros_cbi.h
@@ -38,63 +38,47 @@ enum cbi_ssfc_value_id {
/*
* Macros to help generate the enum list of field and value names.
*/
-#define CBI_FW_CONFIG_ENUM(node) DT_STRING_TOKEN(node, enum_name)
-#define CBI_FW_CONFIG_COMPAT named_cbi_fw_config
/*
- * Prepend enum name with CBI_FW_CONFIG_FIELD_
+ * Retrieve the enum-name property for this node.
*/
-#define CBI_FW_CONFIG_F_PREPEND(id) DT_CAT(CBI_FW_CONFIG_FIELD_, id)
+#define CBI_FW_CONFIG_ENUM(node) DT_STRING_TOKEN(node, enum_name)
+
/*
- * Invoked for each child of all instances of nodes with
- * compatible = "named-cbi-fw-config"
- * Creates an enum field id from the enum-name property.
+ * Create an enum entry without a value (an enum with a following comma).
*/
-#define CBI_FW_CONFIG_F_ENUM(node) \
- CBI_FW_CONFIG_F_PREPEND(CBI_FW_CONFIG_ENUM(node))
-
-#define CBI_FW_CONFIG_F_ENUM_WITH_COMMA(node) \
- CBI_FW_CONFIG_F_ENUM(node),
+#define CBI_FW_CONFIG_ENUM_WITH_COMMA(node) \
+ CBI_FW_CONFIG_ENUM(node),
/*
- * Invoked for each node that has compatible = "named-cbi-fw-config"
+ * Create a single enum entry with assignment to the node's value,
+ * along with a following comma.
*/
-#define CBI_FW_CONFIG_F_ALL(inst) \
- DT_FOREACH_CHILD_STATUS_OKAY(inst, CBI_FW_CONFIG_F_ENUM_WITH_COMMA)
-
-enum cbi_fw_config_field_id {
- DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_COMPAT,
- CBI_FW_CONFIG_F_ALL)
- CBI_FW_CONFIG_FIELDS_COUNT
-};
-
-#define CBI_FW_CONFIG_VALUE_COMPAT named_cbi_fw_config_value
-
-#define CBI_FW_CONFIG_V_PARENT(node) CBI_FW_CONFIG_ENUM(DT_PARENT(node))
+#define CBI_FW_CONFIG_ENUM_WITH_VALUE(node) \
+ CBI_FW_CONFIG_ENUM(node) = DT_PROP(node, value),
/*
- * Create the full enum name for this child node, as
- * CBI_FW_CONFIG_FIELD_field_value
+ * Generate a list of enum entries without a value.
*/
-#define CBI_FW_CONFIG_V_NAME(p, e) DT_CAT4(CBI_FW_CONFIG_VALUE_, p, _, e)
-
-#define CBI_FW_CONFIG_V_ENUM(node) \
- CBI_FW_CONFIG_V_NAME(CBI_FW_CONFIG_V_PARENT(node), \
- DT_STRING_TOKEN(node, enum_name))
+#define CBI_FW_CONFIG_CHILD_ENUM_LIST(node) \
+ DT_FOREACH_CHILD_STATUS_OKAY(node, CBI_FW_CONFIG_ENUM_WITH_COMMA)
/*
- * Create a single enum entry with assignment to the child value.
+ * Enum list of all fields.
*/
-#define CBI_FW_CONFIG_V_ENTRY(node) \
- CBI_FW_CONFIG_V_ENUM(node) = DT_PROP(node, value),
+enum cbi_fw_config_field_id {
+ DT_FOREACH_STATUS_OKAY(named_cbi_fw_config,
+ CBI_FW_CONFIG_CHILD_ENUM_LIST)
+ CBI_FW_CONFIG_FIELDS_COUNT
+};
/*
* enum list of all child values.
*/
enum cbi_fw_config_value_id {
- DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_VALUE_COMPAT,
- CBI_FW_CONFIG_V_ENTRY)
- CBI_FW_CONFIG_VALUES_COUNT
+ DT_FOREACH_STATUS_OKAY(named_cbi_fw_config_value,
+ CBI_FW_CONFIG_ENUM_WITH_VALUE)
+ CBI_FW_CONFIG_VALUES_LAST /* added to ensure at least one entry */
};
/**