aboutsummaryrefslogtreecommitdiffstats
path: root/nicintel_eeprom.c
diff options
context:
space:
mode:
authorAlexander Goncharov <chat@joursoir.net>2022-07-18 18:58:56 +0300
committerAnastasia Klimchuk <aklm@chromium.org>2022-08-30 10:15:29 +0000
commit7ebb18985d747de33224c856773da421b6895448 (patch)
tree548f365d18100ba80c2ef511b5022e44a7de67cc /nicintel_eeprom.c
parent3234e04743ebcfed542ec7c551fd17435c5cbc1a (diff)
downloadflashrom-7ebb18985d747de33224c856773da421b6895448.tar.gz
flashrom-7ebb18985d747de33224c856773da421b6895448.tar.bz2
flashrom-7ebb18985d747de33224c856773da421b6895448.zip
nicintel_eeprom: unify the code path of opaque master registration
TOPIC=register_master_api TEST=builds Change-Id: I9f5f181fe4497ac95e89df8588522a40ba8be024 Signed-off-by: Alexander Goncharov <chat@joursoir.net> Ticket: https://ticket.coreboot.org/issues/391 Reviewed-on: https://review.coreboot.org/c/flashrom/+/66158 Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'nicintel_eeprom.c')
-rw-r--r--nicintel_eeprom.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/nicintel_eeprom.c b/nicintel_eeprom.c
index 1cbb6bb1..60a6370a 100644
--- a/nicintel_eeprom.c
+++ b/nicintel_eeprom.c
@@ -474,6 +474,7 @@ static const struct opaque_master opaque_master_nicintel_ee_i210 = {
static int nicintel_ee_init(void)
{
+ const struct opaque_master *mst;
uint32_t eec = 0;
struct pci_dev *dev = pcidev_init(nics_intel_ee, PCI_BASE_ADDRESS_0);
@@ -502,32 +503,25 @@ static int nicintel_ee_init(void)
}
}
- struct nicintel_eeprom_data *data = calloc(1, sizeof(*data));
- if (!data) {
- msg_perr("Unable to allocate space for OPAQUE master data\n");
- return 1;
- }
- data->eec = eec;
-
- return register_opaque_master(&opaque_master_nicintel_ee_82580, data);
+ mst = &opaque_master_nicintel_ee_82580;
} else {
nicintel_eebar = rphysmap("Intel i210 NIC w/ emulated EEPROM",
io_base_addr + 0x12000, MEMMAP_SIZE);
if (!nicintel_eebar)
return 1;
- struct nicintel_eeprom_data *data = calloc(1, sizeof(*data));
- if (!data) {
- msg_perr("Unable to allocate space for OPAQUE master data\n");
- return 1;
- }
- data->eec = eec;
- data->done_i20_write = false;
+ mst = &opaque_master_nicintel_ee_i210;
+ }
- return register_opaque_master(&opaque_master_nicintel_ee_i210, data);
+ struct nicintel_eeprom_data *data = calloc(1, sizeof(*data));
+ if (!data) {
+ msg_perr("Unable to allocate space for OPAQUE master data\n");
+ return 1;
}
+ data->eec = eec;
+ data->done_i20_write = false;
- return 1;
+ return register_opaque_master(mst, data);
}
const struct programmer_entry programmer_nicintel_eeprom = {