diff options
author | SangYoun Kwak <sy.kwak@samsung.com> | 2022-05-02 14:33:07 +0900 |
---|---|---|
committer | SangYoun Kwak <sy.kwak@samsung.com> | 2022-05-02 14:33:07 +0900 |
commit | 483c1b1310088ad90490936e36e19a0abb8eee8e (patch) | |
tree | 125334fa03d27a28eaa7d56f54cfe8ec665c712c | |
parent | f6fc8860b9878ea2d54171bd311d6fe3a26defa1 (diff) | |
download | device-483c1b1310088ad90490936e36e19a0abb8eee8e.tar.gz device-483c1b1310088ad90490936e36e19a0abb8eee8e.tar.bz2 device-483c1b1310088ad90490936e36e19a0abb8eee8e.zip |
Add new API to get current partition
Change-Id: I29f146cd093294511642e029deed55f8703bed28
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
-rw-r--r-- | include/backend/hal-board-interface.h | 1 | ||||
-rw-r--r-- | include/hal-board.h | 13 | ||||
-rw-r--r-- | src/board.c | 16 |
3 files changed, 28 insertions, 2 deletions
diff --git a/include/backend/hal-board-interface.h b/include/backend/hal-board-interface.h index 2294cf6..b73f47d 100644 --- a/include/backend/hal-board-interface.h +++ b/include/backend/hal-board-interface.h @@ -32,6 +32,7 @@ typedef struct _hal_backend_board_funcs { int (*get_boot_mode)(char *buffer, int len); int (*get_boot_reason)(char *buffer, int len); + int (*get_current_partition)(char *partition_ab); int (*switch_partition)(char partition_ab); int (*set_partition_ab_cloned)(void); int (*clear_partition_ab_cloned)(void); diff --git a/include/hal-board.h b/include/hal-board.h index 7f70fc9..f1dfe22 100644 --- a/include/hal-board.h +++ b/include/hal-board.h @@ -94,9 +94,18 @@ int hal_device_board_get_boot_reason(char *buffer, int len);// not in use /** - * @brief Switch partition to partition_ab ('a' or 'b') + * @brief Get partition_ab ('a' or 'b') * - * @param[in] partition_ab Partition name to switch to ('a' or 'b') + * @param[in] partition_ab Current partition name ('a' or 'b') + * + * @return 0 on success, otherwise a negative error value + */ +int hal_device_board_get_current_partition(char *partition_ab); + +/** + * @brief Switch partition to partition_ab ('a' or 'b') or toggle partition if partition_ab is '\0' + * + * @param[in] partition_ab Partition name to switch to ('a' or 'b') or '\0'(toggle) * * @return 0 on success, otherwise a negative error value */ diff --git a/src/board.c b/src/board.c index 60c8bf2..4affda1 100644 --- a/src/board.c +++ b/src/board.c @@ -155,6 +155,22 @@ int hal_device_board_get_boot_reason(char *buffer, int len) return hal_board_funcs->get_boot_reason(buffer, len); } +int hal_device_board_get_current_partition(char *partition_ab) +{ + int ret; + + if (!hal_board_funcs && !hal_initialized) { + if ((ret = hal_device_board_get_backend()) < 0) + return ret; + } + + if (!hal_board_funcs || + !hal_board_funcs->get_current_partition) + return -ENODEV; + + return hal_board_funcs->get_current_partition(partition_ab); +} + int hal_device_board_switch_partition(char partition_ab) { int ret; |