diff options
Diffstat (limited to 'futility/updater.c')
-rw-r--r-- | futility/updater.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/futility/updater.c b/futility/updater.c index 01aa13af..2f7a29cb 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -1708,11 +1708,33 @@ static int save_from_stdin(const char *output) } /* + * Setup quirks for updating current image. + * + * Quirks must be loaded after image loaded because we use image contents to + * decide default quirks to load. Also, we have to load default quirks first so + * user can override them using command line. + * + * Returns 0 on success, otherwise number of failures. + */ +static int updater_setup_quirks(struct updater_config *cfg, + const struct updater_config_arguments *arg) +{ + int errorcnt = 0; + const char *quirks = updater_get_default_quirks(cfg); + + if (quirks) + errorcnt += !!setup_config_quirks(quirks, cfg); + if (arg->quirks) + errorcnt += !!setup_config_quirks(arg->quirks, cfg); + return errorcnt; +} + +/* * Loads images into updater configuration. * Returns 0 on success, otherwise number of failures. */ static int updater_load_images(struct updater_config *cfg, - int host_only, + const struct updater_config_arguments *arg, const char *image, const char *ec_image, const char *pd_image) @@ -1728,8 +1750,10 @@ static int updater_load_images(struct updater_config *cfg, errorcnt += !!save_from_stdin(image); } errorcnt += !!load_firmware_image(&cfg->image, image, ar); + if (!errorcnt) + errorcnt += updater_setup_quirks(cfg, arg); } - if (cfg->emulation || host_only) + if (cfg->emulation || arg->host_only) return errorcnt; if (!cfg->ec_image.data && ec_image) @@ -1841,7 +1865,7 @@ static int updater_setup_archive( } errorcnt += updater_load_images( - cfg, arg->host_only, model->image, model->ec_image, + cfg, arg, model->image, model->ec_image, model->pd_image); errorcnt += patch_image_by_model(&cfg->image, model, ar); return errorcnt; @@ -1858,7 +1882,6 @@ int updater_setup_config(struct updater_config *cfg, int errorcnt = 0; int check_single_image = 0, check_wp_disabled = 0; int do_output = 0; - const char *default_quirks = NULL; const char *archive_path = arg->archive; /* Setup values that may change output or decision of other argument. */ @@ -1942,8 +1965,7 @@ int updater_setup_config(struct updater_config *cfg, /* Always load images specified from command line directly. */ errorcnt += updater_load_images( - cfg, arg->host_only, arg->image, arg->ec_image, - arg->pd_image); + cfg, arg, arg->image, arg->ec_image, arg->pd_image); if (!archive_path) archive_path = "."; @@ -2004,14 +2026,11 @@ int updater_setup_config(struct updater_config *cfg, } /* - * Quirks must be loaded after images are loaded because we use image - * contents to decide default quirks to load. Also, we have to load - * default quirks first so user can override them using command line. + * Images should be loaded now (either in first updater_load_images or + * second call from updater_setup_archive) and quirks should be loaded. + * For invocation without image, we want to get quirks now. */ - default_quirks = updater_get_default_quirks(cfg); - if (default_quirks) - errorcnt += !!setup_config_quirks(default_quirks, cfg); - if (arg->quirks) + if (!cfg->image.data && arg->quirks) errorcnt += !!setup_config_quirks(arg->quirks, cfg); /* Additional checks. */ |