Module Name: src
Committed By: riastradh
Date: Wed Jul 24 03:01:38 UTC 2013
Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: pci.h
Log Message:
Add pci_kludgey_find_dev to <linux/pci.h>.
This is not a Linux KPI, but the Linux KPI (pci_get_bus_and_slot)
doesn't pass along the original pci device or bus, so this is what
we'll use to replace uses of it (or, the one use of it) without
changing much code.
To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/linux/pci.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/include/linux/pci.h
diff -u src/sys/external/bsd/drm2/include/linux/pci.h:1.1.2.4 src/sys/external/bsd/drm2/include/linux/pci.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/linux/pci.h:1.1.2.4 Wed Jul 24 03:01:09 2013
+++ src/sys/external/bsd/drm2/include/linux/pci.h Wed Jul 24 03:01:38 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: pci.h,v 1.1.2.4 2013/07/24 03:01:09 riastradh Exp $ */
+/* $NetBSD: pci.h,v 1.1.2.5 2013/07/24 03:01:38 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,6 +34,7 @@
#include <sys/types.h>
#include <sys/bus.h>
+#include <sys/kmem.h>
#include <sys/systm.h>
#include <dev/pci/pcivar.h>
@@ -46,6 +47,7 @@ struct pci_device_id;
struct pci_dev {
struct pci_bus *bus;
struct pci_attach_args pd_pa;
+ bool pd_kludged; /* XXX pci_kludgey_find_dev hack */
};
#define PCI_CAP_ID_AGP PCI_CAP_AGP
@@ -112,4 +114,44 @@ pci_bus_alloc_resource(struct pci_bus *b
return 0;
}
+/*
+ * XXX Mega-kludgerific!
+ *
+ * XXX Doesn't check whether any such device actually exists.
+ */
+
+static inline struct pci_dev *
+pci_kludgey_find_dev(struct pci_dev *pdev, int bus, int dev, int func)
+{
+ struct pci_dev *const otherdev = kmem_zalloc(sizeof(*otherdev),
+ KM_SLEEP);
+
+#ifdef DIAGNOSTIC
+ {
+ int obus, odev, ofunc;
+
+ pci_decompose_tag(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, &obus,
+ &odev, &ofunc);
+ KASSERT(obus == bus);
+ }
+#endif
+
+ otherdev->bus = NULL; /* XXX struct pci_dev::bus */
+ otherdev->device = dev;
+ otherdev->pd_pa = pdev->pd_pa;
+ otherdev->pd_pa.pa_tag = pci_make_tag(otherdev->pd_pa.pa_pc,
+ bus, dev, func);
+ otherdev->pd_kludged = true;
+
+ return otherdev;
+}
+
+static inline void
+pci_dev_put(struct pci_dev *pdev)
+{
+
+ KASSERT(pdev->pd_kludged);
+ kmem_free(pdev, sizeof(*pdev));
+}
+
#endif /* _LINUX_PCI_H_ */