Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/riastradh-drm2]: src/sys/external/bsd/drm2/include/linux Add pci_kludgey...



details:   https://anonhg.NetBSD.org/src/rev/9b9a8feba2f1
branches:  riastradh-drm2
changeset: 788274:9b9a8feba2f1
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jul 24 03:01:38 2013 +0000

description:
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.

diffstat:

 sys/external/bsd/drm2/include/linux/pci.h |  44 ++++++++++++++++++++++++++++++-
 1 files changed, 43 insertions(+), 1 deletions(-)

diffs (70 lines):

diff -r 092567bfef67 -r 9b9a8feba2f1 sys/external/bsd/drm2/include/linux/pci.h
--- a/sys/external/bsd/drm2/include/linux/pci.h Wed Jul 24 03:01:24 2013 +0000
+++ b/sys/external/bsd/drm2/include/linux/pci.h Wed Jul 24 03:01:38 2013 +0000
@@ -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_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 @@
        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_ */



Home | Main Index | Thread Index | Old Index