Source-Changes-HG archive

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

[src/trunk]: src/sys Eliminate Linux struct pci_dev::dev, struct platform_dev...



details:   https://anonhg.NetBSD.org/src/rev/0a699a3e56b3
branches:  trunk
changeset: 811374:0a699a3e56b3
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Oct 27 13:21:18 2015 +0000

description:
Eliminate Linux struct pci_dev::dev, struct platform_device::dev.

diffstat:

 sys/arch/arm/nvidia/tegra_nouveau.c                               |   6 ++--
 sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/device.h |   5 ++-
 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.c              |  14 ++++++++-
 sys/external/bsd/drm2/include/linux/pci.h                         |  11 +-------
 sys/external/bsd/drm2/include/linux/platform_device.h             |  11 ++++++-
 sys/external/bsd/drm2/nouveau/nouveau_pci.c                       |  12 ++-----
 6 files changed, 32 insertions(+), 27 deletions(-)

diffs (190 lines):

diff -r 8899d6efc6be -r 0a699a3e56b3 sys/arch/arm/nvidia/tegra_nouveau.c
--- a/sys/arch/arm/nvidia/tegra_nouveau.c       Tue Oct 27 13:18:21 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_nouveau.c       Tue Oct 27 13:21:18 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_nouveau.c,v 1.6 2015/10/18 17:07:36 jmcneill Exp $ */
+/* $NetBSD: tegra_nouveau.c,v 1.7 2015/10/27 13:21:19 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "locators.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_nouveau.c,v 1.6 2015/10/18 17:07:36 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_nouveau.c,v 1.7 2015/10/27 13:21:19 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -149,7 +149,7 @@
        dev->platformdev = &sc->sc_platform_dev;
 
        dev->platformdev->id = -1;
-       dev->platformdev->dev = *sc->sc_dev;    /* XXX */
+       dev->platformdev->pd_dev = sc->sc_dev;
        dev->platformdev->dmat = sc->sc_dmat;
        dev->platformdev->nresource = 2;
        dev->platformdev->resource[0].tag = bst;
diff -r 8899d6efc6be -r 0a699a3e56b3 sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/device.h
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/device.h Tue Oct 27 13:18:21 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/device.h Tue Oct 27 13:21:18 2015 +0000
@@ -152,8 +152,9 @@
 static inline struct device *
 nv_device_base(struct nouveau_device *device)
 {
-       return nv_device_is_pci(device) ? &device->pdev->dev :
-                                         &device->platformdev->dev;
+       return nv_device_is_pci(device)
+           ? pci_dev_dev(device->pdev)
+           : platform_device_dev(device->platformdev);
 }
 
 #ifdef __NetBSD__
diff -r 8899d6efc6be -r 0a699a3e56b3 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.c      Tue Oct 27 13:18:21 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.c      Tue Oct 27 13:21:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_drm.c,v 1.6 2015/10/13 01:43:47 mrg Exp $      */
+/*     $NetBSD: nouveau_drm.c,v 1.7 2015/10/27 13:21:18 riastradh Exp $        */
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_drm.c,v 1.6 2015/10/13 01:43:47 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_drm.c,v 1.7 2015/10/27 13:21:18 riastradh Exp $");
 
 #include <linux/console.h>
 #include <linux/module.h>
