From: SangYoun Kwak Date: Mon, 2 May 2022 05:33:07 +0000 (+0900) Subject: Add new API to get current partition X-Git-Tag: submit/tizen/20220525.001052~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=483c1b1310088ad90490936e36e19a0abb8eee8e;p=platform%2Fhal%2Fapi%2Fdevice.git Add new API to get current partition Change-Id: I29f146cd093294511642e029deed55f8703bed28 Signed-off-by: SangYoun Kwak --- 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;