Edward O'Callaghan submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Nikolai Artemiev: Looks good to me, but someone else must approve Anastasia Klimchuk: Looks good to me, approved
internal.c: Seperate out get_params() from internal_init()

Move all programmer parameter wrangling into its own
function.

BUG=none
TEST=`flashrom -p internal` on dooly DUT.

Change-Id: I66bb370eb0466c5c838621762a6ba825c44567d4
Tested-by: Nikolai Artemiev <nartemiev@google.com>
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/61578
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M internal.c
1 file changed, 35 insertions(+), 15 deletions(-)

diff --git a/internal.c b/internal.c
index b8e0564..995290e 100644
--- a/internal.c
+++ b/internal.c
@@ -174,22 +174,21 @@
.chip_writen = fallback_chip_writen,
};

-static int internal_init(void)
+static int get_params(int *boardenable, int *boardmismatch,
+ int *force_laptop, int *not_a_laptop,
+ char **board_vendor, char **board_model)
{
- int ret = 0;
- int force_laptop = 0;
- int not_a_laptop = 0;
- char *board_vendor = NULL;
- char *board_model = NULL;
-#if defined(__i386__) || defined(__x86_64__)
- const char *cb_vendor = NULL;
- const char *cb_model = NULL;
-#endif
char *arg;

+ /* default values. */
+ *force_laptop = 0;
+ *not_a_laptop = 0;
+ *board_vendor = NULL;
+ *board_model = NULL;
+
arg = extract_programmer_param("boardenable");
if (arg && !strcmp(arg,"force")) {
- force_boardenable = 1;
+ *boardenable = 1;
} else if (arg && !strlen(arg)) {
msg_perr("Missing argument for boardenable.\n");
free(arg);
@@ -203,7 +202,7 @@

arg = extract_programmer_param("boardmismatch");
if (arg && !strcmp(arg,"force")) {
- force_boardmismatch = 1;
+ *boardmismatch = 1;
} else if (arg && !strlen(arg)) {
msg_perr("Missing argument for boardmismatch.\n");
free(arg);
@@ -217,9 +216,9 @@

arg = extract_programmer_param("laptop");
if (arg && !strcmp(arg, "force_I_want_a_brick"))
- force_laptop = 1;
+ *force_laptop = 1;
else if (arg && !strcmp(arg, "this_is_not_a_laptop"))
- not_a_laptop = 1;
+ *not_a_laptop = 1;
else if (arg && !strlen(arg)) {
msg_perr("Missing argument for laptop.\n");
free(arg);
@@ -233,7 +232,7 @@

arg = extract_programmer_param("mainboard");
if (arg && strlen(arg)) {
- if (board_parse_parameter(arg, &board_vendor, &board_model)) {
+ if (board_parse_parameter(arg, board_vendor, board_model)) {
free(arg);
return 1;
}
@@ -244,6 +243,27 @@
}
free(arg);

+ return 0;
+}
+
+static int internal_init(void)
+{
+ int ret = 0;
+ int force_laptop;
+ int not_a_laptop;
+ char *board_vendor;
+ char *board_model;
+#if defined(__i386__) || defined(__x86_64__)
+ const char *cb_vendor = NULL;
+ const char *cb_model = NULL;
+#endif
+
+ ret = get_params(&force_boardenable, &force_boardmismatch,
+ &force_laptop, &not_a_laptop,
+ &board_vendor, &board_model);
+ if (ret)
+ return ret;
+
/* Default to Parallel/LPC/FWH flash devices. If a known host controller
* is found, the host controller init routine sets the
* internal_buses_supported bitfield.

2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one.

To view, visit change 61578. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I66bb370eb0466c5c838621762a6ba825c44567d4
Gerrit-Change-Number: 61578
Gerrit-PatchSet: 4
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Nikolai Artemiev <nartemiev@google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged