Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/71578 )
Change subject: internal.c: Factor out laptop alerts into helper func ......................................................................
internal.c: Factor out laptop alerts into helper func
Minor however a unfortant '_' suffix is temporarily needed to skirt around global variable shadowing.
Change-Id: I8eea91012e6539b4fdf5d49a75a9cb48bb8a57ca Signed-off-by: Edward O'Callaghan quasisec@google.com --- M internal.c 1 file changed, 45 insertions(+), 26 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/78/71578/1
diff --git a/internal.c b/internal.c index 38a8405..cdc6f7b 100644 --- a/internal.c +++ b/internal.c @@ -164,6 +164,37 @@ return 0; }
+// FIXME: remove '_' suffix once global shadowing is fixed. +static void report_nonwl_laptop_detected(int is_laptop_, bool laptop_ok_) +{ + /* Report if a non-whitelisted laptop is detected that likely uses a legacy bus. */ + if (is_laptop_ && !laptop_ok_) { + msg_pinfo("========================================================================\n"); + if (is_laptop_ == 1) { + msg_pinfo("You seem to be running flashrom on an unknown laptop. Some\n" + "internal buses have been disabled for safety reasons.\n\n"); + } else { + msg_pinfo("You may be running flashrom on an unknown laptop. We could not\n" + "detect this for sure because your vendor has not set up the SMBIOS\n" + "tables correctly. Some internal buses have been disabled for\n" + "safety reasons. You can enforce using all buses by adding\n" + " -p internal:laptop=this_is_not_a_laptop\n" + "to the command line, but please read the following warning if you\n" + "are not sure.\n\n"); + } + msg_perr("Laptops, notebooks and netbooks are difficult to support and we\n" + "recommend to use the vendor flashing utility. The embedded controller\n" + "(EC) in these machines often interacts badly with flashing.\n" + "See the manpage and https://flashrom.org/Laptops for details.\n\n" + "If flash is shared with the EC, erase is guaranteed to brick your laptop\n" + "and write may brick your laptop.\n" + "Read and probe may irritate your EC and cause fan failure, backlight\n" + "failure and sudden poweroff.\n" + "You have been warned.\n" + "========================================================================\n"); + } +} + static int internal_init(const struct programmer_cfg *cfg) { int ret = 0; @@ -283,32 +314,7 @@ if (internal_buses_supported & BUS_NONSPI) register_par_master(&par_master_internal, internal_buses_supported, NULL);
- /* Report if a non-whitelisted laptop is detected that likely uses a legacy bus. */ - if (is_laptop && !laptop_ok) { - msg_pinfo("========================================================================\n"); - if (is_laptop == 1) { - msg_pinfo("You seem to be running flashrom on an unknown laptop. Some\n" - "internal buses have been disabled for safety reasons.\n\n"); - } else { - msg_pinfo("You may be running flashrom on an unknown laptop. We could not\n" - "detect this for sure because your vendor has not set up the SMBIOS\n" - "tables correctly. Some internal buses have been disabled for\n" - "safety reasons. You can enforce using all buses by adding\n" - " -p internal:laptop=this_is_not_a_laptop\n" - "to the command line, but please read the following warning if you\n" - "are not sure.\n\n"); - } - msg_perr("Laptops, notebooks and netbooks are difficult to support and we\n" - "recommend to use the vendor flashing utility. The embedded controller\n" - "(EC) in these machines often interacts badly with flashing.\n" - "See the manpage and https://flashrom.org/Laptops for details.\n\n" - "If flash is shared with the EC, erase is guaranteed to brick your laptop\n" - "and write may brick your laptop.\n" - "Read and probe may irritate your EC and cause fan failure, backlight\n" - "failure and sudden poweroff.\n" - "You have been warned.\n" - "========================================================================\n"); - } + report_nonwl_laptop_detected(is_laptop, laptop_ok);
ret = 0;