summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2016-04-15 03:42:12 +0000
committerjhb <jhb@FreeBSD.org>2016-04-15 03:42:12 +0000
commit784a797eede7e9e2ee3e82efedc1fc47547ca85b (patch)
treef27f63561d0afda441fc0921b7455bd4dce5e730 /sys/powerpc
parentde393d2ab18de0224c30483ed700a7388058f4e9 (diff)
downloadFreeBSD-src-784a797eede7e9e2ee3e82efedc1fc47547ca85b.zip
FreeBSD-src-784a797eede7e9e2ee3e82efedc1fc47547ca85b.tar.gz
Add a new PCI bus interface method to alloc the ivars (dinfo) for a device.
The ACPI and OFW PCI bus drivers as well as CardBus override this to allocate the larger ivars to hold additional info beyond the stock PCI ivars. This removes the need to pass the size to functions like pci_add_iov_child() and pci_read_device() simplifying IOV and bus rescanning implementations. As a result of this and earlier changes, the ACPI PCI bus driver no longer needs its own device_attach and pci_create_iov_child methods but can use the methods in the stock PCI bus driver instead. Differential Revision: https://reviews.freebsd.org/D5891
Diffstat (limited to 'sys/powerpc')
-rw-r--r--sys/powerpc/ofw/ofw_pcibus.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/sys/powerpc/ofw/ofw_pcibus.c b/sys/powerpc/ofw/ofw_pcibus.c
index 4ce6e73..01e2343 100644
--- a/sys/powerpc/ofw/ofw_pcibus.c
+++ b/sys/powerpc/ofw/ofw_pcibus.c
@@ -59,6 +59,7 @@ typedef uint32_t ofw_pci_intr_t;
/* Methods */
static device_probe_t ofw_pcibus_probe;
static device_attach_t ofw_pcibus_attach;
+static pci_alloc_devinfo_t ofw_pcibus_alloc_devinfo;
static pci_assign_interrupt_t ofw_pcibus_assign_interrupt;
static ofw_bus_get_devinfo_t ofw_pcibus_get_devinfo;
static bus_child_deleted_t ofw_pcibus_child_deleted;
@@ -78,6 +79,7 @@ static device_method_t ofw_pcibus_methods[] = {
DEVMETHOD(bus_child_pnpinfo_str, ofw_pcibus_child_pnpinfo_str_method),
/* PCI interface */
+ DEVMETHOD(pci_alloc_devinfo, ofw_pcibus_alloc_devinfo),
DEVMETHOD(pci_assign_interrupt, ofw_pcibus_assign_interrupt),
/* ofw_bus interface */
@@ -144,6 +146,15 @@ ofw_pcibus_attach(device_t dev)
return (bus_generic_attach(dev));
}
+struct pci_devinfo *
+ofw_pcibus_alloc_devinfo(device_t dev)
+{
+ struct ofw_pcibus_devinfo *dinfo;
+
+ dinfo = malloc(sizeof(*dinfo), M_DEVBUF, M_WAITOK | M_ZERO);
+ return (&dinfo->opd_dinfo);
+}
+
static void
ofw_pcibus_enum_devtree(device_t dev, u_int domain, u_int busno)
{
@@ -185,8 +196,8 @@ ofw_pcibus_enum_devtree(device_t dev, u_int domain, u_int busno)
* to the PCI bus.
*/
- dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib,
- domain, busno, slot, func, sizeof(*dinfo));
+ dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib, dev,
+ domain, busno, slot, func);
if (dinfo == NULL)
continue;
if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) !=
@@ -244,7 +255,7 @@ ofw_pcibus_enum_bus(device_t dev, u_int domain, u_int busno)
continue;
dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(
- pcib, domain, busno, s, f, sizeof(*dinfo));
+ pcib, dev, domain, busno, s, f);
if (dinfo == NULL)
continue;
OpenPOWER on IntegriCloud