mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 14:11:15 +02:00
libflashrom: Update the API for progress callback
The initial version of API for progress callback would require the
callback function to make a second call to get the needed data about
progress state (current, total etc).
This patch changes the callback API, so that callback function gets
all needed data straight away as parameters, and with this,
callback has all the data to do its job.
Since the initial version was submitted and it was in the tree for a
while, the change needs to add a _v2 suffix for new thing and
deprecated attribute for old thing.
Testing: both unit tests and cli are libflashrom clients.
All unit tests run successfully, for the cli all scenarios from
commit 75dc0655b9
run successfully.
Change-Id: Ia8cc0461c449b7e65888a64cdc594c55b81eae7a
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/86031
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
This commit is contained in:
@ -26,6 +26,6 @@ int open_logfile(const char * const filename);
|
||||
int close_logfile(void);
|
||||
void start_logging(void);
|
||||
int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap);
|
||||
void flashrom_progress_cb(struct flashrom_flashctx *flashctx);
|
||||
void flashrom_progress_cb(enum flashrom_progress_stage stage, size_t current, size_t total, void* user_data);
|
||||
|
||||
#endif /* __CLI_OUTPUT_H__ */
|
||||
|
@ -621,9 +621,12 @@ struct flashrom_flashctx {
|
||||
void *data;
|
||||
} chip_restore_fn[MAX_CHIP_RESTORE_FUNCTIONS];
|
||||
/* Progress reporting */
|
||||
flashrom_progress_callback *progress_callback;
|
||||
struct flashrom_progress *progress_state;
|
||||
flashrom_progress_callback_v2 *progress_callback;
|
||||
struct flashrom_progress progress_state;
|
||||
struct stage_progress stage_progress[FLASHROM_PROGRESS_NR];
|
||||
/* deprecated, do not use */
|
||||
flashrom_progress_callback *deprecated_progress_callback;
|
||||
struct flashrom_progress *deprecated_progress_state;
|
||||
|
||||
/* Maximum allowed % of redundant erase */
|
||||
int sacrifice_ratio;
|
||||
|
@ -75,14 +75,31 @@ enum flashrom_progress_stage {
|
||||
FLASHROM_PROGRESS_ERASE,
|
||||
FLASHROM_PROGRESS_NR,
|
||||
};
|
||||
|
||||
struct flashrom_progress {
|
||||
enum flashrom_progress_stage stage;
|
||||
size_t current;
|
||||
size_t total;
|
||||
void *user_data;
|
||||
};
|
||||
|
||||
struct flashrom_flashctx;
|
||||
typedef void(flashrom_progress_callback)(struct flashrom_flashctx *flashctx);
|
||||
|
||||
/**
|
||||
* @deprecated Use flashrom_set_progress_callback_v2 instead
|
||||
*/
|
||||
void flashrom_set_progress_callback(
|
||||
struct flashrom_flashctx *const flashctx,
|
||||
flashrom_progress_callback *progress_callback,
|
||||
struct flashrom_progress *progress_state)
|
||||
__attribute__((deprecated("Use flashrom_set_progress_callback_v2 instead")));
|
||||
|
||||
typedef void(flashrom_progress_callback_v2)(enum flashrom_progress_stage stage,
|
||||
size_t current,
|
||||
size_t total,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* @brief Set the progress callback function.
|
||||
*
|
||||
@ -90,12 +107,12 @@ typedef void(flashrom_progress_callback)(struct flashrom_flashctx *flashctx);
|
||||
* to indicate the progress has changed. This allows frontends to do whatever
|
||||
* they see fit with such values, e.g. update a progress bar in a GUI tool.
|
||||
*
|
||||
* @param progress_callback Pointer to the new progress callback function.
|
||||
* @param progress_state Pointer to progress state to include with the progress
|
||||
* callback.
|
||||
* @param flashrom_progress_callback_v2 Pointer to the new progress callback function.
|
||||
* @param user_data A pointer to a piece of data which is managed by progress caller
|
||||
*/
|
||||
void flashrom_set_progress_callback(struct flashrom_flashctx *const flashctx,
|
||||
flashrom_progress_callback *progress_callback, struct flashrom_progress *progress_state);
|
||||
void flashrom_set_progress_callback_v2(struct flashrom_flashctx *const flashctx,
|
||||
flashrom_progress_callback_v2 *progress_callback,
|
||||
void* user_data);
|
||||
|
||||
/** @} */ /* end flashrom-general */
|
||||
|
||||
|
Reference in New Issue
Block a user