mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 15:12:36 +02:00
nicintel_eeprom: refactor i210 variable into reentrant pattern
Move global Intel I210 specific variable into a struct and store within the opaque_master data filed for the life-time of the driver. This is one of the steps on the way to move opaque_master data memory management behind the initialisation API. TOPIC=register_master_api TEST=builds Change-Id: Ifda0d8666399ea165bac6378c57720b5560806f1 Signed-off-by: Alexander Goncharov <chat@joursoir.net> Ticket: https://ticket.coreboot.org/issues/391 Reviewed-on: https://review.coreboot.org/c/flashrom/+/66690 Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Thomas Heijligen <src@posteo.de> Reviewed-by: Felix Singer <felixsinger@posteo.net> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
parent
95b6cf1835
commit
3234e04743
@ -73,13 +73,15 @@
|
||||
|
||||
static uint8_t *nicintel_eebar;
|
||||
static struct pci_dev *nicintel_pci;
|
||||
static bool done_i20_write = false;
|
||||
|
||||
#define UNPROG_DEVICE 0x1509
|
||||
|
||||
struct nicintel_eeprom_data {
|
||||
/* Intel 82580 variable(s) */
|
||||
uint32_t eec;
|
||||
|
||||
/* Intel I210 variable(s) */
|
||||
bool done_i20_write;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -219,7 +221,8 @@ static int nicintel_ee_write_word_i210(unsigned int addr, uint16_t data)
|
||||
static int nicintel_ee_write_i210(struct flashctx *flash, const uint8_t *buf,
|
||||
unsigned int addr, unsigned int len)
|
||||
{
|
||||
done_i20_write = true;
|
||||
struct nicintel_eeprom_data *opaque_data = flash->mst->opaque.data;
|
||||
opaque_data->done_i20_write = true;
|
||||
|
||||
if (addr & 1) {
|
||||
uint16_t data;
|
||||
@ -400,11 +403,12 @@ static int nicintel_ee_erase_82580(struct flashctx *flash, unsigned int addr, un
|
||||
return nicintel_ee_write_82580(flash, NULL, addr, len);
|
||||
}
|
||||
|
||||
static int nicintel_ee_shutdown_i210(void *arg)
|
||||
static int nicintel_ee_shutdown_i210(void *opaque_data)
|
||||
{
|
||||
struct nicintel_eeprom_data *data = opaque_data;
|
||||
int ret = 0;
|
||||
|
||||
if (!done_i20_write)
|
||||
if (!data->done_i20_write)
|
||||
goto out;
|
||||
|
||||
uint32_t flup = pci_mmio_readl(nicintel_eebar + EEC);
|
||||
@ -421,6 +425,7 @@ static int nicintel_ee_shutdown_i210(void *arg)
|
||||
msg_perr("Flash update failed\n");
|
||||
|
||||
out:
|
||||
free(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -511,7 +516,15 @@ static int nicintel_ee_init(void)
|
||||
if (!nicintel_eebar)
|
||||
return 1;
|
||||
|
||||
return register_opaque_master(&opaque_master_nicintel_ee_i210, NULL);
|
||||
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 register_opaque_master(&opaque_master_nicintel_ee_i210, data);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user