diff options
author | Yuval Peress <peress@google.com> | 2021-10-11 20:40:48 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-13 03:44:26 +0000 |
commit | e46d6b63a075fab257a89e2c45fcbdf2f687e19f (patch) | |
tree | 004ffcfba87c8ff07474642d8a4f54a0e29e29a4 | |
parent | 191dfd83456aef0813160ef4ac53742f8a1d7756 (diff) | |
download | chrome-ec-e46d6b63a075fab257a89e2c45fcbdf2f687e19f.tar.gz |
zephyr: cros_cbi remove unused cached_ssfc
The cros,cbi driver was found to contain a bug. During
CBI_SSFC_INIT_DEFAULT_ID() the static cached_ssfc variable was being
initialized. While all the functions using the ssfc values were using
the ones stored in the device's data struct. This means that the case
statements generated were always returning 0 for every case.
BRANCH=none
BUG=b:202789410
TEST=zmake configure --test zephyr/test/drivers
Signed-off-by: Yuval Peress <peress@google.com>
Change-Id: Icac1491c72e95e4700ce696f91f2cfaf56e0ebff
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3218464
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r-- | zephyr/drivers/cros_cbi/cros_cbi.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/zephyr/drivers/cros_cbi/cros_cbi.c b/zephyr/drivers/cros_cbi/cros_cbi.c index a36a4e9143..f3acda15ce 100644 --- a/zephyr/drivers/cros_cbi/cros_cbi.c +++ b/zephyr/drivers/cros_cbi/cros_cbi.c @@ -25,15 +25,16 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(named_cbi_ssfc) < 2, "More than 1 CBI SSFS node"); #define CBI_SSFC_NODE DT_INST(0, named_cbi_ssfc) -#define CBI_SSFC_INIT_DEFAULT_ID(id) \ - do { \ - if (DT_PROP(id, default)) { \ - cached_ssfc.CBI_SSFC_UNION_ENTRY_NAME(DT_PARENT(id)) = \ - DT_PROP(id, value); \ - } \ +#define CBI_SSFC_INIT_DEFAULT_ID(id, data) \ + do { \ + if (DT_PROP(id, default)) { \ + data->cached_ssfc.CBI_SSFC_UNION_ENTRY_NAME( \ + DT_PARENT(id)) = DT_PROP(id, value); \ + } \ } while (0); -#define CBI_SSFC_INIT_DEFAULT(inst) CBI_SSFC_INIT_DEFAULT_ID(DT_DRV_INST(inst)) +#define CBI_SSFC_INIT_DEFAULT(inst, data) \ + CBI_SSFC_INIT_DEFAULT_ID(DT_DRV_INST(inst), data) #define CBI_SSFC_VALUE_ARRAY_ID(id) \ [CBI_SSFC_VALUE_ID(id)] = DT_PROP(id, value), @@ -132,7 +133,6 @@ DT_INST_FOREACH_STATUS_OKAY(CBI_SSFC_VALUE_BUILD_ASSERT) static const uint8_t ssfc_values[] = { DT_INST_FOREACH_STATUS_OKAY(CBI_SSFC_VALUE_ARRAY) }; -static union cbi_ssfc cached_ssfc __attribute__((unused)); /* CBI SSFC part end */ @@ -155,7 +155,7 @@ static void cros_cbi_ssfc_init(const struct device *dev) struct cros_cbi_data *data = (struct cros_cbi_data *)(dev->data); if (cbi_get_ssfc(&data->cached_ssfc.raw_value) != EC_SUCCESS) { - DT_INST_FOREACH_STATUS_OKAY(CBI_SSFC_INIT_DEFAULT) + DT_INST_FOREACH_STATUS_OKAY_VARGS(CBI_SSFC_INIT_DEFAULT, data) } LOG_INF("Read CBI SSFC : 0x%08X\n", data->cached_ssfc.raw_value); |