aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2023-12-29 19:33:21 +0100
committerMartin Mares <mj@ucw.cz>2023-12-29 19:33:21 +0100
commita997ef132d943990cdb65d32a6605b6ff4bfcd79 (patch)
tree1ea603f13689dc416abcce297fe3e794e3bf69b3
parent30e9f21eac66bf2c4ee02e37cb54aa54d616fad4 (diff)
downloadpciutils-a997ef132d943990cdb65d32a6605b6ff4bfcd79.tar.gz
Rename aux fields in structs pci_access and pci_dev to backend_data
This hopefully conveys the purpose much better than just "aux".
-rw-r--r--lib/dump.c18
-rw-r--r--lib/ecam.c42
-rw-r--r--lib/hurd.c13
-rw-r--r--lib/mmio-ports.c10
-rw-r--r--lib/pci.h4
-rw-r--r--lib/win32-cfgmgr32.c34
6 files changed, 62 insertions, 59 deletions
diff --git a/lib/dump.c b/lib/dump.c
index 8b7320a..829071f 100644
--- a/lib/dump.c
+++ b/lib/dump.c
@@ -40,7 +40,7 @@ dump_alloc_data(struct pci_dev *dev, int len)
dd->allocated = len;
dd->len = 0;
memset(dd->data, 0xff, len);
- dev->aux = dd;
+ dev->backend_data = dd;
}
static int
@@ -97,7 +97,7 @@ dump_init(struct pci_access *a)
dump_validate(buf, "#######: ") || dump_validate(buf, "########: ")) &&
sscanf(buf, "%x: ", &i) == 1)
{
- struct dump_data *dd = dev->aux;
+ struct dump_data *dd = dev->backend_data;
z = strchr(buf, ' ') + 1;
while (isxdigit(z[0]) && isxdigit(z[1]) && (!z[2] || z[2] == ' ') &&
sscanf(z, "%x", &j) == 1 && j < 256)
@@ -110,9 +110,9 @@ dump_init(struct pci_access *a)
if (i >= dd->allocated) /* Need to re-allocate the buffer */
{
dump_alloc_data(dev, 4096);
- memcpy(((struct dump_data *) dev->aux)->data, dd->data, 256);
+ memcpy(((struct dump_data *) dev->backend_data)->data, dd->data, 256);
pci_mfree(dd);
- dd = dev->aux;
+ dd = dev->backend_data;
}
dd->data[i++] = j;
if (i > dd->len)
@@ -145,14 +145,14 @@ static int
dump_read(struct pci_dev *d, int pos, byte *buf, int len)
{
struct dump_data *dd;
- if (!(dd = d->aux))
+ if (!(dd = d->backend_data))
{
struct pci_dev *e = d->access->devices;
while (e && (e->domain != d->domain || e->bus != d->bus || e->dev != d->dev || e->func != d->func))
e = e->next;
if (!e)
return 0;
- dd = e->aux;
+ dd = e->backend_data;
}
if (pos + len > dd->len)
return 0;
@@ -170,10 +170,10 @@ dump_write(struct pci_dev *d UNUSED, int pos UNUSED, byte *buf UNUSED, int len U
static void
dump_cleanup_dev(struct pci_dev *d)
{
- if (d->aux)
+ if (d->backend_data)
{
- pci_mfree(d->aux);
- d->aux = NULL;
+ pci_mfree(d->backend_data);
+ d->backend_data = NULL;
}
}
diff --git a/lib/ecam.c b/lib/ecam.c
index e2b9412..c72eae6 100644
--- a/lib/ecam.c
+++ b/lib/ecam.c
@@ -680,7 +680,8 @@ struct mmap_cache
int w;
};
-struct ecam_aux
+// Back-end data linked to struct pci_access
+struct ecam_access
{
struct acpi_mcfg *mcfg;
struct mmap_cache *cache;
@@ -689,22 +690,22 @@ struct ecam_aux
static void
munmap_reg(struct pci_access *a)
{
- struct ecam_aux *aux = a->aux;
- struct mmap_cache *cache = aux->cache;
+ struct ecam_access *eacc = a->backend_data;
+ struct mmap_cache *cache = eacc->cache;
if (!cache)
return;
munmap(cache->map, cache->length + (cache->addr & (pagesize-1)));
pci_mfree(cache);
- aux->cache = NULL;
+ eacc->cache = NULL;
}
static int
mmap_reg(struct pci_access *a, int w, int domain, u8 bus, u8 dev, u8 func, int pos, volatile void **reg)
{
- struct ecam_aux *aux = a->aux;
- struct mmap_cache *cache = aux->cache;
+ struct ecam_access *eacc = a->backend_data;
+ struct mmap_cache *cache = eacc->cache;
const char *addrs;
void *map;
off_t addr;
@@ -720,7 +721,7 @@ mmap_reg(struct pci_access *a, int w, int domain, u8 bus, u8 dev, u8 func, int p
else
{
addrs = pci_get_param(a, "ecam.addrs");
- if (!get_bus_addr(aux->mcfg, addrs, domain, bus, &addr, &length))
+ if (!get_bus_addr(eacc->mcfg, addrs, domain, bus, &addr, &length))
return 0;
map = mmap(NULL, length + (addr & (pagesize-1)), w ? PROT_WRITE : PROT_READ, MAP_SHARED, a->fd, addr & ~(pagesize-1));
@@ -730,7 +731,7 @@ mmap_reg(struct pci_access *a, int w, int domain, u8 bus, u8 dev, u8 func, int p
if (cache)
munmap(cache->map, cache->length + (cache->addr & (pagesize-1)));
else
- cache = aux->cache = pci_malloc(a, sizeof(*cache));
+ cache = eacc->cache = pci_malloc(a, sizeof(*cache));
cache->map = map;
cache->addr = addr;
@@ -915,7 +916,7 @@ ecam_init(struct pci_access *a)
#endif
const char *addrs = pci_get_param(a, "ecam.addrs");
struct acpi_mcfg *mcfg = NULL;
- struct ecam_aux *aux = NULL;
+ struct ecam_access *eacc = NULL;
int use_bsd = 0;
int use_x86bios = 0;
int test_domain = 0;
@@ -948,10 +949,10 @@ ecam_init(struct pci_access *a)
a->error("Option ecam.addrs was not specified and ACPI MCFG table cannot be found.");
}
- aux = pci_malloc(a, sizeof(*aux));
- aux->mcfg = mcfg;
- aux->cache = NULL;
- a->aux = aux;
+ eacc = pci_malloc(a, sizeof(*eacc));
+ eacc->mcfg = mcfg;
+ eacc->cache = NULL;
+ a->backend_data = eacc;
if (mcfg)
get_mcfg_allocation(mcfg, 0, &test_domain, &test_bus, NULL, NULL, NULL);
@@ -966,14 +967,15 @@ ecam_init(struct pci_access *a)
static void
ecam_cleanup(struct pci_access *a)
{
- struct ecam_aux *aux = a->aux;
+ struct ecam_access *eacc = a->backend_data;
if (a->fd < 0)
return;
munmap_reg(a);
- pci_mfree(aux->mcfg);
- pci_mfree(aux);
+ pci_mfree(eacc->mcfg);
+ pci_mfree(eacc);
+ a->backend_data = NULL;
close(a->fd);
a->fd = -1;
@@ -983,7 +985,7 @@ static void
ecam_scan(struct pci_access *a)
{
const char *addrs = pci_get_param(a, "ecam.addrs");
- struct ecam_aux *aux = a->aux;
+ struct ecam_access *eacc = a->backend_data;
u32 *segments;
int i, j, count;
int domain;
@@ -991,11 +993,11 @@ ecam_scan(struct pci_access *a)
segments = pci_malloc(a, 0xFFFF/8);
memset(segments, 0, 0xFFFF/8);
- if (aux->mcfg)
+ if (eacc->mcfg)
{
- count = get_mcfg_allocations_count(aux->mcfg);
+ count = get_mcfg_allocations_count(eacc->mcfg);
for (i = 0; i < count; i++)
- segments[aux->mcfg->allocations[i].pci_segment / 32] |= 1 << (aux->mcfg->allocations[i].pci_segment % 32);
+ segments[eacc->mcfg->allocations[i].pci_segment / 32] |= 1 << (eacc->mcfg->allocations[i].pci_segment % 32);
}
else
{
diff --git a/lib/hurd.c b/lib/hurd.c
index a9c9b89..3e65fb8 100644
--- a/lib/hurd.c
+++ b/lib/hurd.c
@@ -74,8 +74,8 @@ hurd_cleanup(struct pci_access *a UNUSED)
static void
hurd_init_dev(struct pci_dev *d)
{
- d->aux = pci_malloc(d->access, sizeof(mach_port_t));
- *((mach_port_t *) d->aux) = MACH_PORT_NULL;
+ d->backend_data = pci_malloc(d->access, sizeof(mach_port_t));
+ *((mach_port_t *) d->backend_data) = MACH_PORT_NULL;
}
/* Deallocate the port and free its space */
@@ -84,17 +84,18 @@ hurd_cleanup_dev(struct pci_dev *d)
{
mach_port_t device_port;
- device_port = *((mach_port_t *) d->aux);
+ device_port = *((mach_port_t *) d->backend_data);
mach_port_deallocate(mach_task_self(), device_port);
- pci_mfree(d->aux);
+ pci_mfree(d->backend_data);
+ d->backend_data = NULL;
}
static mach_port_t
device_port_lookup(struct pci_dev *d)
{
char server[NAME_MAX];
- mach_port_t device_port = *((mach_port_t *) d->aux);
+ mach_port_t device_port = *((mach_port_t *) d->backend_data);
if (device_port != MACH_PORT_NULL)
return device_port;
@@ -107,7 +108,7 @@ device_port_lookup(struct pci_dev *d)
if (device_port == MACH_PORT_NULL)
d->access->error("Cannot find the PCI arbiter");
- *((mach_port_t *) d->aux) = device_port;
+ *((mach_port_t *) d->backend_data) = device_port;
return device_port;
}
diff --git a/lib/mmio-ports.c b/lib/mmio-ports.c
index f380cb3..9a9b48d 100644
--- a/lib/mmio-ports.c
+++ b/lib/mmio-ports.c
@@ -45,7 +45,7 @@ static long pagesize;
static void
munmap_regs(struct pci_access *a)
{
- struct mmio_cache *cache = a->aux;
+ struct mmio_cache *cache = a->backend_data;
if (!cache)
return;
@@ -54,14 +54,14 @@ munmap_regs(struct pci_access *a)
if (cache->addr_page != cache->data_page)
munmap(cache->data_map, pagesize);
- pci_mfree(a->aux);
- a->aux = NULL;
+ pci_mfree(a->backend_data);
+ a->backend_data = NULL;
}
static int
mmap_regs(struct pci_access *a, off_t addr_reg, off_t data_reg, int data_off, volatile void **addr, volatile void **data)
{
- struct mmio_cache *cache = a->aux;
+ struct mmio_cache *cache = a->backend_data;
off_t addr_page = addr_reg & ~(pagesize-1);
off_t data_page = data_reg & ~(pagesize-1);
void *addr_map = MAP_FAILED;
@@ -101,7 +101,7 @@ mmap_regs(struct pci_access *a, off_t addr_reg, off_t data_reg, int data_off, vo
munmap(cache->data_map, pagesize);
if (!cache)
- cache = a->aux = pci_malloc(a, sizeof(*cache));
+ cache = a->backend_data = pci_malloc(a, sizeof(*cache));
cache->addr_page = addr_page;
cache->data_page = data_page;
diff --git a/lib/pci.h b/lib/pci.h
index 0b27dc3..03b4c41 100644
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -89,7 +89,7 @@ struct pci_access {
int fd_rw; /* proc/sys: fd opened read-write */
int fd_vpd; /* sys: fd for VPD */
struct pci_dev *cached_dev; /* proc/sys: device the fds are for */
- void *aux; /* Auxiliary data for use by the back-end */
+ void *backend_data; /* Private data of the back end */
};
/* Initialize PCI access */
@@ -164,7 +164,7 @@ struct pci_dev {
u8 *cache; /* Cached config registers */
int cache_len;
int hdrtype; /* Cached low 7 bits of header type, -1 if unknown */
- void *aux; /* Auxiliary data for use by the back-end */
+ void *backend_data; /* Private data for of the back end */
struct pci_property *properties; /* A linked list of extra properties */
struct pci_cap *last_cap; /* Last capability in the list */
};
diff --git a/lib/win32-cfgmgr32.c b/lib/win32-cfgmgr32.c
index fe3a40a..4acac2e 100644
--- a/lib/win32-cfgmgr32.c
+++ b/lib/win32-cfgmgr32.c
@@ -833,7 +833,7 @@ get_device_driver_path(struct pci_dev *d, SC_HANDLE manager, BOOL manager_suppor
LPWSTR service_name = NULL;
ULONG devinst_id_len = 0;
char *driver_path = NULL;
- DEVINST devinst = (DEVINST)d->aux;
+ DEVINST devinst = (DEVINST)d->backend_data;
ULONG problem = 0;
ULONG status = 0;
HKEY key = NULL;
@@ -1565,9 +1565,9 @@ scan_devinst_id(struct pci_access *a, DEVINSTID_A devinst_id)
d = pci_get_dev(a, domain, bus, dev, func);
pci_link_dev(a, d);
- if (!d->access->aux)
+ if (!d->access->backend_data)
d->no_config_access = 1;
- d->aux = (void *)devinst;
+ d->backend_data = (void *)devinst;
/* Parse device id part of devinst id and fill details into pci_dev. */
if (!a->buscentric)
@@ -1581,7 +1581,7 @@ scan_devinst_id(struct pci_access *a, DEVINSTID_A devinst_id)
fill_resources(d, devinst, devinst_id);
/*
- * Set parent field to cfgmgr32 parent devinst handle and aux field to current
+ * Set parent field to cfgmgr32 parent devinst handle and backend_data field to current
* devinst handle. At later stage in win32_cfgmgr32_scan() when all pci_dev
* devices are linked, change every devinst handle by pci_dev.
*/
@@ -1653,7 +1653,7 @@ win32_cfgmgr32_scan(struct pci_access *a)
for (d1 = a->devices; d1; d1 = d1->next)
{
for (d2 = a->devices; d2; d2 = d2->next)
- if ((DEVINST)d1->parent == (DEVINST)d2->aux)
+ if ((DEVINST)d1->parent == (DEVINST)d2->backend_data)
break;
d1->parent = d2;
if (d1->parent)
@@ -1661,9 +1661,9 @@ win32_cfgmgr32_scan(struct pci_access *a)
}
}
- /* devinst stored in ->aux is not needed anymore, clear it. */
+ /* devinst stored in ->backend_data is not needed anymore, clear it. */
for (d = a->devices; d; d = d->next)
- d->aux = NULL;
+ d->backend_data = NULL;
pci_mfree(devinst_id_list);
}
@@ -1713,7 +1713,7 @@ win32_cfgmgr32_fill_info(struct pci_dev *d, unsigned int flags)
* All available flags were filled by win32_cfgmgr32_scan().
* Filling more flags is possible only from config space.
*/
- if (!d->access->aux)
+ if (!d->access->backend_data)
return;
pci_generic_fill_info(d, flags);
@@ -1723,14 +1723,14 @@ static int
win32_cfgmgr32_read(struct pci_dev *d, int pos, byte *buf, int len)
{
struct pci_access *a = d->access;
- struct pci_access *acfg = a->aux;
- struct pci_dev *dcfg = d->aux;
+ struct pci_access *acfg = a->backend_data;
+ struct pci_dev *dcfg = d->backend_data;
if (!acfg)
return pci_emulated_read(d, pos, buf, len);
if (!dcfg)
- d->aux = dcfg = pci_get_dev(acfg, d->domain, d->bus, d->dev, d->func);
+ d->backend_data = dcfg = pci_get_dev(acfg, d->domain, d->bus, d->dev, d->func);
return pci_read_block(dcfg, pos, buf, len);
}
@@ -1739,14 +1739,14 @@ static int
win32_cfgmgr32_write(struct pci_dev *d, int pos, byte *buf, int len)
{
struct pci_access *a = d->access;
- struct pci_access *acfg = a->aux;
- struct pci_dev *dcfg = d->aux;
+ struct pci_access *acfg = a->backend_data;
+ struct pci_dev *dcfg = d->backend_data;
if (!acfg)
return 0;
if (!dcfg)
- d->aux = dcfg = pci_get_dev(acfg, d->domain, d->bus, d->dev, d->func);
+ d->backend_data = dcfg = pci_get_dev(acfg, d->domain, d->bus, d->dev, d->func);
return pci_write_block(dcfg, pos, buf, len);
}
@@ -1754,7 +1754,7 @@ win32_cfgmgr32_write(struct pci_dev *d, int pos, byte *buf, int len)
static void
win32_cfgmgr32_cleanup_dev(struct pci_dev *d)
{
- struct pci_dev *dcfg = d->aux;
+ struct pci_dev *dcfg = d->backend_data;
if (dcfg)
pci_free_dev(dcfg);
@@ -1798,13 +1798,13 @@ win32_cfgmgr32_init(struct pci_access *a)
return;
}
- a->aux = acfg;
+ a->backend_data = acfg;
}
static void
win32_cfgmgr32_cleanup(struct pci_access *a)
{
- struct pci_access *acfg = a->aux;
+ struct pci_access *acfg = a->backend_data;
if (acfg)
pci_cleanup(acfg);