diff options
Diffstat (limited to 'zephyr/shim/src/cbi/cbi_eeprom.c')
-rw-r--r-- | zephyr/shim/src/cbi/cbi_eeprom.c | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/zephyr/shim/src/cbi/cbi_eeprom.c b/zephyr/shim/src/cbi/cbi_eeprom.c index 9cd0d0a955..aa6c4e0fa1 100644 --- a/zephyr/shim/src/cbi/cbi_eeprom.c +++ b/zephyr/shim/src/cbi/cbi_eeprom.c @@ -3,16 +3,15 @@ * found in the LICENSE file. */ -#include "console.h" -#include "cros_board_info.h" -#include "write_protect.h" - #include <zephyr/drivers/eeprom.h> #include <zephyr/drivers/gpio.h> -#define CBI_EEPROM_NODE DT_NODELABEL(cbi_eeprom) +#include "console.h" +#include "cros_board_info.h" +#include "write_protect.h" -BUILD_ASSERT(DT_NODE_EXISTS(CBI_EEPROM_NODE), "cbi_eeprom node not defined"); +#if DT_NODE_EXISTS(DT_NODELABEL(cbi_eeprom)) +#define CBI_EEPROM_DEV DEVICE_DT_GET(DT_NODELABEL(cbi_eeprom)) #ifdef CONFIG_PLATFORM_EC_EEPROM_CBI_WP #if !DT_NODE_EXISTS(DT_ALIAS(gpio_cbi_wp)) @@ -26,39 +25,22 @@ void cbi_latch_eeprom_wp(void) } #endif /* CONFIG_PLATFORM_EC_EEPROM_CBI_WP */ -test_mockable_static int eeprom_load(uint8_t offset, uint8_t *data, int len) +static int eeprom_load(uint8_t offset, uint8_t *data, int len) { - const struct device *dev; - - dev = DEVICE_DT_GET(CBI_EEPROM_NODE); - - if (!device_is_ready(dev)) { - return -ENODEV; - } - - return eeprom_read(dev, offset, data, len); + return eeprom_read(CBI_EEPROM_DEV, offset, data, len); } static int eeprom_is_write_protected(void) { - if (IS_ENABLED(CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK)) { + if (IS_ENABLED(CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK)) return 0; - } return write_protect_is_asserted(); } static int eeprom_store(uint8_t *cbi) { - const struct device *dev; - - dev = DEVICE_DT_GET(CBI_EEPROM_NODE); - - if (!device_is_ready(dev)) { - return -ENODEV; - } - - return eeprom_write(dev, 0, cbi, + return eeprom_write(CBI_EEPROM_DEV, 0, cbi, ((struct cbi_header *)cbi)->total_size); } @@ -72,3 +54,4 @@ const struct cbi_storage_config_t cbi_config = { .storage_type = CBI_STORAGE_TYPE_EEPROM, .drv = &eeprom_drv, }; +#endif |