summaryrefslogtreecommitdiff
path: root/common/system.c
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2019-05-28 09:01:51 -0600
committerCommit Bot <commit-bot@chromium.org>2019-06-03 20:35:51 +0000
commit9e9c24307deb302ed969b268e97cebfa4061c79c (patch)
treee0ec7e986f0241d1b44e4a3a15d05eef61e4aa97 /common/system.c
parent93a3f30e55e2ac5304a7cb66f24a76d51127e242 (diff)
downloadchrome-ec-9e9c24307deb302ed969b268e97cebfa4061c79c.tar.gz
common: board_[read/write]_serial weak reference cleanup
board_read_serial and board_write_serial were prototyped as weak and this made all instances, that included that prototype, weak as well. In order to not lose information from the prototype, default and override functions, I changed to use the override weak marker symbols. These functions defaulted for specific configurations as different functionality and used an #ifdef tree to do this. I made these a single definition for each function and used IS_ENABLED instead of the #ifdef tree. I also added a definition for the case that the configuration would not have produced a function. BUG=none BRANCH=none TEST=make buildall -j Change-Id: Ie41c53f3a17d665358e46eefd3ded3066ee80a7d Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1631583 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'common/system.c')
-rw-r--r--common/system.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/common/system.c b/common/system.c
index 39390a9418..2a7059d455 100644
--- a/common/system.c
+++ b/common/system.c
@@ -1589,33 +1589,27 @@ int system_can_boot_ap(void)
#ifdef CONFIG_SERIALNO_LEN
/* By default, read serial number from flash, can be overridden. */
-#if defined(CONFIG_FLASH_PSTATE) && defined(CONFIG_FLASH_PSTATE_BANK)
-__attribute__((weak))
-const char *board_read_serial(void)
-{
- return flash_read_pstate_serial();
-}
-#elif defined(CONFIG_OTP)
-__attribute__((weak))
-const char *board_read_serial(void)
+__overridable const char *board_read_serial(void)
{
- return otp_read_serial();
+ if (IS_ENABLED(CONFIG_FLASH_PSTATE) &&
+ IS_ENABLED(CONFIG_FLASH_PSTATE_BANK))
+ return flash_read_pstate_serial();
+ else if (IS_ENABLED(CONFIG_OTP))
+ return otp_read_serial();
+ else
+ return "";
}
-#endif
-#if defined(CONFIG_FLASH_PSTATE) && defined(CONFIG_FLASH_PSTATE_BANK)
-__attribute__((weak))
-int board_write_serial(const char *serialno)
-{
- return flash_write_pstate_serial(serialno);
-}
-#elif defined(CONFIG_OTP)
-__attribute__((weak))
-int board_write_serial(const char *serialno)
+__overridable int board_write_serial(const char *serialno)
{
- return otp_write_serial(serialno);
+ if (IS_ENABLED(CONFIG_FLASH_PSTATE) &&
+ IS_ENABLED(CONFIG_FLASH_PSTATE_BANK))
+ return flash_write_pstate_serial(serialno);
+ else if (IS_ENABLED(CONFIG_OTP))
+ return otp_write_serial(serialno);
+ else
+ return EC_ERROR_UNIMPLEMENTED;
}
-#endif
#endif /* CONFIG_SERIALNO_LEN */