From 9307e68d688996f2d827a2a7e0e0ea4f151f0ff2 Mon Sep 17 00:00:00 2001 From: Alexander Goncharov Date: Fri, 12 Aug 2022 09:03:49 +0300 Subject: nicintel_eeprom: pack pci device struct into programmer's data Move global variable into a struct and store within the opaque_master data field 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: I69271bc77a6d7211e692c0b48d1853b95ffa80e9 Signed-off-by: Alexander Goncharov Ticket: https://ticket.coreboot.org/issues/391 Reviewed-on: https://review.coreboot.org/c/flashrom/+/66691 Reviewed-by: Felix Singer Reviewed-by: Anastasia Klimchuk Tested-by: build bot (Jenkins) --- nicintel_eeprom.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'nicintel_eeprom.c') diff --git a/nicintel_eeprom.c b/nicintel_eeprom.c index 60a6370a2..db89dea66 100644 --- a/nicintel_eeprom.c +++ b/nicintel_eeprom.c @@ -72,11 +72,12 @@ #define EE_PAGE_MASK 0x3f static uint8_t *nicintel_eebar; -static struct pci_dev *nicintel_pci; #define UNPROG_DEVICE 0x1509 struct nicintel_eeprom_data { + struct pci_dev *nicintel_pci; + /* Intel 82580 variable(s) */ uint32_t eec; @@ -125,7 +126,9 @@ static int nicintel_ee_probe_i210(struct flashctx *flash) static int nicintel_ee_probe_82580(struct flashctx *flash) { - if (nicintel_pci->device_id == UNPROG_DEVICE) + const struct nicintel_eeprom_data *data = flash->mst->opaque.data; + + if (data->nicintel_pci->device_id == UNPROG_DEVICE) flash->chip->total_size = 16; /* Fall back to minimum supported size. */ else { uint32_t tmp = pci_mmio_readl(nicintel_eebar + EEC); @@ -434,7 +437,7 @@ static int nicintel_ee_shutdown_82580(void *opaque_data) struct nicintel_eeprom_data *data = opaque_data; int ret = 0; - if (nicintel_pci->device_id != UNPROG_DEVICE) { + if (data->nicintel_pci->device_id != UNPROG_DEVICE) { uint32_t old_eec = data->eec; /* Request bitbanging and unselect the chip first to be safe. */ if (nicintel_ee_req() || nicintel_ee_bitset(EEC, EE_CS, 1)) { @@ -490,7 +493,6 @@ static int nicintel_ee_init(void) if (!nicintel_eebar) return 1; - nicintel_pci = dev; if (dev->device_id != UNPROG_DEVICE) { eec = pci_mmio_readl(nicintel_eebar + EEC); @@ -518,6 +520,7 @@ static int nicintel_ee_init(void) msg_perr("Unable to allocate space for OPAQUE master data\n"); return 1; } + data->nicintel_pci = dev; data->eec = eec; data->done_i20_write = false; -- cgit v1.2.3