@@ -614,8 +614,13 @@
 
 int nouveau_pmops_suspend(struct device *dev)
 {
+#ifdef __NetBSD__
+       struct drm_device *drm_dev = device_private(dev);
+       struct pci_dev *pdev __unused = drm_dev->pdev;
+#else
        struct pci_dev *pdev = to_pci_dev(dev);
        struct drm_device *drm_dev = pci_get_drvdata(pdev);
+#endif
        int ret;
 
        if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
@@ -671,8 +676,13 @@
 
 int nouveau_pmops_resume(struct device *dev)
 {
+#ifdef __NetBSD__
+       struct drm_device *drm_dev = device_private(dev);
+       struct pci_dev *pdev __unused = drm_dev->pdev;
+#else
        struct pci_dev *pdev = to_pci_dev(dev);
        struct drm_device *drm_dev = pci_get_drvdata(pdev);
+#endif
        int ret;
 
        if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
diff -r 8899d6efc6be -r 0a699a3e56b3 sys/external/bsd/drm2/include/linux/pci.h
--- a/sys/external/bsd/drm2/include/linux/pci.h Tue Oct 27 13:18:21 2015 +0000
+++ b/sys/external/bsd/drm2/include/linux/pci.h Tue Oct 27 13:21:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci.h,v 1.20 2015/10/17 14:54:10 jmcneill Exp $        */
+/*     $NetBSD: pci.h,v 1.21 2015/10/27 13:21:18 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -146,7 +146,6 @@
        }                       pd_resources[PCI_NUM_RESOURCES];
        struct pci_conf_state   *pd_saved_state;
        struct acpi_devnode     *pd_ad;
-       struct device           dev;            /* XXX Don't believe me!  */
        struct pci_bus          *bus;
        uint32_t                devfn;
        uint16_t                vendor;
@@ -164,14 +163,6 @@
        return pdev->pd_dev;
 }
 
-/* XXX Nouveau kludge!  Don't believe me!  */
-static inline struct pci_dev *
-to_pci_dev(struct device *dev)
-{
-
-       return container_of(dev, struct pci_dev, dev);
-}
-
 /* XXX Nouveau kludge!  */
 static inline struct drm_device *
 pci_get_drvdata(struct pci_dev *pdev)
diff -r 8899d6efc6be -r 0a699a3e56b3 sys/external/bsd/drm2/include/linux/platform_device.h
--- a/sys/external/bsd/drm2/include/linux/platform_device.h     Tue Oct 27 13:18:21 2015 +0000
+++ b/sys/external/bsd/drm2/include/linux/platform_device.h     Tue Oct 27 13:21:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: platform_device.h,v 1.6 2015/10/18 14:04:03 jmcneill Exp $     */
+/*     $NetBSD: platform_device.h,v 1.7 2015/10/27 13:21:18 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #define NUM_PLATFORM_RESOURCE  2
 
 struct platform_device {
-       struct device   dev;    /* XXX DON'T BELIEVE ME */
+       device_t        pd_dev;
        uint64_t        id;
 
        bus_dma_tag_t   dmat;
@@ -50,4 +50,11 @@
        }               resource[NUM_PLATFORM_RESOURCE];
 };
 
+static inline device_t
+platform_device_dev(const struct platform_device *platformdev)
+{
+
+       return platformdev->pd_dev;
+}
+
 #endif  /* _LINUX_PLATFORM_DEVICE_H_ */
diff -r 8899d6efc6be -r 0a699a3e56b3 sys/external/bsd/drm2/nouveau/nouveau_pci.c
--- a/sys/external/bsd/drm2/nouveau/nouveau_pci.c       Tue Oct 27 13:18:21 2015 +0000
+++ b/sys/external/bsd/drm2/nouveau/nouveau_pci.c       Tue Oct 27 13:21:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_pci.c,v 1.4 2015/10/17 12:02:44 jmcneill Exp $ */
+/*     $NetBSD: nouveau_pci.c,v 1.5 2015/10/27 13:21:19 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_pci.c,v 1.4 2015/10/17 12:02:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_pci.c,v 1.5 2015/10/27 13:21:19 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/device.h>
@@ -196,19 +196,15 @@
 static bool
 nouveau_pci_suspend(device_t self, const pmf_qual_t *qual __unused)
 {
-       struct nouveau_pci_softc *const sc = device_private(self);
-       struct device *const dev = &sc->sc_pci_dev.dev; /* XXX KLUDGE */
 
-       return nouveau_pmops_suspend(dev) == 0;
+       return nouveau_pmops_suspend(self) == 0;
 }
 
 static bool
 nouveau_pci_resume(device_t self, const pmf_qual_t *qual)
 {
-       struct nouveau_pci_softc *const sc = device_private(self);
-       struct device *const dev = &sc->sc_pci_dev.dev; /* XXX KLUDGE */
 
-       return nouveau_pmops_resume(dev) == 0;
+       return nouveau_pmops_resume(self) == 0;
 }
 
 static void



Home | Main Index | Thread Index | Old Index