mirror of https://github.com/xemu-project/xemu.git
pci: Define pci_bus_dev_fn/pci_bus_fn/pci_bus_ret_fn
They're used in quite a few places of pci.[ch] and also in the rest of the code base. Define them so that it doesn't need to be defined all over the places. The pci_bus_fn is similar to pci_bus_dev_fn that only takes a PCIBus* and an opaque. The pci_bus_ret_fn is similar to pci_bus_fn but it allows to return a void* pointer. Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20211028043129.38871-2-peterx@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
36efa250a4
commit
b3dcf94f77
20
hw/pci/pci.c
20
hw/pci/pci.c
|
@ -1655,9 +1655,7 @@ static const pci_class_desc pci_class_descriptions[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
static void pci_for_each_device_under_bus_reverse(PCIBus *bus,
|
static void pci_for_each_device_under_bus_reverse(PCIBus *bus,
|
||||||
void (*fn)(PCIBus *b,
|
pci_bus_dev_fn fn,
|
||||||
PCIDevice *d,
|
|
||||||
void *opaque),
|
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
PCIDevice *d;
|
PCIDevice *d;
|
||||||
|
@ -1672,8 +1670,7 @@ static void pci_for_each_device_under_bus_reverse(PCIBus *bus,
|
||||||
}
|
}
|
||||||
|
|
||||||
void pci_for_each_device_reverse(PCIBus *bus, int bus_num,
|
void pci_for_each_device_reverse(PCIBus *bus, int bus_num,
|
||||||
void (*fn)(PCIBus *b, PCIDevice *d, void *opaque),
|
pci_bus_dev_fn fn, void *opaque)
|
||||||
void *opaque)
|
|
||||||
{
|
{
|
||||||
bus = pci_find_bus_nr(bus, bus_num);
|
bus = pci_find_bus_nr(bus, bus_num);
|
||||||
|
|
||||||
|
@ -1683,9 +1680,7 @@ void pci_for_each_device_reverse(PCIBus *bus, int bus_num,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pci_for_each_device_under_bus(PCIBus *bus,
|
static void pci_for_each_device_under_bus(PCIBus *bus,
|
||||||
void (*fn)(PCIBus *b, PCIDevice *d,
|
pci_bus_dev_fn fn, void *opaque)
|
||||||
void *opaque),
|
|
||||||
void *opaque)
|
|
||||||
{
|
{
|
||||||
PCIDevice *d;
|
PCIDevice *d;
|
||||||
int devfn;
|
int devfn;
|
||||||
|
@ -1699,8 +1694,7 @@ static void pci_for_each_device_under_bus(PCIBus *bus,
|
||||||
}
|
}
|
||||||
|
|
||||||
void pci_for_each_device(PCIBus *bus, int bus_num,
|
void pci_for_each_device(PCIBus *bus, int bus_num,
|
||||||
void (*fn)(PCIBus *b, PCIDevice *d, void *opaque),
|
pci_bus_dev_fn fn, void *opaque)
|
||||||
void *opaque)
|
|
||||||
{
|
{
|
||||||
bus = pci_find_bus_nr(bus, bus_num);
|
bus = pci_find_bus_nr(bus, bus_num);
|
||||||
|
|
||||||
|
@ -2078,10 +2072,8 @@ static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pci_for_each_bus_depth_first(PCIBus *bus,
|
void pci_for_each_bus_depth_first(PCIBus *bus, pci_bus_ret_fn begin,
|
||||||
void *(*begin)(PCIBus *bus, void *parent_state),
|
pci_bus_fn end, void *parent_state)
|
||||||
void (*end)(PCIBus *bus, void *state),
|
|
||||||
void *parent_state)
|
|
||||||
{
|
{
|
||||||
PCIBus *sec;
|
PCIBus *sec;
|
||||||
void *state;
|
void *state;
|
||||||
|
|
|
@ -401,6 +401,10 @@ typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque, int pin);
|
||||||
OBJECT_DECLARE_TYPE(PCIBus, PCIBusClass, PCI_BUS)
|
OBJECT_DECLARE_TYPE(PCIBus, PCIBusClass, PCI_BUS)
|
||||||
#define TYPE_PCIE_BUS "PCIE"
|
#define TYPE_PCIE_BUS "PCIE"
|
||||||
|
|
||||||
|
typedef void (*pci_bus_dev_fn)(PCIBus *b, PCIDevice *d, void *opaque);
|
||||||
|
typedef void (*pci_bus_fn)(PCIBus *b, void *opaque);
|
||||||
|
typedef void *(*pci_bus_ret_fn)(PCIBus *b, void *opaque);
|
||||||
|
|
||||||
bool pci_bus_is_express(PCIBus *bus);
|
bool pci_bus_is_express(PCIBus *bus);
|
||||||
|
|
||||||
void pci_root_bus_init(PCIBus *bus, size_t bus_size, DeviceState *parent,
|
void pci_root_bus_init(PCIBus *bus, size_t bus_size, DeviceState *parent,
|
||||||
|
@ -458,23 +462,18 @@ static inline int pci_dev_bus_num(const PCIDevice *dev)
|
||||||
|
|
||||||
int pci_bus_numa_node(PCIBus *bus);
|
int pci_bus_numa_node(PCIBus *bus);
|
||||||
void pci_for_each_device(PCIBus *bus, int bus_num,
|
void pci_for_each_device(PCIBus *bus, int bus_num,
|
||||||
void (*fn)(PCIBus *bus, PCIDevice *d, void *opaque),
|
pci_bus_dev_fn fn,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
void pci_for_each_device_reverse(PCIBus *bus, int bus_num,
|
void pci_for_each_device_reverse(PCIBus *bus, int bus_num,
|
||||||
void (*fn)(PCIBus *bus, PCIDevice *d,
|
pci_bus_dev_fn fn,
|
||||||
void *opaque),
|
|
||||||
void *opaque);
|
void *opaque);
|
||||||
void pci_for_each_bus_depth_first(PCIBus *bus,
|
void pci_for_each_bus_depth_first(PCIBus *bus, pci_bus_ret_fn begin,
|
||||||
void *(*begin)(PCIBus *bus, void *parent_state),
|
pci_bus_fn end, void *parent_state);
|
||||||
void (*end)(PCIBus *bus, void *state),
|
|
||||||
void *parent_state);
|
|
||||||
PCIDevice *pci_get_function_0(PCIDevice *pci_dev);
|
PCIDevice *pci_get_function_0(PCIDevice *pci_dev);
|
||||||
|
|
||||||
/* Use this wrapper when specific scan order is not required. */
|
/* Use this wrapper when specific scan order is not required. */
|
||||||
static inline
|
static inline
|
||||||
void pci_for_each_bus(PCIBus *bus,
|
void pci_for_each_bus(PCIBus *bus, pci_bus_fn fn, void *opaque)
|
||||||
void (*fn)(PCIBus *bus, void *opaque),
|
|
||||||
void *opaque)
|
|
||||||
{
|
{
|
||||||
pci_for_each_bus_depth_first(bus, NULL, fn, opaque);
|
pci_for_each_bus_depth_first(bus, NULL, fn, opaque);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue